Revision fc7151bb Target/Modules/PowerManagement_1-2/Boot/main.c
Target/Modules/PowerManagement_1-2/Boot/main.c | ||
---|---|---|
88 | 88 |
|
89 | 89 |
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = { |
90 | 90 |
.magicNumber = BL_MAGIC_NUMBER, |
91 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Beta, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
|
|
91 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Beta, BL_VERSION_MAJOR, BL_VERSION_MINOR, 3},
|
|
92 | 92 |
.vSSSP = {BL_VERSION_ID_SSSP, BL_SSSP_VERSION_MAJOR, BL_SSSP_VERSION_MINOR, 0}, |
93 | 93 |
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported |
94 | 94 |
.cbShutdownHibernate = blCallbackShutdownHibernate, |
... | ... | |
309 | 309 |
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; |
310 | 310 |
GPIO_Init(GPIOA, &GPIO_InitStructure); |
311 | 311 |
#endif |
312 |
|
|
313 | 312 |
} /*** end of Init ***/ |
314 | 313 |
|
315 | 314 |
/* |
... | ... | |
553 | 552 |
} /*** end of shutdownToTransportation ***/ |
554 | 553 |
|
555 | 554 |
/* |
556 |
* Final shutdown of the system to enter deepseleep mode.
|
|
555 |
* Final shutdown of the system to enter deepsleep mode. |
|
557 | 556 |
*/ |
558 | 557 |
void shutdownToDeepsleep() { |
559 | 558 |
/* configure some criticpal GPIOs as input |
... | ... | |
612 | 611 |
PWR_BackupAccessCmd(ENABLE); |
613 | 612 |
RTC_WriteBackupRegister(BL_RTC_BACKUP_REG, backup.raw); |
614 | 613 |
|
615 |
/* morse 'OK' via the LED to signal that shutodnw was successful */
|
|
614 |
/* morse 'OK' via the LED to signal that shutdown was successful */
|
|
616 | 615 |
blinkOK(1); |
617 | 616 |
|
618 | 617 |
/* reset the MCU */ |
... | ... | |
641 | 640 |
PWR_BackupAccessCmd(ENABLE); |
642 | 641 |
RTC_WriteBackupRegister(BL_RTC_BACKUP_REG, backup.raw); |
643 | 642 |
|
644 |
/* morse 'OK' via the LED to signal that shutodnw was successful */
|
|
643 |
/* morse 'OK' via the LED to signal that shutdown was successful */
|
|
645 | 644 |
blinkOK(1); |
646 | 645 |
|
647 | 646 |
/* reset the MCU */ |
... | ... | |
656 | 655 |
*/ |
657 | 656 |
void configGpioForShutdown() { |
658 | 657 |
/* setup the configuration */ |
659 |
GPIO_InitTypeDef gpio_init;
|
|
658 |
GPIO_InitTypeDef gpio_init; |
|
660 | 659 |
gpio_init.GPIO_Mode = GPIO_Mode_IN; |
661 | 660 |
gpio_init.GPIO_Speed = GPIO_Speed_50MHz; |
662 | 661 |
gpio_init.GPIO_OType = GPIO_OType_PP; |
... | ... | |
1305 | 1304 |
shutdownToTransportation(); |
1306 | 1305 |
|
1307 | 1306 |
return; |
1308 |
} /*** end of bLCallbackTransportation ***/
|
|
1307 |
} /*** end of blCallbackTransportation ***/
|
|
1309 | 1308 |
|
1310 | 1309 |
/* |
1311 | 1310 |
* Callback function that handles the system shutdown and enters deepsleep mode. |
... | ... | |
1346 | 1345 |
shutdownToDeepsleep(); |
1347 | 1346 |
|
1348 | 1347 |
return; |
1349 |
} /*** end of bLCallbackDeepsleep ***/
|
|
1348 |
} /*** end of blCallbackDeepsleep ***/
|
|
1350 | 1349 |
|
1351 | 1350 |
/* |
1352 | 1351 |
* Callback function that handles the system shutdown and enters hibernate mode. |
... | ... | |
1386 | 1385 |
shutdownToHibernate(); |
1387 | 1386 |
|
1388 | 1387 |
return; |
1389 |
} /*** end of bLCallbackShutdownHibernate ***/
|
|
1388 |
} /*** end of blCallbackShutdownHibernate ***/
|
|
1390 | 1389 |
|
1391 | 1390 |
/* |
1392 | 1391 |
* Callback function that handles the system shutdown and initializes a restart. |
... | ... | |
1398 | 1397 |
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD, ENABLE); |
1399 | 1398 |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
1400 | 1399 |
|
1401 |
/* set/keep the SYS_SYNC and SYS_PD signal active */ |
|
1400 |
/* set/keep the SYS_SYNC and SYS_PD signals active */
|
|
1402 | 1401 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
1403 | 1402 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
1404 | 1403 |
|
... | ... | |
1431 | 1430 |
shutdownAndRestart(); |
1432 | 1431 |
|
1433 | 1432 |
return; |
1434 |
} /*** end of bLCallbackRestart ***/ |
|
1435 |
|
|
1433 |
} /*** end of blCallbackRestart ***/ |
|
1436 | 1434 |
|
1437 | 1435 |
/* |
1438 | 1436 |
* Callback function that handles a system shutdown/restart request from another module. |
... | ... | |
1444 | 1442 |
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD, ENABLE); |
1445 | 1443 |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
1446 | 1444 |
|
1447 |
/* set/keep the SYS_SYNC and SYS_PD signal active */ |
|
1445 |
/* set/keep the SYS_SYNC and SYS_PD signals active */
|
|
1448 | 1446 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
1449 | 1447 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
1450 | 1448 |
|
... | ... | |
1461 | 1459 |
/* wait for all boards to be ready for shutdown */ |
1462 | 1460 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
1463 | 1461 |
if (GPIO_ReadOutputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
1464 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
1462 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
1465 | 1463 |
setLed(BLT_TRUE); |
1466 | 1464 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
1467 | 1465 |
setLed(BLT_FALSE); |
... | ... | |
1518 | 1516 |
return; |
1519 | 1517 |
} /*** end of blCallbackHandleShutdownRequest ***/ |
1520 | 1518 |
|
1521 |
|
|
1522 | 1519 |
/*********************************** end of main.c *************************************/ |
Also available in: Unified diff