mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Merge remote-tracking branch 'remotes/esp8266/esp8266' into esp8266
This commit is contained in:
@ -702,12 +702,12 @@ void ICACHE_FLASH_ATTR String::trim(void)
|
||||
|
||||
long ICACHE_FLASH_ATTR String::toInt(void) const
|
||||
{
|
||||
if (buffer) return atol_internal(buffer);
|
||||
if (buffer) return atol(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
float ICACHE_FLASH_ATTR String::toFloat(void) const
|
||||
{
|
||||
if (buffer) return float(atof_internal(buffer));
|
||||
if (buffer) return atof(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define sprintf ets_sprintf
|
||||
#define strcpy ets_strcpy
|
||||
|
||||
long atol_internal(const char* s)
|
||||
long atol(const char* s)
|
||||
{
|
||||
int result = 0;
|
||||
int i;
|
||||
@ -44,10 +44,52 @@ long atol_internal(const char* s)
|
||||
return sign * result;
|
||||
}
|
||||
|
||||
float atof_internal(const char* s)
|
||||
// Source:
|
||||
// https://github.com/anakod/Sming/blob/master/Sming/system/stringconversion.cpp#L93
|
||||
double atof(const char* s)
|
||||
{
|
||||
float result = 0;
|
||||
return result;
|
||||
double result = 0;
|
||||
double sign = 1;
|
||||
|
||||
while (*s == ' ' || *s == '\t' || *s == '\r' || *s == '\n')
|
||||
++s;
|
||||
|
||||
if (*s == 0)
|
||||
return 0;
|
||||
|
||||
if (*s == '-')
|
||||
{
|
||||
sign = -1;
|
||||
++s;
|
||||
}
|
||||
if (*s == '+')
|
||||
{
|
||||
++s;
|
||||
}
|
||||
|
||||
bool decimals = false;
|
||||
double factor = 1.0;
|
||||
char c;
|
||||
while((c = *s))
|
||||
{
|
||||
if (c == '.')
|
||||
{
|
||||
decimals = true;
|
||||
++s;
|
||||
continue;
|
||||
}
|
||||
|
||||
int d = c - '0';
|
||||
if (d < 0 || d > 9)
|
||||
break;
|
||||
|
||||
result = 10.0 * result + d;
|
||||
if (decimals)
|
||||
factor *= 0.1;
|
||||
++s;
|
||||
}
|
||||
|
||||
return result * factor;
|
||||
}
|
||||
|
||||
|
||||
|
101
hardware/esp8266com/esp8266/cores/esp8266/libc_replacements.c
Normal file
101
hardware/esp8266com/esp8266/cores/esp8266/libc_replacements.c
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
libc_replacements.c - replaces libc functions with functions
|
||||
from Espressif SDK
|
||||
|
||||
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
|
||||
This file is part of the esp8266 core for Arduino environment.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "ets_sys.h"
|
||||
#include "os_type.h"
|
||||
#include "osapi.h"
|
||||
#include "mem.h"
|
||||
#include "user_interface.h"
|
||||
|
||||
|
||||
void* malloc(size_t size) {
|
||||
return os_malloc(size);
|
||||
}
|
||||
|
||||
void free(void* ptr) {
|
||||
os_free(ptr);
|
||||
}
|
||||
|
||||
void* realloc(void* ptr, size_t size) {
|
||||
return os_realloc(ptr, size);
|
||||
}
|
||||
|
||||
int printf(const char* format, ...) {
|
||||
va_list arglist;
|
||||
va_start(arglist, format);
|
||||
ets_vprintf(format, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
int sprintf(char* buffer, const char* format, ...) {
|
||||
va_list arglist;
|
||||
va_start(arglist, format);
|
||||
ets_vsprintf(buffer, format, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
int snprintf(char* buffer, size_t size, const char* format, ...) {
|
||||
va_list arglist;
|
||||
va_start(arglist, format);
|
||||
ets_vsnprintf(buffer, size, format, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t n) {
|
||||
return ets_memcmp(s1, s2, n);
|
||||
}
|
||||
|
||||
void* memcpy(void *dest, const void *src, size_t n) {
|
||||
return ets_memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
void* memset(void *s, int c, size_t n) {
|
||||
return ets_memset(s, c, n);
|
||||
}
|
||||
|
||||
int strcmp(const char *s1, const char *s2) {
|
||||
return ets_strcmp(s1, s2);
|
||||
}
|
||||
|
||||
char* strcpy(char *dest, const char *src) {
|
||||
return ets_strcpy(dest, src);
|
||||
}
|
||||
|
||||
size_t strlen(const char *s) {
|
||||
return ets_strlen(s);
|
||||
}
|
||||
|
||||
int strncmp(const char *s1, const char *s2, size_t len) {
|
||||
return ets_strncmp(s1, s2, len);
|
||||
}
|
||||
|
||||
char *strncpy(char *dest, const char *src, size_t n) {
|
||||
return ets_strncpy(dest, src, n);
|
||||
}
|
||||
|
||||
char *ets_strstr(const char *haystack, const char *needle) {
|
||||
return strstr(haystack, needle);
|
||||
}
|
||||
|
@ -11,13 +11,6 @@ void HSPI::begin()
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_HSPIQ_MISO); // gpio12
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_HSPID_MOSI); // gpio13
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_HSPI_CLK); // gpio14
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_HSPI_CS0); // gpio15
|
||||
|
||||
uint32_t regvalue = SPI_FLASH_DOUT;
|
||||
regvalue |= SPI_DOUTDIN | SPI_CK_I_EDGE;
|
||||
regvalue &= ~(BIT2 | SPI_FLASH_USR_ADDR | SPI_FLASH_USR_DUMMY | SPI_FLASH_USR_DIN | SPI_USR_COMMAND);
|
||||
|
||||
SET_PERI_REG_MASK(SPI_FLASH_USER(hspi_port), regvalue);
|
||||
|
||||
// SPI clock=CPU clock/8
|
||||
WRITE_PERI_REG(SPI_FLASH_CLOCK(hspi_port),
|
||||
@ -26,6 +19,12 @@ void HSPI::begin()
|
||||
((1&SPI_CLKCNT_H)<<SPI_CLKCNT_H_S)|
|
||||
((3&SPI_CLKCNT_L)<<SPI_CLKCNT_L_S)); //clear bit 31,set SPI clock div
|
||||
|
||||
uint32_t regvalue = SPI_FLASH_DOUT;
|
||||
regvalue |= SPI_DOUTDIN | SPI_CK_I_EDGE;
|
||||
regvalue &= ~(BIT2 | SPI_FLASH_USR_ADDR | SPI_FLASH_USR_DUMMY | SPI_FLASH_USR_DIN | SPI_USR_COMMAND);
|
||||
|
||||
WRITE_PERI_REG(SPI_FLASH_USER(hspi_port), regvalue);
|
||||
WRITE_PERI_REG(SPI_FLASH_CTRL1(hspi_port), 0);
|
||||
}
|
||||
|
||||
void HSPI::end()
|
||||
|
@ -27,7 +27,7 @@ private:
|
||||
uint32_t _clkDiv;
|
||||
uint32_t *spi_fifo;
|
||||
const uint32_t hspi_port = 1;
|
||||
const uint32_t hspi_fifo_size = 32;
|
||||
const uint32_t hspi_fifo_size = 16;
|
||||
|
||||
private:
|
||||
inline void hspi_wait_ready(void){while (READ_PERI_REG(SPI_FLASH_CMD(hspi_port))&SPI_FLASH_USR);}
|
||||
|
@ -26,7 +26,11 @@
|
||||
|
||||
void TFT::TFTinit (void)
|
||||
{
|
||||
pinMode(2, OUTPUT);
|
||||
pinMode(4, OUTPUT);
|
||||
pinMode(15, OUTPUT);
|
||||
SPI.begin();
|
||||
SPI.setClockDivider(2);
|
||||
|
||||
TFT_CS_HIGH;
|
||||
TFT_DC_HIGH;
|
||||
|
@ -81,12 +81,12 @@ Modified by Sermus for ESP8266
|
||||
#define XP 21 // can be a digital pin, this is A3
|
||||
|
||||
#else
|
||||
#define TFT_CS_LOW //ESP8266 hspi has hardware controlled CS
|
||||
#define TFT_CS_HIGH
|
||||
#define TFT_DC_LOW pinMode(2, 0);
|
||||
#define TFT_DC_HIGH pinMode(2, 1);
|
||||
#define TFT_BL_OFF pinMode(0, 0);
|
||||
#define TFT_BL_ON pinMode(0, 1);
|
||||
#define TFT_CS_LOW digitalWrite(15, 0);
|
||||
#define TFT_CS_HIGH digitalWrite(15, 1);
|
||||
#define TFT_DC_LOW digitalWrite(2, 0);
|
||||
#define TFT_DC_HIGH digitalWrite(2, 1);
|
||||
#define TFT_BL_OFF digitalWrite(4, 0);
|
||||
#define TFT_BL_ON digitalWrite(4, 1);
|
||||
|
||||
#define YP A2 // must be an analog pin, use "An" notation!
|
||||
#define XM A1 // must be an analog pin, use "An" notation!
|
||||
|
@ -23,7 +23,7 @@ compiler.S.flags=-c -g -x assembler-with-cpp -MMD
|
||||
compiler.c.elf.ldscript=eagle.app.v6.ld
|
||||
compiler.c.elf.flags=-nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{compiler.c.elf.ldscript}"
|
||||
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
|
||||
compiler.c.elf.libs=-lc -lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp
|
||||
compiler.c.elf.libs=-lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp
|
||||
|
||||
compiler.cpp.cmd=xtensa-lx106-elf-g++
|
||||
compiler.cpp.flags=-c -Os -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -std=c++11 -MMD
|
||||
@ -66,7 +66,7 @@ recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.fla
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{build.path}/{archive_file}" {compiler.c.elf.libs} -Wl,--end-group "-L{build.path}"
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{build.path}/{archive_file}" {compiler.c.elf.libs} -Wl,--end-group -lc "-L{build.path}"
|
||||
|
||||
## Create eeprom
|
||||
recipe.objcopy.eep.pattern=
|
||||
|
Reference in New Issue
Block a user