📄 rf04dev.lst
字号:
121 * is pressed.
122 *
123 * Parameters:
124 *
125 * @param void
126 *
127 * @return BOOL
128 * TRUE: Button is being pushed
129 * FALSE: Button is not being pushed
130 *
131 ******************************************************************************/
132 #define BUTTON_ACTIVE_TIMEOUT 10
\ In segment BANKED_CODE, align 1, keep-with-next
133 BOOL buttonPushed( void ) {
\ buttonPushed:
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
134 UINT8 i;
135 BOOL value;
136 static BOOL prevValue;
137
138 if (value = BUTTON_PRESSED()){
\ 000004 A281 MOV C,0x80.1
\ 000006 E4 CLR A
\ 000007 92E0 MOV 0xE0 /* A */.0,C
\ 000009 F4 CPL A
\ 00000A 5401 ANL A,#0x1
\ 00000C F9 MOV R1,A
\ 00000D 6008 JZ ??buttonPushed_0
139 for(i = 0;i < BUTTON_ACTIVE_TIMEOUT; i++){
\ 00000F 7A00 MOV R2,#0x0
140 if(!BUTTON_PRESSED()){
\ ??buttonPushed_1:
\ 000011 A281 MOV C,0x80.1
\ 000013 5009 JNC ??buttonPushed_2
141 value = FALSE;
\ 000015 7900 MOV R1,#0x0
142 break;
143 }
144 }
145 }
146
147 if(value){
148 if (!prevValue){
149 value = prevValue = TRUE;
150 }
151 else{
152 value = FALSE;
153 }
154 }
155 else{
156 prevValue = FALSE;
\ ??buttonPushed_0:
\ 000017 E4 CLR A
\ 000018 90.... MOV DPTR,#??prevValue
\ 00001B F0 MOVX @DPTR,A
157 }
158 return value;
\ ??buttonPushed_3:
\ 00001C 80.. SJMP ?Subroutine0
\ ??buttonPushed_2:
\ 00001E 0A INC R2
\ 00001F EA MOV A,R2
\ 000020 C3 CLR C
\ 000021 940A SUBB A,#0xa
\ 000023 40EC JC ??buttonPushed_1
\ 000025 90.... MOV DPTR,#??prevValue
\ 000028 E0 MOVX A,@DPTR
\ 000029 7006 JNZ ??buttonPushed_4
\ 00002B 7401 MOV A,#0x1
\ 00002D F0 MOVX @DPTR,A
\ 00002E F9 MOV R1,A
\ 00002F 80EB SJMP ??buttonPushed_3
\ ??buttonPushed_4:
\ 000031 7900 MOV R1,#0x0
\ 000033 80E7 SJMP ??buttonPushed_3
159 }
\ In segment XDATA_Z, align 1, keep-with-next
\ 000000 REQUIRE __INIT_XDATA_Z
\ ??prevValue:
\ 000000 DS 1
160
161
162 /******************************************************************************
163 * @fn joystickPushed
164 *
165 * @brief
166 * This function detects if the joystick is being pushed. The function
167 * implements software debounce. Return true only if previuosly called
168 * with joystick not pushed. Return true only once each time the joystick
169 * is pressed.
170 *
171 * Parameters:
172 *
173 * @param void
174 *
175 * @return BOOL
176 * TRUE: Button is being pushed
177 * FALSE: Button is not being pushed
178 *
179 ******************************************************************************/
\ In segment BANKED_CODE, align 1, keep-with-next
180 BOOL joystickPushed( void ) {
\ joystickPushed:
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
181 UINT8 i;
182 BOOL value;
183 static BOOL prevValue;
184
185 if (value = JOYSTICK_PRESSED()){
\ 000004 A285 MOV C,0x80.5
\ 000006 E4 CLR A
\ 000007 92E0 MOV 0xE0 /* A */.0,C
\ 000009 F9 MOV R1,A
\ 00000A 6008 JZ ??joystickPushed_0
186 for(i = 0;i < BUTTON_ACTIVE_TIMEOUT; i++){
\ 00000C 7A00 MOV R2,#0x0
187 if(!JOYSTICK_PRESSED()){
\ ??joystickPushed_1:
\ 00000E A285 MOV C,0x80.5
\ 000010 4009 JC ??joystickPushed_2
188 value = FALSE;
\ 000012 7900 MOV R1,#0x0
189 break;
190 }
191 }
192 }
193
194 if(value){
195 if (!prevValue){
196 value = prevValue = TRUE;
197 }
198 else{
199 value = FALSE;
200 }
201 }
202 else{
203 prevValue = FALSE;
\ ??joystickPushed_0:
\ 000014 E4 CLR A
\ 000015 90.... MOV DPTR,#??prevValue_1
\ 000018 F0 MOVX @DPTR,A
204 }
205
206 return value;
\ ??joystickPushed_3:
\ 000019 80.. SJMP ?Subroutine0
\ ??joystickPushed_2:
\ 00001B 0A INC R2
\ 00001C EA MOV A,R2
\ 00001D C3 CLR C
\ 00001E 940A SUBB A,#0xa
\ 000020 40EC JC ??joystickPushed_1
\ 000022 90.... MOV DPTR,#??prevValue_1
\ 000025 E0 MOVX A,@DPTR
\ 000026 7006 JNZ ??joystickPushed_4
\ 000028 7401 MOV A,#0x1
\ 00002A F0 MOVX @DPTR,A
\ 00002B F9 MOV R1,A
\ 00002C 80EB SJMP ??joystickPushed_3
\ ??joystickPushed_4:
\ 00002E 7900 MOV R1,#0x0
\ 000030 80E7 SJMP ??joystickPushed_3
207 }
\ In segment XDATA_Z, align 1, keep-with-next
\ 000000 REQUIRE __INIT_XDATA_Z
\ ??prevValue_1:
\ 000000 DS 1
\ In segment SFR_AN, at 0x80
\ union <unnamed> volatile __sfr _A_P0
\ _A_P0:
\ 000000 DS 1
208
209 #ifdef CC2430DB
210 /******************************************************************************
211 * @fn getLdrValue
212 *
213 * @brief
214 * Returns a value indicating the illumination of the light dependent
215 * resistor (LDR). Values range from 0xFF (255) for saturated sensor
216 * (resistor value around 5 kOhm), to 0 for dark sensor (resistor value
217 * around 20MOhm).
218 *
219 * Parameters:
220 *
221 * @param void
222 *
223 * @return UINT8
224 * 0xFF (255) maximum illumination (saturated sensor)
225 * 0x00 dark sensor
226 *
227 ******************************************************************************/
228 UINT8 getLdrValue( void ){
229 INT8 adcValue = halAdcSampleSingle(ADC_REF_AVDD, ADC_8_BIT, ADC_INPUT_LDR);
230
231 adcValue = (adcValue > 0) ? adcValue : 0;
232 // max 8 bit value from ADC is 0x7F (127)
233 adcValue *= 2;
234
235 return 255 - adcValue;
236 }
237
238 /******************************************************************************
239 * @fn getXacceleration
240 *
241 * @brief
242 * This function returns the value of the current acceleration of the of
243 * accelerometer in the x-axis.
244 *
245 * Parameters:
246 *
247 * @param void
248 *
249 * @return UINT8
250 * 0xFF (255) +18g (theoretical value)
251 * 0x7F (127) 0g no acceleration
252 * 0x00 -18g (theoretical value)
253 *
254 * Wait 20 ms after VCC is turned on before calling this function.
255 ******************************************************************************/
256 UINT8 getXacceleration( void ){
257 INT8 adcValue = halAdcSampleSingle(ADC_REF_AVDD, ADC_8_BIT, ADC_INPUT_ACC_X);
258 return (adcValue > 0) ? adcValue : 0;
259 }
260
261 /******************************************************************************
262 * @fn getYacceleration
263 *
264 * @brief
265 * This function returns the value of the current acceleration of the of
266 * accelerometer in the y-axis.
267 *
268 * Parameters:
269 *
270 * @param void
271 *
272 * @return UINT8
273 * 0xFF (255) +18g (theoretical value)
274 * 0x7F (127) 0g no acceleration
275 * 0x00 -18g (theoretical value)
276 *
277 * Wait 20 ms after VCC is turned on before calling this function.
278 ******************************************************************************/
279 UINT8 getYacceleration( void ){
280 INT8 adcValue = halAdcSampleSingle(ADC_REF_AVDD, ADC_8_BIT, ADC_INPUT_ACC_Y);
281 return (adcValue > 0) ? adcValue : 0;
282 }
283 #endif
Maximum stack usage in bytes:
Function ISTACK PSTACK XSTACK
-------- ------ ------ ------
buttonPushed 2 0 0
getJoystickDirection 1 0 11
-> halAdcSampleSingle 0 0 22
getPotValue 2 0 0
-> halAdcSampleSingle 4 0 0
joystickPushed 2 0 0
Segment part sizes:
Function/Label Bytes
-------------- -----
getJoystickDirection 153
getPotValue 35
?Subroutine0 7
buttonPushed 53
prevValue 1
joystickPushed 50
prevValue 1
_A_P0 1
298 bytes in segment BANKED_CODE
1 byte in segment SFR_AN
2 bytes in segment XDATA_Z
298 bytes of CODE memory
0 bytes of DATA memory (+ 1 byte shared)
2 bytes of XDATA memory
Errors: none
Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -