Johny Mattsson 224788b642 Make NodeMCU compile and link for ESP32.
A fair bit of reshuffling with include paths and overrides was necessary, as
the two RTOS SDKs (ESP8266 and ESP32) don't have the same header structure
(or even libraries for that matter). Uses the xtensa-esp108-elf toolchain
to build.

Completely untested beyond linking, as I still can't flash the ESP32 module
I have :(  I'd be most surprised if it does anything useful at this point
considering I've spent almost no time on the linker script or UART setup.

Anything using espconn has been ifdef'd out since espconn is not (and
probably will not be) available. Notably this includes the entire net module
as well as coap, mqtt and enduser_setup.

Many (most?) hardware bus drivers and related modules are also ifdef'd
out for now due to hardware differences. Functions surrounding sleep,
rtc and RF modes have also been hit by the ifdef hammer. Grep'ing for
__ESP8266__ and/or FIXME is a quick way of finding these places. With
time I hope all of these will be reinstated.
2016-06-09 18:40:56 +10:00

63 lines
1.7 KiB
C

#include "pin_map.h"
#include "eagle_soc.h"
#include "osapi.h"
uint32_t pin_mux[GPIO_PIN_NUM];
uint8_t pin_num[GPIO_PIN_NUM];
uint8_t pin_func[GPIO_PIN_NUM];
#ifdef GPIO_INTERRUPT_ENABLE
uint8_t pin_num_inv[GPIO_PIN_NUM_INV];
uint8_t pin_int_type[GPIO_PIN_NUM];
#endif
typedef struct {
int8 mux;
uint8 num;
uint8 func;
uint8 intr_type;
} pin_rec;
#define DECLARE_PIN(n,p) { (PERIPHS_IO_MUX_##p##_U - PERIPHS_IO_MUX), n, FUNC_GPIO##n, GPIO_PIN_INTR_DISABLE}
#if defined(__ESP8266__)
static const pin_rec pin_map[] = {
{PAD_XPD_DCDC_CONF - PERIPHS_IO_MUX, 16, 0, GPIO_PIN_INTR_DISABLE},
DECLARE_PIN( 5, GPIO5),
DECLARE_PIN( 4, GPIO4),
DECLARE_PIN( 0, GPIO0),
DECLARE_PIN( 2, GPIO2),
DECLARE_PIN(14, MTMS),
DECLARE_PIN(12, MTDI),
DECLARE_PIN(13, MTCK),
DECLARE_PIN(15, MTDO),
DECLARE_PIN( 3, U0RXD),
DECLARE_PIN( 1, U0TXD),
DECLARE_PIN( 9, SD_DATA2),
DECLARE_PIN(10, SD_DATA3)
};
#elif defined(__ESP32__)
// FIXME: fill in
static const pin_rec pin_map[] = {};
#endif
void get_pin_map(void) {
/*
* Flash copy of the pin map. This has to be copied to RAM to be accessible from the ISR.
* Note that the mux field is a signed offset from PERIPHS_IO_MUX to allow the whole struct
* to be stored in a single 32-bit record.
*/
int i;
/* Take temporary stack copy to avoid unaligned exceptions on Flash version */
pin_rec pin[GPIO_PIN_NUM];
os_memcpy(pin, pin_map, sizeof(pin_map) );
for (i=0; i<GPIO_PIN_NUM; i++) {
pin_mux[i] = pin[i].mux + PERIPHS_IO_MUX;
pin_func[i] = pin[i].func;
pin_num[i] = pin[i].num;
#ifdef GPIO_INTERRUPT_ENABLE
pin_num_inv[pin_num[i]] = i;
pin_int_type[i] = pin[i].intr_type;
#endif
}
}