File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 8181// This API does not init usb which is only init if DFU is entered
8282void board_init (void );
8383
84+ // board_init2 is the same as board_init, but allows custom boards
85+ // to have a chance at board_init without modifying the boards.c file.
86+ void board_init2 (void ) __attribute__ ((weak ));
87+
8488// opposite to board_init(), reset all board peripherals. Is called before jumping to application
8589// TODO force this API in the future
8690void board_teardown (void ) __attribute__ ((weak ));
8791
92+ // board_teardown2() is called immeidately after board_init()
93+ void board_teardown2 (void ) __attribute__ ((weak ));
94+
8895// Reset board, not return
8996void board_reset (void );
9097
@@ -112,6 +119,9 @@ extern void board_timer_handler(void);
112119// Check if application is valid
113120bool board_app_valid (void );
114121
122+ // Additional check if application is valid for custom board.
123+ bool board_app_valid2 (void ) __attribute__ ((weak ));
124+
115125// Jump to Application
116126void board_app_jump (void );
117127
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ static bool check_dfu_mode(void);
6363int main (void )
6464{
6565 board_init ();
66+ if (board_init2 ) board_init2 ();
6667 TU_LOG1 ("TinyUF2\r\n" );
6768
6869#if TINYUF2_PROTECT_BOOTLOADER
@@ -74,6 +75,7 @@ int main(void)
7475 {
7576 TU_LOG1 ("Jump to application\r\n" );
7677 if (board_teardown ) board_teardown ();
78+ if (board_teardown2 ) board_teardown2 ();
7779 board_app_jump ();
7880 while (1 ) {}
7981 }
@@ -122,6 +124,7 @@ static bool check_dfu_mode(void)
122124
123125 // Check if app is valid
124126 if ( !board_app_valid () ) return true;
127+ if ( board_app_valid2 && !board_app_valid2 () ) return true;
125128
126129#if TINYUF2_DFU_DOUBLE_TAP
127130// TU_LOG1_HEX(DBL_TAP_REG);
You can’t perform that action at this time.
0 commit comments