Revision fc7151bb Target/Modules/DiWheelDrive_1-1/Boot/main.c
Target/Modules/DiWheelDrive_1-1/Boot/main.c | ||
---|---|---|
47 | 47 |
#define RESET_TIMEOUT_MS 100 |
48 | 48 |
|
49 | 49 |
/**************************************************************************************** |
50 |
* Function prototypes |
|
50 |
* Function prototypes and static variables
|
|
51 | 51 |
****************************************************************************************/ |
52 | 52 |
static void Init(void); |
53 | 53 |
|
... | ... | |
78 | 78 |
|
79 | 79 |
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = { |
80 | 80 |
.magicNumber = BL_MAGIC_NUMBER, |
81 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Beta, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
|
|
81 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Beta, BL_VERSION_MAJOR, BL_VERSION_MINOR, 3},
|
|
82 | 82 |
.vSSSP = {BL_VERSION_ID_SSSP, BL_SSSP_VERSION_MAJOR, BL_SSSP_VERSION_MINOR, 0}, |
83 | 83 |
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported |
84 | 84 |
.cbShutdownHibernate = blCallbackShutdownHibernate, |
... | ... | |
306 | 306 |
/* CNF2[1:0] = %01 and MODE2[1:0] = %00 */ |
307 | 307 |
GPIOA->CRH |= (blt_int32u)((blt_int32u)0x4 << 8); |
308 | 308 |
#endif |
309 |
|
|
310 | 309 |
} /*** end of Init ***/ |
311 | 310 |
|
312 | 311 |
/* |
... | ... | |
458 | 457 |
/* wait for all boards to be ready for shutdown */ |
459 | 458 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
460 | 459 |
if (GPIO_ReadInputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
461 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
460 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
462 | 461 |
setLed(BLT_TRUE); |
463 | 462 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
464 | 463 |
setLed(BLT_FALSE); |
... | ... | |
502 | 501 |
/* wait for all boards to be ready for shutdown */ |
503 | 502 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
504 | 503 |
if (GPIO_ReadInputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
505 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
504 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
506 | 505 |
setLed(BLT_TRUE); |
507 | 506 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
508 | 507 |
setLed(BLT_FALSE); |
... | ... | |
546 | 545 |
/* wait for all boards to be ready for shutdown */ |
547 | 546 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
548 | 547 |
if (GPIO_ReadInputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
549 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
548 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
550 | 549 |
setLed(BLT_TRUE); |
551 | 550 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
552 | 551 |
setLed(BLT_FALSE); |
... | ... | |
567 | 566 |
PWR_EnterSTANDBYMode(); |
568 | 567 |
|
569 | 568 |
return; |
570 |
} /* end of shutdownToHibernate ***/ |
|
569 |
} /*** end of shutdownToHibernate ***/
|
|
571 | 570 |
|
572 | 571 |
/* |
573 | 572 |
* Final shutdown of the system and restart. |
... | ... | |
589 | 588 |
/* wait for all boards to be ready for shutdown */ |
590 | 589 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
591 | 590 |
if (GPIO_ReadInputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
592 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
591 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
593 | 592 |
setLed(BLT_TRUE); |
594 | 593 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
595 | 594 |
setLed(BLT_FALSE); |
... | ... | |
614 | 613 |
*/ |
615 | 614 |
|
616 | 615 |
return; |
617 |
} /*** end of shutdownAndRestart***/ |
|
616 |
} /*** end of shutdownAndRestart ***/
|
|
618 | 617 |
|
619 | 618 |
/* |
620 | 619 |
* Configures some GPIO pins as inputs for safety reasons. |
... | ... | |
824 | 823 |
* In transportation low-power mode the system can only be woken up by pulling down the NRST signal. |
825 | 824 |
* Furthermore, the system can not be charged when in transportation mode. |
826 | 825 |
*/ |
827 |
void blCallbackShutdownTransportation(void) {
|
|
826 |
void blCallbackShutdownTransportation() { |
|
828 | 827 |
/* make sure that the required clocks are activated */ |
829 | 828 |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
830 | 829 |
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); |
... | ... | |
833 | 832 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
834 | 833 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
835 | 834 |
|
836 |
setLed(BLT_TRUE);
|
|
835 |
/* initialized the standalone timer */
|
|
837 | 836 |
saTimerInit(); |
838 | 837 |
|
838 |
setLed(BLT_TRUE); |
|
839 |
|
|
839 | 840 |
shutdownToTransportation(BLT_TRUE); |
840 | 841 |
|
841 | 842 |
return; |
... | ... | |
855 | 856 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
856 | 857 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
857 | 858 |
|
859 |
/* initialized the standalone timer */ |
|
858 | 860 |
saTimerInit(); |
859 | 861 |
|
862 |
setLed(BLT_TRUE); |
|
863 |
|
|
860 | 864 |
shutdownToDeepsleep(BLT_TRUE); |
861 | 865 |
|
862 | 866 |
return; |
... | ... | |
875 | 879 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
876 | 880 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
877 | 881 |
|
882 |
/* initialized the standalone timer */ |
|
878 | 883 |
saTimerInit(); |
879 | 884 |
|
885 |
setLed(BLT_TRUE); |
|
886 |
|
|
880 | 887 |
shutdownToHibernate(BLT_TRUE); |
881 | 888 |
|
882 | 889 |
return; |
... | ... | |
891 | 898 |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
892 | 899 |
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); |
893 | 900 |
|
894 |
/* set/keep the SYS_SYNC and SYS_PD signal active */ |
|
901 |
/* set/keep the SYS_SYNC and SYS_PD signals active */
|
|
895 | 902 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
896 | 903 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
897 | 904 |
|
898 |
/* ensure that all modules had a chance to detect the pulse on SYS_PD_N */
|
|
905 |
/* initialized the standalone timer */
|
|
899 | 906 |
saTimerInit(); |
907 |
|
|
908 |
setLed(BLT_TRUE); |
|
909 |
|
|
910 |
/* deactivate SYS_PD_N and ensure that all modules had a chance to detect the falling edge */ |
|
900 | 911 |
msleep(1); |
901 | 912 |
GPIO_SetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
902 | 913 |
msleep(1); |
... | ... | |
916 | 927 |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
917 | 928 |
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); |
918 | 929 |
|
919 |
/* set/keep the SYS_SYNC and SYS_PD signal active */ |
|
930 |
/* set/keep the SYS_SYNC and SYS_PD signals active */
|
|
920 | 931 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
921 | 932 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
922 | 933 |
|
... | ... | |
933 | 944 |
/* wait for all boards to be ready for shutdown */ |
934 | 945 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
935 | 946 |
if (GPIO_ReadOutputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
936 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
947 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
937 | 948 |
setLed(BLT_TRUE); |
938 | 949 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
939 | 950 |
setLed(BLT_FALSE); |
Also available in: Unified diff