source: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/WVariant.h@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 6.1 KB
Line 
1#ifndef _VARIANTS_
2#define _VARIANTS_
3
4#include <stdint.h>
5#include "sam.h"
6
7#ifdef __cplusplus
8extern "C"{
9#endif // __cplusplus
10
11/* Definitions and types for pins */
12typedef enum _EAnalogChannel
13{
14 No_ADC_Channel=-1,
15 ADC_Channel0=0,
16 ADC_Channel1=1,
17 ADC_Channel2=2,
18 ADC_Channel3=3,
19 ADC_Channel4=4,
20 ADC_Channel5=5,
21 ADC_Channel6=6,
22 ADC_Channel7=7,
23 ADC_Channel10=10,
24 ADC_Channel16=16,
25 ADC_Channel17=17,
26 ADC_Channel18=18,
27 ADC_Channel19=19,
28 DAC_Channel0,
29} EAnalogChannel ;
30
31// Definitions for TC channels
32typedef enum _ETCChannel
33{
34 NOT_ON_TIMER=-1,
35 TC3_CH0 = (3<<8)|(0),
36 TC3_CH1 = (3<<8)|(1),
37 TCC0_CH0 = (0<<8)|(0),
38 TCC0_CH1 = (0<<8)|(1),
39 TCC0_CH4 = (0<<8)|(4),
40 TCC0_CH5 = (0<<8)|(5),
41 TCC0_CH6 = (0<<8)|(6),
42 TCC0_CH7 = (0<<8)|(7),
43 TCC1_CH0 = (1<<8)|(0),
44 TCC1_CH1 = (1<<8)|(1),
45 TCC2_CH0 = (2<<8)|(0),
46 TCC2_CH1 = (2<<8)|(1)
47} ETCChannel ;
48
49extern const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM] ;
50
51#define GetTCNumber( x ) ( (x) >> 8 )
52#define GetTCChannelNumber( x ) ( (x) && 0xff )
53#define GetTC( x ) ( g_apTCInstances[(x) >> 8] )
54
55// Definitions for PWM channels
56typedef enum _EPWMChannel
57{
58 NOT_ON_PWM=-1,
59 PWM3_CH0=TC3_CH0,
60 PWM3_CH1=TC3_CH1,
61 PWM0_CH0=TCC0_CH0,
62 PWM0_CH1=TCC0_CH1,
63 PWM0_CH4=TCC0_CH4,
64 PWM0_CH5=TCC0_CH5,
65 PWM0_CH6=TCC0_CH6,
66 PWM0_CH7=TCC0_CH7,
67 PWM1_CH0=TCC1_CH0,
68 PWM1_CH1=TCC1_CH1,
69 PWM2_CH0=TCC2_CH0,
70 PWM2_CH1=TCC2_CH1
71} EPWMChannel ;
72
73typedef enum _EPortType
74{
75 NOT_A_PORT=-1,
76 PORTA=0,
77 PORTB=1,
78 PORTC=2,
79} EPortType ;
80
81typedef enum _EExt_Interrupts
82{
83 EXTERNAL_INT_0 = 0, // Available on pin 11
84 EXTERNAL_INT_1, // Available on pin 13
85 EXTERNAL_INT_2, // Available on pins 10, A0, A5
86 EXTERNAL_INT_3, // Available on pin 12
87 EXTERNAL_INT_4, // Available on pin 6, 8, A3
88 EXTERNAL_INT_5, // Available on pin 7, 9, A4
89 EXTERNAL_INT_6, // Available on pin 16
90 EXTERNAL_INT_7, // Available on pin 17
91 EXTERNAL_INT_8, // Available on pin A1
92 EXTERNAL_INT_9, // Available on pin 3, A2
93 EXTERNAL_INT_10, // Available on pin 0, 21
94 EXTERNAL_INT_11, // Available on pin 1, 20
95 EXTERNAL_INT_12, // Available on pin 18
96 EXTERNAL_INT_13, // Available on pin EDBG_GPIO0 (43)
97 EXTERNAL_INT_14, // Available on pin 4
98 EXTERNAL_INT_15, // Available on pin 5
99 EXTERNAL_INT_NMI, // Available on pin 2
100 EXTERNAL_NUM_INTERRUPTS,
101 NOT_AN_INTERRUPT = -1,
102 EXTERNAL_INT_NONE = NOT_AN_INTERRUPT,
103} EExt_Interrupts ;
104
105//A B C D E F G H
106//EIC REF ADC AC PTC DAC SERCOM SERCOM_ALT TC/TCC TCC COM AC/GCLK
107
108typedef enum _EPioType
109{
110 PIO_NOT_A_PIN=-1, /* Not under control of a peripheral. */
111 PIO_EXTINT, /* The pin is controlled by the associated signal of peripheral A. */
112 PIO_ANALOG, /* The pin is controlled by the associated signal of peripheral B. */
113 PIO_SERCOM, /* The pin is controlled by the associated signal of peripheral C. */
114 PIO_SERCOM_ALT, /* The pin is controlled by the associated signal of peripheral D. */
115 PIO_TIMER, /* The pin is controlled by the associated signal of peripheral E. */
116 PIO_TIMER_ALT, /* The pin is controlled by the associated signal of peripheral F. */
117 PIO_COM, /* The pin is controlled by the associated signal of peripheral G. */
118 PIO_AC_CLK, /* The pin is controlled by the associated signal of peripheral H. */
119 PIO_DIGITAL, /* The pin is controlled by PORT. */
120 PIO_INPUT, /* The pin is controlled by PORT and is an input. */
121 PIO_INPUT_PULLUP, /* The pin is controlled by PORT and is an input with internal pull-up resistor enabled. */
122 PIO_OUTPUT, /* The pin is controlled by PORT and is an output. */
123
124 PIO_PWM=PIO_TIMER,
125 PIO_PWM_ALT=PIO_TIMER_ALT,
126} EPioType ;
127
128/**
129 * Pin Attributes to be OR-ed
130 */
131#define PIN_ATTR_NONE (0UL<<0)
132#define PIN_ATTR_COMBO (1UL<<0)
133#define PIN_ATTR_ANALOG (1UL<<1)
134#define PIN_ATTR_DIGITAL (1UL<<2)
135#define PIN_ATTR_PWM (1UL<<3)
136#define PIN_ATTR_TIMER (1UL<<4)
137#define PIN_ATTR_EXTINT (1UL<<5)
138
139/* Types used for the table below */
140typedef struct _PinDescription
141{
142 EPortType ulPort ;
143 uint32_t ulPin ;
144 EPioType ulPinType ;
145 uint32_t ulPinAttribute ;
146 EAnalogChannel ulADCChannelNumber ; /* ADC Channel number in the SAM device */
147 EPWMChannel ulPWMChannel ;
148 ETCChannel ulTCChannel ;
149 EExt_Interrupts ulExtInt ;
150} PinDescription ;
151
152/* Pins table to be instantiated into variant.cpp */
153extern const PinDescription g_APinDescription[] ;
154
155/* Generic Clock Multiplexer IDs */
156#define GCM_DFLL48M_REF (0x00U)
157#define GCM_FDPLL96M_INPUT (0x01U)
158#define GCM_FDPLL96M_32K (0x02U)
159#define GCM_WDT (0x03U)
160#define GCM_RTC (0x04U)
161#define GCM_EIC (0x05U)
162#define GCM_USB (0x06U)
163#define GCM_EVSYS_CHANNEL_0 (0x07U)
164#define GCM_EVSYS_CHANNEL_1 (0x08U)
165#define GCM_EVSYS_CHANNEL_2 (0x09U)
166#define GCM_EVSYS_CHANNEL_3 (0x0AU)
167#define GCM_EVSYS_CHANNEL_4 (0x0BU)
168#define GCM_EVSYS_CHANNEL_5 (0x0CU)
169#define GCM_EVSYS_CHANNEL_6 (0x0DU)
170#define GCM_EVSYS_CHANNEL_7 (0x0EU)
171#define GCM_EVSYS_CHANNEL_8 (0x0FU)
172#define GCM_EVSYS_CHANNEL_9 (0x10U)
173#define GCM_EVSYS_CHANNEL_10 (0x11U)
174#define GCM_EVSYS_CHANNEL_11 (0x12U)
175#define GCM_SERCOMx_SLOW (0x13U)
176#define GCM_SERCOM0_CORE (0x14U)
177#define GCM_SERCOM1_CORE (0x15U)
178#define GCM_SERCOM2_CORE (0x16U)
179#define GCM_SERCOM3_CORE (0x17U)
180#define GCM_SERCOM4_CORE (0x18U)
181#define GCM_SERCOM5_CORE (0x19U)
182#define GCM_TCC0_TCC1 (0x1AU)
183#define GCM_TCC2_TC3 (0x1BU)
184#define GCM_TC4_TC5 (0x1CU)
185#define GCM_TC6_TC7 (0x1DU)
186#define GCM_ADC (0x1EU)
187#define GCM_AC_DIG (0x1FU)
188#define GCM_AC_ANA (0x20U)
189#define GCM_DAC (0x21U)
190#define GCM_PTC (0x22U)
191#define GCM_I2S_0 (0x23U)
192#define GCM_I2S_1 (0x24U)
193
194#ifdef __cplusplus
195} // extern "C"
196#endif // __cplusplus
197
198#endif // _VARIANTS_
Note: See TracBrowser for help on using the repository browser.