Skip to content

Print an error if an invalid BOARD is specified #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions stm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ CFLAGS += -I$(FATFS_DIR)
#CFLAGS += -I$(CC3K_DIR)

BOARD ?= PYBOARD4
ifeq ($(wildcard boards/$(BOARD)/.),)
$(error Invalid BOARD specified)
endif
CFLAGS += -Iboards/$(BOARD)

#Debugging/Optimization
Expand Down Expand Up @@ -67,13 +70,14 @@ SRC_C = \
audio.c \
sdcard.c \
i2c.c \
usrsw.c \
adc.c \
rtc.c \
file.c \
pin.c \
pin_named_pins.c \
pin_map.c \
exti.c \
usrsw.c \
# pybwlan.c \

SRC_S = \
Expand Down Expand Up @@ -185,10 +189,21 @@ MAKE_PINS = boards/make-pins.py
BOARD_PINS = boards/$(BOARD)/pins.csv
AF_FILE = boards/stm32f4xx-af.csv
PREFIX_FILE = boards/stm32f4xx-prefix.c

$(BUILD)/pins_$(BOARD).c: $(MAKE_PINS) $(BOARD_PINS) $(AF_FILE) $(PREFIX_FILE)
GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
GEN_PINS_HDR = $(BUILD)/pins.h

# Making OBJ use an order-only depenedency on the generated pins.h file
# has the side effect of making the pins.h file before we actually compile
# any of the objects. The normal dependency generation will deal with the
# case when pins.h is modified. But when it doesn't exist, we don't know
# which source files might need it.
$(OBJ): | $(BUILD)/pins.h

# Use a pattern rule here so that make will only call make-pins.py once to make
# both pins_$(BOARD).c and pins.h
$(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE)
$(ECHO) "Create $@"
$(Q)python $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) > $@
$(Q)python $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) > $(GEN_PINS_SRC)

$(BUILD)/pins_$(BOARD).o: $(BUILD)/pins_$(BOARD).c
$(call compile_c)
Expand Down
9 changes: 3 additions & 6 deletions stm/boards/NETDUINO_PLUS_2/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
#define MICROPY_HW_ENABLE_SERVO (1)
#define MICROPY_HW_ENABLE_AUDIO (0)

#define USRSW_PORT (GPIOB)
#define USRSW_PIN (GPIO_Pin_11)
// USRSW is pulled low. Pressing the button makes the input go high.
#define USRSW_PIN (pin_B11)
#define USRSW_PUPD (GPIO_PuPd_NOPULL)
#define USRSW_EXTI_PIN (EXTI_PinSource11)
#define USRSW_EXTI_PORT (EXTI_PortSourceGPIOB)
#define USRSW_EXTI_LINE (EXTI_Line11)
#define USRSW_EXTI_IRQN (EXTI15_10_IRQn)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Rising)
#define USRSW_PRESSED (1)

/* LED */
#define PYB_LED1_PORT (GPIOA) // Blue LED
Expand Down
11 changes: 4 additions & 7 deletions stm/boards/PYBOARD3/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
#define MICROPY_HW_ENABLE_SERVO (1)
#define MICROPY_HW_ENABLE_AUDIO (0)

#define USRSW_PORT (GPIOA)
#define USRSW_PIN (GPIO_Pin_13)
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
#define USRSW_PIN (pin_A13)
#define USRSW_PUPD (GPIO_PuPd_UP)
#define USRSW_EXTI_PIN (EXTI_PinSource13)
#define USRSW_EXTI_PORT (EXTI_PortSourceGPIOA)
#define USRSW_EXTI_LINE (EXTI_Line13)
#define USRSW_EXTI_IRQN (EXTI15_10_IRQn)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Rising)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Falling)
#define USRSW_PRESSED (0)

/* LED */
#define PYB_LED1_PORT (GPIOA)
Expand Down
11 changes: 4 additions & 7 deletions stm/boards/PYBOARD4/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
#define MICROPY_HW_ENABLE_SERVO (1)
#define MICROPY_HW_ENABLE_AUDIO (0)

#define USRSW_PORT (GPIOB)
#define USRSW_PIN (GPIO_Pin_3)
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
#define USRSW_PIN (pin_B3)
#define USRSW_PUPD (GPIO_PuPd_UP)
#define USRSW_EXTI_PIN (EXTI_PinSource3)
#define USRSW_EXTI_PORT (EXTI_PortSourceGPIOB)
#define USRSW_EXTI_LINE (EXTI_Line3)
#define USRSW_EXTI_IRQN (EXTI3_IRQn)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Rising)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Falling)
#define USRSW_PRESSED (0)

/* LED */
#define PYB_LED1_PORT (GPIOA)
Expand Down
11 changes: 4 additions & 7 deletions stm/boards/STM32F4DISC/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
#define MICROPY_HW_ENABLE_SERVO (0)
#define MICROPY_HW_ENABLE_AUDIO (0)

#define USRSW_PORT (GPIOA)
#define USRSW_PIN (GPIO_Pin_0)
// USRSW is pulled low. Pressing the button makes the input go high.
#define USRSW_PIN (pin_A0)
#define USRSW_PUPD (GPIO_PuPd_NOPULL)
#define USRSW_EXTI_PIN (EXTI_PinSource0)
#define USRSW_EXTI_PORT (EXTI_PortSourceGPIOA)
#define USRSW_EXTI_LINE (EXTI_Line0)
#define USRSW_EXTI_IRQN (EXTI0_IRQn)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Falling)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Rising)
#define USRSW_PRESSED (1)

/* LED */
#define PYB_LED1_PORT (GPIOD)
Expand Down
20 changes: 20 additions & 0 deletions stm/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ def print(self):
self.alt_fn_count, self.alt_fn_name()))
print('')

def print_header(self, hdr_file):
hdr_file.write('extern const pin_obj_t pin_{:s};\n'.
format(self.pin_name()))
if self.alt_fn_count > 0:
hdr_file.write('extern const pin_af_obj_t pin_{:s}_af[];\n'.
format(self.pin_name()))


class Pins(object):

Expand Down Expand Up @@ -191,6 +198,12 @@ def print(self):
print('')
self.print_named('board', self.board_pins)

def print_header(self, hdr_filename):
with open(hdr_filename, 'wb') as hdr_file:
for pin in self.pins:
if pin.board_name:
pin.print_header(hdr_file)


def main():
parser = argparse.ArgumentParser(
Expand All @@ -215,6 +228,12 @@ def main():
help="Specifies beginning portion of generated pins file",
default="stm32f4xx-prefix.c"
)
parser.add_argument(
"-r", "--hdr",
dest="hdr_filename",
help="Specifies name of generated pin header file",
default="build/pins.h"
)
args = parser.parse_args(sys.argv[1:])

pins = Pins()
Expand All @@ -235,6 +254,7 @@ def main():
with open(args.prefix_filename, 'r') as prefix_file:
print(prefix_file.read())
pins.print()
pins.print_header(args.hdr_filename)


if __name__ == "__main__":
Expand Down
Loading