Skip to content

Add Nano32 development board #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e8fd4e5
Add Nano32
Oct 7, 2016
c9c3e78
Change upload.maximum_data_size to 294912
Oct 18, 2016
7eee62e
Update README.md
me-no-dev Oct 7, 2016
6243347
include math.h by default
me-no-dev Oct 7, 2016
3a7ce7e
fix F macro
me-no-dev Oct 7, 2016
9c6fdfa
comment out __FlashStringHelper methods in Print
me-no-dev Oct 7, 2016
6ddf4b6
Print::printf should allocate it's buffer
me-no-dev Oct 7, 2016
d9271d4
add more definitions to pgmspace.h to match ESP8266
me-no-dev Oct 7, 2016
08fb11f
Remove non-working WiFi examples and fix some that require changes
me-no-dev Oct 8, 2016
7f39802
fix i2c hal
me-no-dev Oct 8, 2016
8bfca04
I2C SDA should properly register the ACK bit from some slaves
me-no-dev Oct 10, 2016
a4f3600
prevent some devices from locking the SCL line
me-no-dev Oct 10, 2016
df46317
Prevent I2C Bus locks and wrong data being sent on retry
me-no-dev Oct 10, 2016
afcff1b
use local buffer for printf if size is equal or less than 64
me-no-dev Oct 10, 2016
2f512bc
Do not delete printf buffer if not required
me-no-dev Oct 10, 2016
ae2a984
fix Serial RX
me-no-dev Oct 11, 2016
89a3e09
attach uart isr on the current core
me-no-dev Oct 11, 2016
9b01daa
copy va_list in Print::printf
me-no-dev Oct 11, 2016
d5a59e1
fix GPIO attachInterrupt
me-no-dev Oct 11, 2016
74aeafb
really fix attachInterrupt to work on either core
me-no-dev Oct 11, 2016
713ff09
implement thread-safe i2c
me-no-dev Oct 11, 2016
cff7f69
return proper errors
me-no-dev Oct 11, 2016
13af2c7
implement thread-safe spi
me-no-dev Oct 11, 2016
9d5881a
UART rework
me-no-dev Oct 14, 2016
5cd933e
Implement thread-safe uart
me-no-dev Oct 14, 2016
c36a891
remove unnecessary locks
me-no-dev Oct 14, 2016
c4cd31d
remove unnecessary locks
me-no-dev Oct 14, 2016
a2e3506
fix reported data size and percentage
me-no-dev Oct 17, 2016
74197b1
do not lock for ets_printf
me-no-dev Oct 17, 2016
f0c99ef
Ignore certificates on windows
whatnick Oct 17, 2016
b366e84
ignore ssl only on windows
me-no-dev Oct 17, 2016
5f1a818
First addition of ESP320 support (#19)
Sweet-Peas Oct 17, 2016
6bfaa52
Add Nano32
Oct 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
Arduino core for ESP32 WiFi chip
===========================================

### Development Status
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 :)

The framework can also be downloaded as component in an IDF project and be used like that.

Things that "should" work:
- pinMode
- digitalRead/digitalWrite
- attachInterrupt/detachInterrupt
- Serial (global Serial is attached to pins 1 and 3 by default, there are another 2 serials that you can attach to any pin)
- SPI (global SPI is attached to VSPI pins by default and HSPI can be attached to any pins)
- Wire (global Wire is attached to pins 21 and 22 by default and there is another I2C bus that you can attach to any pins)
- WiFi (about 99% the same as ESP8266)

WiFiClient, WiFiServer and WiFiUdp are not quite ready yet because there are still some small hiccups in LwIP to be overcome.
You can try WiFiClient but you need to disconnect the client yourself to be sure that connection is closed.

