mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-06 05:21:22 +03:00
Merge branch 'Links2004-esp8266' into esp8266
This commit is contained in:
commit
b791c000af
7
.gitignore
vendored
7
.gitignore
vendored
@ -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
|
||||
|
@ -46,6 +46,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
|
||||
|
@ -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;
|
||||
|
||||
@ -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();
|
||||
@ -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();
|
||||
}
|
||||
|
@ -20,8 +20,28 @@
|
||||
|
||||
#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.
|
||||
WAKE_RFCAL = 1, // RF_CAL after deep-sleep wake up, there will be large current.
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -81,7 +81,12 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
|
||||
PIN_PULLUP_DIS(mux);
|
||||
} else if(mode == INPUT_PULLUP) {
|
||||
gpio_output_set(0, 0, 0, 1 << pin);
|
||||
PIN_PULLDWN_DIS(mux);
|
||||
PIN_PULLUP_EN(mux);
|
||||
} else if(mode == INPUT_PULLDOWN) {
|
||||
gpio_output_set(0, 0, 0, 1 << pin);
|
||||
PIN_PULLUP_DIS(mux);
|
||||
PIN_PULLDWN_EN(mux);
|
||||
} else if(mode == OUTPUT) {
|
||||
gpio_output_set(0, 0, 1 << pin, 0);
|
||||
} else if(mode == OUTPUT_OPEN_DRAIN) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ets_sys.h"
|
||||
#include "os_type.h"
|
||||
|
@ -1,14 +1,24 @@
|
||||
#ifndef __PGMSPACE_H_
|
||||
#define __PGMSPACE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "ets_sys.h"
|
||||
#include "osapi.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define PROGMEM
|
||||
#define PGM_P const char *
|
||||
#define PSTR(str) (str)
|
||||
|
||||
#define vsnprintf_P(...) vsnprintf( __VA_ARGS__ )
|
||||
#define vsnprintf_P(...) ets_vsnprintf( __VA_ARGS__ )
|
||||
#define snprintf_P(...) snprintf( __VA_ARGS__ )
|
||||
#define printf_P(...) os_printf(__VA_ARGS__)
|
||||
|
||||
#define _SFR_BYTE(n) (n)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user