Showing with 1,433 additions and 741 deletions.
  1. +0 −1 .travis.yml
  2. +15 −7 atmel-samd/Makefile
  3. +49 −0 atmel-samd/boards/arduino_zero/board.c
  4. +0 −32 atmel-samd/boards/arduino_zero/init.c
  5. +45 −0 atmel-samd/boards/board.h
  6. +65 −0 atmel-samd/boards/circuitplayground_express/board.c
  7. +0 −18 atmel-samd/boards/circuitplayground_express/init.c
  8. +3 −0 atmel-samd/boards/circuitplayground_express/mpconfigboard.h
  9. +1 −1 atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
  10. +38 −0 atmel-samd/boards/feather_m0_adalogger/board.c
  11. +0 −20 atmel-samd/boards/feather_m0_adalogger/init.c
  12. +38 −0 atmel-samd/boards/feather_m0_basic/board.c
  13. +0 −20 atmel-samd/boards/feather_m0_basic/init.c
  14. +38 −0 atmel-samd/boards/feather_m0_express/board.c
  15. +0 −20 atmel-samd/boards/feather_m0_express/init.c
  16. +38 −0 atmel-samd/boards/gemma_m0/board.c
  17. +0 −18 atmel-samd/boards/gemma_m0/init.c
  18. +49 −0 atmel-samd/boards/metro_m0_express/board.c
  19. +0 −31 atmel-samd/boards/metro_m0_express/init.c
  20. +1 −1 atmel-samd/boards/metro_m0_express/mpconfigboard.mk
  21. +3 −3 atmel-samd/boards/metro_m0_express/pins.c
  22. +37 −0 atmel-samd/boards/trinket_m0/board.c
  23. +0 −18 atmel-samd/boards/trinket_m0/init.c
  24. +8 −8 atmel-samd/common-hal/digitalio/DigitalInOut.c
  25. +64 −20 atmel-samd/common-hal/pulseio/PWMOut.c
  26. +23 −0 atmel-samd/main.c
  27. +8 −2 atmel-samd/mpconfigport.h
  28. +5 −5 atmel-samd/samd21_pins.c
  29. +3 −3 conf.py
  30. +1 −1 docs/common_hal.md
  31. +65 −0 docs/design_guide.rst
  32. +12 −3 docs/drivers.rst
  33. +9 −2 esp8266/Makefile
  34. +8 −8 esp8266/common-hal/digitalio/DigitalInOut.c
  35. +11 −6 index.rst
  36. 0 stmhal/input.c → lib/mp-readline/builtin_input.c
  37. +15 −12 py/argcheck.c
  38. +4 −0 py/stackctrl.c
  39. +4 −3 shared-bindings/analogio/AnalogIn.c
  40. +4 −3 shared-bindings/analogio/AnalogOut.c
  41. +9 −6 shared-bindings/analogio/__init__.c
  42. +6 −5 shared-bindings/audioio/AudioOut.c
  43. +5 −4 shared-bindings/audioio/__init__.c
  44. +2 −1 shared-bindings/bitbangio/I2C.c
  45. +7 −6 shared-bindings/bitbangio/OneWire.c
  46. +2 −1 shared-bindings/bitbangio/SPI.c
  47. +9 −6 shared-bindings/bitbangio/__init__.c
  48. +16 −15 shared-bindings/busio/I2C.c
  49. +7 −6 shared-bindings/busio/OneWire.c
  50. +2 −1 shared-bindings/busio/SPI.c
  51. +53 −52 shared-bindings/busio/UART.c
  52. +9 −6 shared-bindings/busio/__init__.c
  53. +130 −261 shared-bindings/digitalio/DigitalInOut.c
  54. +10 −23 shared-bindings/digitalio/DigitalInOut.h
  55. +88 −0 shared-bindings/digitalio/Direction.c
  56. +45 −0 shared-bindings/digitalio/Direction.h
  57. +77 −0 shared-bindings/digitalio/DriveMode.c
  58. +46 −0 shared-bindings/digitalio/DriveMode.h
  59. +78 −0 shared-bindings/digitalio/Pull.c
  60. +46 −0 shared-bindings/digitalio/Pull.h
  61. +19 −7 shared-bindings/digitalio/__init__.c
  62. +22 −4 shared-bindings/index.rst
  63. +12 −11 shared-bindings/pulseio/PWMOut.c
  64. +16 −14 shared-bindings/pulseio/PulseIn.c
  65. +10 −9 shared-bindings/pulseio/PulseOut.c
  66. +17 −9 shared-bindings/pulseio/__init__.c
  67. +1 −1 shared-bindings/time/__init__.c
  68. +6 −4 shared-bindings/touchio/TouchIn.c
  69. +8 −8 shared-bindings/touchio/__init__.c
  70. +9 −9 shared-bindings/usb_hid/Device.c
  71. +0 −4 shared-bindings/usb_hid/__init__.c
  72. +1 −1 stmhal/Makefile
  73. +1 −1 teensy/Makefile
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ script:
- tools/build_adafruit_bins.sh
- make -C minimal CROSS=1 build/firmware.bin
- ls -l minimal/build/firmware.bin
- tools/check_code_size.sh
- mkdir -p ${HOME}/persist
# Save new firmware for reference, but only if building a main branch, not a pull request
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cp minimal/build/firmware.bin ${HOME}/persist/; fi'
Expand Down
22 changes: 15 additions & 7 deletions atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ 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/$(BOARD)/init.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
freetouch/adafruit_ptc.c \
lib/fatfs/ff.c \
Expand All @@ -223,14 +223,14 @@ SRC_C = \
lib/utils/pyhelp.c \
lib/utils/stdout_helpers.c \
lib/libc/string0.c \
lib/mp-readline/builtin_input.c \
lib/mp-readline/readline.c

