mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Fix inconsistent CRLF/LF combinations (#6653)
These files had either CRLF, LFCR or LF or a mixture of it. Consistently format them as git text files (unix style) with trailing whitespace removed.
This commit is contained in:
parent
855b91ea69
commit
1e17dddd89
@ -1,168 +1,168 @@
|
|||||||
/*
|
/*
|
||||||
HardwareSerial.cpp - esp8266 UART support
|
HardwareSerial.cpp - esp8266 UART support
|
||||||
|
|
||||||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
||||||
This file is part of the esp8266 core for Arduino environment.
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
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,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
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 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)
|
Modified 25 April 2015 by Thomas Flayols (add configuration different from 8N1 in ESP8266)
|
||||||
Modified 3 May 2015 by Hristo Gochkov (change register access methods)
|
Modified 3 May 2015 by Hristo Gochkov (change register access methods)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <PolledTimeout.h>
|
#include <PolledTimeout.h>
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "HardwareSerial.h"
|
#include "HardwareSerial.h"
|
||||||
#include "Esp.h"
|
#include "Esp.h"
|
||||||
|
|
||||||
HardwareSerial::HardwareSerial(int uart_nr)
|
HardwareSerial::HardwareSerial(int uart_nr)
|
||||||
: _uart_nr(uart_nr), _rx_size(256)
|
: _uart_nr(uart_nr), _rx_size(256)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin)
|
void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin)
|
||||||
{
|
{
|
||||||
end();
|
end();
|
||||||
_uart = uart_init(_uart_nr, baud, (int) config, (int) mode, tx_pin, _rx_size);
|
_uart = uart_init(_uart_nr, baud, (int) config, (int) mode, tx_pin, _rx_size);
|
||||||
#if defined(DEBUG_ESP_PORT) && !defined(NDEBUG)
|
#if defined(DEBUG_ESP_PORT) && !defined(NDEBUG)
|
||||||
if (static_cast<void*>(this) == static_cast<void*>(&DEBUG_ESP_PORT))
|
if (static_cast<void*>(this) == static_cast<void*>(&DEBUG_ESP_PORT))
|
||||||
{
|
{
|
||||||
setDebugOutput(true);
|
setDebugOutput(true);
|
||||||
println();
|
println();
|
||||||
println(ESP.getFullVersion());
|
println(ESP.getFullVersion());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareSerial::end()
|
void HardwareSerial::end()
|
||||||
{
|
{
|
||||||
if(uart_get_debug() == _uart_nr) {
|
if(uart_get_debug() == _uart_nr) {
|
||||||
uart_set_debug(UART_NO);
|
uart_set_debug(UART_NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
uart_uninit(_uart);
|
uart_uninit(_uart);
|
||||||
_uart = NULL;
|
_uart = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareSerial::updateBaudRate(unsigned long baud)
|
void HardwareSerial::updateBaudRate(unsigned long baud)
|
||||||
{
|
{
|
||||||
if(!_uart) {
|
if(!_uart) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uart_set_baudrate(_uart, baud);
|
uart_set_baudrate(_uart, baud);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t HardwareSerial::setRxBufferSize(size_t size){
|
size_t HardwareSerial::setRxBufferSize(size_t size){
|
||||||
if(_uart) {
|
if(_uart) {
|
||||||
_rx_size = uart_resize_rx_buffer(_uart, size);
|
_rx_size = uart_resize_rx_buffer(_uart, size);
|
||||||
} else {
|
} else {
|
||||||
_rx_size = size;
|
_rx_size = size;
|
||||||
}
|
}
|
||||||
return _rx_size;
|
return _rx_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareSerial::setDebugOutput(bool en)
|
void HardwareSerial::setDebugOutput(bool en)
|
||||||
{
|
{
|
||||||
if(!_uart) {
|
if(!_uart) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(en) {
|
if(en) {
|
||||||
if(uart_tx_enabled(_uart)) {
|
if(uart_tx_enabled(_uart)) {
|
||||||
uart_set_debug(_uart_nr);
|
uart_set_debug(_uart_nr);
|
||||||
} else {
|
} else {
|
||||||
uart_set_debug(UART_NO);
|
uart_set_debug(UART_NO);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// disable debug for this interface
|
// disable debug for this interface
|
||||||
if(uart_get_debug() == _uart_nr) {
|
if(uart_get_debug() == _uart_nr) {
|
||||||
uart_set_debug(UART_NO);
|
uart_set_debug(UART_NO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int HardwareSerial::available(void)
|
int HardwareSerial::available(void)
|
||||||
{
|
{
|
||||||
int result = static_cast<int>(uart_rx_available(_uart));
|
int result = static_cast<int>(uart_rx_available(_uart));
|
||||||
if (!result) {
|
if (!result) {
|
||||||
optimistic_yield(10000);
|
optimistic_yield(10000);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareSerial::flush()
|
void HardwareSerial::flush()
|
||||||
{
|
{
|
||||||
uint8_t bit_length = 0;
|
uint8_t bit_length = 0;
|
||||||
if(!_uart || !uart_tx_enabled(_uart)) {
|
if(!_uart || !uart_tx_enabled(_uart)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bit_length = uart_get_bit_length(_uart_nr); // data width, parity and stop
|
bit_length = uart_get_bit_length(_uart_nr); // data width, parity and stop
|
||||||
uart_wait_tx_empty(_uart);
|
uart_wait_tx_empty(_uart);
|
||||||
//Workaround for a bug in serial not actually being finished yet
|
//Workaround for a bug in serial not actually being finished yet
|
||||||
//Wait for 8 data bits, 1 parity and 2 stop bits, just in case
|
//Wait for 8 data bits, 1 parity and 2 stop bits, just in case
|
||||||
delayMicroseconds(bit_length * 1000000 / uart_get_baudrate(_uart) + 1);
|
delayMicroseconds(bit_length * 1000000 / uart_get_baudrate(_uart) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareSerial::startDetectBaudrate()
|
void HardwareSerial::startDetectBaudrate()
|
||||||
{
|
{
|
||||||
uart_start_detect_baudrate(_uart_nr);
|
uart_start_detect_baudrate(_uart_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long HardwareSerial::testBaudrate()
|
unsigned long HardwareSerial::testBaudrate()
|
||||||
{
|
{
|
||||||
return uart_detect_baudrate(_uart_nr);
|
return uart_detect_baudrate(_uart_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
|
unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
|
||||||
{
|
{
|
||||||
esp8266::polledTimeout::oneShotFastMs timeOut(timeoutMillis);
|
esp8266::polledTimeout::oneShotFastMs timeOut(timeoutMillis);
|
||||||
unsigned long detectedBaudrate;
|
unsigned long detectedBaudrate;
|
||||||
while (!timeOut) {
|
while (!timeOut) {
|
||||||
if ((detectedBaudrate = testBaudrate())) {
|
if ((detectedBaudrate = testBaudrate())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
yield();
|
yield();
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
return detectedBaudrate;
|
return detectedBaudrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t HardwareSerial::readBytes(char* buffer, size_t size)
|
size_t HardwareSerial::readBytes(char* buffer, size_t size)
|
||||||
{
|
{
|
||||||
size_t got = 0;
|
size_t got = 0;
|
||||||
|
|
||||||
while (got < size)
|
while (got < size)
|
||||||
{
|
{
|
||||||
esp8266::polledTimeout::oneShotFastMs timeOut(_timeout);
|
esp8266::polledTimeout::oneShotFastMs timeOut(_timeout);
|
||||||
size_t avail;
|
size_t avail;
|
||||||
while ((avail = available()) == 0 && !timeOut);
|
while ((avail = available()) == 0 && !timeOut);
|
||||||
if (avail == 0)
|
if (avail == 0)
|
||||||
break;
|
break;
|
||||||
got += read(buffer + got, std::min(size - got, avail));
|
got += read(buffer + got, std::min(size - got, avail));
|
||||||
}
|
}
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
|
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
|
||||||
HardwareSerial Serial(UART0);
|
HardwareSerial Serial(UART0);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL1)
|
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL1)
|
||||||
HardwareSerial Serial1(UART1);
|
HardwareSerial Serial1(UART1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
/**
|
/**
|
||||||
StreamString.h
|
StreamString.h
|
||||||
|
|
||||||
Copyright (c) 2015 Markus Sattler. All rights reserved.
|
Copyright (c) 2015 Markus Sattler. All rights reserved.
|
||||||
This file is part of the esp8266 core for Arduino environment.
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
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,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef STREAMSTRING_H_
|
#ifndef STREAMSTRING_H_
|
||||||
#define STREAMSTRING_H_
|
#define STREAMSTRING_H_
|
||||||
|
|
||||||
|
|
||||||
class StreamString: public Stream, public String {
|
class StreamString: public Stream, public String {
|
||||||
public:
|
public:
|
||||||
size_t write(const uint8_t *buffer, size_t size) override;
|
size_t write(const uint8_t *buffer, size_t size) override;
|
||||||
size_t write(uint8_t data) override;
|
size_t write(uint8_t data) override;
|
||||||
|
|
||||||
int available() override;
|
int available() override;
|
||||||
int read() override;
|
int read() override;
|
||||||
int peek() override;
|
int peek() override;
|
||||||
void flush() override;
|
void flush() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* STREAMSTRING_H_ */
|
#endif /* STREAMSTRING_H_ */
|
||||||
|
@ -1,71 +1,71 @@
|
|||||||
/**
|
/**
|
||||||
* base64.cpp
|
* base64.cpp
|
||||||
*
|
*
|
||||||
* Created on: 09.12.2015
|
* Created on: 09.12.2015
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Markus Sattler. All rights reserved.
|
* Copyright (c) 2015 Markus Sattler. All rights reserved.
|
||||||
* This file is part of the ESP8266 core for Arduino.
|
* This file is part of the ESP8266 core for Arduino.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "libb64/cdecode.h"
|
#include "libb64/cdecode.h"
|
||||||
#include "libb64/cencode.h"
|
#include "libb64/cencode.h"
|
||||||
}
|
}
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert input data to base64
|
* convert input data to base64
|
||||||
* @param data const uint8_t *
|
* @param data const uint8_t *
|
||||||
* @param length size_t
|
* @param length size_t
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
String base64::encode(const uint8_t * data, size_t length, bool doNewLines) {
|
String base64::encode(const uint8_t * data, size_t length, bool doNewLines) {
|
||||||
// base64 needs more size then the source data, use cencode.h macros
|
// base64 needs more size then the source data, use cencode.h macros
|
||||||
size_t size = ((doNewLines ? base64_encode_expected_len(length)
|
size_t size = ((doNewLines ? base64_encode_expected_len(length)
|
||||||
: base64_encode_expected_len_nonewlines(length)) + 1);
|
: base64_encode_expected_len_nonewlines(length)) + 1);
|
||||||
char * buffer = (char *) malloc(size);
|
char * buffer = (char *) malloc(size);
|
||||||
if(buffer) {
|
if(buffer) {
|
||||||
base64_encodestate _state;
|
base64_encodestate _state;
|
||||||
if(doNewLines)
|
if(doNewLines)
|
||||||
{
|
{
|
||||||
base64_init_encodestate(&_state);
|
base64_init_encodestate(&_state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
base64_init_encodestate_nonewlines(&_state);
|
base64_init_encodestate_nonewlines(&_state);
|
||||||
}
|
}
|
||||||
int len = base64_encode_block((const char *) &data[0], length, &buffer[0], &_state);
|
int len = base64_encode_block((const char *) &data[0], length, &buffer[0], &_state);
|
||||||
len = base64_encode_blockend((buffer + len), &_state);
|
len = base64_encode_blockend((buffer + len), &_state);
|
||||||
|
|
||||||
String base64 = String(buffer);
|
String base64 = String(buffer);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return base64;
|
return base64;
|
||||||
}
|
}
|
||||||
return String("-FAIL-");
|
return String("-FAIL-");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert input data to base64
|
* convert input data to base64
|
||||||
* @param text const String&
|
* @param text const String&
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
String base64::encode(const String& text, bool doNewLines) {
|
String base64::encode(const String& text, bool doNewLines) {
|
||||||
return base64::encode((const uint8_t *) text.c_str(), text.length(), doNewLines);
|
return base64::encode((const uint8_t *) text.c_str(), text.length(), doNewLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
/**
|
/**
|
||||||
* base64.h
|
* base64.h
|
||||||
*
|
*
|
||||||
* Created on: 09.12.2015
|
* Created on: 09.12.2015
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Markus Sattler. All rights reserved.
|
* Copyright (c) 2015 Markus Sattler. All rights reserved.
|
||||||
* This file is part of the ESP8266 core for Arduino.
|
* This file is part of the ESP8266 core for Arduino.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CORE_BASE64_H_
|
#ifndef CORE_BASE64_H_
|
||||||
#define CORE_BASE64_H_
|
#define CORE_BASE64_H_
|
||||||
|
|
||||||
class base64 {
|
class base64 {
|
||||||
public:
|
public:
|
||||||
// NOTE: The default behaviour of backend (lib64)
|
// NOTE: The default behaviour of backend (lib64)
|
||||||
// is to add a newline every 72 (encoded) characters output.
|
// is to add a newline every 72 (encoded) characters output.
|
||||||
// This may 'break' longer uris and json variables
|
// This may 'break' longer uris and json variables
|
||||||
static String encode(const uint8_t * data, size_t length, bool doNewLines = true);
|
static String encode(const uint8_t * data, size_t length, bool doNewLines = true);
|
||||||
static String encode(const String& text, bool doNewLines = true);
|
static String encode(const String& text, bool doNewLines = true);
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* CORE_BASE64_H_ */
|
#endif /* CORE_BASE64_H_ */
|
||||||
|
@ -1,50 +1,50 @@
|
|||||||
/*
|
/*
|
||||||
core_esp8266_features.h - list of features integrated in to ESP8266 core
|
core_esp8266_features.h - list of features integrated in to ESP8266 core
|
||||||
|
|
||||||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
||||||
This file is part of the esp8266 core for Arduino environment.
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
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,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef CORE_ESP8266_FEATURES_H
|
#ifndef CORE_ESP8266_FEATURES_H
|
||||||
#define CORE_ESP8266_FEATURES_H
|
#define CORE_ESP8266_FEATURES_H
|
||||||
|
|
||||||
|
|
||||||
#define CORE_HAS_LIBB64
|
#define CORE_HAS_LIBB64
|
||||||
#define CORE_HAS_BASE64_CLASS
|
#define CORE_HAS_BASE64_CLASS
|
||||||
#define CORE_HAS_CXA_GUARD
|
#define CORE_HAS_CXA_GUARD
|
||||||
#define CORE_HAS_UMM
|
#define CORE_HAS_UMM
|
||||||
|
|
||||||
#define WIFI_HAS_EVENT_CALLBACK
|
#define WIFI_HAS_EVENT_CALLBACK
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include <stdlib.h> // malloc()
|
#include <stdlib.h> // malloc()
|
||||||
#include <stddef.h> // size_t
|
#include <stddef.h> // size_t
|
||||||
|
|
||||||
namespace arduino
|
namespace arduino
|
||||||
{
|
{
|
||||||
extern "C++"
|
extern "C++"
|
||||||
template <typename T, typename ...TConstructorArgs>
|
template <typename T, typename ...TConstructorArgs>
|
||||||
T* new0 (size_t n, TConstructorArgs... TconstructorArgs)
|
T* new0 (size_t n, TConstructorArgs... TconstructorArgs)
|
||||||
{
|
{
|
||||||
// n==0: single allocation, otherwise it is an array
|
// n==0: single allocation, otherwise it is an array
|
||||||
size_t offset = n? sizeof(size_t): 0;
|
size_t offset = n? sizeof(size_t): 0;
|
||||||
size_t arraysize = n? n: 1;
|
size_t arraysize = n? n: 1;
|
||||||
T* ptr = (T*)malloc(offset + (arraysize * sizeof(T)));
|
T* ptr = (T*)malloc(offset + (arraysize * sizeof(T)));
|
||||||
if (ptr)
|
if (ptr)
|
||||||
@ -54,43 +54,43 @@ namespace arduino
|
|||||||
for (size_t i = 0; i < arraysize; i++)
|
for (size_t i = 0; i < arraysize; i++)
|
||||||
new (ptr + offset + i * sizeof(T)) T(TconstructorArgs...);
|
new (ptr + offset + i * sizeof(T)) T(TconstructorArgs...);
|
||||||
return ptr + offset;
|
return ptr + offset;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define arduino_new(Type, ...) arduino::new0<Type>(0, ##__VA_ARGS__)
|
#define arduino_new(Type, ...) arduino::new0<Type>(0, ##__VA_ARGS__)
|
||||||
#define arduino_newarray(Type, n, ...) arduino::new0<Type>(n, ##__VA_ARGS__)
|
#define arduino_newarray(Type, n, ...) arduino::new0<Type>(n, ##__VA_ARGS__)
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
#ifndef __STRINGIFY
|
#ifndef __STRINGIFY
|
||||||
#define __STRINGIFY(a) #a
|
#define __STRINGIFY(a) #a
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// these low level routines provide a replacement for SREG interrupt save that AVR uses
|
// these low level routines provide a replacement for SREG interrupt save that AVR uses
|
||||||
// but are esp8266 specific. A normal use pattern is like
|
// but are esp8266 specific. A normal use pattern is like
|
||||||
//
|
//
|
||||||
//{
|
//{
|
||||||
// uint32_t savedPS = xt_rsil(1); // this routine will allow level 2 and above
|
// uint32_t savedPS = xt_rsil(1); // this routine will allow level 2 and above
|
||||||
// // do work here
|
// // do work here
|
||||||
// xt_wsr_ps(savedPS); // restore the state
|
// xt_wsr_ps(savedPS); // restore the state
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
// level (0-15), interrupts of the given level and above will be active
|
// level (0-15), interrupts of the given level and above will be active
|
||||||
// level 15 will disable ALL interrupts,
|
// level 15 will disable ALL interrupts,
|
||||||
// level 0 will enable ALL interrupts,
|
// level 0 will enable ALL interrupts,
|
||||||
//
|
//
|
||||||
#ifndef CORE_MOCK
|
#ifndef CORE_MOCK
|
||||||
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
|
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
|
||||||
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
|
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
|
||||||
|
|
||||||
inline uint32_t esp_get_cycle_count() __attribute__((always_inline));
|
inline uint32_t esp_get_cycle_count() __attribute__((always_inline));
|
||||||
inline uint32_t esp_get_cycle_count() {
|
inline uint32_t esp_get_cycle_count() {
|
||||||
uint32_t ccount;
|
uint32_t ccount;
|
||||||
__asm__ __volatile__("rsr %0,ccount":"=a"(ccount));
|
__asm__ __volatile__("rsr %0,ccount":"=a"(ccount));
|
||||||
return ccount;
|
return ccount;
|
||||||
}
|
}
|
||||||
#endif // not CORE_MOCK
|
#endif // not CORE_MOCK
|
||||||
|
|
||||||
#endif // CORE_ESP8266_FEATURES_H
|
#endif // CORE_ESP8266_FEATURES_H
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
/*
|
/*
|
||||||
debug.cpp - debug helper functions
|
debug.cpp - debug helper functions
|
||||||
Copyright (c) 2015 Markus Sattler. All rights reserved.
|
Copyright (c) 2015 Markus Sattler. All rights reserved.
|
||||||
This file is part of the esp8266 core for Arduino environment.
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
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,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
void ICACHE_RAM_ATTR hexdump(const void *mem, uint32_t len, uint8_t cols) {
|
void ICACHE_RAM_ATTR hexdump(const void *mem, uint32_t len, uint8_t cols) {
|
||||||
const uint8_t* src = (const uint8_t*) mem;
|
const uint8_t* src = (const uint8_t*) mem;
|
||||||
os_printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);
|
os_printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);
|
||||||
for(uint32_t i = 0; i < len; i++) {
|
for(uint32_t i = 0; i < len; i++) {
|
||||||
if(i % cols == 0) {
|
if(i % cols == 0) {
|
||||||
os_printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
|
os_printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
os_printf("%02X ", *src);
|
os_printf("%02X ", *src);
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
os_printf("\n");
|
os_printf("\n");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user