Revision fc7151bb Target/Modules/LightRing_1-0/Boot/main.c
Target/Modules/LightRing_1-0/Boot/main.c | ||
---|---|---|
46 | 46 |
****************************************************************************************/ |
47 | 47 |
|
48 | 48 |
/**************************************************************************************** |
49 |
* Function prototypes |
|
49 |
* Function prototypes and static variables
|
|
50 | 50 |
****************************************************************************************/ |
51 | 51 |
static void Init(void); |
52 | 52 |
|
... | ... | |
75 | 75 |
|
76 | 76 |
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = { |
77 | 77 |
.magicNumber = BL_MAGIC_NUMBER, |
78 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Beta, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
|
|
78 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Beta, BL_VERSION_MAJOR, BL_VERSION_MINOR, 3},
|
|
79 | 79 |
.vSSSP = {BL_VERSION_ID_SSSP, BL_SSSP_VERSION_MAJOR, BL_SSSP_VERSION_MINOR, 0}, |
80 | 80 |
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported |
81 | 81 |
.cbShutdownHibernate = blCallbackShutdownHibernate, |
... | ... | |
257 | 257 |
/* enable clocks for CAN controller peripheral */ |
258 | 258 |
RCC->APB1ENR |= (blt_int32u)0x02000000; |
259 | 259 |
#endif |
260 |
|
|
260 | 261 |
#if (BOOT_COM_UART_ENABLE > 0 || BOOT_GATE_UART_ENABLE > 0) |
261 | 262 |
/* enable clocks for USART1 peripheral, transmitter and receiver pins (GPIOA and AFIO) */ |
262 | 263 |
RCC->APB2ENR |= (blt_int32u)(0x00004000 | 0x00000004 | 0x00000001); |
... | ... | |
344 | 345 |
gpio_init.GPIO_Speed = GPIO_Speed_50MHz; |
345 | 346 |
GPIO_Init(SYS_SYNC_N_GPIO, &gpio_init); |
346 | 347 |
|
348 |
/* initialize SYS_UART_DN and let it go (inactive) */ |
|
349 |
GPIO_SetBits(SYS_UART_DN_GPIO, SYS_UART_DN_PIN); |
|
350 |
gpio_init.GPIO_Pin = SYS_UART_DN_PIN; |
|
351 |
gpio_init.GPIO_Mode = GPIO_Mode_Out_OD; |
|
352 |
gpio_init.GPIO_Speed = GPIO_Speed_50MHz; |
|
353 |
GPIO_Init(SYS_UART_DN_GPIO, &gpio_init); |
|
354 |
|
|
347 | 355 |
/* |
348 | 356 |
* INPUTS |
349 | 357 |
*/ |
... | ... | |
416 | 424 |
|
417 | 425 |
/* wait for all boards to be ready for shutdown */ |
418 | 426 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
419 |
// this must no be skipped, since the pull-up voltage for SYS_SYNC_N (VIO3.3) must be configured at this point by definition. |
|
427 |
// this must not be skipped, since the pull-up voltage for SYS_SYNC_N (VIO3.3) must be configured at this point by definition.
|
|
420 | 428 |
setLed(BLT_TRUE); |
421 | 429 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
422 | 430 |
setLed(BLT_FALSE); |
... | ... | |
448 | 456 |
|
449 | 457 |
/* wait for all boards to be ready for shutdown */ |
450 | 458 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
451 |
// this must no be skipped, since the pull-up voltage for SYS_SYNC_N (VIO3.3) must be configured at this point by definition. |
|
459 |
// this must not be skipped, since the pull-up voltage for SYS_SYNC_N (VIO3.3) must be configured at this point by definition.
|
|
452 | 460 |
setLed(BLT_TRUE); |
453 | 461 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
454 | 462 |
setLed(BLT_FALSE); |
... | ... | |
480 | 488 |
|
481 | 489 |
/* wait for all boards to be ready for shutdown */ |
482 | 490 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
483 |
// this must no be skipped, since the pull-up voltage for SYS_SYNC_N (VIO3.3) must be configured at this point by definition. |
|
491 |
// this must not be skipped, since the pull-up voltage for SYS_SYNC_N (VIO3.3) must be configured at this point by definition.
|
|
484 | 492 |
setLed(BLT_TRUE); |
485 | 493 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
486 | 494 |
setLed(BLT_FALSE); |
... | ... | |
502 | 510 |
return; |
503 | 511 |
} /*** end of shutdownToHibernate ***/ |
504 | 512 |
|
513 |
/* |
|
514 |
* Final shutdown of the system and restart. |
|
515 |
*/ |
|
505 | 516 |
void shutdownAndRestart(const blt_bool exec_disambiguation) { |
506 | 517 |
/* configure some criticpal GPIOs as input |
507 | 518 |
* This is required, because otherwise some hardware might be powered through these signals */ |
... | ... | |
509 | 520 |
|
510 | 521 |
/* wait for all boards to be ready for shutdown */ |
511 | 522 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
512 |
// this must no be skipped, since the pull-up voltage for SYS_SYNC_N (VIO3.3) must be configured at this point by definition. |
|
523 |
// this must not be skipped, since the pull-up voltage for SYS_SYNC_N (VIO3.3) must be configured at this point by definition.
|
|
513 | 524 |
setLed(BLT_TRUE); |
514 | 525 |
waitForSignal(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN, Bit_SET); |
515 | 526 |
setLed(BLT_FALSE); |
... | ... | |
533 | 544 |
*/ |
534 | 545 |
|
535 | 546 |
return; |
536 |
} /*** end of shutdownAndRestart***/ |
|
547 |
} /*** end of shutdownAndRestart ***/
|
|
537 | 548 |
|
538 | 549 |
/* |
539 | 550 |
* Configures some GPIO pins as inputs for safety reasons. |
... | ... | |
602 | 613 |
// setLed(BLT_FALSE); |
603 | 614 |
// } else if (currentTime < loopStartTime + 50+100+50) { |
604 | 615 |
// setLed(BLT_TRUE); |
605 |
// } else if ( currentTime < loopStartTime + 50+100+50+300) {
|
|
616 |
// } else if (currentTime < loopStartTime + 50+100+50+300) { |
|
606 | 617 |
// setLed(BLT_FALSE); |
607 | 618 |
// } else { |
608 | 619 |
// loopStartTime = currentTime; |
... | ... | |
636 | 647 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
637 | 648 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
638 | 649 |
|
650 |
/* initialized the standalone timer */ |
|
639 | 651 |
saTimerInit(); |
640 | 652 |
|
641 | 653 |
setLed(BLT_TRUE); |
... | ... | |
659 | 671 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
660 | 672 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
661 | 673 |
|
674 |
/* initialized the standalone timer */ |
|
662 | 675 |
saTimerInit(); |
663 | 676 |
|
664 | 677 |
setLed(BLT_TRUE); |
... | ... | |
681 | 694 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
682 | 695 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
683 | 696 |
|
697 |
/* initialized the standalone timer */ |
|
684 | 698 |
saTimerInit(); |
685 | 699 |
|
686 | 700 |
setLed(BLT_TRUE); |
... | ... | |
703 | 717 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
704 | 718 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
705 | 719 |
|
706 |
/* ensure that all modules had a chance to detect the pulse on SYS_PD_N */
|
|
720 |
/* initialized the standalone timer */
|
|
707 | 721 |
saTimerInit(); |
722 |
|
|
723 |
setLed(BLT_TRUE); |
|
724 |
|
|
725 |
/* deactivate SYS_PD_N and ensure that all modules had a chance to detect the falling edge */ |
|
708 | 726 |
msleep(1); |
709 | 727 |
GPIO_SetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
710 | 728 |
msleep(1); |
... | ... | |
712 | 730 |
shutdownAndRestart(BLT_TRUE); |
713 | 731 |
|
714 | 732 |
return; |
715 |
} /** end of blCallbackShutdownRestart ***/ |
|
733 |
} /*** end of blCallbackShutdownRestart ***/
|
|
716 | 734 |
|
717 | 735 |
/* |
718 | 736 |
* Callback function that handles a system shutdown/restart request from another module. |
... | ... | |
728 | 746 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
729 | 747 |
GPIO_ResetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
730 | 748 |
|
731 |
/* ensure that all modules had a chance to detect the pulse on SYS_PD_N */
|
|
749 |
/* initialized the standalone timer */
|
|
732 | 750 |
saTimerInit(); |
751 |
|
|
752 |
setLed(BLT_TRUE); |
|
753 |
|
|
754 |
/* deactivate SYS_PD_N and ensure that all modules had a chance to detect the falling edge */ |
|
733 | 755 |
msleep(1); |
734 | 756 |
GPIO_SetBits(SYS_PD_N_GPIO, SYS_PD_N_PIN); |
735 | 757 |
msleep(1); |
Also available in: Unified diff