| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#if defined(__arm__) |
| 21 |
|
| 22 |
#ifndef Sd2PinMap_h |
| 23 |
#define Sd2PinMap_h |
| 24 |
|
| 25 |
#include <Arduino.h> |
| 26 |
|
| 27 |
uint8_t const SS_PIN = SS; |
| 28 |
uint8_t const MOSI_PIN = MOSI; |
| 29 |
uint8_t const MISO_PIN = MISO; |
| 30 |
uint8_t const SCK_PIN = SCK; |
| 31 |
|
| 32 |
#endif |
| 33 |
|
| 34 |
#elif defined(__AVR__) |
| 35 |
|
| 36 |
|
| 37 |
#ifndef Sd2PinMap_h |
| 38 |
#define Sd2PinMap_h |
| 39 |
#include <avr/io.h> |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
struct pin_map_t { |
| 44 |
volatile uint8_t* ddr; |
| 45 |
volatile uint8_t* pin; |
| 46 |
volatile uint8_t* port; |
| 47 |
uint8_t bit; |
| 48 |
}; |
| 49 |
|
| 50 |
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
uint8_t const SDA_PIN = 20; |
| 55 |
uint8_t const SCL_PIN = 21; |
| 56 |
|
| 57 |
|
| 58 |
uint8_t const SS_PIN = 53; |
| 59 |
uint8_t const MOSI_PIN = 51; |
| 60 |
uint8_t const MISO_PIN = 50; |
| 61 |
uint8_t const SCK_PIN = 52; |
| 62 |
|
| 63 |
static const pin_map_t digitalPinMap[] = { |
| 64 |
{&DDRE, &PINE, &PORTE, 0}, |
| 65 |
{&DDRE, &PINE, &PORTE, 1}, |
| 66 |
{&DDRE, &PINE, &PORTE, 4}, |
| 67 |
{&DDRE, &PINE, &PORTE, 5}, |
| 68 |
{&DDRG, &PING, &PORTG, 5}, |
| 69 |
{&DDRE, &PINE, &PORTE, 3}, |
| 70 |
{&DDRH, &PINH, &PORTH, 3}, |
| 71 |
{&DDRH, &PINH, &PORTH, 4}, |
| 72 |
{&DDRH, &PINH, &PORTH, 5}, |
| 73 |
{&DDRH, &PINH, &PORTH, 6}, |
| 74 |
{&DDRB, &PINB, &PORTB, 4}, |
| 75 |
{&DDRB, &PINB, &PORTB, 5}, |
| 76 |
{&DDRB, &PINB, &PORTB, 6}, |
| 77 |
{&DDRB, &PINB, &PORTB, 7}, |
| 78 |
{&DDRJ, &PINJ, &PORTJ, 1}, |
| 79 |
{&DDRJ, &PINJ, &PORTJ, 0}, |
| 80 |
{&DDRH, &PINH, &PORTH, 1}, |
| 81 |
{&DDRH, &PINH, &PORTH, 0}, |
| 82 |
{&DDRD, &PIND, &PORTD, 3}, |
| 83 |
{&DDRD, &PIND, &PORTD, 2}, |
| 84 |
{&DDRD, &PIND, &PORTD, 1}, |
| 85 |
{&DDRD, &PIND, &PORTD, 0}, |
| 86 |
{&DDRA, &PINA, &PORTA, 0}, |
| 87 |
{&DDRA, &PINA, &PORTA, 1}, |
| 88 |
{&DDRA, &PINA, &PORTA, 2}, |
| 89 |
{&DDRA, &PINA, &PORTA, 3}, |
| 90 |
{&DDRA, &PINA, &PORTA, 4}, |
| 91 |
{&DDRA, &PINA, &PORTA, 5}, |
| 92 |
{&DDRA, &PINA, &PORTA, 6}, |
| 93 |
{&DDRA, &PINA, &PORTA, 7}, |
| 94 |
{&DDRC, &PINC, &PORTC, 7}, |
| 95 |
{&DDRC, &PINC, &PORTC, 6}, |
| 96 |
{&DDRC, &PINC, &PORTC, 5}, |
| 97 |
{&DDRC, &PINC, &PORTC, 4}, |
| 98 |
{&DDRC, &PINC, &PORTC, 3}, |
| 99 |
{&DDRC, &PINC, &PORTC, 2}, |
| 100 |
{&DDRC, &PINC, &PORTC, 1}, |
| 101 |
{&DDRC, &PINC, &PORTC, 0}, |
| 102 |
{&DDRD, &PIND, &PORTD, 7}, |
| 103 |
{&DDRG, &PING, &PORTG, 2}, |
| 104 |
{&DDRG, &PING, &PORTG, 1}, |
| 105 |
{&DDRG, &PING, &PORTG, 0}, |
| 106 |
{&DDRL, &PINL, &PORTL, 7}, |
| 107 |
{&DDRL, &PINL, &PORTL, 6}, |
| 108 |
{&DDRL, &PINL, &PORTL, 5}, |
| 109 |
{&DDRL, &PINL, &PORTL, 4}, |
| 110 |
{&DDRL, &PINL, &PORTL, 3}, |
| 111 |
{&DDRL, &PINL, &PORTL, 2}, |
| 112 |
{&DDRL, &PINL, &PORTL, 1}, |
| 113 |
{&DDRL, &PINL, &PORTL, 0}, |
| 114 |
{&DDRB, &PINB, &PORTB, 3}, |
| 115 |
{&DDRB, &PINB, &PORTB, 2}, |
| 116 |
{&DDRB, &PINB, &PORTB, 1}, |
| 117 |
{&DDRB, &PINB, &PORTB, 0}, |
| 118 |
{&DDRF, &PINF, &PORTF, 0}, |
| 119 |
{&DDRF, &PINF, &PORTF, 1}, |
| 120 |
{&DDRF, &PINF, &PORTF, 2}, |
| 121 |
{&DDRF, &PINF, &PORTF, 3}, |
| 122 |
{&DDRF, &PINF, &PORTF, 4}, |
| 123 |
{&DDRF, &PINF, &PORTF, 5}, |
| 124 |
{&DDRF, &PINF, &PORTF, 6}, |
| 125 |
{&DDRF, &PINF, &PORTF, 7}, |
| 126 |
{&DDRK, &PINK, &PORTK, 0}, |
| 127 |
{&DDRK, &PINK, &PORTK, 1}, |
| 128 |
{&DDRK, &PINK, &PORTK, 2}, |
| 129 |
{&DDRK, &PINK, &PORTK, 3}, |
| 130 |
{&DDRK, &PINK, &PORTK, 4}, |
| 131 |
{&DDRK, &PINK, &PORTK, 5}, |
| 132 |
{&DDRK, &PINK, &PORTK, 6}, |
| 133 |
{&DDRK, &PINK, &PORTK, 7} |
| 134 |
}; |
| 135 |
|
| 136 |
#elif (defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && defined(CORE_MICRODUINO) |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
uint8_t const SDA_PIN = 20; |
| 141 |
uint8_t const SCL_PIN = 21; |
| 142 |
|
| 143 |
|
| 144 |
uint8_t const SS_PIN = 10; |
| 145 |
uint8_t const MOSI_PIN = 11; |
| 146 |
uint8_t const MISO_PIN = 12; |
| 147 |
uint8_t const SCK_PIN = 13; |
| 148 |
|
| 149 |
static const pin_map_t digitalPinMap[] = { |
| 150 |
{&DDRD, &PIND, &PORTD, 0}, |
| 151 |
{&DDRD, &PIND, &PORTD, 1}, |
| 152 |
{&DDRD, &PIND, &PORTD, 2}, |
| 153 |
{&DDRD, &PIND, &PORTD, 3}, |
| 154 |
{&DDRB, &PINB, &PORTB, 0}, |
| 155 |
{&DDRB, &PINB, &PORTB, 1}, |
| 156 |
{&DDRB, &PINB, &PORTB, 2}, |
| 157 |
{&DDRB, &PINB, &PORTB, 3}, |
| 158 |
{&DDRD, &PIND, &PORTD, 6}, |
| 159 |
{&DDRD, &PIND, &PORTD, 5}, |
| 160 |
{&DDRB, &PINB, &PORTB, 4}, |
| 161 |
{&DDRB, &PINB, &PORTB, 5}, |
| 162 |
{&DDRB, &PINB, &PORTB, 6}, |
| 163 |
{&DDRB, &PINB, &PORTB, 7}, |
| 164 |
{&DDRC, &PINC, &PORTC, 7}, |
| 165 |
{&DDRC, &PINC, &PORTC, 6}, |
| 166 |
{&DDRC, &PINC, &PORTC, 5}, |
| 167 |
{&DDRC, &PINC, &PORTC, 4}, |
| 168 |
{&DDRC, &PINC, &PORTC, 3}, |
| 169 |
{&DDRC, &PINC, &PORTC, 2}, |
| 170 |
{&DDRC, &PINC, &PORTC, 1}, |
| 171 |
{&DDRC, &PINC, &PORTC, 0}, |
| 172 |
{&DDRD, &PIND, &PORTD, 4}, |
| 173 |
{&DDRD, &PIND, &PORTD, 7}, |
| 174 |
{&DDRA, &PINA, &PORTA, 7}, |
| 175 |
{&DDRA, &PINA, &PORTA, 6}, |
| 176 |
{&DDRA, &PINA, &PORTA, 5}, |
| 177 |
{&DDRA, &PINA, &PORTA, 4}, |
| 178 |
{&DDRA, &PINA, &PORTA, 3}, |
| 179 |
{&DDRA, &PINA, &PORTA, 2}, |
| 180 |
{&DDRA, &PINA, &PORTA, 1}, |
| 181 |
{&DDRA, &PINA, &PORTA, 0} |
| 182 |
}; |
| 183 |
|
| 184 |
#elif defined(__AVR_ATmega128RFA1__) && defined(CORE_MICRODUINO) |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
uint8_t const SDA_PIN = 18; |
| 189 |
uint8_t const SCL_PIN = 19; |
| 190 |
|
| 191 |
|
| 192 |
uint8_t const SS_PIN = 10; |
| 193 |
uint8_t const MOSI_PIN = 11; |
| 194 |
uint8_t const MISO_PIN = 12; |
| 195 |
uint8_t const SCK_PIN = 13; |
| 196 |
|
| 197 |
static const pin_map_t digitalPinMap[] = { |
| 198 |
{&DDRD, &PINE, &PORTE, 0}, |
| 199 |
{&DDRD, &PINE, &PORTE, 1}, |
| 200 |
{&DDRD, &PIND, &PORTD, 2}, |
| 201 |
{&DDRD, &PIND, &PORTD, 3}, |
| 202 |
{&DDRB, &PINE, &PORTE, 3}, |
| 203 |
{&DDRB, &PINE, &PORTE, 4}, |
| 204 |
{&DDRB, &PINE, &PORTE, 5}, |
| 205 |
{&DDRB, &PINB, &PORTB, 7}, |
| 206 |
{&DDRD, &PINB, &PORTB, 6}, |
| 207 |
{&DDRD, &PINB, &PORTB, 5}, |
| 208 |
{&DDRB, &PINB, &PORTB, 4}, |
| 209 |
{&DDRB, &PINB, &PORTB, 2}, |
| 210 |
{&DDRB, &PINB, &PORTB, 3}, |
| 211 |
{&DDRB, &PINB, &PORTB, 1}, |
| 212 |
{&DDRF, &PINF, &PORTF, 7}, |
| 213 |
{&DDRF, &PINF, &PORTF, 6}, |
| 214 |
{&DDRF, &PINF, &PORTF, 5}, |
| 215 |
{&DDRF, &PINF, &PORTF, 4}, |
| 216 |
{&DDRD, &PIND, &PORTD, 1}, |
| 217 |
{&DDRD, &PIND, &PORTD, 0}, |
| 218 |
{&DDRF, &PINF, &PORTF, 3}, |
| 219 |
{&DDRF, &PINF, &PORTF, 2}, |
| 220 |
}; |
| 221 |
|
| 222 |
#elif defined(__AVR_ATmega32U4__) && defined(CORE_MICRODUINO) |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
uint8_t const SDA_PIN = 18; |
| 227 |
uint8_t const SCL_PIN = 19; |
| 228 |
|
| 229 |
|
| 230 |
uint8_t const SS_PIN = 10; |
| 231 |
uint8_t const MOSI_PIN = 11; |
| 232 |
uint8_t const MISO_PIN = 12; |
| 233 |
uint8_t const SCK_PIN = 13; |
| 234 |
|
| 235 |
static const pin_map_t digitalPinMap[] = { |
| 236 |
{&DDRD, &PIND, &PORTD, 2}, |
| 237 |
{&DDRD, &PIND, &PORTD, 3}, |
| 238 |
{&DDRE, &PINE, &PORTE, 6}, |
| 239 |
{&DDRD, &PIND, &PORTD, 6}, |
| 240 |
{&DDRD, &PIND, &PORTD, 7}, |
| 241 |
{&DDRC, &PINC, &PORTC, 6}, |
| 242 |
{&DDRC, &PINC, &PORTC, 7}, |
| 243 |
{&DDRE, &PINE, &PORTE, 7}, |
| 244 |
{&DDRB, &PINB, &PORTB, 6}, |
| 245 |
{&DDRB, &PINB, &PORTB, 5}, |
| 246 |
{&DDRB, &PINB, &PORTB, 0}, |
| 247 |
{&DDRB, &PINB, &PORTB, 2}, |
| 248 |
{&DDRB, &PINB, &PORTB, 3}, |
| 249 |
{&DDRB, &PINB, &PORTB, 1}, |
| 250 |
{&DDRF, &PINF, &PORTF, 7}, |
| 251 |
{&DDRF, &PINF, &PORTF, 6}, |
| 252 |
{&DDRF, &PINF, &PORTF, 5}, |
| 253 |
{&DDRF, &PINF, &PORTF, 4}, |
| 254 |
{&DDRD, &PIND, &PORTD, 1}, |
| 255 |
{&DDRD, &PIND, &PORTD, 0}, |
| 256 |
{&DDRF, &PINF, &PORTF, 1}, |
| 257 |
{&DDRF, &PINF, &PORTF, 0}, |
| 258 |
}; |
| 259 |
|
| 260 |
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
uint8_t const SDA_PIN = 17; |
| 265 |
uint8_t const SCL_PIN = 18; |
| 266 |
|
| 267 |
|
| 268 |
uint8_t const SS_PIN = 4; |
| 269 |
uint8_t const MOSI_PIN = 5; |
| 270 |
uint8_t const MISO_PIN = 6; |
| 271 |
uint8_t const SCK_PIN = 7; |
| 272 |
|
| 273 |
static const pin_map_t digitalPinMap[] = { |
| 274 |
{&DDRB, &PINB, &PORTB, 0}, |
| 275 |
{&DDRB, &PINB, &PORTB, 1}, |
| 276 |
{&DDRB, &PINB, &PORTB, 2}, |
| 277 |
{&DDRB, &PINB, &PORTB, 3}, |
| 278 |
{&DDRB, &PINB, &PORTB, 4}, |
| 279 |
{&DDRB, &PINB, &PORTB, 5}, |
| 280 |
{&DDRB, &PINB, &PORTB, 6}, |
| 281 |
{&DDRB, &PINB, &PORTB, 7}, |
| 282 |
{&DDRD, &PIND, &PORTD, 0}, |
| 283 |
{&DDRD, &PIND, &PORTD, 1}, |
| 284 |
{&DDRD, &PIND, &PORTD, 2}, |
| 285 |
{&DDRD, &PIND, &PORTD, 3}, |
| 286 |
{&DDRD, &PIND, &PORTD, 4}, |
| 287 |
{&DDRD, &PIND, &PORTD, 5}, |
| 288 |
{&DDRD, &PIND, &PORTD, 6}, |
| 289 |
{&DDRD, &PIND, &PORTD, 7}, |
| 290 |
{&DDRC, &PINC, &PORTC, 0}, |
| 291 |
{&DDRC, &PINC, &PORTC, 1}, |
| 292 |
{&DDRC, &PINC, &PORTC, 2}, |
| 293 |
{&DDRC, &PINC, &PORTC, 3}, |
| 294 |
{&DDRC, &PINC, &PORTC, 4}, |
| 295 |
{&DDRC, &PINC, &PORTC, 5}, |
| 296 |
{&DDRC, &PINC, &PORTC, 6}, |
| 297 |
{&DDRC, &PINC, &PORTC, 7}, |
| 298 |
{&DDRA, &PINA, &PORTA, 7}, |
| 299 |
{&DDRA, &PINA, &PORTA, 6}, |
| 300 |
{&DDRA, &PINA, &PORTA, 5}, |
| 301 |
{&DDRA, &PINA, &PORTA, 4}, |
| 302 |
{&DDRA, &PINA, &PORTA, 3}, |
| 303 |
{&DDRA, &PINA, &PORTA, 2}, |
| 304 |
{&DDRA, &PINA, &PORTA, 1}, |
| 305 |
{&DDRA, &PINA, &PORTA, 0} |
| 306 |
}; |
| 307 |
|
| 308 |
#elif defined(__AVR_ATmega32U4__) |
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
uint8_t const SDA_PIN = 2; |
| 313 |
uint8_t const SCL_PIN = 3; |
| 314 |
|
| 315 |
|
| 316 |
uint8_t const SS_PIN = 17; |
| 317 |
uint8_t const MOSI_PIN = 16; |
| 318 |
uint8_t const MISO_PIN = 14; |
| 319 |
uint8_t const SCK_PIN = 15; |
| 320 |
|
| 321 |
static const pin_map_t digitalPinMap[] = { |
| 322 |
{&DDRD, &PIND, &PORTD, 2}, |
| 323 |
{&DDRD, &PIND, &PORTD, 3}, |
| 324 |
{&DDRD, &PIND, &PORTD, 1}, |
| 325 |
{&DDRD, &PIND, &PORTD, 0}, |
| 326 |
{&DDRD, &PIND, &PORTD, 4}, |
| 327 |
{&DDRC, &PINC, &PORTC, 6}, |
| 328 |
{&DDRD, &PIND, &PORTD, 7}, |
| 329 |
{&DDRE, &PINE, &PORTE, 6}, |
| 330 |
{&DDRB, &PINB, &PORTB, 4}, |
| 331 |
{&DDRB, &PINB, &PORTB, 5}, |
| 332 |
{&DDRB, &PINB, &PORTB, 6}, |
| 333 |
{&DDRB, &PINB, &PORTB, 7}, |
| 334 |
{&DDRD, &PIND, &PORTD, 6}, |
| 335 |
{&DDRC, &PINC, &PORTC, 7}, |
| 336 |
{&DDRB, &PINB, &PORTB, 3}, |
| 337 |
{&DDRB, &PINB, &PORTB, 1}, |
| 338 |
{&DDRB, &PINB, &PORTB, 2}, |
| 339 |
{&DDRB, &PINB, &PORTB, 0}, |
| 340 |
{&DDRF, &PINF, &PORTF, 7}, |
| 341 |
{&DDRF, &PINF, &PORTF, 6}, |
| 342 |
{&DDRF, &PINF, &PORTF, 5}, |
| 343 |
{&DDRF, &PINF, &PORTF, 4}, |
| 344 |
{&DDRF, &PINF, &PORTF, 1}, |
| 345 |
{&DDRF, &PINF, &PORTF, 0}, |
| 346 |
}; |
| 347 |
|
| 348 |
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
uint8_t const SDA_PIN = 1; |
| 353 |
uint8_t const SCL_PIN = 0; |
| 354 |
|
| 355 |
|
| 356 |
uint8_t const SS_PIN = 20; |
| 357 |
uint8_t const MOSI_PIN = 22; |
| 358 |
uint8_t const MISO_PIN = 23; |
| 359 |
uint8_t const SCK_PIN = 21; |
| 360 |
|
| 361 |
static const pin_map_t digitalPinMap[] = { |
| 362 |
{&DDRD, &PIND, &PORTD, 0}, |
| 363 |
{&DDRD, &PIND, &PORTD, 1}, |
| 364 |
{&DDRD, &PIND, &PORTD, 2}, |
| 365 |
{&DDRD, &PIND, &PORTD, 3}, |
| 366 |
{&DDRD, &PIND, &PORTD, 4}, |
| 367 |
{&DDRD, &PIND, &PORTD, 5}, |
| 368 |
{&DDRD, &PIND, &PORTD, 6}, |
| 369 |
{&DDRD, &PIND, &PORTD, 7}, |
| 370 |
{&DDRE, &PINE, &PORTE, 0}, |
| 371 |
{&DDRE, &PINE, &PORTE, 1}, |
| 372 |
{&DDRC, &PINC, &PORTC, 0}, |
| 373 |
{&DDRC, &PINC, &PORTC, 1}, |
| 374 |
{&DDRC, &PINC, &PORTC, 2}, |
| 375 |
{&DDRC, &PINC, &PORTC, 3}, |
| 376 |
{&DDRC, &PINC, &PORTC, 4}, |
| 377 |
{&DDRC, &PINC, &PORTC, 5}, |
| 378 |
{&DDRC, &PINC, &PORTC, 6}, |
| 379 |
{&DDRC, &PINC, &PORTC, 7}, |
| 380 |
{&DDRE, &PINE, &PORTE, 6}, |
| 381 |
{&DDRE, &PINE, &PORTE, 7}, |
| 382 |
{&DDRB, &PINB, &PORTB, 0}, |
| 383 |
{&DDRB, &PINB, &PORTB, 1}, |
| 384 |
{&DDRB, &PINB, &PORTB, 2}, |
| 385 |
{&DDRB, &PINB, &PORTB, 3}, |
| 386 |
{&DDRB, &PINB, &PORTB, 4}, |
| 387 |
{&DDRB, &PINB, &PORTB, 5}, |
| 388 |
{&DDRB, &PINB, &PORTB, 6}, |
| 389 |
{&DDRB, &PINB, &PORTB, 7}, |
| 390 |
{&DDRA, &PINA, &PORTA, 0}, |
| 391 |
{&DDRA, &PINA, &PORTA, 1}, |
| 392 |
{&DDRA, &PINA, &PORTA, 2}, |
| 393 |
{&DDRA, &PINA, &PORTA, 3}, |
| 394 |
{&DDRA, &PINA, &PORTA, 4}, |
| 395 |
{&DDRA, &PINA, &PORTA, 5}, |
| 396 |
{&DDRA, &PINA, &PORTA, 6}, |
| 397 |
{&DDRA, &PINA, &PORTA, 7}, |
| 398 |
{&DDRE, &PINE, &PORTE, 4}, |
| 399 |
{&DDRE, &PINE, &PORTE, 5}, |
| 400 |
{&DDRF, &PINF, &PORTF, 0}, |
| 401 |
{&DDRF, &PINF, &PORTF, 1}, |
| 402 |
{&DDRF, &PINF, &PORTF, 2}, |
| 403 |
{&DDRF, &PINF, &PORTF, 3}, |
| 404 |
{&DDRF, &PINF, &PORTF, 4}, |
| 405 |
{&DDRF, &PINF, &PORTF, 5}, |
| 406 |
{&DDRF, &PINF, &PORTF, 6}, |
| 407 |
{&DDRF, &PINF, &PORTF, 7} |
| 408 |
}; |
| 409 |
|
| 410 |
#else |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
uint8_t const SDA_PIN = 18; |
| 415 |
uint8_t const SCL_PIN = 19; |
| 416 |
|
| 417 |
|
| 418 |
uint8_t const SS_PIN = 10; |
| 419 |
uint8_t const MOSI_PIN = 11; |
| 420 |
uint8_t const MISO_PIN = 12; |
| 421 |
uint8_t const SCK_PIN = 13; |
| 422 |
|
| 423 |
static const pin_map_t digitalPinMap[] = { |
| 424 |
{&DDRD, &PIND, &PORTD, 0}, |
| 425 |
{&DDRD, &PIND, &PORTD, 1}, |
| 426 |
{&DDRD, &PIND, &PORTD, 2}, |
| 427 |
{&DDRD, &PIND, &PORTD, 3}, |
| 428 |
{&DDRD, &PIND, &PORTD, 4}, |
| 429 |
{&DDRD, &PIND, &PORTD, 5}, |
| 430 |
{&DDRD, &PIND, &PORTD, 6}, |
| 431 |
{&DDRD, &PIND, &PORTD, 7}, |
| 432 |
{&DDRB, &PINB, &PORTB, 0}, |
| 433 |
{&DDRB, &PINB, &PORTB, 1}, |
| 434 |
{&DDRB, &PINB, &PORTB, 2}, |
| 435 |
{&DDRB, &PINB, &PORTB, 3}, |
| 436 |
{&DDRB, &PINB, &PORTB, 4}, |
| 437 |
{&DDRB, &PINB, &PORTB, 5}, |
| 438 |
{&DDRC, &PINC, &PORTC, 0}, |
| 439 |
{&DDRC, &PINC, &PORTC, 1}, |
| 440 |
{&DDRC, &PINC, &PORTC, 2}, |
| 441 |
{&DDRC, &PINC, &PORTC, 3}, |
| 442 |
{&DDRC, &PINC, &PORTC, 4}, |
| 443 |
{&DDRC, &PINC, &PORTC, 5} |
| 444 |
}; |
| 445 |
#endif |
| 446 |
|
| 447 |
static const uint8_t digitalPinCount = sizeof(digitalPinMap)/sizeof(pin_map_t); |
| 448 |
|
| 449 |
uint8_t badPinNumber(void) |
| 450 |
__attribute__((error("Pin number is too large or not a constant"))); |
| 451 |
|
| 452 |
static inline __attribute__((always_inline)) |
| 453 |
uint8_t getPinMode(uint8_t pin) { |
| 454 |
if (__builtin_constant_p(pin) && pin < digitalPinCount) { |
| 455 |
return (*digitalPinMap[pin].ddr >> digitalPinMap[pin].bit) & 1; |
| 456 |
} else { |
| 457 |
return badPinNumber(); |
| 458 |
} |
| 459 |
} |
| 460 |
static inline __attribute__((always_inline)) |
| 461 |
void setPinMode(uint8_t pin, uint8_t mode) { |
| 462 |
if (__builtin_constant_p(pin) && pin < digitalPinCount) { |
| 463 |
if (mode) { |
| 464 |
*digitalPinMap[pin].ddr |= 1 << digitalPinMap[pin].bit; |
| 465 |
} else { |
| 466 |
*digitalPinMap[pin].ddr &= ~(1 << digitalPinMap[pin].bit); |
| 467 |
} |
| 468 |
} else { |
| 469 |
badPinNumber(); |
| 470 |
} |
| 471 |
} |
| 472 |
static inline __attribute__((always_inline)) |
| 473 |
uint8_t fastDigitalRead(uint8_t pin) { |
| 474 |
if (__builtin_constant_p(pin) && pin < digitalPinCount) { |
| 475 |
return (*digitalPinMap[pin].pin >> digitalPinMap[pin].bit) & 1; |
| 476 |
} else { |
| 477 |
return badPinNumber(); |
| 478 |
} |
| 479 |
} |
| 480 |
static inline __attribute__((always_inline)) |
| 481 |
void fastDigitalWrite(uint8_t pin, uint8_t value) { |
| 482 |
if (__builtin_constant_p(pin) && pin < digitalPinCount) { |
| 483 |
if (value) { |
| 484 |
*digitalPinMap[pin].port |= 1 << digitalPinMap[pin].bit; |
| 485 |
} else { |
| 486 |
*digitalPinMap[pin].port &= ~(1 << digitalPinMap[pin].bit); |
| 487 |
} |
| 488 |
} else { |
| 489 |
badPinNumber(); |
| 490 |
} |
| 491 |
} |
| 492 |
#endif |
| 493 |
|
| 494 |
#elif defined (__CPU_ARC__) |
| 495 |
|
| 496 |
#if defined (__ARDUINO_ARC__) |
| 497 |
|
| 498 |
uint8_t const SDA_PIN = 18; |
| 499 |
uint8_t const SCL_PIN = 19; |
| 500 |
|
| 501 |
|
| 502 |
uint8_t const SS_PIN = 10; |
| 503 |
uint8_t const MOSI_PIN = 11; |
| 504 |
uint8_t const MISO_PIN = 12; |
| 505 |
uint8_t const SCK_PIN = 13; |
| 506 |
|
| 507 |
#endif |
| 508 |
|
| 509 |
#else |
| 510 |
#error Architecture or board not supported. |
| 511 |
#endif |