Revision fc7151bb Target/Modules/DiWheelDrive_1-2/Boot/main.c
Target/Modules/DiWheelDrive_1-2/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 |
/* |
... | ... | |
456 | 455 |
/* wait for all boards to be ready for shutdown */ |
457 | 456 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
458 | 457 |
if (GPIO_ReadInputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
459 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
458 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
460 | 459 |
setLed(BLT_TRUE); |
461 | 460 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
462 | 461 |
setLed(BLT_FALSE); |
... | ... | |
500 | 499 |
/* wait for all boards to be ready for shutdown */ |
501 | 500 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
502 | 501 |
if (GPIO_ReadInputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
503 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
502 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
504 | 503 |
setLed(BLT_TRUE); |
505 | 504 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
506 | 505 |
setLed(BLT_FALSE); |
... | ... | |
544 | 543 |
/* wait for all boards to be ready for shutdown */ |
545 | 544 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
546 | 545 |
if (GPIO_ReadInputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
547 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
546 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
548 | 547 |
setLed(BLT_TRUE); |
549 | 548 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
550 | 549 |
setLed(BLT_FALSE); |
... | ... | |
565 | 564 |
PWR_EnterSTANDBYMode(); |
566 | 565 |
|
567 | 566 |
return; |
568 |
} /* end of shutdownToHibernate ***/ |
|
567 |
} /*** end of shutdownToHibernate ***/
|
|
569 | 568 |
|
570 | 569 |
/* |
571 | 570 |
* Final shutdown of the system and restart. |
... | ... | |
587 | 586 |
/* wait for all boards to be ready for shutdown */ |
588 | 587 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
589 | 588 |
if (GPIO_ReadInputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
590 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
589 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
591 | 590 |
setLed(BLT_TRUE); |
592 | 591 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
593 | 592 |
setLed(BLT_FALSE); |
... | ... | |
612 | 611 |
*/ |
613 | 612 |
|
614 | 613 |
return; |
615 |
} /*** end of shutdownAndRestart***/ |
|
614 |
} /*** end of shutdownAndRestart ***/
|
|
616 | 615 |
|
617 | 616 |
/* |
618 | 617 |
* Configures some GPIO pins as inputs for safety reasons. |
... | ... | |
802 | 801 |
GPIO_SetBits(SYS_UART_UP_GPIO, SYS_UART_UP_PIN); |
803 | 802 |
|
804 | 803 |
return handleColdReset(); |
805 |
} /*** end of handleImuWakeu ***/ |
|
804 |
} /*** end of handleImuWakeup ***/
|
|
806 | 805 |
|
807 | 806 |
/* |
808 | 807 |
* Callback function that handles the system shutdown and enters transportation mode. |
... | ... | |
810 | 809 |
* In transportation low-power mode the system can only be woken up by pulling down the NRST signal. |
811 | 810 |
* Furthermore, the system can not be charged when in transportation mode. |
812 | 811 |
*/ |
813 |
void blCallbackShutdownTransportation(void) {
|
|
812 |
void blCallbackShutdownTransportation() { |
|
814 | 813 |
/* make sure that the required clocks are activated */ |
815 | 814 |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
816 | 815 |
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); |
... | ... | |
819 | 818 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
820 | 819 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
821 | 820 |
|
822 |
setLed(BLT_TRUE);
|
|
821 |
/* initialized the standalone timer */
|
|
823 | 822 |
saTimerInit(); |
824 | 823 |
|
824 |
setLed(BLT_TRUE); |
|
825 |
|
|
825 | 826 |
shutdownToTransportation(BLT_TRUE); |
826 | 827 |
|
827 | 828 |
return; |
... | ... | |
841 | 842 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
842 | 843 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
843 | 844 |
|
845 |
/* initialized the standalone timer */ |
|
844 | 846 |
saTimerInit(); |
845 | 847 |
|
848 |
setLed(BLT_TRUE); |
|
849 |
|
|
846 | 850 |
shutdownToDeepsleep(BLT_TRUE); |
847 | 851 |
|
848 | 852 |
return; |
... | ... | |
861 | 865 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
862 | 866 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
863 | 867 |
|
868 |
/* initialized the standalone timer */ |
|
864 | 869 |
saTimerInit(); |
865 | 870 |
|
871 |
setLed(BLT_TRUE); |
|
872 |
|
|
866 | 873 |
shutdownToHibernate(BLT_TRUE); |
867 | 874 |
|
868 | 875 |
return; |
... | ... | |
877 | 884 |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
878 | 885 |
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); |
879 | 886 |
|
880 |
/* set/keep the SYS_SYNC and SYS_PD signal active */ |
|
887 |
/* set/keep the SYS_SYNC and SYS_PD signals active */
|
|
881 | 888 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
882 | 889 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
883 | 890 |
|
884 |
/* ensure that all modules had a chance to detect the pulse on SYS_PD_N */
|
|
891 |
/* initialized the standalone timer */
|
|
885 | 892 |
saTimerInit(); |
893 |
|
|
894 |
setLed(BLT_TRUE); |
|
895 |
|
|
896 |
/* deactivate SYS_PD_N and ensure that all modules had a chance to detect the falling edge */ |
|
886 | 897 |
msleep(1); |
887 | 898 |
GPIO_SetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
888 | 899 |
msleep(1); |
... | ... | |
902 | 913 |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
903 | 914 |
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); |
904 | 915 |
|
905 |
/* set/keep the SYS_SYNC and SYS_PD signal active */ |
|
916 |
/* set/keep the SYS_SYNC and SYS_PD signals active */
|
|
906 | 917 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
907 | 918 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
908 | 919 |
|
... | ... | |
919 | 930 |
/* wait for all boards to be ready for shutdown */ |
920 | 931 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
921 | 932 |
if (GPIO_ReadOutputDataBit(SYS_REG_EN_GPIO, SYS_REG_EN_PIN) == Bit_SET) { |
922 |
// this must skipped if the pullup voltage (VIO3.3) is not active |
|
933 |
// this must be skipped if the pullup voltage (VIO3.3) is not active
|
|
923 | 934 |
setLed(BLT_TRUE); |
924 | 935 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
925 | 936 |
setLed(BLT_FALSE); |
Also available in: Unified diff