Skip to content

Commit 7739e45

Browse files
Michael Letskytannewt
authored andcommitted
Xplain SAM21D Firmware update
1 parent e1a6f6d commit 7739e45

File tree

8 files changed

+456
-0
lines changed

8 files changed

+456
-0
lines changed
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "conf_clocks_external_32k.h"
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
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 "Atmel/Microchip"
19+
#endif
20+
21+
#ifndef USB_DEVICE_PRODUCT_NAME
22+
# define USB_DEVICE_PRODUCT_NAME "Xplain Pro SAMD21"
23+
#endif
24+
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 + HID mouse + HID kbd)
33+
#define USB_DEVICE_NB_INTERFACE 5
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+
// (6 | USB_EP_DIR_IN) // HID mouse report
41+
// (7 | USB_EP_DIR_IN) // HID keyboard report
42+
#define USB_DEVICE_MAX_EP 7
43+
44+
#define UDI_CDC_PORT_NB 1
45+
#define UDI_CDC_ENABLE_EXT(port) mp_cdc_enable(port)
46+
extern bool mp_cdc_enable(uint8_t port);
47+
#define UDI_CDC_DISABLE_EXT(port) mp_cdc_disable(port)
48+
extern void mp_cdc_disable(uint8_t port);
49+
#define UDI_CDC_LOW_RATE
50+
51+
#define UDI_CDC_DEFAULT_RATE 115200
52+
#define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1
53+
#define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE
54+
#define UDI_CDC_DEFAULT_DATABITS 8
55+
56+
#define UDI_CDC_RX_NOTIFY(port) usb_rx_notify()
57+
void usb_rx_notify(void);
58+
#define UDI_CDC_SET_CODING_EXT(port,cfg)
59+
#define UDI_CDC_SET_DTR_EXT(port,set) usb_dtr_notify(port, set)
60+
void usb_dtr_notify(uint8_t port, bool set);
61+
#define UDI_CDC_SET_RTS_EXT(port,set) usb_rts_notify(port, set)
62+
void usb_rts_notify(uint8_t port, bool set);
63+
64+
/**
65+
* USB CDC low level configuration
66+
* In standalone these configurations are defined by the CDC module.
67+
* For composite device, these configuration must be defined here
68+
* @{
69+
*/
70+
//! Endpoint numbers definition
71+
72+
#define UDI_CDC_COMM_EP_0 (3 | USB_EP_DIR_IN) // Notify endpoint
73+
#define UDI_CDC_DATA_EP_IN_0 (4 | USB_EP_DIR_IN) // TX
74+
#define UDI_CDC_DATA_EP_OUT_0 (5 | USB_EP_DIR_OUT) // RX
75+
76+
//! Interface numbers
77+
#define UDI_CDC_COMM_IFACE_NUMBER_0 0
78+
#define UDI_CDC_DATA_IFACE_NUMBER_0 1
79+
80+
/**
81+
* Configuration of MSC interface
82+
* @{
83+
*/
84+
//! Vendor name and Product version of MSC interface
85+
#define UDI_MSC_GLOBAL_VENDOR_ID \
86+
'A', 'T', 'M', 'E', 'L', ' ', ' ', ' '
87+
#define UDI_MSC_GLOBAL_PRODUCT_VERSION \
88+
'1', '.', '0', '0'
89+
90+
//! Interface callback definition
91+
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
92+
extern bool mp_msc_enable(void);
93+
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
94+
extern void mp_msc_disable(void);
95+
96+
//! Enable id string of interface to add an extra USB string
97+
#define UDI_MSC_STRING_ID 5
98+
99+
/**
100+
* USB MSC low level configuration
101+
* In standalone these configurations are defined by the MSC module.
102+
* For composite device, these configuration must be defined here
103+
* @{
104+
*/
105+
//! Endpoint numbers definition
106+
#define UDI_MSC_EP_IN (1 | USB_EP_DIR_IN)
107+
#define UDI_MSC_EP_OUT (2 | USB_EP_DIR_OUT)
108+
109+
//! Interface number
110+
#define UDI_MSC_IFACE_NUMBER 2
111+
112+
/**
113+
* Configuration of HID Mouse interface
114+
* @{
115+
*/
116+
//! Interface callback definition
117+
#define UDI_HID_MOUSE_ENABLE_EXT() mp_mouse_enable()
118+
extern bool mp_mouse_enable(void);
119+
#define UDI_HID_MOUSE_DISABLE_EXT() mp_mouse_disable()
120+
extern void mp_mouse_disable(void);
121+
122+
//! Enable id string of interface to add an extra USB string
123+
#define UDI_HID_MOUSE_STRING_ID 6
124+
125+
/**
126+
* USB HID Mouse low level configuration
127+
* In standalone these configurations are defined by the HID Mouse module.
128+
* For composite device, these configuration must be defined here
129+
* @{
130+
*/
131+
//! Endpoint numbers definition
132+
#define UDI_HID_MOUSE_EP_IN (6 | USB_EP_DIR_IN)
133+
134+
//! Interface number
135+
#define UDI_HID_MOUSE_IFACE_NUMBER 3
136+
//@}
137+
//@}
138+
139+
/**
140+
* Configuration of HID Keyboard interface
141+
* @{
142+
*/
143+
//! Interface callback definition
144+
#define UDI_HID_KBD_ENABLE_EXT() mp_keyboard_enable()
145+
extern bool mp_keyboard_enable(void);
146+
#define UDI_HID_KBD_DISABLE_EXT() mp_keyboard_disable()
147+
extern void mp_keyboard_disable(void);
148+
#define UDI_HID_KBD_CHANGE_LED(value) mp_keyboard_led(value)
149+
extern void mp_keyboard_led(uint8_t);
150+
151+
//! Enable id string of interface to add an extra USB string
152+
#define UDI_HID_KBD_STRING_ID 7
153+
154+
/**
155+
* USB HID Keyboard low level configuration
156+
* In standalone these configurations are defined by the HID Keyboard module.
157+
* For composite device, these configuration must be defined here
158+
* @{
159+
*/
160+
//! Endpoint numbers definition
161+
#define UDI_HID_KBD_EP_IN (7 | USB_EP_DIR_IN)
162+
163+
//! Interface number
164+
#define UDI_HID_KBD_IFACE_NUMBER 4
165+
166+
/**
167+
* Description of Composite Device
168+
* @{
169+
*/
170+
//! USB Interfaces descriptor structure
171+
#define UDI_COMPOSITE_DESC_T \
172+
usb_iad_desc_t udi_cdc_iad; \
173+
udi_cdc_comm_desc_t udi_cdc_comm; \
174+
udi_cdc_data_desc_t udi_cdc_data; \
175+
udi_msc_desc_t udi_msc; \
176+
udi_hid_mouse_desc_t udi_hid_mouse; \
177+
udi_hid_kbd_desc_t udi_hid_kbd
178+
179+
//! USB Interfaces descriptor value for Full Speed
180+
#define UDI_COMPOSITE_DESC_FS \
181+
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
182+
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
183+
.udi_cdc_data = UDI_CDC_DATA_DESC_0_FS, \
184+
.udi_msc = UDI_MSC_DESC_FS, \
185+
.udi_hid_mouse = UDI_HID_MOUSE_DESC, \
186+
.udi_hid_kbd = UDI_HID_KBD_DESC
187+
188+
//! USB Interfaces descriptor value for High Speed
189+
#define UDI_COMPOSITE_DESC_HS \
190+
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
191+
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
192+
.udi_cdc_data = UDI_CDC_DATA_DESC_0_HS, \
193+
.udi_msc = UDI_MSC_DESC_HS, \
194+
.udi_hid_mouse = UDI_HID_MOUSE_DESC, \
195+
.udi_hid_kbd = UDI_HID_KBD_DESC
196+
197+
//! USB Interface APIs
198+
#define UDI_COMPOSITE_API \
199+
&udi_api_cdc_comm, \
200+
&udi_api_cdc_data, \
201+
&udi_api_msc, \
202+
&udi_api_hid_mouse, \
203+
&udi_api_hid_kbd
204+
//@}
205+
206+
/**
207+
* USB Device Driver Configuration
208+
* @{
209+
*/
210+
//@}
211+
212+
//! The includes of classes and other headers must be done at the end of this file to avoid compile error
213+
#include "udi_cdc.h"
214+
#include "udi_msc.h"
215+
#include "udi_hid_mouse.h"
216+
#include "udi_hid_kbd.h"
217+
218+
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
14+
void board_init(void)
15+
{
16+
/* This function is meant to contain board-specific initialization code
17+
* for, e.g., the I/O pins. The initialization can rely on application-
18+
* specific board configuration, found in conf_board.h.
19+
*/
20+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// LEDs
2+
//#define MICROPY_HW_LED_MSC PIN_PA17 // red
3+
// #define UART_REPL
4+
#define USB_REPL
5+
6+
#define MICROPY_HW_BOARD_NAME "Xplain Pro SAMD21"
7+
#define MICROPY_HW_MCU_NAME "samd21j18"
8+
9+
#define AUTORESET_DELAY_MS 500
10+
11+
#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25 | PORT_PA13)
12+
#define MICROPY_PORT_B (PORT_PB22 | PORT_PB16 | PORT_PB23)
13+
#define SPI_FLASH_SERCOM SERCOM5
14+
#define SPI_FLASH_MUX_SETTING SPI_SIGNAL_MUX_SETTING_E
15+
#define SPI_FLASH_PAD0_PINMUX PINMUX_PB16C_SERCOM5_PAD0
16+
#define SPI_FLASH_PAD1_PINMUX PINMUX_UNUSED
17+
#define SPI_FLASH_PAD2_PINMUX PINMUX_PB22D_SERCOM5_PAD2
18+
#define SPI_FLASH_PAD3_PINMUX PINMUX_PB23D_SERCOM5_PAD3
19+
#define SPI_FLASH_CS PIN_PA13
20+
#define SPI_FLASH_BAUDRATE 1000000
21+
22+
#include "spi_flash.h"
23+
24+
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
25+
26+
#include "flash_AT25DF081A.h"

0 commit comments

Comments
 (0)