Skip to content

Commit 7d843cb

Browse files
committed
Merge branch 'master' into me-no-dev
2 parents be1c91b + a6c02bc commit 7d843cb

File tree

14 files changed

+61
-29
lines changed

14 files changed

+61
-29
lines changed

README.md

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
Arduino core for ESP32 WiFi chip
2-
===========================================
1+
# Arduino core for ESP32 WiFi chip
32

4-
### Development Status
3+
- [Development Status](#development-status)
4+
- Installing options:
5+
+ [Using Arduino IDE](#using-arduino-ide)
6+
+ [Using PlatformIO](#using-platformio)
7+
+ [Using as ESP-IDF component](#using-as-esp-idf-component)
8+
- [ESP32Dev Board PINMAP](#esp32dev-board-pinmap)
9+
10+
## Development Status
511
Not everything is working yet, you can not get it through package manager, but you can give it a go and help us find bugs in the things that are implemented :)
612

713
The framework can also be downloaded as component in an IDF project and be used like that.
@@ -21,11 +27,11 @@ Things that work:
2127
WiFiClient, WiFiServer and WiFiUdp are not quite ready yet because there are still some small hiccups in LwIP to be overcome.
2228
You can try WiFiClient but you need to disconnect the client yourself to be sure that connection is closed.
2329

24-
### Installation
30+
## Using Arduino IDE
2531

26-
####[Instructions for Windows](doc/windows.md)
32+
###[Instructions for Windows](doc/windows.md)
2733

28-
#### Instructions for Mac
34+
### Instructions for Mac
2935
- Install latest Arduino IDE from [arduino.cc](https://www.arduino.cc/en/Main/Software)
3036
- Open Terminal and execute the following command (copy->paste and hit enter):
3137

@@ -41,7 +47,7 @@ You can try WiFiClient but you need to disconnect the client yourself to be sure
4147
```
4248
- Restart Arduino IDE
4349

44-
#### Instructions for Debian/Ubuntu Linux
50+
### Instructions for Debian/Ubuntu Linux
4551
- Install latest Arduino IDE from [arduino.cc](https://www.arduino.cc/en/Main/Software)
4652
- Open Terminal and execute the following command (copy->paste and hit enter):
4753

@@ -59,7 +65,21 @@ You can try WiFiClient but you need to disconnect the client yourself to be sure
5965
```
6066
- Restart Arduino IDE
6167

62-
#### Instructions for using as esp-idf component
68+
## Using PlatformIO
69+
70+
[PlatformIO](http://platformio.org) is an open source ecosystem for IoT
71+
development with cross platform build system, library manager and full support
72+
for Espressif ESP32 development. It works on the popular host OS: Mac OS X, Windows,
73+
Linux 32/64, Linux ARM (like Raspberry Pi, BeagleBone, CubieBoard).
74+
75+
- [What is PlatformIO?](http://docs.platformio.org/page/what-is-platformio.html)
76+
- [PlatformIO IDE](http://platformio.org/platformio-ide)
77+
- Quick Start with [PlatformIO IDE](http://docs.platformio.org/page/ide/atom.html#quick-start) or [PlatformIO Core](http://docs.platformio.org/page/core.html)
78+
- [Integration with Cloud and Standalone IDEs](http://docs.platformio.org/page/ide.html) -
79+
Cloud9, Codeanywehre, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM and Visual Studio
80+
- [Project Examples](https://github.com/platformio/platform-espressif32/tree/develop/examples)
81+
82+
## Using as ESP-IDF component
6383
- Download and install [esp-idf](https://github.com/espressif/esp-idf)
6484
- Create blank idf project (from one of the examples)
6585
- in the project folder, create a folder called components and clone this repository inside
@@ -112,4 +132,6 @@ You can try WiFiClient but you need to disconnect the client yourself to be sure
112132
- Else it will wait for WiFi.begin
113133
- ```make flash monitor``` will build, upload and open serial monitor to your board
114134

135+
## ESP32Dev Board PINMAP
136+
115137
![Pin Functions](doc/esp32_pinmap.png)

cores/esp32/Arduino.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,20 @@ extern "C" {
100100
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
101101
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
102102

103+
// avr-libc defines _NOP() since 1.6.2
104+
#ifndef _NOP
105+
#define _NOP() do { __asm__ volatile ("nop"); } while (0)
106+
#endif
107+
108+
typedef unsigned int word;
109+
103110
#define bit(b) (1UL << (b))
104111
#define _BV(b) (1UL << (b))
105112

106113
#define digitalPinToPort(pin) (((pin)>31)?1:0)
107-
#define digitalPinToBitMask(pin) (1UL << (pin))
114+
#define digitalPinToBitMask(pin) (1UL << (((pin)>31)?((pin)-31):(pin)))
108115
#define digitalPinToTimer(pin) (0)
116+
#define analogInPinToBit(P) (P)
109117
#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG))
110118
#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG))
111119
#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG))
@@ -118,6 +126,13 @@ extern "C" {
118126
typedef bool boolean;
119127
typedef uint8_t byte;
120128

129+
void init(void);
130+
void initVariant(void);
131+
void initArduino(void);
132+
133+
void setup(void);
134+
void loop(void);
135+
121136
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
122137
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
123138

cores/esp32/IPAddress.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ size_t IPAddress::printTo(Print& p) const
7272
return n;
7373
}
7474

75-
String IPAddress::toString()
75+
String IPAddress::toString() const
7676
{
7777
char szRet[16];
7878
sprintf(szRet,"%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]);
@@ -119,4 +119,4 @@ bool IPAddress::fromString(const char *address)
119119
}
120120
_address.bytes[3] = acc;
121121
return true;
122-
}
122+
}

cores/esp32/IPAddress.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class IPAddress: public Printable
8181
IPAddress& operator=(uint32_t address);
8282

8383
virtual size_t printTo(Print& p) const;
84-
String toString();
84+
String toString() const;
8585

8686
friend class EthernetClass;
8787
friend class UDP;

cores/esp32/esp32-hal-gpio.c

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#define ETS_GPIO_INUM 12
2828

29+
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};
30+
2931
const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={
3032
{0x44, 11, 11, 1},
3133
{0x88, -1, -1, -1},

cores/esp32/esp32-hal-gpio.h

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ typedef struct {
6565
} esp32_gpioMux_t;
6666

6767
extern const esp32_gpioMux_t esp32_gpioMux[40];
68+
extern const int8_t esp32_adc2gpio[20];
6869

6970
#define digitalPinIsValid(pin) ((pin) < 40 && esp32_gpioMux[(pin)].reg)
7071
#define digitalPinCanOutput(pin) ((pin) < 34 && esp32_gpioMux[(pin)].reg)

cores/esp32/main.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
#include "freertos/FreeRTOS.h"
22
#include "freertos/task.h"
3-
#include "esp32-hal.h"
3+
#include "Arduino.h"
44

55
#if CONFIG_AUTOSTART_ARDUINO
66

7-
extern "C" void initArduino();
8-
extern void loop();
9-
extern void setup();
10-
117
void loopTask(void *pvParameters)
128
{
13-
bool setup_done = false;
9+
setup();
1410
for(;;) {
15-
if(!setup_done) {
16-
setup();
17-
setup_done = true;
18-
}
1911
loop();
2012
}
2113
}

variants/esp32/pins_arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define NUM_DIGITAL_PINS 40
66
#define NUM_ANALOG_INPUTS 16
77

8-
#define analogInputToDigitalPin(p)
8+
#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
99
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
1010
#define digitalPinHasPWM(p) (p < 34)
1111

variants/esp320/pins_arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define NUM_DIGITAL_PINS 12
66
#define NUM_ANALOG_INPUTS 5
77

8-
#define analogInputToDigitalPin(p)
8+
#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
99
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
1010
#define digitalPinHasPWM(p) (p < 34)
1111

variants/espea32/pins_arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define NUM_DIGITAL_PINS 40
66
#define NUM_ANALOG_INPUTS 16
77

8-
#define analogInputToDigitalPin(p)
8+
#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
99
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
1010
#define digitalPinHasPWM(p) (p < 34)
1111

variants/lolin32/pins_arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define NUM_DIGITAL_PINS 40
66
#define NUM_ANALOG_INPUTS 16
77

8-
#define analogInputToDigitalPin(p)
8+
#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
99
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
1010
#define digitalPinHasPWM(p) (p < 34)
1111

variants/nano32/pins_arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define NUM_DIGITAL_PINS 38
66
#define NUM_ANALOG_INPUTS 16
77

8-
#define analogInputToDigitalPin(p)
8+
#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
99
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
1010
#define digitalPinHasPWM(p) (p < 34)
1111

variants/node32s/pins_arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define NUM_DIGITAL_PINS 40
66
#define NUM_ANALOG_INPUTS 16
77

8-
#define analogInputToDigitalPin(p)
8+
#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
99
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
1010
#define digitalPinHasPWM(p) (p < 34)
1111

variants/quantum/pins_arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define NUM_DIGITAL_PINS 40
66
#define NUM_ANALOG_INPUTS 16
77

8-
#define analogInputToDigitalPin(p)
8+
#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
99
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
1010
#define digitalPinHasPWM(p) (p < 34)
1111

0 commit comments

Comments
 (0)