Skip to content

Commit 196992a

Browse files
committed
Merge branch 'esp8266' into smartconfig
* esp8266: (21 commits) HardwareSerial: add other configs than 8N1 Delete jre-8u31.zip.sha Fix Windows build Add boot loader compatible speed of 74880 to serial. update SDK to esp_iot_sdk_v1.0.1_15_04_24 include stdlib_noniso.h in Arduino.h see #110 strnlen implementation missing strn program space wrappers uart_interrupt_handler is now in ram move libm to flash (.irom0.text) saves 3544 Byte in ram see #104 Revert c_types.h fix bug #98 add INPUT_PULLDOWN support add prototypes for ets_vsnprintf and ets_vprintf fix some compiler warnings update SDK to 1.0.1_b2_15_04_10 + SSL Patch update SDK to 1.0.1_b1_15_04_02 add files to ignore (use hardlink) to get git hardware in arduino dir Add method to configure softAP IP address test for #86 add to ESP class: getChipId getSDKversion getBootVersion getBootMode getCPUfreqMHz ...
2 parents f0cf0be + 6a37b44 commit 196992a

35 files changed

+821
-90
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ build/windows/launcher/launch4j
4949
build/windows/WinAVR-*.zip
5050
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
5151
avr-toolchain-*.zip
52+
/hardware/tools/esp8266/utils/
53+
/hardware/tools/esp8266/xtensa-lx106-elf
54+
/hardware/tools/esp8266/esptool.exe
55+
/hardware/tools/avr/
56+
/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/
57+
/hardware/tools/bossac.exe
58+
/hardware/tools/listComPorts.exe

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ more than 20 milliseconds is not recommended.
6262

6363
```Serial``` object works much the same way as on a regular Arduino. Apart from hardware FIFO (128 bytes for TX and RX) HardwareSerial has additional 256-byte TX and RX buffers. Both transmit and receive is interrupt-driven. Write and read functions only block the sketch execution when the respective FIFO/buffers are full/empty.
6464

65-
Only 8n1 mode is supported right now.
66-
6765
By default the diagnostic output from WiFi libraries is disabled when you call ```Serial.begin```. To enable debug output again, call ```Serial.setDebugOutput(true);```
6866

6967
#### WiFi(ESP8266WiFi library) ####

