Skip to content

Commit

Permalink
Merge branch 'esp8266' into smartconfig
Browse files Browse the repository at this point in the history
* 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
  ...
  • Loading branch information
igrr committed Apr 26, 2015
2 parents f0cf0be + 6a37b44 commit 196992a
Show file tree
Hide file tree
Showing 35 changed files with 821 additions and 90 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ build/windows/launcher/launch4j
build/windows/WinAVR-*.zip
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
avr-toolchain-*.zip
/hardware/tools/esp8266/utils/
/hardware/tools/esp8266/xtensa-lx106-elf
/hardware/tools/esp8266/esptool.exe
/hardware/tools/avr/
/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/
/hardware/tools/bossac.exe
/hardware/tools/listComPorts.exe
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ more than 20 milliseconds is not recommended.

```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.

Only 8n1 mode is supported right now.

By default the diagnostic output from WiFi libraries is disabled when you call ```Serial.begin```. To enable debug output again, call ```Serial.setDebugOutput(true);```

#### WiFi(ESP8266WiFi library) ####
Expand Down
2 changes: 1 addition & 1 deletion app/src/processing/app/AbstractMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void actionPerformed(ActionEvent event) {

String[] serialRateStrings = {
"300", "1200", "2400", "4800", "9600",
"19200", "38400", "57600", "115200"
"19200", "38400", "57600", "74880", "115200"
};

serialRates = new JComboBox();
Expand Down
49 changes: 17 additions & 32 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<condition property="launch4j-download-unpack-target-name" value="launch4j-windows"><os family="windows" /></condition>
<property name="launch4j-download-unpack-target-name" value="launch4j-linux"/>

<property name="MACOSX_BUNDLED_JVM" value="${java.home}/../"/>
<property name="WINDOWS_BUNDLED_JVM" value="${java.home}"/>

<!-- Libraries required for running arduino -->
<fileset dir=".." id="runtime.jars">
<include name="arduino-core/arduino-core.jar" />
Expand Down Expand Up @@ -729,30 +732,6 @@
<target name="linux-dist" depends="build"
description="Build .tar.xz of linux version">

<!--get src="http://dev.processing.org/build/jre-tools-6u18-linux-i586.tgz"
dest="linux/jre.tgz"
usetimestamp="true" />
<untar compression="gzip"
dest="linux/work"
src="linux/jre.tgz"
overwrite="false"/-->

<!--
<tar compression="gzip" basedir="linux/work"
destfile="linux/arduino-${version}.tgz" />
<tar compression="gzip" destfile="linux/arduino-${version}-linux.tgz">
<tarfileset dir="linux/work"
prefix="arduino-${version}"
excludes="arduino,
hardware/tools/avrdude,
java/**"
/>
<tarfileset file="linux/work/arduino" filemode="755" prefix="arduino-${version}" />
<tarfileset file="linux/work/hardware/tools/avrdude" filemode="755"
prefix="arduino-${version}/hardware/tools" />
</tar>
-->
<move file="linux/work" tofile="linux/arduino-${version}" />

<exec executable="tar" dir="linux">
Expand Down Expand Up @@ -935,15 +914,21 @@
dir="windows/work" spawn="true"/>
</target>

<target name="windows-dist" depends="windows-build"
description="Create .zip files of windows version">
<target name="windows-dist" depends="windows-build" description="Create .zip files of windows version">

<antcall target="unzip">
<param name="archive_file" value="windows/jre-8u31.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/jre-8u31.zip" />
<param name="final_folder" value="${staging_folder}/work/java" />
<param name="dest_folder" value="${staging_folder}/work/" />
</antcall>
<loadproperties srcfile="${WINDOWS_BUNDLED_JVM}/../release" prefix="windows"/>

<fail message="It looks like ${WINDOWS_BUNDLED_JVM} does not contain a Windows JVM">
<condition>
<not>
<equals arg1="${windows.OS_NAME}" arg2="&quot;Windows&quot;"/>
</not>
</condition>
</fail>

<copy todir="${staging_folder}/work/java" includeemptydirs="true" preservelastmodified="true" overwrite="true" failonerror="true">
<fileset dir="${WINDOWS_BUNDLED_JVM}" includes="*/**"/>
</copy>

<zip destfile="windows/arduino-${version}-${platform}.zip" level="9">
<zipfileset dir="windows/work"
Expand Down
1 change: 0 additions & 1 deletion build/windows/jre-8u31.zip.sha

This file was deleted.

6 changes: 6 additions & 0 deletions hardware/arduino/sam/cores/arduino/avr/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ typedef uint32_t prog_uint32_t;
#define strstr_P(a, b) strstr((a), (b))
#define strlen_P(a) strlen((a))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
#define strcasecmp_P(a, b) strcasecmp((a), (b))
#define strncpy_P(dest, src, size) strncpy((dest), (src), (size))
#define strncat_P(dest, src, size) strncat((dest), (src), (size))
#define strncmp_P(a, b, size) strncmp((a), (b), (size))
#define strnlen_P(s, size) strnlen((const char *)(s), (size))
#define strncasecmp_P(a, b, size) strncasecmp((a), (b), (size))

#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
Expand Down
4 changes: 2 additions & 2 deletions hardware/esp8266com/esp8266/cores/esp8266/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ extern "C" {
#include <string.h>
#include <math.h>

#include "stdlib_noniso.h"
#include "binary.h"
#include "pgmspace.h"



void yield(void);

#define HIGH 0x1
Expand All @@ -46,6 +45,7 @@ void yield(void);
#define INPUT 0x0
#define OUTPUT 0x1
#define INPUT_PULLUP 0x2
#define INPUT_PULLDOWN 0x3
#define OUTPUT_OPEN_DRAIN 0x4

#define PI 3.1415926535897932384626433832795
Expand Down
46 changes: 42 additions & 4 deletions hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ extern "C" {
#include "user_interface.h"
}

extern "C" void ets_wdt_enable (void);
extern "C" void ets_wdt_disable (void);
extern "C" void wdt_feed (void);

//extern "C" void ets_wdt_init(uint32_t val);
extern "C" void ets_wdt_enable(void);
extern "C" void ets_wdt_disable(void);
extern "C" void wdt_feed(void);

EspClass ESP;

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

}

void EspClass::wdtEnable(int)
void EspClass::wdtEnable(uint32_t timeout_ms)
{
//todo find doku for ets_wdt_init may set the timeout
ets_wdt_enable();
}

void EspClass::wdtEnable(WDTO_t timeout_ms)
{
wdtEnable((uint32_t) timeout_ms);
}

void EspClass::wdtDisable(void)
{
ets_wdt_disable();
Expand Down Expand Up @@ -70,3 +78,33 @@ uint16_t EspClass::getVCC(void)
{
return system_get_vdd33();
}

uint32_t EspClass::getFreeHeap(void)
{
return system_get_free_heap_size();
}

uint32_t EspClass::getChipId(void)
{
return system_get_chip_id();
}

const char * EspClass::getSDKversion(void)
{
return system_get_sdk_version();
}

uint8_t EspClass::getBootVersion(void)
{
return system_get_boot_version();
}

uint8_t EspClass::getBootMode(void)
{
return system_get_boot_mode();
}

uint8_t EspClass::getCPUfreqMHz(void)
{
return system_get_cpu_freq();
}
35 changes: 34 additions & 1 deletion hardware/esp8266com/esp8266/cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,27 @@

#ifndef ESP_H
#define ESP_H
/**
* AVR macros for WDT managment
*/
typedef enum {
WDTO_0MS = 0, //!< WDTO_0MS
WDTO_15MS = 15, //!< WDTO_15MS
WDTO_30MS = 30, //!< WDTO_30MS
WDTO_60MS = 60, //!< WDTO_60MS
WDTO_120MS = 120, //!< WDTO_120MS
WDTO_250MS = 250, //!< WDTO_250MS
WDTO_500MS = 500, //!< WDTO_500MS
WDTO_1S = 1000,//!< WDTO_1S
WDTO_2S = 2000,//!< WDTO_2S
WDTO_4S = 4000,//!< WDTO_4S
WDTO_8S = 8000 //!< WDTO_8S
} WDTO_t;


#define wdt_enable(time) ESP.wdtEnable(time)
#define wdt_disable() ESP.wdtDisable()
#define wdt_reset() ESP.wdtFeed()

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

void wdtEnable(int timeout_ms = 0);
// TODO: figure out how to set WDT timeout
void wdtEnable(uint32_t timeout_ms = 0);
void wdtEnable(WDTO_t timeout_ms = WDTO_0MS);

void wdtDisable(void);
void wdtFeed(void);

Expand All @@ -44,6 +66,17 @@ class EspClass {
void reset(void);
void restart(void);
uint16_t getVCC(void);
uint32_t getFreeHeap(void);

uint32_t getChipId(void);

const char * getSDKversion(void);

uint8_t getBootVersion(void);
uint8_t getBootMode(void);

uint8_t getCPUfreqMHz(void);

};

extern EspClass ESP;
Expand Down
14 changes: 7 additions & 7 deletions hardware/esp8266com/esp8266/cores/esp8266/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 31 March 2015 by Markus Sattler (rewrite the code for UART0 + UART1 support in ESP8266)
Modified 25 April 2015 by Thomas Flayols (add configuration different from 8N1 in ESP8266)
*/

#include <stdlib.h>
Expand Down Expand Up @@ -86,7 +86,7 @@ void uart_disarm_tx_interrupt(uart_t* uart);
void uart_set_baudrate(uart_t* uart, int baud_rate);
int uart_get_baudrate(uart_t* uart);

uart_t* uart_init(UARTnr_t uart_nr, int baudrate);
uart_t* uart_init(UARTnr_t uart_nr, int baudrate, byte config);
void uart_uninit(uart_t* uart);
void uart_swap(uart_t* uart);

Expand All @@ -101,7 +101,7 @@ UARTnr_t uart_get_debug();
// ####################################################################################################
// ####################################################################################################

void ICACHE_FLASH_ATTR uart_interrupt_handler(uart_t* uart) {
void uart_interrupt_handler(uart_t* uart) {

// -------------- UART 0 --------------
uint32_t status = READ_PERI_REG(UART_INT_ST(0));
Expand Down Expand Up @@ -278,7 +278,7 @@ int ICACHE_FLASH_ATTR uart_get_baudrate(uart_t* uart) {
return uart->baud_rate;
}

uart_t* ICACHE_FLASH_ATTR uart_init(UARTnr_t uart_nr, int baudrate) {
uart_t* ICACHE_FLASH_ATTR uart_init(UARTnr_t uart_nr, int baudrate, byte config) {

uint32_t conf1 = 0x00000000;
uart_t* uart = (uart_t*) os_malloc(sizeof(uart_t));
Expand Down Expand Up @@ -314,7 +314,7 @@ uart_t* ICACHE_FLASH_ATTR uart_init(UARTnr_t uart_nr, int baudrate) {
break;
}
uart_set_baudrate(uart, baudrate);
WRITE_PERI_REG(UART_CONF0(uart->uart_nr), 0x3 << UART_BIT_NUM_S); // 8n1
WRITE_PERI_REG(UART_CONF0(uart->uart_nr), config);

uart_flush(uart);
uart_interrupt_enable(uart);
Expand Down Expand Up @@ -453,7 +453,7 @@ void ICACHE_FLASH_ATTR uart1_write_char(char c) {
}
}

static UARTnr_t s_uart_debug_nr = UART_NO;
static UARTnr_t s_uart_debug_nr = UART0;
void ICACHE_FLASH_ATTR uart_set_debug(UARTnr_t uart_nr) {
s_uart_debug_nr = uart_nr;
switch(s_uart_debug_nr) {
Expand Down Expand Up @@ -493,7 +493,7 @@ void ICACHE_FLASH_ATTR HardwareSerial::begin(unsigned long baud, byte config) {
uart_set_debug(UART_NO);
}

_uart = uart_init(_uart_nr, baud);
_uart = uart_init(_uart_nr, baud, config);

if(_uart == 0) {
return;
Expand Down
53 changes: 27 additions & 26 deletions hardware/esp8266com/esp8266/cores/esp8266/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Modified 3 December 2013 by Matthijs Kooijman
Modified 18 December 2014 by Ivan Grokhotkov (esp8266 platform support)
Modified 31 March 2015 by Markus Sattler (rewrite the code for UART0 + UART1 support in ESP8266)
Modified 25 April 2015 by Thomas Flayols (add configuration different from 8N1 in ESP8266)
*/

#ifndef HardwareSerial_h
Expand All @@ -33,31 +34,31 @@
#define SERIAL_TX_BUFFER_SIZE 256
#define SERIAL_RX_BUFFER_SIZE 256

// // Define config for Serial.begin(baud, config);
// #define SERIAL_5N1 0x00
// #define SERIAL_6N1 0x02
// #define SERIAL_7N1 0x04
// #define SERIAL_8N1 0x06
// #define SERIAL_5N2 0x08
// #define SERIAL_6N2 0x0A
// #define SERIAL_7N2 0x0C
// #define SERIAL_8N2 0x0E
// #define SERIAL_5E1 0x20
// #define SERIAL_6E1 0x22
// #define SERIAL_7E1 0x24
// #define SERIAL_8E1 0x26
// #define SERIAL_5E2 0x28
// #define SERIAL_6E2 0x2A
// #define SERIAL_7E2 0x2C
// #define SERIAL_8E2 0x2E
// #define SERIAL_5O1 0x30
// #define SERIAL_6O1 0x32
// #define SERIAL_7O1 0x34
// #define SERIAL_8O1 0x36
// #define SERIAL_5O2 0x38
// #define SERIAL_6O2 0x3A
// #define SERIAL_7O2 0x3C
// #define SERIAL_8O2 0x3E
// Define config for Serial.begin(baud, config);
#define SERIAL_5N1 0x10
#define SERIAL_6N1 0x14
#define SERIAL_7N1 0x18
#define SERIAL_8N1 0x1c
#define SERIAL_5N2 0x30
#define SERIAL_6N2 0x34
#define SERIAL_7N2 0x38
#define SERIAL_8N2 0x3c
#define SERIAL_5E1 0x12
#define SERIAL_6E1 0x16
#define SERIAL_7E1 0x1a
#define SERIAL_8E1 0x1e
#define SERIAL_5E2 0x32
#define SERIAL_6E2 0x36
#define SERIAL_7E2 0x3a
#define SERIAL_8E2 0x3e
#define SERIAL_5O1 0x13
#define SERIAL_6O1 0x17
#define SERIAL_7O1 0x1b
#define SERIAL_8O1 0x1f
#define SERIAL_5O2 0x33
#define SERIAL_6O2 0x37
#define SERIAL_7O2 0x3b
#define SERIAL_8O2 0x3f

class cbuf;

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

void begin(unsigned long baud) {
begin(baud, 0);
begin(baud, SERIAL_8N1);
}
void begin(unsigned long, uint8_t);
void end();
Expand Down
Loading

0 comments on commit 196992a

Please sign in to comment.