Skip to content

nativeio, microcontroller and board modules #50

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 3 commits into from
Nov 21, 2016
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
56 changes: 38 additions & 18 deletions atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ INC += -I.
INC += -I..
INC += -I../lib/mp-readline
INC += -I../lib/timeutils
INC += -Icommon-hal/modules/
INC += -Iasf_conf/
INC += -Iasf/common/boards/
INC += -Iasf/common/services/sleepmgr/
Expand Down Expand Up @@ -79,7 +78,23 @@ CFLAGS_CORTEX_M0 = \
-msoft-float \
-mfloat-abi=soft \
-fsingle-precision-constant \
-fno-strict-aliasing \
-Wdouble-promotion \
-Wno-endif-labels \
-Wstrict-prototypes \
-Werror-implicit-function-declaration \
-Wpointer-arith \
-Wfloat-equal \
-Wundef \
-Wshadow \
-Wwrite-strings \
-Wsign-compare \
-Wmissing-format-attribute \
-Wno-deprecated-declarations \
-Wpacked \
-Wnested-externs \
-Wunreachable-code \
-Wcast-align \
-D__SAMD21G18A__ \
-DUSB_DEVICE_PRODUCT_ID=$(USB_PID) \
-DUSB_DEVICE_VENDOR_ID=$(USB_VID) \
Expand All @@ -92,9 +107,15 @@ CFLAGS_CORTEX_M0 = \
-DEXTINT_CALLBACK_MODE=true \
-DUDD_ENABLE \
-DUSART_CALLBACK_MODE=true \
-DSPI_CALLBACK_MODE=false \
-DI2C_MASTER_CALLBACK_MODE=false \
-DDAC_CALLBACK_MODE=false \
-DTCC_ASYNC=false \
-DADC_CALLBACK_MODE=false \
-DTC_ASYNC=true \
-DUSB_DEVICE_LPM_SUPPORT
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)
-DUSB_DEVICE_LPM_SUPPORT \
--param max-inline-insns-single=500
CFLAGS = $(INC) -Wall -Werror -std=gnu11 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)

#Debugging/Optimization
# TODO(tannewt): Figure out what NDEBUG does. Adding it to the debug build
Expand Down Expand Up @@ -154,17 +175,10 @@ SRC_C = \
builtin_open.c \
fatfs_port.c \
main.c \
modmachine.c \
modmachine_adc.c \
modmachine_dac.c \
modmachine_pin.c \
modmachine_pwm.c \
modneopixel_write.c \
moduos.c \
modutime.c \
mphalport.c \
pin_named_pins.c \
samdneopixel.c \
samd21_pins.c \
neopixel_status.c \
tick.c \
$(FLASH_IMPL) \
asf/common/services/sleepmgr/samd/sleepmgr.c \
Expand All @@ -178,7 +192,6 @@ SRC_C = \
asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c \
asf/sam0/utils/cmsis/samd21/source/system_samd21.c \
asf/sam0/utils/syscalls/gcc/syscalls.c \
boards/samd21_pins.c \
boards/$(BOARD)/init.c \
boards/$(BOARD)/pins.c \
lib/fatfs/ff.c \
Expand All @@ -194,12 +207,19 @@ STM_SRC_C = $(addprefix stmhal/,\
input.c \
)

# TODO(tannewt): Use this sed line to extract the RST docs from these sources:
# sed': sed -n 's+^//|++p' ../api/machine.c
#
# RST lines are prefixed with //|
SRC_BINDINGS = \
modules/machine.c
board/__init__.c \
microcontroller/__init__.c \
microcontroller/Pin.c \
nativeio/__init__.c \
nativeio/AnalogIn.c \
nativeio/AnalogOut.c \
nativeio/DigitalInOut.c \
nativeio/I2C.c \
nativeio/PWMOut.c \
nativeio/SPI.c \
neopixel_write/__init__.c \
time/__init__.c

SRC_BINDINGS_EXPANDED = $(addprefix shared-bindings/, $(SRC_BINDINGS)) \
$(addprefix common-hal/, $(SRC_BINDINGS))
Expand Down
10 changes: 5 additions & 5 deletions atmel-samd/autoreset.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

extern volatile bool reset_next_character;

void autoreset_tick();
void autoreset_tick(void);

void autoreset_start();
void autoreset_stop();
void autoreset_enable();
void autoreset_disable();
void autoreset_start(void);
void autoreset_stop(void);
void autoreset_enable(void);
void autoreset_disable(void);

#endif // __MICROPY_INCLUDED_ATMEL_SAMD_AUTORESET_H__
4 changes: 2 additions & 2 deletions atmel-samd/boards/arduino_zero/conf_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void usb_rts_notify(uint8_t port, bool set);

//! Interface callback definition
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
extern bool mp_msc_enable();
extern bool mp_msc_enable(void);
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
extern void mp_msc_disable();
extern void mp_msc_disable(void);

//! Enable id string of interface to add an extra USB string
#define UDI_MSC_STRING_ID 5
Expand Down
4 changes: 3 additions & 1 deletion atmel-samd/boards/arduino_zero/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#define MICROPY_HW_LED_TX PIN_PA27
#define MICROPY_HW_LED_RX PIN_PB03

#define MICROPY_HW_NEOPIXEL PIN_PB22
#define MICROPY_HW_NEOPIXEL &pin_PB22

#define AUTORESET_DELAY_MS 500

#define FLASH_INCLUDE "internal_flash.h"
8 changes: 5 additions & 3 deletions atmel-samd/boards/arduino_zero/pins.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "boards/samd21_pins.h"
#include "shared-bindings/board/__init__.h"

STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
#include "samd21_pins.h"