app/src/processing/app/AbstractMonitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void actionPerformed(ActionEvent event) {
135135

136136
String[] serialRateStrings = {
137137
"300", "1200", "2400", "4800", "9600",
138-
"19200", "38400", "57600", "115200"
138+
"19200", "38400", "57600", "74880", "115200"
139139
};
140140

141141
serialRates = new JComboBox();

build/build.xml

+17-32
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
<condition property="launch4j-download-unpack-target-name" value="launch4j-windows"><os family="windows" /></condition>
4848
<property name="launch4j-download-unpack-target-name" value="launch4j-linux"/>
4949

50+
<property name="MACOSX_BUNDLED_JVM" value="${java.home}/../"/>
51+
<property name="WINDOWS_BUNDLED_JVM" value="${java.home}"/>
52+
5053
<!-- Libraries required for running arduino -->
5154
<fileset dir=".." id="runtime.jars">
5255
<include name="arduino-core/arduino-core.jar" />
@@ -729,30 +732,6 @@
729732
<target name="linux-dist" depends="build"
730733
description="Build .tar.xz of linux version">
731734

732-
<!--get src="http://dev.processing.org/build/jre-tools-6u18-linux-i586.tgz"
733-
dest="linux/jre.tgz"
734-
usetimestamp="true" />
735-
<untar compression="gzip"
736-
dest="linux/work"
737-
src="linux/jre.tgz"
738-
overwrite="false"/-->
739-
740-
<!--
741-
<tar compression="gzip" basedir="linux/work"
742-
destfile="linux/arduino-${version}.tgz" />
743-
744-
<tar compression="gzip" destfile="linux/arduino-${version}-linux.tgz">
745-
<tarfileset dir="linux/work"
746-
prefix="arduino-${version}"
747-
excludes="arduino,
748-
hardware/tools/avrdude,
749-
java/**"
750-
/>
751-
<tarfileset file="linux/work/arduino" filemode="755" prefix="arduino-${version}" />
752-
<tarfileset file="linux/work/hardware/tools/avrdude" filemode="755"
753-
prefix="arduino-${version}/hardware/tools" />
754-
</tar>
755-
-->
756735
<move file="linux/work" tofile="linux/arduino-${version}" />
757736

758737
<exec executable="tar" dir="linux">
@@ -935,15 +914,21 @@
935914
dir="windows/work" spawn="true"/>
936915
</target>
937916

938-
<target name="windows-dist" depends="windows-build"
939-
description="Create .zip files of windows version">
917+
<target name="windows-dist" depends="windows-build" description="Create .zip files of windows version">
940918

941-
<antcall target="unzip">
942-
<param name="archive_file" value="windows/jre-8u31.zip" />
943-
<param name="archive_url" value="http://arduino.cc/download.php?f=/jre-8u31.zip" />
944-
<param name="final_folder" value="${staging_folder}/work/java" />
945-
<param name="dest_folder" value="${staging_folder}/work/" />
946-
</antcall>
919+
<loadproperties srcfile="${WINDOWS_BUNDLED_JVM}/../release" prefix="windows"/>
920+
921+
<fail message="It looks like ${WINDOWS_BUNDLED_JVM} does not contain a Windows JVM">
922+
<condition>
923+
<not>
924+
<equals arg1="${windows.OS_NAME}" arg2="&quot;Windows&quot;"/>
925+
</not>
926+
</condition>
927+
</fail>
928+
929+
<copy todir="${staging_folder}/work/java" includeemptydirs="true" preservelastmodified="true" overwrite="true" failonerror="true">
930+
<fileset dir="${WINDOWS_BUNDLED_JVM}" includes="*/**"/>
931+
</copy>
947932

948933
<zip destfile="windows/arduino-${version}-${platform}.zip" level="9">
949934
<zipfileset dir="windows/work"

build/windows/jre-8u31.zip.sha

-1
This file was deleted.

hardware/arduino/sam/cores/arduino/avr/pgmspace.h

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ typedef uint32_t prog_uint32_t;
2626
#define strstr_P(a, b) strstr((a), (b))
2727
#define strlen_P(a) strlen((a))
2828
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
29+
#define strcasecmp_P(a, b) strcasecmp((a), (b))
30+
#define strncpy_P(dest, src, size) strncpy((dest), (src), (size))
31+
#define strncat_P(dest, src, size) strncat((dest), (src), (size))
32+
#define strncmp_P(a, b, size) strncmp((a), (b), (size))
33+
#define strnlen_P(s, size) strnlen((const char *)(s), (size))
34+
#define strncasecmp_P(a, b, size) strncasecmp((a), (b), (size))
2935

3036
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
3137
#define pgm_read_word(addr) (*(const unsigned short *)(addr))

hardware/esp8266com/esp8266/cores/esp8266/Arduino.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ extern "C" {
3333
#include <string.h>
3434
#include <math.h>
3535

36+
#include "stdlib_noniso.h"
3637
#include "binary.h"
3738
#include "pgmspace.h"
3839

39-
40-
4140
void yield(void);
4241

4342
#define HIGH 0x1
@@ -46,6 +45,7 @@ void yield(void);
4645
#define INPUT 0x0
4746
#define OUTPUT 0x1
4847
#define INPUT_PULLUP 0x2
48+
#define INPUT_PULLDOWN 0x3
4949
#define OUTPUT_OPEN_DRAIN 0x4
5050

5151
#define PI 3.1415926535897932384626433832795

hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp

+42-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ extern "C" {
2424
#include "user_interface.h"
2525
}
2626

27-
extern "C" void ets_wdt_enable (void);
28-
extern "C" void ets_wdt_disable (void);
29-
extern "C" void wdt_feed (void);
27+
28+
//extern "C" void ets_wdt_init(uint32_t val);
29+
extern "C" void ets_wdt_enable(void);
30+
extern "C" void ets_wdt_disable(void);
31+
extern "C" void wdt_feed(void);
3032

3133
EspClass ESP;
3234

@@ -35,11 +37,17 @@ EspClass::EspClass()
3537

3638
}
3739

38-
void EspClass::wdtEnable(int)
40+
void EspClass::wdtEnable(uint32_t timeout_ms)
3941
{
42+
//todo find doku for ets_wdt_init may set the timeout
4043
ets_wdt_enable();
4144
}
4245

46+
void EspClass::wdtEnable(WDTO_t timeout_ms)
47+
{
48+
wdtEnable((uint32_t) timeout_ms);
49+
}
50+
4351
void EspClass::wdtDisable(void)
4452
{
4553
ets_wdt_disable();
@@ -70,3 +78,33 @@ uint16_t EspClass::getVCC(void)
7078
{
7179
return system_get_vdd33();
7280
}
81+
82+
uint32_t EspClass::getFreeHeap(void)
83+
{
84+
return system_get_free_heap_size();
85+
}
86+
87+
uint32_t EspClass::getChipId(void)
88+
{
89+
return system_get_chip_id();
90+
}
91+
92+
const char * EspClass::getSDKversion(void)
93+
{
94+
return system_get_sdk_version();
95+
}
96+
97+
uint8_t EspClass::getBootVersion(void)
98+
{
99+
return system_get_boot_version();
100+
}
101+
102+
uint8_t EspClass::getBootMode(void)
103+
{
104+
return system_get_boot_mode();
105+
}
106+
107+
uint8_t EspClass::getCPUfreqMHz(void)
108+
{
109+
return system_get_cpu_freq();
110+
}

hardware/esp8266com/esp8266/cores/esp8266/Esp.h

+34-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,27 @@
2020

2121
#ifndef ESP_H
2222
#define ESP_H
23+
/**
24+
* AVR macros for WDT managment
25+
*/
26+
typedef enum {
27+
WDTO_0MS = 0, //!< WDTO_0MS
28+
WDTO_15MS = 15, //!< WDTO_15MS
29+
WDTO_30MS = 30, //!< WDTO_30MS
30+
WDTO_60MS = 60, //!< WDTO_60MS
31+
WDTO_120MS = 120, //!< WDTO_120MS
32+
WDTO_250MS = 250, //!< WDTO_250MS
33+
WDTO_500MS = 500, //!< WDTO_500MS
34+
WDTO_1S = 1000,//!< WDTO_1S
35+
WDTO_2S = 2000,//!< WDTO_2S
36+
WDTO_4S = 4000,//!< WDTO_4S
37+
WDTO_8S = 8000 //!< WDTO_8S
38+
} WDTO_t;
39+
2340

41+
#define wdt_enable(time) ESP.wdtEnable(time)
42+
#define wdt_disable() ESP.wdtDisable()
43+
#define wdt_reset() ESP.wdtFeed()
2444

2545
enum WakeMode {
2646
WAKE_RF_DEFAULT = 0, // RF_CAL or not after deep-sleep wake up, depends on init data byte 108.
@@ -33,8 +53,10 @@ class EspClass {
3353
public:
3454
EspClass();
3555

36-
void wdtEnable(int timeout_ms = 0);
3756
// TODO: figure out how to set WDT timeout
57+
void wdtEnable(uint32_t timeout_ms = 0);
58+
void wdtEnable(WDTO_t timeout_ms = WDTO_0MS);
59+
3860
void wdtDisable(void);
3961
void wdtFeed(void);
4062

@@ -44,6 +66,17 @@ class EspClass {
4466
void reset(void);
4567
void restart(void);
4668
uint16_t getVCC(void);
69+
uint32_t getFreeHeap(void);
70+
71+
uint32_t getChipId(void);
72+
73+
const char * getSDKversion(void);
74+
75+
uint8_t getBootVersion(void);
76+
uint8_t getBootMode(void);
77+
78+
uint8_t getCPUfreqMHz(void);
79+
4780
};
4881

4982
extern EspClass ESP;

hardware/esp8266com/esp8266/cores/esp8266/HardwareSerial.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2020
2121
Modified 31 March 2015 by Markus Sattler (rewrite the code for UART0 + UART1 support in ESP8266)
22-
22+
Modified 25 April 2015 by Thomas Flayols (add configuration different from 8N1 in ESP8266)
2323
*/
2424

2525
#include <stdlib.h>
@@ -86,7 +86,7 @@ void uart_disarm_tx_interrupt(uart_t* uart);
8686
void uart_set_baudrate(uart_t* uart, int baud_rate);
8787
int uart_get_baudrate(uart_t* uart);
8888

89-
uart_t* uart_init(UARTnr_t uart_nr, int baudrate);
89+
uart_t* uart_init(UARTnr_t uart_nr, int baudrate, byte config);
9090
void uart_uninit(uart_t* uart);
9191
void uart_swap(uart_t* uart);
9292

@@ -101,7 +101,7 @@ UARTnr_t uart_get_debug();
101101
// ####################################################################################################
102102
// ####################################################################################################
103103

104-
void ICACHE_FLASH_ATTR uart_interrupt_handler(uart_t* uart) {
104+
void uart_interrupt_handler(uart_t* uart) {
105105

106106
// -------------- UART 0 --------------
107107
uint32_t status = READ_PERI_REG(UART_INT_ST(0));
@@ -278,7 +278,7 @@ int ICACHE_FLASH_ATTR uart_get_baudrate(uart_t* uart) {
278278
return uart->baud_rate;
279279
}
280280

281-
uart_t* ICACHE_FLASH_ATTR uart_init(UARTnr_t uart_nr, int baudrate) {
281+
uart_t* ICACHE_FLASH_ATTR uart_init(UARTnr_t uart_nr, int baudrate, byte config) {
282282

283283
uint32_t conf1 = 0x00000000;
284284
uart_t* uart = (uart_t*) os_malloc(sizeof(uart_t));
@@ -314,7 +314,7 @@ uart_t* ICACHE_FLASH_ATTR uart_init(UARTnr_t uart_nr, int baudrate) {
314314
break;
315315
}
316316
uart_set_baudrate(uart, baudrate);
317-
WRITE_PERI_REG(UART_CONF0(uart->uart_nr), 0x3 << UART_BIT_NUM_S); // 8n1
317+
WRITE_PERI_REG(UART_CONF0(uart->uart_nr), config);
318318

319319
uart_flush(uart);
320320
uart_interrupt_enable(uart);
@@ -453,7 +453,7 @@ void ICACHE_FLASH_ATTR uart1_write_char(char c) {
453453
}
454454
}
455455

456-
static UARTnr_t s_uart_debug_nr = UART_NO;
456+
static UARTnr_t s_uart_debug_nr = UART0;
457457
void ICACHE_FLASH_ATTR uart_set_debug(UARTnr_t uart_nr) {
458458
s_uart_debug_nr = uart_nr;
459459
switch(s_uart_debug_nr) {
@@ -493,7 +493,7 @@ void ICACHE_FLASH_ATTR HardwareSerial::begin(unsigned long baud, byte config) {
493493
uart_set_debug(UART_NO);
494494
}
495495

496-
_uart = uart_init(_uart_nr, baud);
496+
_uart = uart_init(_uart_nr, baud, config);
497497

498498
if(_uart == 0) {
499499
return;

hardware/esp8266com/esp8266/cores/esp8266/HardwareSerial.h

+27-26
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Modified 3 December 2013 by Matthijs Kooijman
2222
Modified 18 December 2014 by Ivan Grokhotkov (esp8266 platform support)
2323
Modified 31 March 2015 by Markus Sattler (rewrite the code for UART0 + UART1 support in ESP8266)
24+
Modified 25 April 2015 by Thomas Flayols (add configuration different from 8N1 in ESP8266)
2425
*/
2526

2627
#ifndef HardwareSerial_h
@@ -33,31 +34,31 @@
3334
#define SERIAL_TX_BUFFER_SIZE 256
3435
#define SERIAL_RX_BUFFER_SIZE 256
3536

36-
// // Define config for Serial.begin(baud, config);
37-
// #define SERIAL_5N1 0x00
38-
// #define SERIAL_6N1 0x02
39-
// #define SERIAL_7N1 0x04
40-
// #define SERIAL_8N1 0x06
41-
// #define SERIAL_5N2 0x08
42-
// #define SERIAL_6N2 0x0A
43-
// #define SERIAL_7N2 0x0C
44-
// #define SERIAL_8N2 0x0E
45-
// #define SERIAL_5E1 0x20
46-
// #define SERIAL_6E1 0x22
47-
// #define SERIAL_7E1 0x24
48-
// #define SERIAL_8E1 0x26
49-
// #define SERIAL_5E2 0x28
50-
// #define SERIAL_6E2 0x2A
51-
// #define SERIAL_7E2 0x2C
52-
// #define SERIAL_8E2 0x2E
53-
// #define SERIAL_5O1 0x30
54-
// #define SERIAL_6O1 0x32
55-
// #define SERIAL_7O1 0x34
56-
// #define SERIAL_8O1 0x36
57-
// #define SERIAL_5O2 0x38
58-
// #define SERIAL_6O2 0x3A
59-
// #define SERIAL_7O2 0x3C
60-
// #define SERIAL_8O2 0x3E
37+
// Define config for Serial.begin(baud, config);
38+
#define SERIAL_5N1 0x10
39+
#define SERIAL_6N1 0x14
40+
#define SERIAL_7N1 0x18
41+
#define SERIAL_8N1 0x1c
42+
#define SERIAL_5N2 0x30
43+
#define SERIAL_6N2 0x34
44+
#define SERIAL_7N2 0x38
45+
#define SERIAL_8N2 0x3c
46+
#define SERIAL_5E1 0x12
47+
#define SERIAL_6E1 0x16
48+
#define SERIAL_7E1 0x1a
49+
#define SERIAL_8E1 0x1e
50+
#define SERIAL_5E2 0x32
51+
#define SERIAL_6E2 0x36
52+
#define SERIAL_7E2 0x3a
53+
#define SERIAL_8E2 0x3e
54+
#define SERIAL_5O1 0x13
55+
#define SERIAL_6O1 0x17
56+
#define SERIAL_7O1 0x1b
57+
#define SERIAL_8O1 0x1f
58+
#define SERIAL_5O2 0x33
59+
#define SERIAL_6O2 0x37
60+
#define SERIAL_7O2 0x3b
61+
#define SERIAL_8O2 0x3f
6162

6263
class cbuf;
6364

@@ -79,7 +80,7 @@ class HardwareSerial: public Stream {
7980
HardwareSerial(UARTnr_t uart_nr);
8081

8182
void begin(unsigned long baud) {
82-
begin(baud, 0);
83+
begin(baud, SERIAL_8N1);
8384
}
8485
void begin(unsigned long, uint8_t);
8586
void end();

0 commit comments

Comments
 (0)