-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToZero_4x_SPI.h
63 lines (49 loc) · 1.79 KB
/
ToZero_4x_SPI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
ToZero_4x_SPI.h - Library for use with the ToZero 4x adapter board that maps
the pinout of the Teensy family of microcontrollers (3.2, 3.5, 3.6, LC) to
the Raspberry Pi GPIO header
Copyright (c) 2020 Christopher (@ZodiusInfuser) Parrott. All right reserved.
*/
#ifndef _TO_ZERO_4X_SPI_H
#define _TO_ZERO_4X_SPI_H
#include <ToZero_4x_GPIO.h>
#if defined(__IMXRT1062__) //Teensy 4.0 & 4.1
#include <SPI.h>
static SPIClass& GPIO_SPI = SPI;
#if (defined(ARDUINO_TEENSY40) && !defined(NO_TEENSY_UNDERSIDE_PINS)) || defined(ARDUINO_TEENSY41)
static SPIClass& BreakoutSPI = SPI1;
#endif
#define GPIO_SPI_MOSI GPIO_10
#define GPIO_SPI_MISO GPIO_9
#define GPIO_SPI_SCK GPIO_11
#define GPIO_SPI_CE0 GPIO_8
#ifdef GPIO_7
#define GPIO_SPI_CE1 GPIO_7
#endif
#if (defined(ARDUINO_TEENSY40) && !defined(NO_TEENSY_UNDERSIDE_PINS)) || defined(ARDUINO_TEENSY41)
#define BREAKOUT_SPI_MOSI 26
#define BREAKOUT_SPI_SCK 27
#endif
#if defined(ARDUINO_TEENSY40)
#define BREAKOUT_SPI_MISO 1
#define BREAKOUT_SPI_CE0 0
#elif defined(ARDUINO_TEENSY41)
#define BREAKOUT_SPI_MISO 39
#define BREAKOUT_SPI_CE0 38
#endif
#define TO_ZERO_SPI_SETUP
static inline void ToZero_SPI_Setup(void)
{
#if (defined(ARDUINO_TEENSY40) && !defined(NO_TEENSY_UNDERSIDE_PINS)) || defined(ARDUINO_TEENSY41)
BreakoutSPI.setMISO(BREAKOUT_SPI_MISO);
BreakoutSPI.setCS(BREAKOUT_SPI_CE0);
#endif
};
#if !defined(NO_TO_ZERO_WARNINGS)
#pragma message "ToZero 4x SPI loaded. Remember to call ToZero_SPI_Setup(); in you Arduino setup() function."
#endif
#elif !defined(_TO_ZERO_4X_H) && !defined(TOZERO_BOARD_ERROR)
#define TOZERO_BOARD_ERROR
#error "Incompatible Board Selected. The ToZero 4x adapter only supports the Teensy 4.0 & 4.1. If using a Teensy 3.2, 3.5, 3.6 or LC then a ToZero 3x adapter will be needed."
#endif
#endif