Skip to content

Commit 6fcb54d

Browse files
authored
Merge pull request #18 from turbinenreiter/master
Add Adalogger board definition in preparation of adding SD card support.
2 parents 46e7f8e + 9b1170a commit 6fcb54d

File tree

8 files changed

+492
-0
lines changed

8 files changed

+492
-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 "rom_fs.h"
72+
#define Lun_0_test_unit_ready rom_fs_test_unit_ready
73+
#define Lun_0_read_capacity rom_fs_read_capacity
74+
#define Lun_0_unload NULL /* Can not be unloaded */
75+
#define Lun_0_wr_protect rom_fs_wr_protect
76+
#define Lun_0_removal rom_fs_removal
77+
#define Lun_0_usb_read_10 rom_fs_usb_read_10
78+
#define Lun_0_usb_write_10 rom_fs_usb_write_10
79+
#define LUN_0_NAME "\"On-Chip ROM\""
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: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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 "Feather M0 Adalogger"
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)
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)
58+
#define UDI_CDC_SET_RTS_EXT(port,set)
59+
60+
/**
61+
* USB CDC low level configuration
62+
* In standalone these configurations are defined by the CDC module.
63+
* For composite device, these configuration must be defined here
64+
* @{
65+
*/
66+
//! Endpoint numbers definition
67+
68+
#define UDI_CDC_COMM_EP_0 (3 | USB_EP_DIR_IN) // Notify endpoint
69+
#define UDI_CDC_DATA_EP_IN_0 (4 | USB_EP_DIR_IN) // TX
70+
#define UDI_CDC_DATA_EP_OUT_0 (5 | USB_EP_DIR_OUT) // RX
71+
72+
//! Interface numbers
73+
#define UDI_CDC_COMM_IFACE_NUMBER_0 0
74+
#define UDI_CDC_DATA_IFACE_NUMBER_0 1
75+
76+
/**
77+
* Configuration of MSC interface
78+
* @{
79+
*/
80+
//! Vendor name and Product version of MSC interface
81+
#define UDI_MSC_GLOBAL_VENDOR_ID \
82+
'A', 'T', 'M', 'E', 'L', ' ', ' ', ' '
83+
#define UDI_MSC_GLOBAL_PRODUCT_VERSION \
84+
'1', '.', '0', '0'
85+
86+
//! Interface callback definition
87+
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
88+
extern bool mp_msc_enable();
89+
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
90+
extern void mp_msc_disable();
91+
92+
//! Enable id string of interface to add an extra USB string
93+
#define UDI_MSC_STRING_ID 5
94+
95+
/**
96+
* USB MSC low level configuration
97+
* In standalone these configurations are defined by the MSC module.
98+
* For composite device, these configuration must be defined here
99+
* @{
100+
*/
101+
//! Endpoint numbers definition
102+
#define UDI_MSC_EP_IN (1 | USB_EP_DIR_IN)
103+
#define UDI_MSC_EP_OUT (2 | USB_EP_DIR_OUT)
104+
105+
//! Interface number
106+
#define UDI_MSC_IFACE_NUMBER 2
107+
108+
/**
109+
* Description of Composite Device
110+
* @{
111+
*/
112+
//! USB Interfaces descriptor structure
113+
#define UDI_COMPOSITE_DESC_T \
114+
usb_iad_desc_t udi_cdc_iad; \
115+
udi_cdc_comm_desc_t udi_cdc_comm; \
116+
udi_cdc_data_desc_t udi_cdc_data; \
117+
udi_msc_desc_t udi_msc
118+
119+
//! USB Interfaces descriptor value for Full Speed
120+
#define UDI_COMPOSITE_DESC_FS \
121+
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
122+
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
123+
.udi_cdc_data = UDI_CDC_DATA_DESC_0_FS, \
124+
.udi_msc = UDI_MSC_DESC_FS
125+
126+
//! USB Interfaces descriptor value for High Speed
127+
#define UDI_COMPOSITE_DESC_HS \
128+
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
129+
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
130+
.udi_cdc_data = UDI_CDC_DATA_DESC_0_HS, \
131+
.udi_msc = UDI_MSC_DESC_HS
132+
133+
//! USB Interface APIs
134+
#define UDI_COMPOSITE_API \
135+
&udi_api_cdc_comm, \
136+
&udi_api_cdc_data, \
137+
&udi_api_msc
138+
//@}
139+
140+
/**
141+
* USB Device Driver Configuration
142+
* @{
143+
*/
144+
//@}
145+
146+
//! The includes of classes and other headers must be done at the end of this file to avoid compile error
147+
#include "udi_cdc.h"
148+
#include "udi_msc.h"
149+
150+
#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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// LEDs
2+
#define MICROPY_HW_LED1 PIN_PA17 // red
3+
// #define UART_REPL
4+
#define USB_REPL
5+
6+
#define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Adalogger"
7+
#define MICROPY_HW_MCU_NAME "samd21g18"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
LD_FILE = boards/samd21x18-bootloader.ld
2+
USB_VID = 0x239A
3+
USB_PID = 0x8015

0 commit comments

Comments
 (0)