1 /*
2  * hal432.c
3  *
4  * <FILE_BRIEF>
5  *
6  * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
7  *
8  *
9  *  Redistribution and use in source and binary forms, with or without
10  *  modification, are permitted provided that the following conditions
11  *  are met:
12  *
13  *    Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  *    Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the
19  *    distribution.
20  *
21  *    Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 
39 //! \ingroup MODULHAL
40 //! \file hal432.c
41 
42 #include "hw_compiler_specific.h"
43 #include "HalGlobalVars.h"
44 #include "edt.h"
45 #include "hal.h"
46 #include "hal_ref.h"
47 #include "stream.h"
48 #include "string.h"
49 
50 DeviceSettings deviceSettings;
51 REQUIRED(deviceSettings)
52 
53 DevicePowerSettings devicePowerSettings;
54 REQUIRED(devicePowerSettings)
55 
56 unsigned short altRomAddressForCpuRead;
57 REQUIRED(altRomAddressForCpuRead)
58 
59 unsigned short wdtctlAddress5xx;
60 REQUIRED(wdtctlAddress5xx)
61 
62 unsigned short enhancedPsa;
63 REQUIRED(enhancedPsa)
64 // global variables use for JTAG/SWD DAP
65 unsigned long cswValues[4];
66 REQUIRED(cswValues)
67 ARMConfigSettings armConfigSettings;
68 REQUIRED(armConfigSettings)
69 
70 VAR_AT(HalRec hal_functions_[HAL_FUNCTIONS_SIZE], HAL_ADDR_VAR_HAL_FUNCTION);
71 
72 #define MACRO(x)  {ID_##x, (void*)_hal_##x },
73 HalRec hal_functions_default_[HAL_FUNCTIONS_DEFAULT_SIZE] =
74 {
75     MACRO(Zero)
76     MACRO_LIST
77 };
78 #undef MACRO
79 
REQUIRED(_init_Hal)80 REQUIRED(_init_Hal)
81 
82 void _init_Hal(void)
83 {
84     unsigned char i;
85 
86     for(i=0; i < (sizeof(hal_functions_)/sizeof(HalRec)); i++)
87     {
88         if(i < (sizeof(hal_functions_default_)/sizeof(HalRec)))
89         {
90             hal_functions_[i].id = hal_functions_default_[i].id;
91             hal_functions_[i].function = hal_functions_default_[i].function;
92         }
93         else
94         {
95             hal_functions_[i].id = 0xFFFF;
96             hal_functions_[i].function = NULL;
97         }
98     }
99 }
100 
HAL_FUNCTION(_hal_Zero)101 HAL_FUNCTION(_hal_Zero)
102 {
103     return 0;
104 }
105 
HAL_FUNCTION(_hal_Init)106 HAL_FUNCTION(_hal_Init)
107 {
108     IHIL_Init();
109     return 0;
110 }
111 
HAL_FUNCTION(_hal_ResetStaticGlobalVars)112 HAL_FUNCTION(_hal_ResetStaticGlobalVars)
113 {
114     return -1;
115 }
116 
HAL_FUNCTION(_hal_SetVcc)117 HAL_FUNCTION(_hal_SetVcc)
118 {
119     unsigned short vcc;
120     STREAM_get_word(&vcc);
121     IHIL_SetVcc(vcc);
122     return 0;
123 }
124 
HAL_FUNCTION(_hal_SwitchMosfet)125 HAL_FUNCTION(_hal_SwitchMosfet)
126 {
127     return -1;
128 }
129 
HAL_FUNCTION(_hal_GetVcc)130 HAL_FUNCTION(_hal_GetVcc)
131 {
132     double vcc = 0;
133     double ext_vcc = 0;
134 
135     IHIL_GetVcc(&vcc, &ext_vcc);
136     STREAM_put_word((unsigned short)vcc); // this is a workaround
137     STREAM_put_word((unsigned short)ext_vcc);
138     return 0;
139 }
140 
HAL_FUNCTION(_hal_GetFuses)141 HAL_FUNCTION(_hal_GetFuses)
142 {
143     return -1;
144 }
145 
HAL_FUNCTION(_hal_DummyMacro)146 HAL_FUNCTION(_hal_DummyMacro)
147 {
148     return -1;
149 }
150 
151 /* EOF */
152