Browse Source

stmhal/led: Refactor LED to use mp_hal_pin_output() init function.

As part of this patch the MICROPY_HW_LED_OTYPE setting is removed because
it is now unused (all boards anyway had this as OUTPUT_PP).
pull/2531/head
Damien George 8 years ago
parent
commit
b4cc68e4a4
  1. 5
      stmhal/boards/ESPRUINO_PICO/mpconfigboard.h
  2. 5
      stmhal/boards/HYDRABUS/mpconfigboard.h
  3. 5
      stmhal/boards/LIMIFROG/mpconfigboard.h
  4. 5
      stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
  5. 5
      stmhal/boards/NUCLEO_F401RE/mpconfigboard.h
  6. 5
      stmhal/boards/NUCLEO_F411RE/mpconfigboard.h
  7. 5
      stmhal/boards/OLIMEX_E407/mpconfigboard.h
  8. 5
      stmhal/boards/PYBLITEV10/mpconfigboard.h
  9. 5
      stmhal/boards/PYBV10/mpconfigboard.h
  10. 5
      stmhal/boards/PYBV11/mpconfigboard.h
  11. 5
      stmhal/boards/PYBV3/mpconfigboard.h
  12. 5
      stmhal/boards/PYBV4/mpconfigboard.h
  13. 5
      stmhal/boards/STM32F411DISC/mpconfigboard.h
  14. 5
      stmhal/boards/STM32F429DISC/mpconfigboard.h
  15. 5
      stmhal/boards/STM32F4DISC/mpconfigboard.h
  16. 5
      stmhal/boards/STM32F7DISC/mpconfigboard.h
  17. 5
      stmhal/boards/STM32L476DISC/mpconfigboard.h
  18. 11
      stmhal/led.c

5
stmhal/boards/ESPRUINO_PICO/mpconfigboard.h

@ -66,6 +66,5 @@
#define MICROPY_HW_LED2 (pin_B12) // green
#define MICROPY_HW_LED3 (pin_B12) // green
#define MICROPY_HW_LED4 (pin_B12) // green
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))

5
stmhal/boards/HYDRABUS/mpconfigboard.h

@ -69,9 +69,8 @@
#define MICROPY_HW_LED2 (pin_A4) // same as LED1
#define MICROPY_HW_LED3 (pin_A4) // same as LED1
#define MICROPY_HW_LED4 (pin_A4) // same as LED1
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// SD card detect switch (not used, always on)
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)

5
stmhal/boards/LIMIFROG/mpconfigboard.h

@ -63,9 +63,8 @@ void LIMIFROG_board_early_init(void);
// LEDs
#define MICROPY_HW_LED1 (pin_C3) // red
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRR = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRR = pin->pin_mask<<16)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// USB config
// #define MICROPY_HW_USB_OTG_ID_PIN (pin_C12) // This is not the official ID Pin which should be PA10

5
stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h

@ -64,9 +64,8 @@ void NETDUINO_PLUS_2_board_early_init(void);
#define MICROPY_HW_LED2 (pin_C13) // White LED (aka Power)
#define MICROPY_HW_LED3 (pin_A10) // Same as Led(1)
#define MICROPY_HW_LED4 (pin_C13) // Same as Led(2)
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// USB VBUS detect pin
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)

5
stmhal/boards/NUCLEO_F401RE/mpconfigboard.h

@ -54,6 +54,5 @@
// LEDs
#define MICROPY_HW_LED1 (pin_A5) // Green LD2 LED on Nucleo
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))

5
stmhal/boards/NUCLEO_F411RE/mpconfigboard.h

@ -65,6 +65,5 @@
// LEDs
#define MICROPY_HW_LED1 (pin_A5) // Green LD2 LED on Nucleo
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))

5
stmhal/boards/OLIMEX_E407/mpconfigboard.h

@ -71,9 +71,8 @@
// LEDs
#define MICROPY_HW_LED1 (pin_C13)
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_C11)

5
stmhal/boards/PYBLITEV10/mpconfigboard.h

@ -73,9 +73,8 @@
#define MICROPY_HW_LED4 (pin_B4) // blue
#define MICROPY_HW_LED3_PWM { TIM2, 2, TIM_CHANNEL_1, GPIO_AF1_TIM2 }
#define MICROPY_HW_LED4_PWM { TIM3, 3, TIM_CHANNEL_1, GPIO_AF2_TIM3 }
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_B5)

5
stmhal/boards/PYBV10/mpconfigboard.h

