Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/12789


Change subject: change LED and switch to sysmoOCTSIM board
......................................................................

change LED and switch to sysmoOCTSIM board

Change-Id: I481d96a284240310b634f6dc0806d4a1972cd3b9
---
M atmel_start_pins.h
M driver_init.c
M usb_dfu_main.c
M usb_start.c
4 files changed, 8 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/89/12789/1

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 @@
        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_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 @@
 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 @@
        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 @@
                                // 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

--
To view, visit https://gerrit.osmocom.org/12789
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: sysmoOCTSIM
Gerrit-MessageType: newchange
Gerrit-Change-Id: I481d96a284240310b634f6dc0806d4a1972cd3b9
Gerrit-Change-Number: 12789
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <[email protected]>

Reply via email to