STM_SRC_C = $(addprefix stmhal/,\
pybstdio.c \
input.c \
)

SRC_BINDINGS = \
SRC_COMMON_HAL = \
board/__init__.c \
microcontroller/__init__.c \
microcontroller/Pin.c \
Expand All @@ -256,8 +256,16 @@ SRC_BINDINGS = \
usb_hid/__init__.c \
usb_hid/Device.c

SRC_BINDINGS_EXPANDED = $(addprefix shared-bindings/, $(SRC_BINDINGS)) \
$(addprefix common-hal/, $(SRC_BINDINGS))
# These don't have corresponding files in each port but are still located in
# shared-bindings to make it clear what the contents of the modules are.
SRC_BINDINGS_ENUMS = \
digitalio/Direction.c \
digitalio/DriveMode.c \
digitalio/Pull.c

SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
$(addprefix common-hal/, $(SRC_COMMON_HAL))

SRC_SHARED_MODULE = \
help.c \
Expand All @@ -274,10 +282,10 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE))
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_ASF:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_BINDINGS_EXPANDED:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))

SRC_QSTR += $(SRC_C) $(SRC_BINDINGS_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(STM_SRC_C)
SRC_QSTR += $(SRC_C) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(STM_SRC_C)

all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2

Expand Down
49 changes: 49 additions & 0 deletions atmel-samd/boards/arduino_zero/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "boards/board.h"
#include "asf/sam0/drivers/port/port.h"
#include "mpconfigboard.h"

void board_init(void)
{
struct port_config pin_conf;
port_get_config_defaults(&pin_conf);

pin_conf.direction = PORT_PIN_DIR_OUTPUT;
port_pin_set_config(MICROPY_HW_LED_TX, &pin_conf);
port_pin_set_output_level(MICROPY_HW_LED_TX, true);

port_pin_set_config(MICROPY_HW_LED_RX, &pin_conf);
port_pin_set_output_level(MICROPY_HW_LED_RX, true);
}

bool board_requests_safe_mode(void) {
return false;
}

void reset_board(void) {
}
32 changes: 0 additions & 32 deletions atmel-samd/boards/arduino_zero/init.c

This file was deleted.

45 changes: 45 additions & 0 deletions atmel-samd/boards/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

// This file defines board specific functions.

#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H__
#define __MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H__

#include <stdbool.h>

// Initializes board related state once on start up.
void board_init(void);

// Returns true if the user initiates safe mode in a board specific way.
// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific
// way.
bool board_requests_safe_mode(void);

// Reset the state of off MCU components such as neopixels.
void reset_board(void);

#endif // __MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H__
65 changes: 65 additions & 0 deletions atmel-samd/boards/circuitplayground_express/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include <string.h>

#include "boards/board.h"
#include "asf/sam0/drivers/port/port.h"
#include "common-hal/microcontroller/Pin.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/neopixel_write/__init__.h"
#include "samd21_pins.h"

void board_init(void)
{
}

// Check the status of the two buttons on CircuitPlayground Express. If both are
// pressed, then boot into user safe mode.
bool board_requests_safe_mode(void) {
struct port_config pin_conf;
port_get_config_defaults(&pin_conf);
pin_conf.direction = PORT_PIN_DIR_INPUT;
pin_conf.input_pull = PORT_PIN_PULL_DOWN;
port_pin_set_config(PIN_PA14, &pin_conf);
port_pin_set_config(PIN_PA28, &pin_conf);
bool safe_mode = port_pin_get_input_level(PIN_PA14) &&
port_pin_get_input_level(PIN_PA28);
reset_pin(PIN_PA14);
reset_pin(PIN_PA28);
return safe_mode;
}

void reset_board(void) {
uint8_t empty[30];
memset(empty, 0, 30);
digitalio_digitalinout_obj_t neopixel_pin;
common_hal_digitalio_digitalinout_construct(&neopixel_pin, &pin_PB23);
common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false,
DRIVE_MODE_PUSH_PULL);
common_hal_neopixel_write(&neopixel_pin, empty, 30);
common_hal_digitalio_digitalinout_deinit(&neopixel_pin);
}
18 changes: 0 additions & 18 deletions atmel-samd/boards/circuitplayground_express/init.c

This file was deleted.

3 changes: 3 additions & 0 deletions atmel-samd/boards/circuitplayground_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@
#include "flash_S25FL216K.h"

#define CALIBRATE_CRYSTALLESS 1

// Explanation of how a user got into safe mode.
#define BOARD_USER_SAFE_MODE "pressing both buttons at start up"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x8015
USB_PID = 0x8019

FLASH_IMPL = spi_flash.c

Expand Down
38 changes: 38 additions & 0 deletions atmel-samd/boards/feather_m0_adalogger/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "boards/board.h"

void board_init(void)
{
}

bool board_requests_safe_mode(void) {
return false;
}

void reset_board(void) {
}
20 changes: 0 additions & 20 deletions atmel-samd/boards/feather_m0_adalogger/init.c

This file was deleted.

38 changes: 38 additions & 0 deletions atmel-samd/boards/feather_m0_basic/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "boards/board.h"

void board_init(void)
{
}

bool board_requests_safe_mode(void) {
return false;
}

void reset_board(void) {
}
Loading