me-no-dev 2016-12-12 02:12:13 +02:00
parent 54b1b8b1d3
commit a6c02bc710
11 changed files with 28 additions and 18 deletions

View File

@ -100,12 +100,20 @@ extern "C" {
#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
// avr-libc defines _NOP() since 1.6.2
#ifndef _NOP
#define _NOP() do { __asm__ volatile ("nop"); } while (0)
#endif
typedef unsigned int word;
#define bit(b) (1UL << (b)) #define bit(b) (1UL << (b))
#define _BV(b) (1UL << (b)) #define _BV(b) (1UL << (b))
#define digitalPinToPort(pin) (((pin)>31)?1:0) #define digitalPinToPort(pin) (((pin)>31)?1:0)
#define digitalPinToBitMask(pin) (1UL << (pin)) #define digitalPinToBitMask(pin) (1UL << (((pin)>31)?((pin)-31):(pin)))
#define digitalPinToTimer(pin) (0) #define digitalPinToTimer(pin) (0)
#define analogInPinToBit(P) (P)
#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG)) #define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG))
#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG)) #define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG))
#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG)) #define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG))
@ -118,6 +126,13 @@ extern "C" {
typedef bool boolean; typedef bool boolean;
typedef uint8_t byte; typedef uint8_t byte;
void init(void);
void initVariant(void);
void initArduino(void);
void setup(void);
void loop(void);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);

View File

@ -26,6 +26,8 @@
#define ETS_GPIO_INUM 12 #define ETS_GPIO_INUM 12
const int8_t esp32_adc2gpio[20] = {36, -1, -1, 39, 32, 33, 34, 35, -1, -1, 4, 0, 2, 15, 13, 12, 14, 27, 25, 26};
const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={ const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={
{0x44, 11, 11, 1}, {0x44, 11, 11, 1},
{0x88, -1, -1, -1}, {0x88, -1, -1, -1},

View File

@ -65,6 +65,7 @@ typedef struct {
} esp32_gpioMux_t; } esp32_gpioMux_t;
extern const esp32_gpioMux_t esp32_gpioMux[40]; extern const esp32_gpioMux_t esp32_gpioMux[40];
extern const int8_t esp32_adc2gpio[20];
#define digitalPinIsValid(pin) ((pin) < 40 && esp32_gpioMux[(pin)].reg) #define digitalPinIsValid(pin) ((pin) < 40 && esp32_gpioMux[(pin)].reg)
#define digitalPinCanOutput(pin) ((pin) < 34 && esp32_gpioMux[(pin)].reg) #define digitalPinCanOutput(pin) ((pin) < 34 && esp32_gpioMux[(pin)].reg)

View File

@ -1,21 +1,13 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp32-hal.h" #include "Arduino.h"
#if CONFIG_AUTOSTART_ARDUINO #if CONFIG_AUTOSTART_ARDUINO
extern "C" void initArduino();
extern void loop();
extern void setup();
void loopTask(void *pvParameters) void loopTask(void *pvParameters)
{ {
bool setup_done = false;
for(;;) {
if(!setup_done) {
setup(); setup();
setup_done = true; for(;;) {
}
loop(); loop();
} }
} }

View File

@ -5,7 +5,7 @@
#define NUM_DIGITAL_PINS 40 #define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 16 #define NUM_ANALOG_INPUTS 16
#define analogInputToDigitalPin(p) #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) #define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34) #define digitalPinHasPWM(p) (p < 34)

View File

@ -5,7 +5,7 @@
#define NUM_DIGITAL_PINS 12 #define NUM_DIGITAL_PINS 12
#define NUM_ANALOG_INPUTS 5 #define NUM_ANALOG_INPUTS 5
#define analogInputToDigitalPin(p) #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) #define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34) #define digitalPinHasPWM(p) (p < 34)

View File

@ -5,7 +5,7 @@
#define NUM_DIGITAL_PINS 40 #define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 16 #define NUM_ANALOG_INPUTS 16
#define analogInputToDigitalPin(p) #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) #define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34) #define digitalPinHasPWM(p) (p < 34)

View File

@ -5,7 +5,7 @@
#define NUM_DIGITAL_PINS 40 #define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 16 #define NUM_ANALOG_INPUTS 16
#define analogInputToDigitalPin(p) #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) #define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34) #define digitalPinHasPWM(p) (p < 34)

View File

@ -5,7 +5,7 @@
#define NUM_DIGITAL_PINS 38 #define NUM_DIGITAL_PINS 38
#define NUM_ANALOG_INPUTS 16 #define NUM_ANALOG_INPUTS 16
#define analogInputToDigitalPin(p) #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) #define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34) #define digitalPinHasPWM(p) (p < 34)

View File

@ -5,7 +5,7 @@
#define NUM_DIGITAL_PINS 40 #define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 16 #define NUM_ANALOG_INPUTS 16
#define analogInputToDigitalPin(p) #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) #define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34) #define digitalPinHasPWM(p) (p < 34)

View File

@ -5,7 +5,7 @@
#define NUM_DIGITAL_PINS 40 #define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 16 #define NUM_ANALOG_INPUTS 16
#define analogInputToDigitalPin(p) #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) #define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34) #define digitalPinHasPWM(p) (p < 34)