STATIC const mp_map_elem_t board_global_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), (mp_obj_t)&pin_PA02 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), (mp_obj_t)&pin_PB08 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), (mp_obj_t)&pin_PB09 },
Expand All @@ -27,4 +29,4 @@ STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), (mp_obj_t)&pin_PB10 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_MISO), (mp_obj_t)&pin_PA12 },
};
MP_DEFINE_CONST_DICT(pin_board_pins_locals_dict, pin_board_pins_locals_dict_table);
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
4 changes: 2 additions & 2 deletions atmel-samd/boards/feather_m0_adalogger/conf_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void usb_rts_notify(uint8_t port, bool set);

//! Interface callback definition
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
extern bool mp_msc_enable();
extern bool mp_msc_enable(void);
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
extern void mp_msc_disable();
extern void mp_msc_disable(void);

//! Enable id string of interface to add an extra USB string
#define UDI_MSC_STRING_ID 5
Expand Down
2 changes: 2 additions & 0 deletions atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
#define MICROPY_HW_MCU_NAME "samd21g18"

#define AUTORESET_DELAY_MS 500

#define FLASH_INCLUDE "internal_flash.h"
6 changes: 3 additions & 3 deletions atmel-samd/boards/feather_m0_adalogger/pins.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "boards/samd21_pins.h"
#include "samd21_pins.h"

STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
STATIC const mp_map_elem_t board_global_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), (mp_obj_t)&pin_PA02 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), (mp_obj_t)&pin_PB08 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), (mp_obj_t)&pin_PB09 },
Expand All @@ -23,4 +23,4 @@ STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_D12), (mp_obj_t)&pin_PA19 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), (mp_obj_t)&pin_PA17 },
};
MP_DEFINE_CONST_DICT(pin_board_pins_locals_dict, pin_board_pins_locals_dict_table);
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
4 changes: 2 additions & 2 deletions atmel-samd/boards/feather_m0_basic/conf_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void usb_rts_notify(uint8_t port, bool set);

//! Interface callback definition
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
extern bool mp_msc_enable();
extern bool mp_msc_enable(void);
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
extern void mp_msc_disable();
extern void mp_msc_disable(void);

//! Enable id string of interface to add an extra USB string
#define UDI_MSC_STRING_ID 5
Expand Down
2 changes: 2 additions & 0 deletions atmel-samd/boards/feather_m0_basic/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
#define MICROPY_HW_MCU_NAME "samd21g18"

#define AUTORESET_DELAY_MS 500

#define FLASH_INCLUDE "internal_flash.h"
6 changes: 3 additions & 3 deletions atmel-samd/boards/feather_m0_basic/pins.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "boards/samd21_pins.h"
#include "samd21_pins.h"

STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
STATIC const mp_map_elem_t board_global_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), (mp_obj_t)&pin_PA02 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), (mp_obj_t)&pin_PB08 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), (mp_obj_t)&pin_PB09 },
Expand All @@ -22,4 +22,4 @@ STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_D12), (mp_obj_t)&pin_PA19 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), (mp_obj_t)&pin_PA17 },
};
MP_DEFINE_CONST_DICT(pin_board_pins_locals_dict, pin_board_pins_locals_dict_table);
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
4 changes: 2 additions & 2 deletions atmel-samd/boards/feather_m0_flash/conf_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void usb_rts_notify(uint8_t port, bool set);

//! Interface callback definition
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
extern bool mp_msc_enable();
extern bool mp_msc_enable(void);
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
extern void mp_msc_disable();
extern void mp_msc_disable(void);

//! Enable id string of interface to add an extra USB string
#define UDI_MSC_STRING_ID 5
Expand Down
2 changes: 2 additions & 0 deletions atmel-samd/boards/feather_m0_flash/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
#define SPI_FLASH_SERCOM SERCOM4

#define AUTORESET_DELAY_MS 500

#define FLASH_INCLUDE "spi_flash.h"
4 changes: 2 additions & 2 deletions atmel-samd/boards/metro_m0_flash/conf_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void usb_rts_notify(uint8_t port, bool set);

//! Interface callback definition
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
extern bool mp_msc_enable();
extern bool mp_msc_enable(void);
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
extern void mp_msc_disable();
extern void mp_msc_disable(void);

//! Enable id string of interface to add an extra USB string
#define UDI_MSC_STRING_ID 5
Expand Down
4 changes: 3 additions & 1 deletion atmel-samd/boards/metro_m0_flash/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define MICROPY_HW_LED_TX PIN_PA27
#define MICROPY_HW_LED_RX PIN_PB03

#define MICROPY_HW_NEOPIXEL PIN_PA30
#define MICROPY_HW_NEOPIXEL &pin_PA30

#define SPI_FLASH_BAUDRATE (1000000)

Expand All @@ -33,3 +33,5 @@
#define SPI_FLASH_SERCOM SERCOM4

#define AUTORESET_DELAY_MS 500

#define FLASH_INCLUDE "spi_flash.h"
6 changes: 3 additions & 3 deletions atmel-samd/boards/metro_m0_flash/pins.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "boards/samd21_pins.h"
#include "samd21_pins.h"

STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
STATIC const mp_map_elem_t board_global_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), (mp_obj_t)&pin_PA02 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), (mp_obj_t)&pin_PB08 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), (mp_obj_t)&pin_PB09 },
Expand Down Expand Up @@ -30,4 +30,4 @@ STATIC const mp_map_elem_t pin_board_pins_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_MISO), (mp_obj_t)&pin_PA12 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_CS), (mp_obj_t)&pin_PA13 },
};
MP_DEFINE_CONST_DICT(pin_board_pins_locals_dict, pin_board_pins_locals_dict_table);
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
Loading