Skip to content

Commit 09d2077

Browse files
committed
stmhal: Unify naming of HW config; make SD detect configurable.
All board config macros now begin with MICROPY_HW_. Renamed PYBv10 to PYBV10, since macros should be all uppercase. Made SDCARD_DETECT configurable in mpconfigport.h, so that the SD detect pin can be easily configured.
1 parent 24a140a commit 09d2077

24 files changed

Lines changed: 586 additions & 172 deletions

stmhal/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ INC += -I$(FATFS_DIR)/src
2929
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
3030
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
3131

32-
BOARD ?= PYBv10
32+
BOARD ?= PYBV10
3333
ifeq ($(wildcard boards/$(BOARD)/.),)
3434
$(error Invalid BOARD specified)
3535
endif

stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,16 @@
1919
#define MICROPY_HW_ENABLE_DAC (0)
2020

2121
// USRSW is pulled low. Pressing the button makes the input go high.
22-
#define USRSW_PIN (pin_B11)
23-
#define USRSW_PULL (GPIO_NOPULL)
24-
#define USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
25-
#define USRSW_PRESSED (1)
26-
27-
/* LED */
28-
#define PYB_LED1 (pin_A10) // Blue LED
29-
#define PYB_LED2 (pin_C13) // White LED (aka Power)
30-
#define PYB_LED3 (pin_A10) // Same as Led(1)
31-
#define PYB_LED4 (pin_C13) // Same as Led(2)
32-
33-
#define PYB_OTYPE (GPIO_MODE_OUTPUT_PP)
34-
35-
#define PYB_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
36-
#define PYB_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
37-
22+
#define MICROPY_HW_USRSW_PIN (pin_B11)
23+
#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
24+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
25+
#define MICROPY_HW_USRSW_PRESSED (1)
26+
27+
// LEDs
28+
#define MICROPY_HW_LED1 (pin_A10) // Blue LED
29+
#define MICROPY_HW_LED2 (pin_C13) // White LED (aka Power)
30+
#define MICROPY_HW_LED3 (pin_A10) // Same as Led(1)
31+
#define MICROPY_HW_LED4 (pin_C13) // Same as Led(2)
32+
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
33+
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
34+
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)

stmhal/boards/PYBOARD3/mpconfigboard.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

stmhal/boards/PYBOARD4/mpconfigboard.h

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#define PYBV10
2+
3+
#define MICROPY_HW_BOARD_NAME "PYBv1.0"
4+
5+
#define MICROPY_HW_HAS_SWITCH (1)
6+
#define MICROPY_HW_HAS_SDCARD (1)
7+
#define MICROPY_HW_HAS_MMA7660 (1)
8+
#define MICROPY_HW_HAS_LIS3DSH (0)
9+
#define MICROPY_HW_HAS_LCD (1)
10+
#define MICROPY_HW_HAS_WLAN (0)
11+
#define MICROPY_HW_ENABLE_RNG (1)
12+
#define MICROPY_HW_ENABLE_RTC (1)
13+
#define MICROPY_HW_ENABLE_TIMER (1)
14+
#define MICROPY_HW_ENABLE_SERVO (1)
15+
#define MICROPY_HW_ENABLE_DAC (1)
16+
17+
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
18+
#define MICROPY_HW_USRSW_PIN (pin_B3)
19+
#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
20+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
21+
#define MICROPY_HW_USRSW_PRESSED (0)
22+
23+
// The pyboard has 4 LEDs
24+
#define MICROPY_HW_LED1 (pin_A13) // red
25+
#define MICROPY_HW_LED2 (pin_A14) // green
26+
#define MICROPY_HW_LED3 (pin_A15) // yellow
27+
#define MICROPY_HW_LED4 (pin_B4) // blue
28+
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
29+
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
30+
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
31+
32+
// SD card detect switch
33+
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
34+
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
35+
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ LED_RED,PA13
4343
LED_GREEN,PA14
4444
LED_YELLOW,PA15
4545
SW,PB3
46+
SD,PA8
File renamed without changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#define PYBV3
2+
3+
#define MICROPY_HW_BOARD_NAME "PYBv3"
4+
5+
#define MICROPY_HW_HAS_SWITCH (1)
6+
#define MICROPY_HW_HAS_SDCARD (1)
7+
#define MICROPY_HW_HAS_MMA7660 (1)
8+
#define MICROPY_HW_HAS_LIS3DSH (0)
9+
#define MICROPY_HW_HAS_LCD (0)
10+
#define MICROPY_HW_HAS_WLAN (0)
11+
#define MICROPY_HW_ENABLE_RNG (1)
12+
#define MICROPY_HW_ENABLE_RTC (1)
13+
#define MICROPY_HW_ENABLE_TIMER (1)
14+
#define MICROPY_HW_ENABLE_SERVO (1)
15+
#define MICROPY_HW_ENABLE_DAC (0)
16+
17+
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
18+
#define MICROPY_HW_USRSW_PIN (pin_A13)
19+
#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
20+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
21+
#define MICROPY_HW_USRSW_PRESSED (0)
22+
23+
// LEDs
24+
#define MICROPY_HW_LED1 (pin_A8) // R1 - red
25+
#define MICROPY_HW_LED2 (pin_A10) // R2 - red
26+
#define MICROPY_HW_LED3 (pin_C4) // G1 - green
27+
#define MICROPY_HW_LED4 (pin_C5) // G2 - green
28+
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
29+
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRH = pin->pin_mask)
30+
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRL = pin->pin_mask)
31+
32+
// SD card detect switch
33+
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_C13)
34+
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLDOWN)
35+
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_SET)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ LED_R2,PA10
3434
LED_G1,PC4
3535
LED_G2,PC5
3636
SW,PA13
37-
37+
SD,PC13

0 commit comments

Comments
 (0)