From 0ca77075909714d668a3c7138562b7926835541f Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 7 Mar 2022 15:09:47 -0800 Subject: [PATCH] Add a new 'target_post_setup' hook that targets can use for their own custom initialization --- src/dapboot.c | 3 ++- src/dummy.c | 7 +++++++ src/target.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dapboot.c b/src/dapboot.c index 551bc71..2b66151 100644 --- a/src/dapboot.c +++ b/src/dapboot.c @@ -75,7 +75,8 @@ int main(void) { dfu_setup(usbd_dev, validate_application, NULL, NULL); webusb_setup(usbd_dev); winusb_setup(usbd_dev); - + target_post_setup(); + while (1) { usbd_poll(usbd_dev); } diff --git a/src/dummy.c b/src/dummy.c index b10df11..25e0f2b 100644 --- a/src/dummy.c +++ b/src/dummy.c @@ -26,6 +26,7 @@ void target_get_serial_number(char* dest, size_t max_chars) __attribute__((weak) void target_log(const char* str) __attribute__((weak)); void target_pre_main(void) __attribute__((weak)); void target_pre_detach(bool manifested) __attribute__((weak)); +void target_post_setup(void) __attribute__((weak)); size_t target_get_timeout(void) __attribute__((weak)); void target_get_serial_number(char* dest, size_t max_chars) { @@ -44,6 +45,12 @@ void target_pre_main(void) } +void target_post_setup(void) +{ + /* This runs just before starting to listen to USB */ +} + + void target_pre_detach(bool manifested) { /* This runs just before executing a reboot in response to a USB bus reset or a detach request. diff --git a/src/target.h b/src/target.h index 2f748d0..429177e 100644 --- a/src/target.h +++ b/src/target.h @@ -36,6 +36,7 @@ extern void target_flash_lock(void); extern bool target_flash_program_array(uint16_t* dest, const uint16_t* data, size_t half_word_count); extern void target_pre_main(void); +extern void target_post_setup(void); extern void target_pre_detach(bool manifested); extern size_t target_get_timeout(void);