### Installation
- Install Arduino 1.6.9
- Go to Arduino directory
- Install Arduino IDE
- Go to Arduino IDE installation directory
- Clone this repository into hardware/espressif/esp32 directory (or clone it elsewhere and create a symlink)
```bash
cd hardware
Expand Down
124 changes: 123 additions & 1 deletion boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ esp32.name=ESP32 Dev Module

esp32.upload.tool=esptool
esp32.upload.maximum_size=1044464
esp32.upload.maximum_data_size=114688
esp32.upload.maximum_data_size=294912
esp32.upload.wait_for_upload_port=true

esp32.serial.disableDTR=true
Expand Down Expand Up @@ -40,3 +40,125 @@ esp32.menu.UploadSpeed.460800.macosx=460800
esp32.menu.UploadSpeed.460800.upload.speed=460800
esp32.menu.UploadSpeed.512000.windows=512000
esp32.menu.UploadSpeed.512000.upload.speed=512000

<<<<<<< b366e843a1604bc8afbef1b147f21231ef2bceee

##############################################################
nano32.name=Nano32

nano32.upload.tool=esptool
nano32.upload.maximum_size=1044464
nano32.upload.maximum_data_size=294912
nano32.upload.wait_for_upload_port=true

nano32.serial.disableDTR=true
nano32.serial.disableRTS=true

nano32.build.mcu=esp32
nano32.build.core=esp32
nano32.build.variant=nano32
nano32.build.board=NANO32

nano32.build.f_cpu=160000000L
nano32.build.flash_mode=dio
nano32.build.flash_size=4MB

nano32.menu.FlashFreq.80=80MHz
nano32.menu.FlashFreq.80.build.flash_freq=80m
nano32.menu.FlashFreq.40=40MHz
nano32.menu.FlashFreq.40.build.flash_freq=40m

nano32.menu.UploadSpeed.921600=921600
nano32.menu.UploadSpeed.921600.upload.speed=921600
nano32.menu.UploadSpeed.115200=115200
nano32.menu.UploadSpeed.115200.upload.speed=115200
nano32.menu.UploadSpeed.256000.windows=256000
nano32.menu.UploadSpeed.256000.upload.speed=256000
nano32.menu.UploadSpeed.230400.windows.upload.speed=256000
nano32.menu.UploadSpeed.230400=230400
nano32.menu.UploadSpeed.230400.upload.speed=230400
nano32.menu.UploadSpeed.460800.linux=460800
nano32.menu.UploadSpeed.460800.macosx=460800
nano32.menu.UploadSpeed.460800.upload.speed=460800
nano32.menu.UploadSpeed.512000.windows=512000
nano32.menu.UploadSpeed.512000.upload.speed=512000

##############################################################
esp320.name=Electronic SweetPeas - ESP320

esp320.upload.tool=esptool
esp320.upload.maximum_size=1044464
esp320.upload.maximum_data_size=294912
esp320.upload.wait_for_upload_port=true

esp320.serial.disableDTR=true
esp320.serial.disableRTS=true

esp320.build.mcu=esp32
esp320.build.core=esp32
esp320.build.variant=esp320
esp320.build.board=ESP320

esp320.build.f_cpu=160000000L
esp320.build.flash_mode=qio
esp320.build.flash_size=4MB

esp320.menu.FlashFreq.80=80MHz
esp320.menu.FlashFreq.80.build.flash_freq=80m
esp320.menu.FlashFreq.40=40MHz
esp320.menu.FlashFreq.40.build.flash_freq=40m

esp320.menu.UploadSpeed.921600=921600
esp320.menu.UploadSpeed.921600.upload.speed=921600
esp320.menu.UploadSpeed.115200=115200
esp320.menu.UploadSpeed.115200.upload.speed=115200
esp320.menu.UploadSpeed.256000.windows=256000
esp320.menu.UploadSpeed.256000.upload.speed=256000
esp320.menu.UploadSpeed.230400.windows.upload.speed=256000
esp320.menu.UploadSpeed.230400=230400
esp320.menu.UploadSpeed.230400.upload.speed=230400
esp320.menu.UploadSpeed.460800.linux=460800
esp320.menu.UploadSpeed.460800.macosx=460800
esp320.menu.UploadSpeed.460800.upload.speed=460800
esp320.menu.UploadSpeed.512000.windows=512000
esp320.menu.UploadSpeed.512000.upload.speed=512000

##############################################################
nano32.name=Nano32

nano32.upload.tool=esptool
nano32.upload.maximum_size=1044464
nano32.upload.maximum_data_size=114688
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change upload.maximum_data_size to 294912

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

Thank you 👍

nano32.upload.wait_for_upload_port=true

nano32.serial.disableDTR=true
nano32.serial.disableRTS=true

nano32.build.mcu=esp32
nano32.build.core=esp32
nano32.build.variant=nano32
nano32.build.board=NANO32

nano32.build.f_cpu=160000000L
nano32.build.flash_mode=dio
nano32.build.flash_size=4MB

nano32.menu.FlashFreq.80=80MHz
nano32.menu.FlashFreq.80.build.flash_freq=80m
nano32.menu.FlashFreq.40=40MHz
nano32.menu.FlashFreq.40.build.flash_freq=40m

nano32.menu.UploadSpeed.921600=921600
nano32.menu.UploadSpeed.921600.upload.speed=921600
nano32.menu.UploadSpeed.115200=115200
nano32.menu.UploadSpeed.115200.upload.speed=115200
nano32.menu.UploadSpeed.256000.windows=256000
nano32.menu.UploadSpeed.256000.upload.speed=256000
nano32.menu.UploadSpeed.230400.windows.upload.speed=256000
nano32.menu.UploadSpeed.230400=230400
nano32.menu.UploadSpeed.230400.upload.speed=230400
nano32.menu.UploadSpeed.460800.linux=460800
nano32.menu.UploadSpeed.460800.macosx=460800
nano32.menu.UploadSpeed.460800.upload.speed=460800
nano32.menu.UploadSpeed.512000.windows=512000
nano32.menu.UploadSpeed.512000.upload.speed=512000
40 changes: 4 additions & 36 deletions cores/esp32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,80 +33,48 @@ void HardwareSerial::setDebugOutput(bool en)
return;
}
if(en) {
if(_uart->txEnabled) {
uartSetDebug(_uart);
} else {
uartSetDebug(0);
}
uartSetDebug(_uart);
} else {
if(uartGetDebug() == _uart_nr) {
uartSetDebug(0);
}
}
}

bool HardwareSerial::isTxEnabled(void)
{
if(_uart == 0) {
return false;
}
return _uart->txEnabled;
}

bool HardwareSerial::isRxEnabled(void)
{
if(_uart == 0) {
return false;
}
return _uart->rxEnabled;
}

int HardwareSerial::available(void)
{
if (_uart && _uart->rxEnabled) {
return uartAvailable(_uart);
}
return 0;
return uartAvailable(_uart);
}

int HardwareSerial::peek(void)
{
if (_uart && _uart->rxEnabled) {
if (available()) {
return uartPeek(_uart);
}
return -1;
}

int HardwareSerial::read(void)
{
if(_uart && _uart->rxEnabled) {
if(available()) {
return uartRead(_uart);
}
return -1;
}

void HardwareSerial::flush()
{
if(_uart == 0 || !_uart->txEnabled) {
return;
}
uartFlush(_uart);
}

size_t HardwareSerial::write(uint8_t c)
{
if(_uart == 0 || !_uart->txEnabled) {
return 0;
}
uartWrite(_uart, c);
return 1;
}

size_t HardwareSerial::write(const uint8_t *buffer, size_t size)
{
if(_uart == 0 || !_uart->txEnabled) {
return 0;
}
uartWriteBuf(_uart, buffer, size);
return size;
}
Expand Down
2 changes: 0 additions & 2 deletions cores/esp32/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ class HardwareSerial: public Stream
operator bool() const;

void setDebugOutput(bool);
bool isTxEnabled(void);
bool isRxEnabled(void);

protected:
int _uart_nr;
Expand Down
22 changes: 17 additions & 5 deletions cores/esp32/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,26 @@ size_t Print::write(const uint8_t *buffer, size_t size)

size_t Print::printf(const char *format, ...)
{
char loc_buf[64];
char * temp = loc_buf;
va_list arg;
va_list copy;
va_start(arg, format);
va_copy(copy, arg);
size_t len = vsnprintf(NULL, 0, format, arg);
char temp[len+1];
uint8_t * stemp = (uint8_t*)temp;
va_end(copy);
if(len >= sizeof(loc_buf)){
temp = new char[len+1];
if(temp == NULL) {
return 0;
}
}
len = vsnprintf(temp, len+1, format, arg);
write(stemp, len);
write((uint8_t*)temp, len);
va_end(arg);
if(len > 64){
delete[] temp;
}
return len;
}
/*
Expand Down Expand Up @@ -128,14 +140,14 @@ size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}

/*
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}

*/
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
Expand Down
4 changes: 2 additions & 2 deletions cores/esp32/Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Print
}

size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3)));
size_t print(const __FlashStringHelper *);
//size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
Expand All @@ -84,7 +84,7 @@ class Print
size_t print(double, int = 2);
size_t print(const Printable&);

size_t println(const __FlashStringHelper *);
//size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
Expand Down
6 changes: 2 additions & 4 deletions cores/esp32/WString.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
//#include <pgmspace.h>
#include <pgmspace.h>

// An inherited class for holding the result of a concatenation. These
// result objects are assumed to be writable by subsequent concatenations.
class StringSumHelper;

// an abstract class used as a means to proide a unique pointer type
// but really has no body
class __FlashStringHelper;
#define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
#define F(string_literal) (FPSTR(PSTR(string_literal)))
//class __FlashStringHelper;

// The string class
class String
Expand Down
15 changes: 12 additions & 3 deletions cores/esp32/esp32-hal-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,33 @@ static void IRAM_ATTR __onPinInterrupt(void *arg)
extern void __attachInterrupt(uint8_t pin, voidFuncPtr userFunc, int intr_type)
{
static bool interrupt_initialized = false;
static int core_id = 0;

if(!interrupt_initialized) {
interrupt_initialized = true;
core_id = xPortGetCoreID();
ESP_INTR_DISABLE(ETS_GPIO_INUM);
intr_matrix_set(PRO_CPU_NUM, ETS_GPIO_INTR_SOURCE, ETS_GPIO_INUM);
intr_matrix_set(core_id, ETS_GPIO_INTR_SOURCE, ETS_GPIO_INUM);
xt_set_interrupt_handler(ETS_GPIO_INUM, &__onPinInterrupt, NULL);
ESP_INTR_ENABLE(ETS_GPIO_INUM);
}
__pinInterruptHandlers[pin] = userFunc;
ESP_INTR_DISABLE(ETS_GPIO_INUM);
GPIO.pin[pin].val = (GPIO.pin[pin].val & ~((GPIO_PIN0_INT_ENA << GPIO_PIN0_INT_ENA_S) | (GPIO_PIN0_INT_TYPE << GPIO_PIN0_INT_TYPE_S))) | (((uint32_t)0x4 << GPIO_PIN0_INT_ENA_S) | ((uint32_t)intr_type << GPIO_PIN0_INT_TYPE_S));
if(core_id) { //APP_CPU
GPIO.pin[pin].int_ena = 1;
} else { //PRO_CPU
GPIO.pin[pin].int_ena = 4;
}
GPIO.pin[pin].int_type = intr_type;
ESP_INTR_ENABLE(ETS_GPIO_INUM);
}

extern void __detachInterrupt(uint8_t pin)
{
__pinInterruptHandlers[pin] = NULL;
ESP_INTR_DISABLE(ETS_GPIO_INUM);
GPIO.pin[pin].val = (GPIO.pin[pin].val & ~((GPIO_PIN0_INT_ENA << GPIO_PIN0_INT_ENA_S) | (GPIO_PIN0_INT_TYPE << GPIO_PIN0_INT_TYPE_S)));
GPIO.pin[pin].int_ena = 0;
GPIO.pin[pin].int_type = 0;
ESP_INTR_ENABLE(ETS_GPIO_INUM);
}

Expand Down
Loading