Skip to content

Commit a2936c4

Browse files
committed
adding SAM32 board
SAMD51 running circuitpython talking to an ESP32 running micropython. Full board details at: https://github.com/maholli/SAM32
1 parent 041a84e commit a2936c4

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
28+
#include <string.h>
29+
30+
#include "boards/board.h"
31+
#include "py/mpconfig.h"
32+
33+
#include "common-hal/digitalio/DigitalInOut.h"
34+
#include "shared-bindings/digitalio/DigitalInOut.h"
35+
#include "shared-bindings/neopixel_write/__init__.h"
36+
37+
void board_init(void) {
38+
}
39+
40+
bool board_requests_safe_mode(void) {
41+
return false;
42+
}
43+
44+
void reset_board(void) {
45+
uint8_t zeroes[96];
46+
memset(zeroes, 0, 96);
47+
digitalio_digitalinout_obj_t neopixel;
48+
common_hal_digitalio_digitalinout_construct(&neopixel, &pin_PA15);
49+
common_hal_digitalio_digitalinout_switch_to_output(&neopixel, false, DRIVE_MODE_PUSH_PULL);
50+
common_hal_neopixel_write(&neopixel, zeroes, 96);
51+
common_hal_digitalio_digitalinout_deinit(&neopixel);
52+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
#define MICROPY_HW_BOARD_NAME "SAM32v2a"
3+
#define MICROPY_HW_MCU_NAME "samd51j20"
4+
#define CIRCUITPY_MCU_FAMILY samd51
5+
6+
#define MICROPY_HW_LED_STATUS (&pin_PA27)
7+
#define MICROPY_HW_NEOPIXEL (&pin_PA15)
8+
9+
#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25)
10+
#define MICROPY_PORT_B (0)
11+
#define MICROPY_PORT_C (0)
12+
#define MICROPY_PORT_D (0)
13+
14+
#define AUTORESET_DELAY_MS 500
15+
16+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
17+
18+
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - 0x010000)
19+
20+
#define BOARD_HAS_CRYSTAL 1
21+
22+
#define DEFAULT_I2C_BUS_SCL (&pin_PA04)
23+
#define DEFAULT_I2C_BUS_SDA (&pin_PA07)
24+
25+
#define DEFAULT_SPI_BUS_SCK (&pin_PB13)
26+
#define DEFAULT_SPI_BUS_MOSI (&pin_PB12)
27+
#define DEFAULT_SPI_BUS_MISO (&pin_PB14)
28+
29+
#define DEFAULT_UART_BUS_TX (&pin_PB16)
30+
#define DEFAULT_UART_BUS_RX (&pin_PB17)
31+
32+
#define IGNORE_PIN_PA24 1
33+
#define IGNORE_PIN_PA25 1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
LD_FILE = boards/samd51x20-bootloader.ld
2+
USB_VID = 0x239A
3+
USB_PID = 0x8021
4+
USB_PRODUCT = "SAM32"
5+
USB_MANUFACTURER = "maholli"
6+
7+
QSPI_FLASH_FILESYSTEM = 0
8+
INTERNAL_FLASH_FILESYSTEM = 1
9+
LONGINT_IMPL = MPZ
10+
11+
CHIP_VARIANT = SAMD51J20A
12+
CHIP_FAMILY = samd51
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
#include "board_busses.h"
4+
5+
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
6+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PB08) },
7+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB09) },
8+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA08) },
9+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA09) },
10+
{ MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB04) },
11+
{ MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB05) },
12+
{ MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PB06) },
13+
{ MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PB07) },
14+
15+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) },
16+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB12) },
17+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) },
18+
{ MP_ROM_QSTR(MP_QSTR_xSDCS),MP_ROM_PTR(&pin_PB15) },
19+
20+
{ MP_ROM_QSTR(MP_QSTR_DAC0), MP_ROM_PTR(&pin_PA02) },
21+
{ MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_PA05) },
22+
23+
{ MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_PA10) },
24+
{ MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_PA11) },
25+
{ MP_ROM_QSTR(MP_QSTR_D29), MP_ROM_PTR(&pin_PA12) },
26+
{ MP_ROM_QSTR(MP_QSTR_D30), MP_ROM_PTR(&pin_PA13) },
27+
{ MP_ROM_QSTR(MP_QSTR_D31), MP_ROM_PTR(&pin_PA14) },
28+
{ MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_PA16) },
29+
{ MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_PA17) },
30+
{ MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_PA18) },
31+
{ MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_PA19) },
32+
{ MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_PA20) },
33+
{ MP_ROM_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_PA21) },
34+
{ MP_ROM_QSTR(MP_QSTR_D43), MP_ROM_PTR(&pin_PA22) },
35+
{ MP_ROM_QSTR(MP_QSTR_D44), MP_ROM_PTR(&pin_PA23) },
36+
{ MP_ROM_QSTR(MP_QSTR_D49), MP_ROM_PTR(&pin_PB22) },
37+
{ MP_ROM_QSTR(MP_QSTR_D50), MP_ROM_PTR(&pin_PB23) },
38+
{ MP_ROM_QSTR(MP_QSTR_D59), MP_ROM_PTR(&pin_PB30) },
39+
{ MP_ROM_QSTR(MP_QSTR_D60), MP_ROM_PTR(&pin_PB31) },
40+
{ MP_ROM_QSTR(MP_QSTR_D64), MP_ROM_PTR(&pin_PB03) },
41+
42+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB16) },
43+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17) },
44+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA07) },
45+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA04) },
46+
47+
{ MP_ROM_QSTR(MP_QSTR_RTS), MP_ROM_PTR(&pin_PB11) },
48+
{ MP_ROM_QSTR(MP_QSTR_DTR), MP_ROM_PTR(&pin_PB10) },
49+
50+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA27) },
51+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) },
52+
53+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
54+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
55+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
56+
{ MP_ROM_QSTR(MP_QSTR_VBAT_MES), MP_ROM_PTR(&pin_PA06) },
57+
58+
};
59+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

0 commit comments

Comments
 (0)