Skip to content

Commit 94762bd

Browse files
authored
Merge pull request #47 from keyboardio/f/target-post-setup-hook
Add a new 'target_post_setup' hook that targets can use for their own custom initialization
2 parents 3f5f387 + 0ca7707 commit 94762bd

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/dapboot.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ int main(void) {
7575
dfu_setup(usbd_dev, validate_application, NULL, NULL);
7676
webusb_setup(usbd_dev);
7777
winusb_setup(usbd_dev);
78-
78+
target_post_setup();
79+
7980
while (1) {
8081
usbd_poll(usbd_dev);
8182
}

src/dummy.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void target_get_serial_number(char* dest, size_t max_chars) __attribute__((weak)
2626
void target_log(const char* str) __attribute__((weak));
2727
void target_pre_main(void) __attribute__((weak));
2828
void target_pre_detach(bool manifested) __attribute__((weak));
29+
void target_post_setup(void) __attribute__((weak));
2930
size_t target_get_timeout(void) __attribute__((weak));
3031

3132
void target_get_serial_number(char* dest, size_t max_chars) {
@@ -44,6 +45,12 @@ void target_pre_main(void)
4445

4546
}
4647

48+
void target_post_setup(void)
49+
{
50+
/* This runs just before starting to listen to USB */
51+
}
52+
53+
4754
void target_pre_detach(bool manifested) {
4855
/* This runs just before executing a reboot in response to a USB bus reset
4956
or a detach request.

src/target.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ extern void target_flash_lock(void);
3636
extern bool target_flash_program_array(uint16_t* dest, const uint16_t* data, size_t half_word_count);
3737

3838
extern void target_pre_main(void);
39+
extern void target_post_setup(void);
3940
extern void target_pre_detach(bool manifested);
4041
extern size_t target_get_timeout(void);
4142

0 commit comments

Comments
 (0)