Skip to content

Commit b8bf15d

Browse files
committed
atmel-samd: Add Circuit Playground M0 board. Its experimental.
1 parent f8898d0 commit b8bf15d

8 files changed

Lines changed: 369 additions & 0 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
* \file
3+
*
4+
* \brief Memory access control configuration file.
5+
*
6+
* Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
7+
*
8+
* \asf_license_start
9+
*
10+
* \page License
11+
*
12+
* Redistribution and use in source and binary forms, with or without
13+
* modification, are permitted provided that the following conditions are met:
14+
*
15+
* 1. Redistributions of source code must retain the above copyright notice,
16+
* this list of conditions and the following disclaimer.
17+
*
18+
* 2. Redistributions in binary form must reproduce the above copyright notice,
19+
* this list of conditions and the following disclaimer in the documentation
20+
* and/or other materials provided with the distribution.
21+
*
22+
* 3. The name of Atmel may not be used to endorse or promote products derived
23+
* from this software without specific prior written permission.
24+
*
25+
* 4. This software may only be redistributed and used in connection with an
26+
* Atmel microcontroller product.
27+
*
28+
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31+
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38+
* POSSIBILITY OF SUCH DAMAGE.
39+
*
40+
* \asf_license_stop
41+
*
42+
*/
43+
/*
44+
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45+
*/
46+
47+
#ifndef _CONF_ACCESS_H_
48+
#define _CONF_ACCESS_H_
49+
50+
#include "compiler.h"
51+
#include "board.h"
52+
53+
54+
/*! \name Activation of Logical Unit Numbers
55+
*/
56+
//! @{
57+
#define LUN_0 ENABLE //!< On-Chip Virtual Memory.
58+
#define LUN_1 DISABLE //!< AT45DBX Data Flash.
59+
#define LUN_2 DISABLE //!< SD/MMC Card over SPI.
60+
#define LUN_3 DISABLE //!< SD/MMC Card over MCI Slot 0.
61+
#define LUN_4 DISABLE
62+
#define LUN_5 DISABLE
63+
#define LUN_6 DISABLE
64+
#define LUN_7 DISABLE
65+
#define LUN_USB DISABLE //!< Host Mass-Storage Memory.
66+
//! @}
67+
68+
/*! \name LUN 0 Definitions
69+
*/
70+
//! @{
71+
#define LUN_0_INCLUDE "access_vfs.h"
72+
#define Lun_0_test_unit_ready vfs_test_unit_ready
73+
#define Lun_0_read_capacity vfs_read_capacity
74+
#define Lun_0_unload NULL
75+
#define Lun_0_wr_protect vfs_wr_protect
76+
#define Lun_0_removal vfs_removal
77+
#define Lun_0_usb_read_10 vfs_usb_read_10
78+
#define Lun_0_usb_write_10 vfs_usb_write_10
79+
#define LUN_0_NAME "\"MicroPython VFS[0]\""
80+
//! @}
81+
82+
#define MEM_USB LUN_USB
83+
84+
/*! \name Actions Associated with Memory Accesses
85+
*
86+
* Write here the action to associate with each memory access.
87+
*
88+
* \warning Be careful not to waste time in order not to disturb the functions.
89+
*/
90+
//! @{
91+
#define memory_start_read_action(nb_sectors)
92+
#define memory_stop_read_action()
93+
#define memory_start_write_action(nb_sectors)
94+
#define memory_stop_write_action()
95+
//! @}
96+
97+
/*! \name Activation of Interface Features
98+
*/
99+
//! @{
100+
#define ACCESS_USB true //!< MEM <-> USB interface.
101+
#define ACCESS_MEM_TO_RAM false //!< MEM <-> RAM interface.
102+
#define ACCESS_STREAM false //!< Streaming MEM <-> MEM interface.
103+
#define ACCESS_STREAM_RECORD false //!< Streaming MEM <-> MEM interface in record mode.
104+
#define ACCESS_MEM_TO_MEM false //!< MEM <-> MEM interface.
105+
#define ACCESS_CODEC false //!< Codec interface.
106+
//! @}
107+
108+
/*! \name Specific Options for Access Control
109+
*/
110+
//! @{
111+
#define GLOBAL_WR_PROTECT false //!< Management of a global write protection.
112+
//! @}
113+
114+
115+
#endif // _CONF_ACCESS_H_
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* \file
3+
*
4+
* \brief User board configuration template
5+
*
6+
*/
7+
/*
8+
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
9+
*/
10+
11+
#ifndef CONF_BOARD_H
12+
#define CONF_BOARD_H
13+
14+
#endif // CONF_BOARD_H
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
5+
#ifndef CONF_USB_H_INCLUDED
6+
#define CONF_USB_H_INCLUDED
7+
8+
#define USB_DEVICE_MAJOR_VERSION 1
9+
#define USB_DEVICE_MINOR_VERSION 0
10+
#define USB_DEVICE_POWER 100 // Consumption on Vbus line (mA)
11+
#define USB_DEVICE_ATTR \
12+
(USB_CONFIG_ATTR_BUS_POWERED)
13+
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
14+
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
15+
16+
//! USB Device string definitions (Optional)
17+
#ifndef USB_DEVICE_MANUFACTURE_NAME
18+
# define USB_DEVICE_MANUFACTURE_NAME "Adafruit Industries"
19+
#endif
20+
21+
#ifndef USB_DEVICE_PRODUCT_NAME
22+
# define USB_DEVICE_PRODUCT_NAME "Circuit Playground M0 (Experimental)"
23+
#endif
24+
// #define USB_DEVICE_SERIAL_NAME "12...EF"
25+
#define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number
26+
#define USB_DEVICE_GET_SERIAL_NAME_LENGTH 32
27+
extern char serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
28+
29+
//! Control endpoint size
30+
#define USB_DEVICE_EP_CTRL_SIZE 64
31+
32+
//! Two interfaces for this device (CDC COM + CDC DATA + MSC)
33+
#define USB_DEVICE_NB_INTERFACE 3
34+
35+
// (3 | USB_EP_DIR_IN) // CDC Notify endpoint
36+
// (4 | USB_EP_DIR_IN) // CDC TX
37+
// (5 | USB_EP_DIR_OUT) // CDC RX
38+
// (1 | USB_EP_DIR_IN) // MSC IN
39+
// (2 | USB_EP_DIR_OUT) // MSC OUT
40+
#define USB_DEVICE_MAX_EP 5
41+
42+
#define UDI_CDC_PORT_NB 1
43+
#define UDI_CDC_ENABLE_EXT(port) mp_cdc_enable(port)
44+
extern bool mp_cdc_enable(uint8_t port);
45+
#define UDI_CDC_DISABLE_EXT(port) mp_cdc_disable(port)
46+
extern void mp_cdc_disable(uint8_t port);
47+
#define UDI_CDC_LOW_RATE
48+
49+
#define UDI_CDC_DEFAULT_RATE 115200
50+
#define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1
51+
#define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE
52+
#define UDI_CDC_DEFAULT_DATABITS 8
53+
54+
#define UDI_CDC_RX_NOTIFY(port) usb_rx_notify()
55+
void usb_rx_notify(void);
56+
#define UDI_CDC_SET_CODING_EXT(port,cfg)
57+
#define UDI_CDC_SET_DTR_EXT(port,set) usb_dtr_notify(port, set)
58+
void usb_dtr_notify(uint8_t port, bool set);
59+
#define UDI_CDC_SET_RTS_EXT(port,set) usb_rts_notify(port, set)
60+
void usb_rts_notify(uint8_t port, bool set);
61+
62+
/**
63+
* USB CDC low level configuration
64+
* In standalone these configurations are defined by the CDC module.
65+
* For composite device, these configuration must be defined here
66+
* @{
67+
*/
68+
//! Endpoint numbers definition
69+
70+
#define UDI_CDC_COMM_EP_0 (3 | USB_EP_DIR_IN) // Notify endpoint
71+
#define UDI_CDC_DATA_EP_IN_0 (4 | USB_EP_DIR_IN) // TX
72+
#define UDI_CDC_DATA_EP_OUT_0 (5 | USB_EP_DIR_OUT) // RX
73+
74+
//! Interface numbers
75+
#define UDI_CDC_COMM_IFACE_NUMBER_0 0
76+
#define UDI_CDC_DATA_IFACE_NUMBER_0 1
77+
78+
/**
79+
* Configuration of MSC interface
80+
* @{
81+
*/
82+
//! Vendor name and Product version of MSC interface
83+
#define UDI_MSC_GLOBAL_VENDOR_ID \
84+
'A', 'T', 'M', 'E', 'L', ' ', ' ', ' '
85+
#define UDI_MSC_GLOBAL_PRODUCT_VERSION \
86+
'1', '.', '0', '0'
87+
88+
//! Interface callback definition
89+
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
90+
extern bool mp_msc_enable(void);
91+
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
92+
extern void mp_msc_disable(void);
93+
94+
//! Enable id string of interface to add an extra USB string
95+
#define UDI_MSC_STRING_ID 5
96+
97+
/**
98+
* USB MSC low level configuration
99+
* In standalone these configurations are defined by the MSC module.
100+
* For composite device, these configuration must be defined here
101+
* @{
102+
*/
103+
//! Endpoint numbers definition
104+
#define UDI_MSC_EP_IN (1 | USB_EP_DIR_IN)
105+
#define UDI_MSC_EP_OUT (2 | USB_EP_DIR_OUT)
106+
107+
//! Interface number
108+
#define UDI_MSC_IFACE_NUMBER 2
109+
110+
/**
111+
* Description of Composite Device
112+
* @{
113+
*/
114+
//! USB Interfaces descriptor structure
115+
#define UDI_COMPOSITE_DESC_T \
116+
usb_iad_desc_t udi_cdc_iad; \
117+
udi_cdc_comm_desc_t udi_cdc_comm; \
118+
udi_cdc_data_desc_t udi_cdc_data; \
119+
udi_msc_desc_t udi_msc
120+
121+
//! USB Interfaces descriptor value for Full Speed
122+
#define UDI_COMPOSITE_DESC_FS \
123+
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
124+
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
125+
.udi_cdc_data = UDI_CDC_DATA_DESC_0_FS, \
126+
.udi_msc = UDI_MSC_DESC_FS
127+
128+
//! USB Interfaces descriptor value for High Speed
129+
#define UDI_COMPOSITE_DESC_HS \
130+
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
131+
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
132+
.udi_cdc_data = UDI_CDC_DATA_DESC_0_HS, \
133+
.udi_msc = UDI_MSC_DESC_HS
134+
135+
//! USB Interface APIs
136+
#define UDI_COMPOSITE_API \
137+
&udi_api_cdc_comm, \
138+
&udi_api_cdc_data, \
139+
&udi_api_msc
140+
//@}
141+
142+
/**
143+
* USB Device Driver Configuration
144+
* @{
145+
*/
146+
//@}
147+
148+
//! The includes of classes and other headers must be done at the end of this file to avoid compile error
149+
#include "udi_cdc.h"
150+
#include "udi_msc.h"
151+
152+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* \file
3+
*
4+
* \brief User board initialization template
5+
*
6+
*/
7+
/*
8+
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
9+
*/
10+
11+
#include "board.h"
12+
#include "conf_board.h"
13+
#include "mpconfigboard.h"
14+
#include "asf/sam0/drivers/port/port.h"
15+
16+
void board_init(void)
17+
{
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#define USB_REPL
2+
3+
#define MICROPY_HW_BOARD_NAME "Adafruit Circuit Playground M0 (Experimental)"
4+
#define MICROPY_HW_MCU_NAME "samd21g18"
5+
6+
//#define MICROPY_HW_LED_MSC PIN_PA17
7+
8+
#define SPI_FLASH_BAUDRATE (1000000)
9+
10+
// On-board flash
11+
#define SPI_FLASH_MUX_SETTING SPI_SIGNAL_MUX_SETTING_E
12+
#define SPI_FLASH_PAD0_PINMUX PINMUX_PA12D_SERCOM4_PAD0 // MISO
13+
// Use default pinmux for the chip select since we manage it ourselves.
14+
#define SPI_FLASH_PAD1_PINMUX PINMUX_DEFAULT // CS
15+
#define SPI_FLASH_PAD2_PINMUX PINMUX_PB10D_SERCOM4_PAD2 // MOSI
16+
#define SPI_FLASH_PAD3_PINMUX PINMUX_PB11D_SERCOM4_PAD3 // SCK
17+
#define SPI_FLASH_CS PIN_PB08
18+
#define SPI_FLASH_SERCOM SERCOM4
19+
20+
#define AUTORESET_DELAY_MS 500
21+
22+
#define FLASH_INCLUDE "spi_flash.h"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
LD_FILE = boards/samd21x18-external-flash.ld
2+
USB_VID = 0x239A
3+
USB_PID = 0x8015
4+
5+
FLASH_IMPL = spi_flash.c
6+
7+
CHIP_VARIANT = SAMD21G18A
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "samd21_pins.h"
2+
3+
STATIC const mp_map_elem_t board_global_dict_table[] = {
4+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D10), (mp_obj_t)&pin_PA06 },
5+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D9), (mp_obj_t)&pin_PA07 },
6+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D6), (mp_obj_t)&pin_PA04 },
7+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D12), (mp_obj_t)&pin_PA05 },
8+
9+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D0), (mp_obj_t)&pin_PA11 },
10+
{ MP_OBJ_NEW_QSTR(MP_QSTR_RX), (mp_obj_t)&pin_PA11 },
11+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D1), (mp_obj_t)&pin_PA10 },
12+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TX), (mp_obj_t)&pin_PA10 },
13+
14+
{ MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), (mp_obj_t)&pin_PB22 },
15+
16+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MICROPHONE), (mp_obj_t)&pin_PA08 },
17+
18+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), (mp_obj_t)&pin_PA14 },
19+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ACCELEROMETER_CS), (mp_obj_t)&pin_PA13 },
20+
21+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LEFT_BUTTON), (mp_obj_t)&pin_PA28 },
22+
{ MP_OBJ_NEW_QSTR(MP_QSTR_RIGHT_BUTTON), (mp_obj_t)&pin_PA19 },
23+
24+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SLIDE_SWITCH), (mp_obj_t)&pin_PB09 },
25+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPEAKER), (mp_obj_t)&pin_PA02 },
26+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LIGHT), (mp_obj_t)&pin_PB02 },
27+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TEMPERATURE), (mp_obj_t)&pin_PA09 },
28+
29+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), (mp_obj_t)&pin_PA17 },
30+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA), (mp_obj_t)&pin_PA22 },
31+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D2), (mp_obj_t)&pin_PA22 },
32+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL), (mp_obj_t)&pin_PA23 },
33+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D3), (mp_obj_t)&pin_PA23 },
34+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCK), (mp_obj_t)&pin_PB11 },
35+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), (mp_obj_t)&pin_PB10 },
36+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MISO), (mp_obj_t)&pin_PA12 },
37+
{ MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_CS), (mp_obj_t)&pin_PB08 },
38+
};
39+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

tools/build_adafruit_bins.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
rm -rf atmel-samd/build*
22
rm -rf esp8266/build*
33

4+
make -C atmel-samd BOARD=cplay_m0_flash
45
make -C atmel-samd BOARD=feather_m0_basic
56
make -C atmel-samd BOARD=feather_m0_flash
67
make -C atmel-samd BOARD=metro_m0_flash
@@ -13,6 +14,7 @@ if [ $? -ne 0 ]; then
1314
version=`git rev-parse --short HEAD`
1415
fi
1516

17+
cp atmel-samd/build-cplay_m0_flash/firmware.bin bin/adafruit-micropython-cplay_m0_flash-$version.bin
1618
cp atmel-samd/build-feather_m0_basic/firmware.bin bin/adafruit-micropython-feather_m0_basic-$version.bin
1719
cp atmel-samd/build-feather_m0_flash/firmware.bin bin/adafruit-micropython-feather_m0_flash-$version.bin
1820
cp atmel-samd/build-metro_m0_flash/firmware.bin bin/adafruit-micropython-metro_m0_flash-$version.bin

0 commit comments

Comments
 (0)