Skip to content

Commit 748fea3

Browse files
committed
Merge pull request #1316 from kpurusho/master
Drivers for SAMD21
2 parents 92d1bfa + 1ac74c3 commit 748fea3

File tree

39 files changed

+2623
-30
lines changed

39 files changed

+2623
-30
lines changed

libraries/mbed/targets/hal/TARGET_Atmel/TARGET_SAM_CortexM0+/PortNames.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ extern "C" {
2222

2323
typedef enum {
2424
PortA = 0,
25-
PortB = 1,
26-
PortC = 2
25+
PortB,
26+
#if defined(TARGET_SAMR21G18A)
27+
PortC,
28+
#endif
29+
PortMax
2730
} PortName;
2831

2932
#ifdef __cplusplus
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#ifndef MBED_PERIPHERALNAMES_H
17+
#define MBED_PERIPHERALNAMES_H
18+
19+
#include <compiler.h>
20+
#include "cmsis.h"
21+
#include "PinNames.h"
22+
23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
27+
#define _SERCOM_SPI_NAME(n, unused) \
28+
SPI##n,
29+
30+
#define _SERCOM_PAD_NAME(n, pad) \
31+
SERCOM##n##_PAD##pad = ((n & 0xF) | ((pad & 0xF) << 4)),
32+
33+
#define _SERCOM_I2C_NAME(n, unused) \
34+
I2C##n,
35+
36+
37+
38+
typedef enum {
39+
UART_0 = (int)0x42000800UL, // Base address of SERCOM0
40+
UART_1 = (int)0x42000C00UL, // Base address of SERCOM1
41+
UART_2 = (int)0x42001000UL, // Base address of SERCOM2
42+
UART_3 = (int)0x42001400UL, // Base address of SERCOM3
43+
UART_4 = (int)0x42001800UL, // Base address of SERCOM4
44+
UART_5 = (int)0x42001C00UL // Base address of SERCOM5
45+
} UARTName;
46+
47+
typedef enum {
48+
ADC_0 = 0x0ul,
49+
ADC_1 = 0x1ul,
50+
ADC_2 = 0x2ul,
51+
ADC_3 = 0x3ul,
52+
ADC_4 = 0x4ul,
53+
ADC_5 = 0x5ul,
54+
ADC_6 = 0x6ul,
55+
ADC_7 = 0x7ul,
56+
ADC_8 = 0x8ul,
57+
ADC_9 = 0x8ul,
58+
ADC_10 = 0xAul,
59+
ADC_11 = 0xBul,
60+
ADC_12 = 0xCul,
61+
ADC_13 = 0xDul,
62+
ADC_14 = 0xEul,
63+
ADC_15 = 0xFul,
64+
ADC_16 = 0x10ul,
65+
ADC_17 = 0x11ul,
66+
ADC_18 = 0x12ul,
67+
ADC_19 = 0x13ul
68+
} ADCName;
69+
70+
typedef enum {
71+
DAC_0 = 0x42004800UL
72+
} DACName;
73+
74+
typedef enum { // for each channel
75+
EXTINT_0 = 0,
76+
EXTINT_1,
77+
EXTINT_2,
78+
EXTINT_3,
79+
EXTINT_4,
80+
EXTINT_5,
81+
EXTINT_6,
82+
EXTINT_7,
83+
EXTINT_8,
84+
EXTINT_9,
85+
EXTINT_10,
86+
EXTINT_11,
87+
EXTINT_12,
88+
EXTINT_13,
89+
EXTINT_14,
90+
EXTINT_15
91+
} EXTINTName;
92+
93+
typedef enum {
94+
MREPEAT(SERCOM_INST_NUM, _SERCOM_SPI_NAME, ~)
95+
} SPIName;
96+
97+
typedef enum {
98+
MREPEAT(SERCOM_INST_NUM, _SERCOM_I2C_NAME, ~)
99+
} I2CName;
100+
101+
typedef enum {
102+
/* Pad 0 definitions */
103+
MREPEAT(SERCOM_INST_NUM, _SERCOM_PAD_NAME, 0)
104+
105+
/* Pad 1 definitions */
106+
MREPEAT(SERCOM_INST_NUM, _SERCOM_PAD_NAME, 1)
107+
108+
/* Pad 2 definitions */
109+
MREPEAT(SERCOM_INST_NUM, _SERCOM_PAD_NAME, 2)
110+
111+
/* Pad 3 definitions */
112+
MREPEAT(SERCOM_INST_NUM, _SERCOM_PAD_NAME, 3)
113+
} SercomPadName;
114+
115+
typedef enum {
116+
PWM_0 = (0x42002000UL), /**< \brief (TCC0) APB Base Address */
117+
PWM_1 = (0x42002400UL), /**< \brief (TCC1) APB Base Address */
118+
PWM_2 = (0x42002800UL), /**< \brief (TCC2) APB Base Address */
119+
} PWMName;
120+
121+
struct pwm_pin_channel {
122+
PinName pin;
123+
PWMName pwm;
124+
uint8_t channel_index;
125+
};
126+
127+
#define STDIO_UART_TX USBTX
128+
#define STDIO_UART_RX USBRX
129+
#define STDIO_UART UART_3
130+
131+
// Default peripherals
132+
#define MBED_SPI0 PA18, PA16, PA19, PA17
133+
134+
#define MBED_UART0 PA04, PA05
135+
#define MBED_UARTUSB USBTX, USBRX
136+
137+
#define MBED_I2C0 PA08, PA09
138+
139+
#define MBED_ANALOGOUT0 PA02
140+
141+
#define MBED_ANALOGIN0 PA03
142+
#define MBED_ANALOGIN1 PA08
143+
#define MBED_ANALOGIN2 PB09
144+
#define MBED_ANALOGIN3 PA04
145+
#define MBED_ANALOGIN4 PA05
146+
#define MBED_ANALOGIN5 PA06
147+
#define MBED_ANALOGIN7 PA07
148+
#define MBED_ANALOGIN8 PB00
149+
#define MBED_ANALOGIN9 PB01
150+
151+
#define MBED_PWMOUT0 PA18
152+
#define MBED_PWMOUT1 PA19
153+
154+
#ifdef __cplusplus
155+
}
156+
#endif
157+
158+
#endif

0 commit comments

Comments
 (0)