1 /**
2 * \ingroup MODULMACROS
3 *
4 * \file Configure.c
5 *
6 * \brief Set certain parameters to spcified values
7 *
8 */
9 /*
10 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
11 *
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the
23 * distribution.
24 *
25 * Neither the name of Texas Instruments Incorporated nor the names of
26 * its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42 #include "error_def.h"
43 #include "arch.h"
44 #include "edt.h"
45 #include "hal.h"
46 #include "stream.h"
47 #include "ConfigureParameters.h"
48 #ifdef DB_PRINT
49 #include "debug.h"
50 #endif
51
52 /**
53 Configure
54 Configures specified parameter to the specified value
55 inData: <configureParameter(32) value(32)>
56 outData: <>
57 configureParameter: contains the parameter to be modified
58 value: specifies the vlaue to which to set the parameter
59 */
60
61 #if defined(MSP430_UIF)
62 #ifdef ARCH_MSP432
63 extern ARMConfigSettings armConfigSettings;
64 #endif
65 #endif
66
67 #if defined(MSP_FET)
68 extern ARMConfigSettings armConfigSettings;
69 #endif
70
71 extern ARMConfigSettings armConfigSettings;
72
73 extern DeviceSettings deviceSettings;
74 extern DevicePowerSettings devicePowerSettings;
75 extern unsigned short altRomAddressForCpuRead;
76 extern unsigned short wdtctlAddress5xx;
77 extern unsigned short assertBslValidBit;
78 extern unsigned short enhancedPsa;
79 unsigned long JTAGLock5xx = 0xCACACACA;
80
HAL_FUNCTION(_hal_Configure)81 HAL_FUNCTION(_hal_Configure)
82 {
83 unsigned long configureParameter;
84 unsigned long value;
85
86 // Retrieve parameters from stream
87 if(STREAM_get_long(&configureParameter) < 0)
88 {
89 return (HALERR_CONFIG_NO_PARAMETER);
90 }
91
92 if(STREAM_get_long(&value) < 0)
93 {
94 return (HALERR_CONFIG_NO_VALUE);
95 }
96
97 // Decode and parameter and set value
98 switch(configureParameter)
99 {
100 case (CONFIG_PARAM_ENHANCED_PSA):
101 enhancedPsa = value;
102 break;
103
104 case (CONFIG_PARAM_PSA_TCKL_HIGH):
105 IHIL_SetPsaTCLK(value);
106 break;
107
108 case (CONFIG_PARAM_CLK_CONTROL_TYPE):
109 deviceSettings.clockControlType = value;
110 break;
111
112 case (CONFIG_PARAM_DEFAULT_CLK_CONTROL):
113 break;
114
115 case (CONFIG_PARAM_POWER_TESTREG_MASK):
116 devicePowerSettings.powerTestRegMask = value;
117 break;
118
119 case (CONFIG_PARAM_POWER_TESTREG_DEFAULT):
120 devicePowerSettings.powerTestRegDefault = value;
121 break;
122
123 case (CONFIG_PARAM_TESTREG_ENABLE_LPMX5):
124 devicePowerSettings.enableLpmx5TestReg = value;
125 break;
126
127 case (CONFIG_PARAM_TESTREG_DISABLE_LPMX5):
128 devicePowerSettings.disableLpmx5TestReg = value;
129 break;
130
131 case (CONFIG_PARAM_POWER_TESTREG3V_MASK):
132 devicePowerSettings.powerTestReg3VMask = value;
133 break;
134
135 case (CONFIG_PARAM_POWER_TESTREG3V_DEFAULT):
136 devicePowerSettings.powerTestReg3VDefault = value;
137 break;
138
139 case (CONFIG_PARAM_TESTREG3V_ENABLE_LPMX5):
140 devicePowerSettings.enableLpmx5TestReg3V = value;
141 break;
142
143 case (CONFIG_PARAM_TESTREG3V_DISABLE_LPMX5):
144 devicePowerSettings.disableLpmx5TestReg3V = value;
145 break;
146
147 case (CONFIG_PARAM_JTAG_SPEED):
148 {
149 unsigned long sbwValue = 0;
150 if(STREAM_get_long(&sbwValue) < 0)
151 {
152 return (HALERR_CONFIG_NO_VALUE);
153 }
154 IHIL_SetJtagSpeed(value, sbwValue);
155 break;
156 }
157
158 case (CONFIG_PARAM_SFLLDEH):
159 deviceSettings.stopFLL = value;
160 break;
161
162 case (CONFIG_ALT_ROM_ADDR_FOR_CPU_READ):
163 altRomAddressForCpuRead = value;
164 break;
165
166 case (CONFIG_WDT_ADDRESS_5XX):
167 wdtctlAddress5xx = value;
168 break;
169
170 case (CONFIG_ASSERT_BSL_VALID_BIT):
171 deviceSettings.assertBslValidBit = value;
172 break;
173
174 case (CONFIG_PARAM_SCS_BASE_ADDRESS):
175 #if defined(MSP430_UIF) || defined(MSP_FET)
176 #ifdef ARCH_MSP432
177 armConfigSettings.scsBase = value;
178 #endif
179 #endif
180 break;
181
182 case (CONFIG_PARAM_FPB_BASE_ADDRESS):
183 #if defined(MSP430_UIF) || defined(MSP_FET)
184 #ifdef ARCH_MSP432
185 armConfigSettings.fpbBase = value;
186 #endif
187 #endif
188 break;
189
190 case (CONFIG_PARAM_INTERRUPT_OPTIONS):
191 #if defined(MSP430_UIF) || defined(MSP_FET)
192 #ifdef ARCH_MSP432
193 armConfigSettings.interruptOptions = value | 0x80;
194 #endif
195 #endif
196 break;
197
198 case (CONFIG_PARAM_ULP_MSP432):
199 #if defined(MSP430_UIF) || defined(MSP_FET)
200 #ifdef ARCH_MSP432
201 armConfigSettings.ulpDebug = value;
202 #endif
203 #endif
204 break;
205
206 case (CONFIG_PARAM_JTAG_LOCK_5XX):
207 JTAGLock5xx = value;
208 break;
209
210 default:
211 return (CONFIG_PARAM_UNKNOWN_PARAMETER);
212 }
213
214 return(0);
215 }
216
217