Kévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/12593
Change subject: add button to force DFU bootloader ...................................................................... add button to force DFU bootloader Change-Id: I163ab2de0fcbe13532c1992f6b78d49f4cda2d88 --- M atmel_start_pins.h M driver_init.c M usb_dfu_main.c 3 files changed, 12 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/93/12593/1 diff --git a/atmel_start_pins.h b/atmel_start_pins.h index 23b8d33..86e1dfb 100644 --- a/atmel_start_pins.h +++ b/atmel_start_pins.h @@ -27,9 +27,12 @@ #define GPIO_PIN_FUNCTION_M 12 #define GPIO_PIN_FUNCTION_N 13 -/** LED pin to indicate system state (pull low to switch on */ +/** LED pin to indicate system state (pull low to switch on) */ #define LED_SYSTEM GPIO(GPIO_PORTC, 18) +/** User button to force DFu bootloader (connected to ground when pressed) */ +#define BUTTON_FORCE_DFU GPIO(GPIO_PORTB, 31) + /** USB D+/D- pins */ #define PA24 GPIO(GPIO_PORTA, 24) #define PA25 GPIO(GPIO_PORTA, 25) diff --git a/driver_init.c b/driver_init.c index 0b07cc1..a91b0eb 100644 --- a/driver_init.c +++ b/driver_init.c @@ -148,6 +148,11 @@ gpio_set_pin_direction(LED_SYSTEM, GPIO_DIRECTION_OUT); gpio_set_pin_function(LED_SYSTEM, GPIO_PIN_FUNCTION_OFF); + // configure force DFU user button + gpio_set_pin_direction(BUTTON_FORCE_DFU, GPIO_DIRECTION_IN); + gpio_set_pin_pull_mode(BUTTON_FORCE_DFU, GPIO_PULL_UP); + gpio_set_pin_function(BUTTON_FORCE_DFU, GPIO_PIN_FUNCTION_OFF); + USB_DEVICE_INSTANCE_init(); FLASH_0_init(); } diff --git a/usb_dfu_main.c b/usb_dfu_main.c index 91748a5..449b311 100644 --- a/usb_dfu_main.c +++ b/usb_dfu_main.c @@ -48,6 +48,8 @@ */ static bool check_force_dfu(void) { + gpio_set_pin_pull_mode(BUTTON_FORCE_DFU, GPIO_PULL_UP); // pull button high + return (0 == gpio_get_pin_level(BUTTON_FORCE_DFU)); // signal is low when button is pressed } /** Check if the application is valid @@ -87,7 +89,7 @@ delay_ms(500); } } - if (check_application()) { // application is valid + if (!check_force_dfu() && check_application()) { // application is valid start_application(); // start application } else { usb_dfu(); // start DFU bootloader -- To view, visit https://gerrit.osmocom.org/12593 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-asf4-dfu Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I163ab2de0fcbe13532c1992f6b78d49f4cda2d88 Gerrit-Change-Number: 12593 Gerrit-PatchSet: 1 Gerrit-Owner: Kévin Redon <kre...@sysmocom.de>