Skip to content

Commit 5680933

Browse files
committed
refactor longint settings; make crickit cpx build
1 parent be12e07 commit 5680933

34 files changed

Lines changed: 292 additions & 25 deletions

File tree

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@
5555
[submodule "frozen/Adafruit_CircuitPython_HID"]
5656
path = frozen/Adafruit_CircuitPython_HID
5757
url = https://github.com/adafruit/Adafruit_CircuitPython_HID.git
58+
[submodule "ports/atmel-samd/Adafruit_CircuitPython_Motor"]
59+
path = frozen/Adafruit_CircuitPython_Motor
60+
url = https://github.com/adafruit/Adafruit_CircuitPython_Motor.git
61+
[submodule "ports/atmel-samd/Adafruit_CircuitPython_seesaw"]
62+
path = frozen/Adafruit_CircuitPython_seesaw
63+
url = https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git

ports/atmel-samd/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ ifndef INTERNAL_LIBM
165165
LIBS += -lm
166166
endif
167167

168+
# Propagate longint choice from .mk to C.
169+
ifdef LONGINT_IMPL_NONE
170+
CFLAGS += -DLONGINT_IMPL_NONE
171+
endif
172+
173+
ifdef LONGINT_IMPL_MPZ
174+
CFLAGS += -DLONGINT_IMPL_MPZ
175+
endif
176+
177+
ifdef LONGINT_IMPL_LONGLONG
178+
CFLAGS += -DLONGINT_IMPL_LONGLONG
179+
endif
180+
168181
ifeq ($(CHIP_FAMILY), samd21)
169182
LDFLAGS += -mthumb -mcpu=cortex-m0plus -Lasf/thirdparty/CMSIS/Lib/GCC/
170183
BOOTLOADER_SIZE := 0x2000

ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ USB_PRODUCT = "Arduino Zero"
55
USB_MANUFACTURER = "Arduino"
66

77
INTERNAL_FLASH_FILESYSTEM = 1
8+
LONGINT_IMPL_NONE = 1
89

910
CHIP_VARIANT = SAMD21G18A
1011
CHIP_FAMILY = samd21

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#define MICROPY_HW_BOARD_NAME "Adafruit CircuitPlayground Express"
22
#define MICROPY_HW_MCU_NAME "samd21g18"
33

4-
#define MICROPY_LONGINT_IMPL MICROPY_LONGINT_IMPL_MPZ
5-
#define MP_SSIZE_MAX 0x7fffffff
6-
74
// Don't allow touch on A0 (PA02), because it's connected to the speaker.
85
#define PA02_NO_TOUCH (true)
96

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ USB_PRODUCT = "CircuitPlayground Express"
55
USB_MANUFACTURER = "Adafruit Industries LLC"
66

77
SPI_FLASH_FILESYSTEM = 1
8+
LONGINT_IMPL_MPZ = 1
89

