mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Add ESP32 pin settings
This commit is contained in:
parent
153f9a4d27
commit
a7f67cdfc6
7 changed files with 42 additions and 10 deletions
|
@ -75,4 +75,4 @@ install:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- platformio ci --lib="." --board=uno --board=due --board=genuino101 --board=teensy30 --board=teensy31 --board=teensy35 --board=teensy36 --board=teensylc
|
- platformio ci --lib="." --board=uno --board=due --board=genuino101 --board=teensy30 --board=teensy31 --board=teensy35 --board=teensy36 --board=teensylc
|
||||||
- platformio ci --lib="." --board=esp12e --board=nodemcu --project-option="build_flags=-Wno-unused-function" # Workaround https://github.com/esp8266/Arduino/pull/2881
|
- platformio ci --lib="." --board=esp12e --board=nodemcu --board=esp32dev --project-option="build_flags=-Wno-unused-function" # Workaround https://github.com/esp8266/Arduino/pull/2881
|
||||||
|
|
|
@ -128,6 +128,8 @@ Currently the following boards are supported by the library:
|
||||||
* Also please be aware that:
|
* Also please be aware that:
|
||||||
* GPIO16 is **NOT** usable, as it will be used for some other purposes. For example, reset the SoC itself from sleep mode.
|
* GPIO16 is **NOT** usable, as it will be used for some other purposes. For example, reset the SoC itself from sleep mode.
|
||||||
* GPIO6 to 11 is also **NOT** usable, as they are used to connect SPI flash chip and it is used for storing the executable binary content.
|
* GPIO6 to 11 is also **NOT** usable, as they are used to connect SPI flash chip and it is used for storing the executable binary content.
|
||||||
|
* ESP32 is supported using the [arduino-esp32](https://github.com/espressif/arduino-esp32/)
|
||||||
|
* GPIO5 : SS, GPIO17 : INT, GPIO18 : SCK, GPIO19 : MISO, GPIO23 : MOSI
|
||||||
|
|
||||||
The following boards need to be activated manually in [settings.h](settings.h):
|
The following boards need to be activated manually in [settings.h](settings.h):
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ typedef MAX3421e<P20, P19> MAX3421E; // Balanduino
|
||||||
typedef MAX3421e<P3, P2> MAX3421E; // The Intel Galileo supports much faster read and write speed at pin 2 and 3
|
typedef MAX3421e<P3, P2> MAX3421E; // The Intel Galileo supports much faster read and write speed at pin 2 and 3
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
typedef MAX3421e<P15, P5> MAX3421E; // ESP8266 boards
|
typedef MAX3421e<P15, P5> MAX3421E; // ESP8266 boards
|
||||||
|
#elif defined(ESP32)
|
||||||
|
typedef MAX3421e<P5, P17> MAX3421E; // ESP32 boards
|
||||||
#else
|
#else
|
||||||
typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison, Intel Galileo 2 or Teensy 2.0 and 3.x
|
typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison, Intel Galileo 2 or Teensy 2.0 and 3.x
|
||||||
#endif
|
#endif
|
||||||
|
|
25
avrpins.h
25
avrpins.h
|
@ -1326,9 +1326,8 @@ MAKE_PIN(P13, 13); //
|
||||||
|
|
||||||
#undef MAKE_PIN
|
#undef MAKE_PIN
|
||||||
|
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266) || defined(ESP32)
|
||||||
|
|
||||||
#define pgm_read_pointer(p) pgm_read_ptr(p)
|
|
||||||
|
|
||||||
#define MAKE_PIN(className, pin) \
|
#define MAKE_PIN(className, pin) \
|
||||||
class className { \
|
class className { \
|
||||||
|
@ -1350,6 +1349,10 @@ public: \
|
||||||
} \
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
|
|
||||||
|
#define pgm_read_pointer(p) pgm_read_ptr(p)
|
||||||
|
|
||||||
// Pinout for ESP-12 module
|
// Pinout for ESP-12 module
|
||||||
// 0 .. 16 - Digital pins
|
// 0 .. 16 - Digital pins
|
||||||
// GPIO 6 to 11 and 16 are not usable in this library.
|
// GPIO 6 to 11 and 16 are not usable in this library.
|
||||||
|
@ -1365,6 +1368,24 @@ MAKE_PIN(P13, 13); // MOSI
|
||||||
MAKE_PIN(P14, 14); // SCK
|
MAKE_PIN(P14, 14); // SCK
|
||||||
MAKE_PIN(P15, 15); // SS
|
MAKE_PIN(P15, 15); // SS
|
||||||
|
|
||||||
|
#elif defined(ESP32)
|
||||||
|
|
||||||
|
// Pinout for ESP32 dev module
|
||||||
|
|
||||||
|
MAKE_PIN(P0, 0);
|
||||||
|
MAKE_PIN(P1, 1); // TX0
|
||||||
|
MAKE_PIN(P10, 10); // TX1
|
||||||
|
MAKE_PIN(P3, 3); // RX0
|
||||||
|
MAKE_PIN(P21, 21); // SDA
|
||||||
|
MAKE_PIN(P22, 22); // SCL
|
||||||
|
MAKE_PIN(P19, 19); // MISO
|
||||||
|
MAKE_PIN(P23, 23); // MOSI
|
||||||
|
MAKE_PIN(P18, 18); // SCK
|
||||||
|
MAKE_PIN(P5, 5); // SS
|
||||||
|
MAKE_PIN(P17, 17); // INT
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef MAKE_PIN
|
#undef MAKE_PIN
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
#ifndef _controllerenums_h
|
#ifndef _controllerenums_h
|
||||||
#define _controllerenums_h
|
#define _controllerenums_h
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
#undef PS
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This header file is used to store different enums for the controllers,
|
* This header file is used to store different enums for the controllers,
|
||||||
* This is necessary so all the different libraries can be used at once.
|
* This is necessary so all the different libraries can be used at once.
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
"atmelsam",
|
"atmelsam",
|
||||||
"nordicnrf51",
|
"nordicnrf51",
|
||||||
"ststm32",
|
"ststm32",
|
||||||
"espressif8266"
|
"espressif8266",
|
||||||
|
"espressif32"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
14
usbhost.h
14
usbhost.h
|
@ -111,6 +111,8 @@ typedef SPi< P76, P75, P74, P10 > spi;
|
||||||
typedef SPi< P16, P18, P17, P10 > spi;
|
typedef SPi< P16, P18, P17, P10 > spi;
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
typedef SPi< P14, P13, P12, P15 > spi;
|
typedef SPi< P14, P13, P12, P15 > spi;
|
||||||
|
#elif defined(ESP32)
|
||||||
|
typedef SPi< P18, P23, P19, P5 > spi;
|
||||||
#else
|
#else
|
||||||
#error "No SPI entry in usbhost.h"
|
#error "No SPI entry in usbhost.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -176,7 +178,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
|
||||||
c[0] = reg | 0x02;
|
c[0] = reg | 0x02;
|
||||||
c[1] = data;
|
c[1] = data;
|
||||||
spi4teensy3::send(c, 2);
|
spi4teensy3::send(c, 2);
|
||||||
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266)
|
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
|
||||||
uint8_t c[2];
|
uint8_t c[2];
|
||||||
c[0] = reg | 0x02;
|
c[0] = reg | 0x02;
|
||||||
c[1] = data;
|
c[1] = data;
|
||||||
|
@ -186,7 +188,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
|
||||||
c[0] = reg | 0x02;
|
c[0] = reg | 0x02;
|
||||||
c[1] = data;
|
c[1] = data;
|
||||||
HAL_SPI_Transmit(&SPI_Handle, c, 2, HAL_MAX_DELAY);
|
HAL_SPI_Transmit(&SPI_Handle, c, 2, HAL_MAX_DELAY);
|
||||||
#elif !defined(SPDR) // ESP8266
|
#elif !defined(SPDR) // ESP8266, ESP32
|
||||||
USB_SPI.transfer(reg | 0x02);
|
USB_SPI.transfer(reg | 0x02);
|
||||||
USB_SPI.transfer(data);
|
USB_SPI.transfer(data);
|
||||||
#else
|
#else
|
||||||
|
@ -218,7 +220,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
|
||||||
spi4teensy3::send(reg | 0x02);
|
spi4teensy3::send(reg | 0x02);
|
||||||
spi4teensy3::send(data_p, nbytes);
|
spi4teensy3::send(data_p, nbytes);
|
||||||
data_p += nbytes;
|
data_p += nbytes;
|
||||||
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266)
|
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
|
||||||
USB_SPI.transfer(reg | 0x02);
|
USB_SPI.transfer(reg | 0x02);
|
||||||
USB_SPI.transfer(data_p, nbytes);
|
USB_SPI.transfer(data_p, nbytes);
|
||||||
data_p += nbytes;
|
data_p += nbytes;
|
||||||
|
@ -231,7 +233,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
|
||||||
HAL_SPI_Transmit(&SPI_Handle, &data, 1, HAL_MAX_DELAY);
|
HAL_SPI_Transmit(&SPI_Handle, &data, 1, HAL_MAX_DELAY);
|
||||||
HAL_SPI_Transmit(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
|
HAL_SPI_Transmit(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
|
||||||
data_p += nbytes;
|
data_p += nbytes;
|
||||||
#elif !defined(SPDR) // ESP8266
|
#elif !defined(SPDR) // ESP8266, ESP32
|
||||||
USB_SPI.transfer(reg | 0x02);
|
USB_SPI.transfer(reg | 0x02);
|
||||||
while(nbytes) {
|
while(nbytes) {
|
||||||
USB_SPI.transfer(*data_p);
|
USB_SPI.transfer(*data_p);
|
||||||
|
@ -320,7 +322,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
|
||||||
spi4teensy3::send(reg);
|
spi4teensy3::send(reg);
|
||||||
spi4teensy3::receive(data_p, nbytes);
|
spi4teensy3::receive(data_p, nbytes);
|
||||||
data_p += nbytes;
|
data_p += nbytes;
|
||||||
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266)
|
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
|
||||||
USB_SPI.transfer(reg);
|
USB_SPI.transfer(reg);
|
||||||
memset(data_p, 0, nbytes); // Make sure we send out empty bytes
|
memset(data_p, 0, nbytes); // Make sure we send out empty bytes
|
||||||
USB_SPI.transfer(data_p, nbytes);
|
USB_SPI.transfer(data_p, nbytes);
|
||||||
|
@ -334,7 +336,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
|
||||||
memset(data_p, 0, nbytes); // Make sure we send out empty bytes
|
memset(data_p, 0, nbytes); // Make sure we send out empty bytes
|
||||||
HAL_SPI_Receive(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
|
HAL_SPI_Receive(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
|
||||||
data_p += nbytes;
|
data_p += nbytes;
|
||||||
#elif !defined(SPDR) // ESP8266
|
#elif !defined(SPDR) // ESP8266, ESP32
|
||||||
USB_SPI.transfer(reg);
|
USB_SPI.transfer(reg);
|
||||||
while(nbytes) {
|
while(nbytes) {
|
||||||
*data_p++ = USB_SPI.transfer(0);
|
*data_p++ = USB_SPI.transfer(0);
|
||||||
|
|
Loading…
Reference in a new issue