[136] | 1 | /*
|
---|
| 2 | Copyright (c) 2014 Arduino. All right reserved.
|
---|
| 3 |
|
---|
| 4 | This library is free software; you can redistribute it and/or
|
---|
| 5 | modify it under the terms of the GNU Lesser General Public
|
---|
| 6 | License as published by the Free Software Foundation; either
|
---|
| 7 | version 2.1 of the License, or (at your option) any later version.
|
---|
| 8 |
|
---|
| 9 | This library is distributed in the hope that it will be useful,
|
---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 12 | See the GNU Lesser General Public License for more details.
|
---|
| 13 |
|
---|
| 14 | You should have received a copy of the GNU Lesser General Public
|
---|
| 15 | License along with this library; if not, write to the Free Software
|
---|
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | #ifndef _VARIANT_ARDUINO_ZERO_
|
---|
| 20 | #define _VARIANT_ARDUINO_ZERO_
|
---|
| 21 |
|
---|
| 22 | /*----------------------------------------------------------------------------
|
---|
| 23 | * Definitions
|
---|
| 24 | *----------------------------------------------------------------------------*/
|
---|
| 25 |
|
---|
| 26 | /** Frequency of the board main oscillator */
|
---|
| 27 | #define VARIANT_MAINOSC (32768ul)
|
---|
| 28 |
|
---|
| 29 | /** Master clock frequency */
|
---|
| 30 | #define VARIANT_MCK (48000000ul)
|
---|
| 31 |
|
---|
| 32 | /*----------------------------------------------------------------------------
|
---|
| 33 | * Headers
|
---|
| 34 | *----------------------------------------------------------------------------*/
|
---|
| 35 |
|
---|
| 36 | #include "WVariant.h"
|
---|
| 37 |
|
---|
| 38 | #ifdef __cplusplus
|
---|
| 39 | #include "SERCOM.h"
|
---|
| 40 | #include "Uart.h"
|
---|
| 41 | #endif // __cplusplus
|
---|
| 42 |
|
---|
| 43 | #ifdef __cplusplus
|
---|
| 44 | extern "C"{
|
---|
| 45 | #endif // __cplusplus
|
---|
| 46 |
|
---|
| 47 | /**
|
---|
| 48 | * Libc porting layers
|
---|
| 49 | */
|
---|
| 50 | #if defined ( __GNUC__ )
|
---|
| 51 | # include <syscalls.h> /** RedHat Newlib minimal stub */
|
---|
| 52 | #endif
|
---|
| 53 |
|
---|
| 54 | /*----------------------------------------------------------------------------
|
---|
| 55 | * Pins
|
---|
| 56 | *----------------------------------------------------------------------------*/
|
---|
| 57 |
|
---|
| 58 | // Number of pins defined in PinDescription array
|
---|
| 59 | #define PINS_COUNT (34u)
|
---|
| 60 | #define NUM_DIGITAL_PINS (19u)
|
---|
| 61 | #define NUM_ANALOG_INPUTS (5u)
|
---|
| 62 | #define NUM_ANALOG_OUTPUTS (1u)
|
---|
| 63 |
|
---|
| 64 | #define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) )
|
---|
| 65 | #define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin )
|
---|
| 66 | #define digitalPinToTimer(P) ( )
|
---|
| 67 | //#define analogInPinToBit(P) ( )
|
---|
| 68 | #define portOutputRegister(port) ( &(port->OUT.reg) )
|
---|
| 69 | #define portInputRegister(port) ( &(port->IN.reg) )
|
---|
| 70 | //#define portModeRegister(P) ( )
|
---|
| 71 | #define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER )
|
---|
| 72 |
|
---|
| 73 | // Interrupts
|
---|
| 74 | #define digitalPinToInterrupt(P) ( g_APinDescription[P].ulExtInt )
|
---|
| 75 |
|
---|
| 76 | // LEDs
|
---|
| 77 | #define PIN_LED_13 (13u)
|
---|
| 78 | #define PIN_LED_RXL (30u)
|
---|
| 79 | #define PIN_LED_TXL (31u)
|
---|
| 80 | #define PIN_LED PIN_LED_13
|
---|
| 81 | #define PIN_LED2 PIN_LED_RXL
|
---|
| 82 | #define PIN_LED3 PIN_LED_TXL
|
---|
| 83 | #define LED_BUILTIN PIN_LED_13
|
---|
| 84 |
|
---|
| 85 | /*
|
---|
| 86 | * SPI Interfaces
|
---|
| 87 | */
|
---|
| 88 | #define SPI_INTERFACES_COUNT 1
|
---|
| 89 | /*
|
---|
| 90 | #define SPI_INTERFACE SPI0
|
---|
| 91 | #define SPI_INTERFACE_ID ID_SPI0
|
---|
| 92 | #define SPI_CHANNELS_NUM 4
|
---|
| 93 | #define PIN_SPI_SS0 (77u)
|
---|
| 94 | #define PIN_SPI_SS1 (87u)
|
---|
| 95 | #define PIN_SPI_SS2 (86u)
|
---|
| 96 | #define PIN_SPI_SS3 (78u)
|
---|
| 97 | */
|
---|
| 98 | #define PIN_SPI_MOSI (21u)
|
---|
| 99 | #define PIN_SPI_MISO (18u)
|
---|
| 100 | #define PIN_SPI_SCK (20u)
|
---|
| 101 |
|
---|
| 102 | /*
|
---|
| 103 | #define BOARD_SPI_SS0 (10u)
|
---|
| 104 | #define BOARD_SPI_SS1 (4u)
|
---|
| 105 | #define BOARD_SPI_SS2 (52u)
|
---|
| 106 | #define BOARD_SPI_SS3 PIN_SPI_SS3
|
---|
| 107 |
|
---|
| 108 | #define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3
|
---|
| 109 |
|
---|
| 110 | #define BOARD_PIN_TO_SPI_PIN(x) \
|
---|
| 111 | (x==BOARD_SPI_SS0 ? PIN_SPI_SS0 : \
|
---|
| 112 | (x==BOARD_SPI_SS1 ? PIN_SPI_SS1 : \
|
---|
| 113 | (x==BOARD_SPI_SS2 ? PIN_SPI_SS2 : PIN_SPI_SS3 )))
|
---|
| 114 | #define BOARD_PIN_TO_SPI_CHANNEL(x) \
|
---|
| 115 | (x==BOARD_SPI_SS0 ? 0 : \
|
---|
| 116 | (x==BOARD_SPI_SS1 ? 1 : \
|
---|
| 117 | (x==BOARD_SPI_SS2 ? 2 : 3)))
|
---|
| 118 |
|
---|
| 119 | static const uint8_t SS1 = BOARD_SPI_SS1;
|
---|
| 120 | static const uint8_t SS2 = BOARD_SPI_SS2;
|
---|
| 121 | static const uint8_t SS3 = BOARD_SPI_SS3;*/
|
---|
| 122 | static const uint8_t SS = 14; //GND
|
---|
| 123 | static const uint8_t MOSI = PIN_SPI_MOSI;
|
---|
| 124 | static const uint8_t MISO = PIN_SPI_MISO;
|
---|
| 125 | static const uint8_t SCK = PIN_SPI_SCK;
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 | /*
|
---|
| 129 | * Wire Interfaces
|
---|
| 130 | */
|
---|
| 131 | #define WIRE_INTERFACES_COUNT 1
|
---|
| 132 |
|
---|
| 133 | #define PIN_WIRE_SDA (16u)
|
---|
| 134 | #define PIN_WIRE_SCL (17u)
|
---|
| 135 | /*
|
---|
| 136 | #define WIRE_INTERFACE TWI1
|
---|
| 137 | #define WIRE_INTERFACE_ID ID_TWI1
|
---|
| 138 | #define WIRE_ISR_HANDLER TWI1_Handler
|
---|
| 139 | #define WIRE_ISR_ID TWI1_IRQn
|
---|
| 140 | */
|
---|
| 141 |
|
---|
| 142 | /*
|
---|
| 143 | * UART/USART Interfaces
|
---|
| 144 | */
|
---|
| 145 | // Serial
|
---|
| 146 | //#define PINS_UART (81u)
|
---|
| 147 |
|
---|
| 148 | /*
|
---|
| 149 | * USB Interfaces
|
---|
| 150 | */
|
---|
| 151 | //#define PINS_USB (85u)
|
---|
| 152 |
|
---|
| 153 | /*
|
---|
| 154 | * Analog pins
|
---|
| 155 | */
|
---|
| 156 | static const uint8_t A0 = 24 ;
|
---|
| 157 | static const uint8_t A1 = 25 ;
|
---|
| 158 | static const uint8_t A2 = 26 ;
|
---|
| 159 | static const uint8_t A3 = 27 ;
|
---|
| 160 | static const uint8_t A4 = 28 ;
|
---|
| 161 | static const uint8_t A5 = 29 ;
|
---|
| 162 | #define ADC_RESOLUTION 12
|
---|
| 163 |
|
---|
| 164 | /*
|
---|
| 165 | * DAC
|
---|
| 166 | */
|
---|
| 167 | /*
|
---|
| 168 | #define DACC_INTERFACE DACC
|
---|
| 169 | #define DACC_INTERFACE_ID ID_DACC
|
---|
| 170 | #define DACC_RESOLUTION 12
|
---|
| 171 | #define DACC_ISR_HANDLER DACC_Handler
|
---|
| 172 | #define DACC_ISR_ID DACC_IRQn
|
---|
| 173 | */
|
---|
| 174 |
|
---|
| 175 | /*
|
---|
| 176 | * PWM
|
---|
| 177 | */
|
---|
| 178 | /*
|
---|
| 179 | #define PWM_INTERFACE PWM
|
---|
| 180 | #define PWM_INTERFACE_ID ID_PWM
|
---|
| 181 | #define PWM_FREQUENCY 1000
|
---|
| 182 | #define PWM_MAX_DUTY_CYCLE 255
|
---|
| 183 | #define PWM_MIN_DUTY_CYCLE 0
|
---|
| 184 | #define PWM_RESOLUTION 8
|
---|
| 185 | */
|
---|
| 186 |
|
---|
| 187 | /*
|
---|
| 188 | * TC
|
---|
| 189 | */
|
---|
| 190 | /*
|
---|
| 191 | #define TC_INTERFACE TC0
|
---|
| 192 | #define TC_INTERFACE_ID ID_TC0
|
---|
| 193 | #define TC_FREQUENCY 1000
|
---|
| 194 | #define TC_MAX_DUTY_CYCLE 255
|
---|
| 195 | #define TC_MIN_DUTY_CYCLE 0
|
---|
| 196 | #define TC_RESOLUTION 8
|
---|
| 197 | */
|
---|
| 198 |
|
---|
| 199 | #ifdef __cplusplus
|
---|
| 200 | }
|
---|
| 201 | #endif
|
---|
| 202 |
|
---|
| 203 | /*----------------------------------------------------------------------------
|
---|
| 204 | * Arduino objects - C++ only
|
---|
| 205 | *----------------------------------------------------------------------------*/
|
---|
| 206 |
|
---|
| 207 | #ifdef __cplusplus
|
---|
| 208 |
|
---|
| 209 | /* =========================
|
---|
| 210 | * ===== SERCOM DEFINITION
|
---|
| 211 | * =========================
|
---|
| 212 | */
|
---|
| 213 | extern SERCOM sercom0;
|
---|
| 214 | extern SERCOM sercom1;
|
---|
| 215 | extern SERCOM sercom2;
|
---|
| 216 | extern SERCOM sercom3;
|
---|
| 217 | extern SERCOM sercom4;
|
---|
| 218 | extern SERCOM sercom5;
|
---|
| 219 |
|
---|
| 220 | extern Uart Serial;
|
---|
| 221 | extern Uart Serial5;
|
---|
| 222 |
|
---|
| 223 | #endif
|
---|
| 224 |
|
---|
| 225 | // These serial port names are intended to allow libraries and architecture-neutral
|
---|
| 226 | // sketches to automatically default to the correct port name for a particular type
|
---|
| 227 | // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
|
---|
| 228 | // the first hardware serial port whose RX/TX pins are not dedicated to another use.
|
---|
| 229 | //
|
---|
| 230 | // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
|
---|
| 231 | //
|
---|
| 232 | // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
|
---|
| 233 | //
|
---|
| 234 | // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
|
---|
| 235 | //
|
---|
| 236 | // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
|
---|
| 237 | //
|
---|
| 238 | // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
|
---|
| 239 | // pins are NOT connected to anything by default.
|
---|
| 240 | #define SERIAL_PORT_MONITOR Serial
|
---|
| 241 | #define SERIAL_PORT_USBVIRTUAL SerialUSB
|
---|
| 242 | #define SERIAL_PORT_HARDWARE_OPEN Serial1
|
---|
| 243 | #define SERIAL_PORT_HARDWARE_OPEN1 Serial2
|
---|
| 244 | #define SERIAL_PORT_HARDWARE_OPEN2 Serial3
|
---|
| 245 | #define SERIAL_PORT_HARDWARE Serial
|
---|
| 246 | #define SERIAL_PORT_HARDWARE1 Serial1
|
---|
| 247 | #define SERIAL_PORT_HARDWARE2 Serial2
|
---|
| 248 | #define SERIAL_PORT_HARDWARE3 Serial3
|
---|
| 249 |
|
---|
| 250 | #endif /* _VARIANT_ARDUINO_ZERO_ */
|
---|
| 251 |
|
---|