diff --git a/atmel_start_pins.h b/atmel_start_pins.h index 86e1dfb..7460529 100644 --- a/atmel_start_pins.h +++ b/atmel_start_pins.h @@ -27,11 +27,11 @@ #define GPIO_PIN_FUNCTION_M 12 #define GPIO_PIN_FUNCTION_N 13 -/** LED pin to indicate system state (pull low to switch on) */ -#define LED_SYSTEM GPIO(GPIO_PORTC, 18) +/** LED pin to indicate system state (pull high to switch on) */ +#define LED_SYSTEM GPIO(GPIO_PORTC, 26) /** User button to force DFu bootloader (connected to ground when pressed) */ -#define BUTTON_FORCE_DFU GPIO(GPIO_PORTB, 31) +#define BUTTON_FORCE_DFU GPIO(GPIO_PORTC, 14) /** USB D+/D- pins */ #define PA24 GPIO(GPIO_PORTA, 24) diff --git a/driver_init.c b/driver_init.c index a91b0eb..d5a151f 100644 --- a/driver_init.c +++ b/driver_init.c @@ -144,13 +144,12 @@ void system_init(void) init_mcu(); // configure system LED - gpio_set_pin_level(LED_SYSTEM, true); // switch off LED + gpio_set_pin_level(LED_SYSTEM, false); // switch off LED 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(); diff --git a/usb_dfu_main.c b/usb_dfu_main.c index 449b311..6a524e4 100644 --- a/usb_dfu_main.c +++ b/usb_dfu_main.c @@ -48,8 +48,7 @@ static bool check_bootloader(void) */ 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 + return (0 == gpio_get_pin_level(BUTTON_FORCE_DFU)); // signal is low when button is pressed (pulled high externally) } /** Check if the application is valid diff --git a/usb_start.c b/usb_start.c index ad91840..ab0f332 100644 --- a/usb_start.c +++ b/usb_start.c @@ -80,7 +80,7 @@ static void usb_dfu_reset(const enum usb_event ev, const uint32_t param) void usb_dfu(void) { while (!dfudf_is_enabled()); // wait for DFU to be installed - gpio_set_pin_level(LED_SYSTEM, false); // switch LED on to indicate USB DFU stack is ready + gpio_set_pin_level(LED_SYSTEM, true); // switch LED on to indicate USB DFU stack is ready ASSERT(hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw) <= 15); uint32_t application_start_address = (15 - hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw)) * 8192; // calculate bootloader size to know where we should write the application firmware @@ -89,7 +89,7 @@ void usb_dfu(void) while (true) { // main DFU infinite loop // run the second part of the USB DFU state machine handling non-USB aspects if (USB_DFU_STATE_DFU_DNLOAD_SYNC == dfu_state || USB_DFU_STATE_DFU_DNBUSY == dfu_state) { // there is some data to be flashed - gpio_set_pin_level(LED_SYSTEM, true); // switch LED off to indicate we are flashing + gpio_set_pin_level(LED_SYSTEM, false); // switch LED off to indicate we are flashing if (dfu_download_length > 0) { // there is some data to be flashed int32_t rc = flash_write(&FLASH_0, application_start_address + dfu_download_offset, dfu_download_data, dfu_download_length); // write downloaded data chunk to flash if (ERR_NONE == rc) { @@ -108,7 +108,7 @@ void usb_dfu(void) // this case should not happen, but it's not a critical error dfu_state = USB_DFU_STATE_DFU_DNLOAD_IDLE; // indicate flashing can continue } - gpio_set_pin_level(LED_SYSTEM, false); // switch LED on to indicate USB DFU can resume + gpio_set_pin_level(LED_SYSTEM, true); // switch LED on to indicate USB DFU can resume } if (USB_DFU_STATE_DFU_MANIFEST == dfu_state) { // we can start manifestation (finish flashing) // in theory every DFU files should have a suffix to with a CRC to check the data