Skip to content

Commit cc412a8

Browse files
committed
atmel-samd: Support Trinket and Gemma M0 prototypes.
1 parent 8d5c90b commit cc412a8

22 files changed

Lines changed: 703 additions & 8 deletions

File tree

atmel-samd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ CFLAGS_CORTEX_M0 = \
9595
-Wnested-externs \
9696
-Wunreachable-code \
9797
-Wcast-align \
98-
-D__SAMD21G18A__ \
98+
-D__$(CHIP_VARIANT)__ \
9999
-DUSB_DEVICE_PRODUCT_ID=$(USB_PID) \
100100
-DUSB_DEVICE_VENDOR_ID=$(USB_VID) \
101101
-DBOARD=USER_BOARD \

atmel-samd/boards/arduino_zero/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ USB_VID = 0x2341
33
USB_PID = 0x824D
44

55
FLASH_IMPL = internal_flash.c
6+
7+
CHIP_VARIANT = SAMD21G18A

atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ USB_VID = 0x239A
33
USB_PID = 0x8015
44

55
FLASH_IMPL = internal_flash.c
6+
7+
CHIP_VARIANT = SAMD21G18A

atmel-samd/boards/feather_m0_basic/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ USB_VID = 0x239A
33
USB_PID = 0x8015
44

55
FLASH_IMPL = internal_flash.c
6+
7+
CHIP_VARIANT = SAMD21G18A

atmel-samd/boards/feather_m0_flash/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ USB_VID = 0x239A
33
USB_PID = 0x8015
44

55
FLASH_IMPL = spi_flash.c
6+
7+
CHIP_VARIANT = SAMD21G18A
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 "Metro M0 with Flash (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

atmel-samd/boards/gemma_m0/init.c

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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#define USB_REPL
2+
3+
#define MICROPY_HW_BOARD_NAME "Adafruit Gemma M0 (Experimental)"
4+
#define MICROPY_HW_MCU_NAME "samd21e18"
5+
6+
#define MICROPY_HW_APA102 &pin_PA03
7+
8+
#define AUTORESET_DELAY_MS 500
9+
10+
#define FLASH_INCLUDE "internal_flash.h"

0 commit comments

Comments
 (0)