📄 mac_power_management.lst
字号:
187
188 // Update with the new transceiver state
189 mpmInfo.currentState = mpmInfo.selectedMode;
\ ??mpmSetTask_4:
\ 000082 90.... MOV DPTR,#(mpmInfo + 1)
\ 000085 E0 MOVX A,@DPTR
\ 000086 90.... MOV DPTR,#mpmInfo
\ 000089 F0 MOVX @DPTR,A
190
191 // Clean up and make the callback
192 mschRemoveTask(pTask->priority, 0);
\ 00008A ; Setup parameters for call to function mschRemoveTask
\ 00008A 7A00 MOV R2,#0x0
\ 00008C 8E82 MOV DPL,R6
\ 00008E 8F83 MOV DPH,R7
\ 000090 E0 MOVX A,@DPTR
\ 000091 F9 MOV R1,A
\ 000092 12.... LCALL mschRemoveTask & 0xFFFF
193 mpmSetConfirm(OK_POWER_MODE_CHANGED);
\ 000095 ; Setup parameters for call to function mpmSetConfirm
\ 000095 7900 MOV R1,#0x0
\ ??mpmSetTask_1:
\ 000097 12.... LCALL mpmSetConfirm & 0xFFFF
194
195 } // mpmSetTask
\ ??mpmSetTask_3:
\ 00009A 7F01 MOV R7,#0x1
\ 00009C 02.... LJMP ?BANKED_LEAVE_XDATA
196
197
198
199
200 //-------------------------------------------------------------------------------------------------------
201 // void mpmSetRequest(BYTE mode)
202 //
203 // DESCRIPTION:
204 // This function allows the higher layer to power down CC2430 to extend battery lifetime. CC2430
205 // must be powered up before any MLME or MCPS primitives can be used (both beacon/non-beacon modes).
206 // Power-down is currently only supported for non-beacon PANs.
207 //
208 // The change is not likely to happen instantaneously (under normal conditions the delay can be up
209 // to 320 us). Use either the mpmSetConfirm callback, or poll the current power state by using
210 // mpmGetState() (returns the selected power mode when it has become effective).
211 //
212 // ARGUMENTS:
213 // BYTE mode
214 // MPM_CC2430_ON: The CC2430 crystal oscillator is on, ready to receive/transmit
215 // MPM_CC2430_XOSC_OFF: The CC2430 crystal oscillator is off (startup time ~1 ms)
216 // MPM_CC2430_XOSC_AND_VREG_OFF: The CC2430 voltage regulator is off (startup time ~1.6 ms)
217 //
218 // Note: Nothing will happen if the current state is MPM_CC2430_XOSC_AND_VREG_OFF, and the new
219 // mode is MPM_CC2430_XOSC_OFF.
220 //-------------------------------------------------------------------------------------------------------
\ In segment NEAR_CODE, align 1, keep-with-next
221 ROOT void mpmSetRequest(BYTE mode) {
\ mpmSetRequest:
\ 000000 74F6 MOV A,#-0xa
\ 000002 12.... LCALL ?FUNC_ENTER_XDATA
\ 000005 ; Saved register size: 10
\ 000005 ; Auto size: 0
\ 000005 E9 MOV A,R1
\ 000006 FE MOV R6,A
222 BYTE taskNumber;
223
224 // Any changes?
225 if (mode == mpmInfo.selectedMode) {
\ 000007 90.... MOV DPTR,#(mpmInfo + 1)
\ 00000A E0 MOVX A,@DPTR
\ 00000B 6E XRL A,R6
\ 00000C 7007 JNZ ??mpmSetRequest_0
226 mpmSetConfirm(OK_POWER_MODE_UNCHANGED);
\ 00000E ; Setup parameters for call to function mpmSetConfirm
\ 00000E 7901 MOV R1,#0x1
\ 000010 12.... LCALL mpmSetConfirm
\ 000013 8024 SJMP ??mpmSetRequest_1
227 } else {
228
229 // Reserve the task to be used
230 do {
231 taskNumber = mschReserveTask();
\ ??mpmSetRequest_0:
\ 000015 ; Setup parameters for call to function mschReserveTask
\ 000015 12.... LCALL mschReserveTask
232 } while (taskNumber == NO_TASK);
\ 000018 74FF MOV A,#-0x1
\ 00001A 69 XRL A,R1
\ 00001B 60F8 JZ ??mpmSetRequest_0
233
234 mschAddTask(taskNumber, MAC_TASK_PRI_LOW, mpmSetTask, (WORD)mode);
\ 00001D ; Setup parameters for call to function mschAddTask
\ 00001D 75.... MOV ?V0 + 0,#(mpmSetTask & 0xff)
\ 000020 75.... MOV ?V0 + 1,#((mpmSetTask >> 8) & 0xff)
\ 000023 75.... MOV ?V0 + 2,#((mpmSetTask >> 16) & 0xff)
\ 000026 78.. MOV R0,#?V0 + 0
\ 000028 12.... LCALL ?PUSH_XSTACK_I_THREE
\ 00002B EE MOV A,R6
\ 00002C FC MOV R4,A
\ 00002D 7D00 MOV R5,#0x0
\ 00002F 7A00 MOV R2,#0x0
\ 000031 12.... LCALL mschAddTask
\ 000034 7403 MOV A,#0x3
\ 000036 12.... LCALL ?DEALLOC_XSTACK8
235 }
236
237 } // mpmSetRequest
\ ??mpmSetRequest_1:
\ 000039 7F03 MOV R7,#0x3
\ 00003B 02.... LJMP ?FUNC_LEAVE_XDATA
238
239
240
241
242 //-------------------------------------------------------------------------------------------------------
243 // BYTE mpmGetState(void)
244 //
245 // DESCRIPTION:
246 // Returns the current power state when it has become effective (after a call to mpmSetRequest)
247 //
248 // RETURN VALUE:
249 // BYTE
250 // MPM_CC2430_ON: The CC2430 crystal oscillator is on, ready to receive/transmit
251 // MPM_CC2430_XOSC_OFF: The CC2430 crystal oscillator is off
252 // MPM_CC2430_XOSC_AND_VREG_OFF: The CC2430 voltage regulator is off
253 //-------------------------------------------------------------------------------------------------------
\ In segment NEAR_CODE, align 1, keep-with-next
254 ROOT BYTE mpmGetState(void) {
\ mpmGetState:
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
255 return mpmInfo.currentState;
\ 000004 90.... MOV DPTR,#mpmInfo
\ 000007 E0 MOVX A,@DPTR
\ 000008 F9 MOV R1,A
\ 000009 80.. SJMP ??Subroutine0_0
256 } // mpmGetState
257
258
259 //-------------------------------------------------------------------------------------------------------
260 // ROOT mpmSetAndResumeMacAndCpuPowerMode (POWER_MODE powerMode,
261 // RESUME_MODE resumeMode,
262 // BOOL synchronousStart)
263 //
264 // DESCRIPTION:
265 // Turns off MAC, radio and sets CPU in correct power. The CPU will halt in this routine.
266 // Processing is resumed when an external interrupt or a sleep timer interrupt occurs. Mac processing
267 // is also resumed as part of this routine. RxOnWhenIdle is restored to its value prior to the call
268 // of this routine.
269 // The external interrupt or the sleep timer interrupt must be intialized prior to the call of this
270 // routine.
271 //
272 // ARGUMENTS:
273 // POWER_MODE powerMode
274 // Power mode according to data sheet for CC2430
275 // POWER_MODE_PM1 Voltage regulator to the digital part is on. High speed oscillator is off,
276 // low speed oscillator is on
277 // POWER_MODE_PM2 Voltage regulator to the digital part is off. High speed oscillator is off,
278 // low speed oscillator is on
279 // POWER_MODE_PM3 Voltage regulator to the digital part is off. All oscillators is off.
280 //
281 // RESUME_MODE resumeMode
282 // Depends on how much of the MAC variables that was preserved during power down. In power control
283 // PM1 or when all data are places in upper 4 kRAM, RESUME_MODE_ALL_PRESERVED can be used. The
284 // XDATA segment and the PM0_XDATA segment must be located in upper 4 kRAM.
285 // If the PM0_XDATA segment is located in lower 4 kRAM and XDATA in upper 4 kRAM,
286 // the RESUME_MODE_PARTS_PRESERVED must be used.
287 // RESUME_MODE_ALL_PRESERVED, restarts only timer2
288 // RESUME_MODE_PARTS_PRESERVED restarts timer2, the task and memory pool system
289 //
290 // BOOL synchronousStart
291 // FALSE Start timer2 immediate
292 // TRUE Start timer2 synchronous with external 32.768 kHz clock
293 //
294 //-------------------------------------------------------------------------------------------------------
\ In segment NEAR_CODE, align 1, keep-with-next
295 ROOT void mpmSetAndResumeMacAndCpuPowerMode (POWER_MODE powerMode,
\ mpmSetAndResumeMacAndCpuPowerMode:
296 RESUME_MODE resumeMode,
297 BOOL synchronousStart)
298 {
\ 000000 74F8 MOV A,#-0x8
\ 000002 12.... LCALL ?FUNC_ENTER_XDATA
\ 000005 ; Saved register size: 8
\ 000005 ; Auto size: 1
\ 000005 74FF MOV A,#-0x1
\ 000007 12.... LCALL ?ALLOC_XSTACK8
\ 00000A E9 MOV A,R1
\ 00000B FE MOV R6,A
\ 00000C EA MOV A,R2
\ 00000D FF MOV R7,A
\ 00000E 8B.. MOV ?V0 + 0,R3
299 BYTE rxOnWhenIdle;
300
301 mpmPowerDownMac (&rxOnWhenIdle);
\ 000010 ; Setup parameters for call to function mpmPowerDownMac
\ 000010 85..82 MOV DPL,?XSP + 0
\ 000013 85..83 MOV DPH,?XSP + 1
\ 000016 AA82 MOV R2,DPL
\ 000018 AB83 MOV R3,DPH
\ 00001A 12.... LCALL mpmPowerDownMac
302
303 // Power down cpu
304 SLEEP &= 0xFC;
\ 00001D 53BEFC ANL 0xbe,#0xfc
\ 000020 E5BE MOV A,0xbe
305
306 switch (powerMode)
\ 000022 EE MOV A,R6
\ 000023 12.... LCALL ?UC_SWITCH_DENSE
\ `?<Jumptable for mpmSetAndResumeMacAndCpuPowerM_0`:
\ 000026 00 DB 0
\ 000027 02 DB 2
\ 000028 .... DW ??mpmSetAndResumeMacAndCpuPowerMode_0
\ 00002A .... DW ??mpmSetAndResumeMacAndCpuPowerMode_1
\ 00002C .... DW ??mpmSetAndResumeMacAndCpuPowerMode_2
\ 00002E .... DW ??mpmSetAndResumeMacAndCpuPowerMode_3
307 {
308 case POWER_MODE_PM1:
309 SLEEP |= CC2430_PM1;
\ ??mpmSetAndResumeMacAndCpuPowerMode_1:
\ 000030 43BE01 ORL 0xbe,#0x1
\ 000033 800A SJMP ??mpmSetAndResumeMacAndCpuPowerMode_0
310 break;
311
312 case POWER_MODE_PM2:
313 SLEEP |= CC2430_PM2;
\ ??mpmSetAndResumeMacAndCpuPowerMode_2:
\ 000035 43BE02 ORL 0xbe,#0x2
\ 000038 8005 SJMP ??mpmSetAndResumeMacAndCpuPowerMode_0
314 break;
315
316 case POWER_MODE_PM3:
317 SLEEP |= CC2430_PM3;
\ ??mpmSetAndResumeMacAndCpuPowerMode_3:
\ 00003A 43BE03 ORL 0xbe,#0x3
\ 00003D E5BE MOV A,0xbe
318 break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -