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 81
81
// This API does not init usb which is only init if DFU is entered
82
82
void board_init (void );
83
83
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
+
84
88
// opposite to board_init(), reset all board peripherals. Is called before jumping to application
85
89
// TODO force this API in the future
86
90
void board_teardown (void ) __attribute__ ((weak ));
87
91
92
+ // board_teardown2() is called immeidately after board_init()
93
+ void board_teardown2 (void ) __attribute__ ((weak ));
94
+
88
95
// Reset board, not return
89
96
void board_reset (void );
90
97
@@ -112,6 +119,9 @@ extern void board_timer_handler(void);
112
119
// Check if application is valid
113
120
bool board_app_valid (void );
114
121
122
+ // Additional check if application is valid for custom board.
123
+ bool board_app_valid2 (void ) __attribute__ ((weak ));
124
+
115
125
// Jump to Application
116
126
void board_app_jump (void );
117
127
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ static bool check_dfu_mode(void);
63
63
int main (void )
64
64
{
65
65
board_init ();
66
+ if (board_init2 ) board_init2 ();
66
67
TU_LOG1 ("TinyUF2\r\n" );
67
68
68
69
#if TINYUF2_PROTECT_BOOTLOADER
@@ -74,6 +75,7 @@ int main(void)
74
75
{
75
76
TU_LOG1 ("Jump to application\r\n" );
76
77
if (board_teardown ) board_teardown ();
78
+ if (board_teardown2 ) board_teardown2 ();
77
79
board_app_jump ();
78
80
while (1 ) {}
79
81
}
@@ -122,6 +124,7 @@ static bool check_dfu_mode(void)
122
124
123
125
// Check if app is valid
124
126
if ( !board_app_valid () ) return true;
127
+ if ( board_app_valid2 && !board_app_valid2 () ) return true;
125
128
126
129
#if TINYUF2_DFU_DOUBLE_TAP
127
130
// TU_LOG1_HEX(DBL_TAP_REG);
You can’t perform that action at this time.
0 commit comments