910
CHIP_VARIANT = SAMD21G18A
1011
CHIP_FAMILY = samd21
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <string.h>
28+
29+
#include "boards/board.h"
30+
#include "common-hal/microcontroller/Pin.h"
31+
#include "hal/include/hal_gpio.h"
32+
#include "shared-bindings/digitalio/DigitalInOut.h"
33+
#include "shared-bindings/neopixel_write/__init__.h"
34+
#include "samd21_pins.h"
35+
36+
void board_init(void)
37+
{
38+
}
39+
40+
// Check the status of the two buttons on CircuitPlayground Express. If both are
41+
// pressed, then boot into user safe mode.
42+
bool board_requests_safe_mode(void) {
43+
gpio_set_pin_function(PIN_PA14, GPIO_PIN_FUNCTION_OFF);
44+
gpio_set_pin_direction(PIN_PA14, GPIO_DIRECTION_IN);
45+
gpio_set_pin_pull_mode(PIN_PA14, GPIO_PULL_DOWN);
46+
47+
gpio_set_pin_function(PIN_PA28, GPIO_PIN_FUNCTION_OFF);
48+
gpio_set_pin_direction(PIN_PA28, GPIO_DIRECTION_IN);
49+
gpio_set_pin_pull_mode(PIN_PA28, GPIO_PULL_DOWN);
50+
bool safe_mode = gpio_get_pin_level(PIN_PA14) &&
51+
gpio_get_pin_level(PIN_PA28);
52+
reset_pin(PIN_PA14);
53+
reset_pin(PIN_PA28);
54+
return safe_mode;
55+
}
56+
57+
void reset_board(void) {
58+
uint8_t empty[30];
59+
memset(empty, 0, 30);
60+
digitalio_digitalinout_obj_t neopixel_pin;
61+
common_hal_digitalio_digitalinout_construct(&neopixel_pin, &pin_PB23);
62+
common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false,
63+
DRIVE_MODE_PUSH_PULL);
64+
common_hal_neopixel_write(&neopixel_pin, empty, 30);
65+
common_hal_digitalio_digitalinout_deinit(&neopixel_pin);
66+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#define MICROPY_HW_BOARD_NAME "Adafruit CircuitPlayground Express with Crickit libraries"
2+
#define MICROPY_HW_MCU_NAME "samd21g18"
3+
4+
// No framebuf on CRICKit version to save space.
5+
#define MICROPY_PY_FRAMEBUF (0)
6+
7+
// Don't allow touch on A0 (PA02), because it's connected to the speaker.
8+
#define PA02_NO_TOUCH (true)
9+
10+
// Salae reads 12mhz which is the limit even though we set it to the safer 8mhz.
11+
#define SPI_FLASH_BAUDRATE (8000000)
12+
13+
// On-board flash
14+
#define SPI_FLASH_MOSI_PIN PIN_PA20
15+
#define SPI_FLASH_MISO_PIN PIN_PA16
16+
#define SPI_FLASH_SCK_PIN PIN_PA21
17+
#define SPI_FLASH_CS_PIN PIN_PB22
18+
19+
#define SPI_FLASH_MOSI_PIN_FUNCTION PINMUX_PA20D_SERCOM3_PAD2
20+
#define SPI_FLASH_MISO_PIN_FUNCTION PINMUX_PA16D_SERCOM3_PAD0
21+
#define SPI_FLASH_SCK_PIN_FUNCTION PINMUX_PA21D_SERCOM3_PAD3
22+
#define SPI_FLASH_SERCOM SERCOM3
23+
#define SPI_FLASH_SERCOM_INDEX 3
24+
#define SPI_FLASH_MOSI_PAD 2
25+
#define SPI_FLASH_MISO_PAD 0
26+
#define SPI_FLASH_SCK_PAD 3
27+
28+
// <o> Transmit Data Pinout
29+
// <0x0=>PAD[0,1]_DO_SCK
30+
// <0x1=>PAD[2,3]_DO_SCK
31+
// <0x2=>PAD[3,1]_DO_SCK
32+
// <0x3=>PAD[0,3]_DO_SCK
33+
#define SPI_FLASH_DOPO 1
34+
#define SPI_FLASH_DIPO 0 // same as MISO PAD
35+
36+
// These are pins not to reset.
37+
// PA24 and PA25 are USB.
38+
#define MICROPY_PORT_A (PORT_PA16 | PORT_PA20 | PORT_PA21 | PORT_PA24 | PORT_PA25)
39+
#define MICROPY_PORT_B (PORT_PB22)
40+
#define MICROPY_PORT_C (0)
41+
42+
#define SPEAKER_ENABLE_PIN (&pin_PA30)
43+
44+
#include "external_flash/devices.h"
45+
46+
// If you change this, then make sure to update the linker scripts as well to
47+
// make sure you don't overwrite code.
48+
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
49+
50+
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
51+
52+
#include "external_flash/devices.h"
53+
54+
#define EXTERNAL_FLASH_DEVICE_COUNT 2
55+
#define EXTERNAL_FLASH_DEVICES S25FL216K, \
56+
GD25Q16C
57+
58+
#include "external_flash/external_flash.h"
59+
60+
#define CALIBRATE_CRYSTALLESS 1
61+
62+
// Explanation of how a user got into safe mode.
63+
#define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up"
64+
65+
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
66+
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)
67+
68+
#define DEFAULT_SPI_BUS_SCK (&pin_PA05)
69+
#define DEFAULT_SPI_BUS_MOSI (&pin_PA07)
70+
#define DEFAULT_SPI_BUS_MISO (&pin_PA06)
71+
72+
#define DEFAULT_UART_BUS_RX (&pin_PB09)
73+
#define DEFAULT_UART_BUS_TX (&pin_PB08)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
2+
USB_VID = 0x239A
3+
USB_PID = 0x8019
4+
USB_PRODUCT = "CircuitPlayground Express with Crickit libraries"
5+
USB_MANUFACTURER = "Adafruit Industries LLC"
6+
7+
SPI_FLASH_FILESYSTEM = 1
8+
LONGINT_IMPL_MPZ = 1
9+
10+
CHIP_VARIANT = SAMD21G18A
11+
CHIP_FAMILY = samd21
12+
13+
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
14+
15+
# Include these Python libraries in firmware.
16+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
17+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
18+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
19+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Motor
20+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
21+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_seesaw
22+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor

0 commit comments

Comments
 (0)