MCU筆記
2017/8/12 更新:
microproccesser bus rate = Oscillator / 2
int main()
{
LOCK(); //disable irq
init_periphery(); //initialize.c
->Step1.Set up elpi mode (clock)
->Step2.Setup GPIO
->Step3.Setup lp timer
->Step4.Setup I2C
->Step5.
/* switch to very low power run mode */
set_vlpr_mode();
/* switch to very low power stop mode */
set_vlps_mode();
configure_NVIC(); //initialize.c
->Step0.設定&註冊 irq 優先權
init_app_objects(); //initialize.c
->Step1. initialize button press dispatcher */
->Step2.initialize state object */
init_watchdog(); //initialize.c
UNLOCK(); //enable irq
while(true)
{
set_vlps_mode();
const sEvent * evt = GetEvent(&_BtnObj.base.EvQueue);
if(evt != 0) {
/* dispatch event to btn object */
SMDispatch((sSM*) &_BtnObj, evt);
}
evt = GetEvent(&_StateObj.base.EvQueue);
if(evt != 0) {
/* dispatch event to state object */
SMDispatch((sSM*) &_StateObj, evt);
}
/* feed the watchdog */
COP_DRV_Refresh(0);
}
return 0;
}
沒有留言:
張貼留言