@ -84,9 +84,8 @@
#define MICROPY_HW_LED4 (pin_B4) // blue
#define MICROPY_HW_LED3_PWM { TIM2, 2, TIM_CHANNEL_1, GPIO_AF1_TIM2 }
#define MICROPY_HW_LED4_PWM { TIM3, 3, TIM_CHANNEL_1, GPIO_AF2_TIM3 }
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)

5
stmhal/boards/PYBV11/mpconfigboard.h

@ -84,9 +84,8 @@
#define MICROPY_HW_LED4 (pin_B4) // blue
#define MICROPY_HW_LED3_PWM { TIM2, 2, TIM_CHANNEL_1, GPIO_AF1_TIM2 }
#define MICROPY_HW_LED4_PWM { TIM3, 3, TIM_CHANNEL_1, GPIO_AF2_TIM3 }
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)

5
stmhal/boards/PYBV3/mpconfigboard.h

@ -73,9 +73,8 @@
#define MICROPY_HW_LED4 (pin_C5) // G2 - green
#define MICROPY_HW_LED1_PWM { TIM1, 1, TIM_CHANNEL_1, GPIO_AF1_TIM1 }
#define MICROPY_HW_LED2_PWM { TIM1, 1, TIM_CHANNEL_3, GPIO_AF1_TIM1 }
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_C13)

5
stmhal/boards/PYBV4/mpconfigboard.h

@ -81,9 +81,8 @@
#define MICROPY_HW_LED4 (pin_B4) // blue
#define MICROPY_HW_LED3_PWM { TIM2, 2, TIM_CHANNEL_1, GPIO_AF1_TIM2 }
#define MICROPY_HW_LED4_PWM { TIM3, 3, TIM_CHANNEL_1, GPIO_AF2_TIM3 }
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)

5
stmhal/boards/STM32F411DISC/mpconfigboard.h

@ -63,9 +63,8 @@
#define MICROPY_HW_LED2 (pin_D12) // green
#define MICROPY_HW_LED3 (pin_D13) // orange
#define MICROPY_HW_LED4 (pin_D15) // blue
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// USB config
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)

5
stmhal/boards/STM32F429DISC/mpconfigboard.h

@ -67,9 +67,8 @@
// LEDs
#define MICROPY_HW_LED1 (pin_G14) // red
#define MICROPY_HW_LED2 (pin_G13) // green
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// USB config
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_B13)

5
stmhal/boards/STM32F4DISC/mpconfigboard.h

@ -82,9 +82,8 @@
#define MICROPY_HW_LED2 (pin_D12) // green
#define MICROPY_HW_LED3 (pin_D13) // orange
#define MICROPY_HW_LED4 (pin_D15) // blue
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// USB config
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)

5
stmhal/boards/STM32F7DISC/mpconfigboard.h

@ -79,9 +79,8 @@ void STM32F7DISC_board_early_init(void);
// LEDs
#define MICROPY_HW_LED1 (pin_I1) // green
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRR = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRR = (pin->pin_mask << 16))
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_C13)

5
stmhal/boards/STM32L476DISC/mpconfigboard.h

@ -61,9 +61,8 @@
// LEDs
#define MICROPY_HW_LED1 (pin_B2) // red
#define MICROPY_HW_LED2 (pin_E8) // green
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRR = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRR = pin->pin_mask<<16)
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
// USB config
// #define MICROPY_HW_USB_OTG_ID_PIN (pin_C12) // This is not the official ID Pin which should be PA10

11
stmhal/led.c

@ -67,21 +67,12 @@ STATIC const pyb_led_obj_t pyb_led_obj[] = {
#define NUM_LEDS MP_ARRAY_SIZE(pyb_led_obj)
void led_init(void) {
/* GPIO structure */
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure I/O speed, mode, output type and pull */
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
GPIO_InitStructure.Mode = MICROPY_HW_LED_OTYPE;
GPIO_InitStructure.Pull = GPIO_NOPULL;
/* Turn off LEDs and initialize */
for (int led = 0; led < NUM_LEDS; led++) {
const pin_obj_t *led_pin = pyb_led_obj[led].led_pin;
mp_hal_gpio_clock_enable(led_pin->gpio);
MICROPY_HW_LED_OFF(led_pin);
GPIO_InitStructure.Pin = led_pin->pin_mask;
HAL_GPIO_Init(led_pin->gpio, &GPIO_InitStructure);
mp_hal_pin_output(led_pin);
}
}

Loading…
Cancel
Save