Compare commits

...
37 Commits
Author SHA1 Message Date
Khoi Hoang c07a5e4761 v1.7.1 for multi-address requests
### Releases v1.7.1

1. Add example [AsyncHTTPRequest_ESP_Multi](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/tree/master/examples/AsyncHTTPRequest_ESP_Multi) to demo connection to multiple addresses.
2. Update `Packages' Patches`
2022-02-25 20:48:38 -05:00
Khoi Hoang ffde7a20a0 v1.7.1 for multi-address requests
### Releases v1.7.1

1. Add example [AsyncHTTPRequest_ESP_Multi](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/tree/master/examples/AsyncHTTPRequest_ESP_Multi) to demo connection to multiple addresses.
2. Update `Packages' Patches`
2022-02-25 20:45:58 -05:00
Khoi Hoang 27de84dca8 Update Packages' Patches 2022-02-25 20:45:01 -05:00
Khoi Hoang f1c37f9cf6 Update Packages' Patches 2022-02-25 20:43:56 -05:00
Khoi Hoang 97bf2091a9 Update Packages' Patches 2022-02-25 20:43:07 -05:00
Khoi Hoang 98733a6c4a v1.7.1 for multi-address requests 2022-02-25 20:30:57 -05:00
Khoi Hoang eed2745dfb Fix bug 2022-02-12 14:18:20 -05:00
Khoi Hoang c9ad8ecce1 Fix typo 2022-02-12 00:21:32 -05:00
Khoi Hoang d009fb9baf v1.7.0 to add support to ESP32-S3
### Releases v1.7.0

1. Add support to new `ESP32-S3` 
2. Add `LittleFS` support to `ESP32-C3`
3. Use ESP32-core's LittleFS library instead of Lorol's LITTLEFS library for v2.0.0+
2022-02-11 23:41:55 -05:00
Khoi Hoang f95cc9ee90 v1.7.0 to add support to ESP32-S3
### Releases v1.7.0

1. Add support to new `ESP32-S3` 
2. Add `LittleFS` support to `ESP32-C3`
3. Use ESP32-core's LittleFS library instead of Lorol's LITTLEFS library for v2.0.0+
2022-02-11 23:39:39 -05:00
Khoi Hoang 8a211da406 Add buymeacoffee
Finally, in need of some real coffee ;=))
2022-02-03 17:12:03 -05:00
Khoi Hoang 54f8e860c5 v1.6.0 to reduce v1.5.0 breaking effect
### Releases v1.6.0

1. Reduce the breaking effect of v1.5.0 by enabling compatibility with old code to include only `AsyncHTTPRequest_Generic.h`
2. Update `Packages' Patches`
2022-01-23 19:20:49 -05:00
Khoi Hoang 9267f40827 v1.6.0 to reduce v1.5.0 breaking effect
### Releases v1.6.0

1. Reduce the breaking effect of v1.5.0 by enabling compatibility with old code to include only `AsyncHTTPRequest_Generic.h`
2. Update `Packages' Patches`
2022-01-23 19:16:33 -05:00
Khoi Hoang c1a360018b Update Packages_Patches 2022-01-23 19:15:05 -05:00
Khoi Hoang 8baec56484 Update Packages_Patches 2022-01-23 19:13:57 -05:00
Khoi Hoang 6fe53327c2 Update Packages_Patches 2022-01-23 19:13:20 -05:00
Khoi Hoang eda76fdcf5 Update README.md
Update README.md to add warning about `Breaking Change` in v1.5.0
2022-01-09 18:46:57 -05:00
Khoi Hoang 5bff077888 v1.5.0 to fix multiple-definitions linker error
### Releases v1.5.0

1. Fix `multiple-definitions` linker error and weird bug related to `src_cpp`. Check [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80)
2. Optimize library code by using `reference-passing` instead of `value-passing`
3. Update all examples
2021-12-30 16:53:18 -05:00
Khoi Hoang de52b1ae4a v1.5.0 to fix multiple-definitions linker error
### Releases v1.5.0

1. Fix `multiple-definitions` linker error and weird bug related to `src_cpp`. Check [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80)
2. Optimize library code by using `reference-passing` instead of `value-passing`
3. Update all examples
2021-12-30 16:44:36 -05:00
Khoi Hoang 273ce6163a Delete xbuf_Impl.h 2021-12-30 16:41:01 -05:00
Khoi Hoang 9636d8a920 Delete xbuf.h 2021-12-30 16:40:56 -05:00
Khoi Hoang 9bf7a201c9 v1.5.0 to fix multiple-definitions linker error
### Releases v1.5.0

1. Fix `multiple-definitions` linker error and weird bug related to `src_cpp`. Check [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80)
2. Optimize library code by using `reference-passing` instead of `value-passing`
3. Update all examples
2021-12-30 16:40:14 -05:00
Khoi Hoang 13ce8e73b7 Delete xbuf_Impl.h 2021-12-30 16:38:15 -05:00
Khoi Hoang b82383c2f7 Delete xbuf.h 2021-12-30 16:38:11 -05:00
Khoi Hoang 8ae43fc2db Delete AsyncHTTPRequest_Impl_Generic.h 2021-12-30 16:38:05 -05:00
Khoi Hoang 995edc2533 Delete AsyncHTTPRequest_Generic.h 2021-12-30 16:37:59 -05:00
Khoi Hoang cb144e93c0 Delete AsyncHTTPRequest_Debug_Generic.h 2021-12-30 16:37:55 -05:00
Khoi Hoang a03b1fe869 Delete xbuf.h 2021-12-30 16:37:48 -05:00
Khoi Hoang ad1d27cd2b Delete xbuf.cpp 2021-12-30 16:37:44 -05:00
Khoi Hoang 7740dc4d11 Delete AsyncHTTPRequest_Generic.h 2021-12-30 16:37:38 -05:00
Khoi Hoang 7763f8320e Delete AsyncHTTPRequest_Generic.cpp 2021-12-30 16:37:33 -05:00
Khoi Hoang 6c74904ac9 Delete AsyncHTTPRequest_Debug_Generic.h 2021-12-30 16:37:29 -05:00
Khoi Hoang 996699bd02 Update Packages_Patches 2021-12-20 22:53:58 -05:00
Khoi Hoang 6558ba7ef5 Update Packages_Patches 2021-12-20 22:53:01 -05:00
Khoi Hoang 276f1c7e9b Update Packages_Patches 2021-12-20 22:52:06 -05:00
Khoi Hoang 922ea7f283 Update Packages_Patches 2021-12-20 22:51:29 -05:00
Khoi Hoang 332497041a Update Packages_Patches 2021-12-20 21:49:30 -05:00
104 changed files with 13519 additions and 6259 deletions
+6 -5
View File
@@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
Please ensure to specify the following:
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.1 or STM32 v2.1.0)
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.2 or STM32 v2.2.0)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
* Anything that might be relevant in your opinion, such as:
@@ -26,10 +26,10 @@ Please ensure to specify the following:
### Example
```
Arduino IDE version: 1.8.16
ESP32 Core Version 2.0.1
Arduino IDE version: 1.8.19
ESP32 Core Version 2.0.2
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered an endless loop while trying to connect to Local WiFi.
@@ -50,3 +50,4 @@ There are usually some outstanding feature requests in the [existing issues list
### Sending Pull Requests
Pull Requests with changes and fixes are also welcome!
@@ -0,0 +1,129 @@
/*
Stream.h - base class for character-based streams.
Copyright (c) 2010 David A. Mellis. All right reserved.
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
parsing functions based on TextFinder library by Michael Margolis
*/
#ifndef Stream_h
#define Stream_h
#include <inttypes.h>
#include "Print.h"
// compatability macros for testing
/*
#define getInt() parseInt()
#define getInt(ignore) parseInt(ignore)
#define getFloat() parseFloat()
#define getFloat(ignore) parseFloat(ignore)
#define getString( pre_string, post_string, buffer, length)
readBytesBetween( pre_string, terminator, buffer, length)
*/
// This enumeration provides the lookahead options for parseInt(), parseFloat()
// The rules set out here are used until either the first valid character is found
// or a time out occurs due to lack of input.
enum LookaheadMode{
SKIP_ALL, // All invalid characters are ignored.
SKIP_NONE, // Nothing is skipped, and the stream is not touched unless the first waiting character is valid.
SKIP_WHITESPACE // Only tabs, spaces, line feeds & carriage returns are skipped.
};
#define NO_IGNORE_CHAR '\x01' // a char not found in a valid ASCII numeric field
class Stream : public Print
{
protected:
unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
unsigned long _startMillis = 0; // used for timeout measurement
int timedRead(); // read stream with timeout
int timedPeek(); // peek stream with timeout
int peekNextDigit(LookaheadMode lookahead, bool detectDecimal); // returns the next numeric digit in the stream or -1 if timeout
public:
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
Stream() {_timeout=1000;}
// parsing methods
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
unsigned long getTimeout(void) { return _timeout; }
bool find(char *target); // reads data from the stream until the target string is found
bool find(uint8_t *target) { return find ((char *)target); }
// returns true if target string is found, false if timed out (see setTimeout)
bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found
bool find(uint8_t *target, size_t length) { return find ((char *)target, length); }
// returns true if target string is found, false if timed out
bool find(char target) { return find (&target, 1); }
bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found
bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); }
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found
bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); }
long parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR);
// returns the first valid (long) integer value from the current position.
// lookahead determines how parseInt looks ahead in the stream.
// See LookaheadMode enumeration at the top of the file.
// Lookahead is terminated by the first character that is not a valid part of an integer.
// Once parsing commences, 'ignore' will be skipped in the stream.
float parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR);
// float version of parseInt
size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
// terminates if length characters have been read or timeout (see setTimeout)
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character
size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
// Arduino String functions to be added here
String readString();
String readStringUntil(char terminator);
protected:
long parseInt(char ignore) { return parseInt(SKIP_ALL, ignore); }
float parseFloat(char ignore) { return parseFloat(SKIP_ALL, ignore); }
// These overload exists for compatibility with any class that has derived
// Stream and used parseFloat/Int with a custom ignore character. To keep
// the public API simple, these overload remains protected.
struct MultiTarget {
const char *str; // string you're searching for
size_t len; // length of string you're searching for
size_t index; // index used by the search routine.
};
// This allows you to search for an arbitrary number of strings.
// Returns index of the target that is found first or -1 if timeout occurs.
int findMulti(struct MultiTarget *targets, int tCount);
};
#undef NO_IGNORE_CHAR
#endif
@@ -0,0 +1,129 @@
/*
Stream.h - base class for character-based streams.
Copyright (c) 2010 David A. Mellis. All right reserved.
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
parsing functions based on TextFinder library by Michael Margolis
*/
#ifndef Stream_h
#define Stream_h
#include <inttypes.h>
#include "Print.h"
// compatability macros for testing
/*
#define getInt() parseInt()
#define getInt(ignore) parseInt(ignore)
#define getFloat() parseFloat()
#define getFloat(ignore) parseFloat(ignore)
#define getString( pre_string, post_string, buffer, length)
readBytesBetween( pre_string, terminator, buffer, length)
*/
// This enumeration provides the lookahead options for parseInt(), parseFloat()
// The rules set out here are used until either the first valid character is found
// or a time out occurs due to lack of input.
enum LookaheadMode{
SKIP_ALL, // All invalid characters are ignored.
SKIP_NONE, // Nothing is skipped, and the stream is not touched unless the first waiting character is valid.
SKIP_WHITESPACE // Only tabs, spaces, line feeds & carriage returns are skipped.
};
#define NO_IGNORE_CHAR '\x01' // a char not found in a valid ASCII numeric field
class Stream : public Print
{
protected:
unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
unsigned long _startMillis = 0; // used for timeout measurement
int timedRead(); // read stream with timeout
int timedPeek(); // peek stream with timeout
int peekNextDigit(LookaheadMode lookahead, bool detectDecimal); // returns the next numeric digit in the stream or -1 if timeout
public:
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
Stream() {_timeout=1000;}
// parsing methods
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
unsigned long getTimeout(void) { return _timeout; }
bool find(char *target); // reads data from the stream until the target string is found
bool find(uint8_t *target) { return find ((char *)target); }
// returns true if target string is found, false if timed out (see setTimeout)
bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found
bool find(uint8_t *target, size_t length) { return find ((char *)target, length); }
// returns true if target string is found, false if timed out
bool find(char target) { return find (&target, 1); }
bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found
bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); }
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found
bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); }
long parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR);
// returns the first valid (long) integer value from the current position.
// lookahead determines how parseInt looks ahead in the stream.
// See LookaheadMode enumeration at the top of the file.
// Lookahead is terminated by the first character that is not a valid part of an integer.
// Once parsing commences, 'ignore' will be skipped in the stream.
float parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR);
// float version of parseInt
size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
// terminates if length characters have been read or timeout (see setTimeout)
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character
size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
// Arduino String functions to be added here
String readString();
String readStringUntil(char terminator);
protected:
long parseInt(char ignore) { return parseInt(SKIP_ALL, ignore); }
float parseFloat(char ignore) { return parseFloat(SKIP_ALL, ignore); }
// These overload exists for compatibility with any class that has derived
// Stream and used parseFloat/Int with a custom ignore character. To keep
// the public API simple, these overload remains protected.
struct MultiTarget {
const char *str; // string you're searching for
size_t len; // length of string you're searching for
size_t index; // index used by the search routine.
};
// This allows you to search for an arbitrary number of strings.
// Returns index of the target that is found first or -1 if timeout occurs.
int findMulti(struct MultiTarget *targets, int tCount);
};
#undef NO_IGNORE_CHAR
#endif
@@ -237,7 +237,7 @@ in voltage and temperature. */
//#define LAN8742A_PHY_ADDRESS 0x00U
/* Section 2: PHY configuration section */
#if !defined (LAN8742A_PHY_ADDRESS)
/* LAN8742A PHY Address*/
/* KH, LAN8742A PHY Address*/
#define LAN8742A_PHY_ADDRESS 0x00U
#endif
////////////////////////////////
@@ -232,7 +232,7 @@ in voltage and temperature. */
//#define LAN8742A_PHY_ADDRESS 0x00U
/* Section 2: PHY configuration section */
#if !defined (LAN8742A_PHY_ADDRESS)
/* LAN8742A PHY Address*/
/* KH, LAN8742A PHY Address*/
#define LAN8742A_PHY_ADDRESS 0x00U
#endif
////////////////////////////////
@@ -0,0 +1,519 @@
/**
******************************************************************************
* @file stm32f4xx_hal_conf_default.h
* @brief HAL default configuration file.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_HAL_CONF_DEFAULT_H
#define __STM32F4xx_HAL_CONF_DEFAULT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* ########################## Module Selection ############################## */
/**
* @brief Include the default list of modules to be used in the HAL driver
* and manage module deactivation
*/
#include "stm32yyxx_hal_conf.h"
#if 0
/**
* @brief This is the list of modules to be used in the HAL driver
*/
#define HAL_MODULE_ENABLED
#define HAL_ADC_MODULE_ENABLED
#define HAL_CAN_MODULE_ENABLED
/*#define HAL_CAN_LEGACY_MODULE_ENABLED*/
#define HAL_CRC_MODULE_ENABLED
#define HAL_CEC_MODULE_ENABLED
#define HAL_CRYP_MODULE_ENABLED
#define HAL_DAC_MODULE_ENABLED
#define HAL_DCMI_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_DMA2D_MODULE_ENABLED
#define HAL_ETH_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_NAND_MODULE_ENABLED
#define HAL_NOR_MODULE_ENABLED
#define HAL_PCCARD_MODULE_ENABLED
#define HAL_SRAM_MODULE_ENABLED
#define HAL_SDRAM_MODULE_ENABLED
#define HAL_HASH_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
#define HAL_SMBUS_MODULE_ENABLED
#define HAL_I2S_MODULE_ENABLED
#define HAL_IWDG_MODULE_ENABLED
#define HAL_LTDC_MODULE_ENABLED
#define HAL_DSI_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_QSPI_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_RNG_MODULE_ENABLED
#define HAL_RTC_MODULE_ENABLED
#define HAL_SAI_MODULE_ENABLED
#define HAL_SD_MODULE_ENABLED
#define HAL_SPI_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
#define HAL_USART_MODULE_ENABLED
#define HAL_IRDA_MODULE_ENABLED
#define HAL_SMARTCARD_MODULE_ENABLED
#define HAL_WWDG_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED
#define HAL_PCD_MODULE_ENABLED
#define HAL_HCD_MODULE_ENABLED
#define HAL_FMPI2C_MODULE_ENABLED
#define HAL_FMPSMBUS_MODULE_ENABLED
#define HAL_SPDIFRX_MODULE_ENABLED
#define HAL_DFSDM_MODULE_ENABLED
#define HAL_LPTIM_MODULE_ENABLED
#define HAL_MMC_MODULE_ENABLED
#endif
/* ########################## HSE/HSI Values adaptation ##################### */
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
/**
* @brief Internal High Speed oscillator (HSI) value.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */
#endif /* HSI_VALUE */
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
in voltage and temperature. */
/**
* @brief External Low Speed oscillator (LSE) value.
*/
#if !defined (LSE_VALUE)
#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
/**
* @brief External clock source for I2S peripheral
* This value is used by the I2S HAL module to compute the I2S clock source
* frequency, this source is inserted directly through I2S_CKIN pad.
*/
#if !defined (EXTERNAL_CLOCK_VALUE)
#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */
/* Tip: To avoid modifying this file each time you need to use different HSE,
=== you can define the HSE value in your toolchain compiler preprocessor. */
/* ########################### System Configuration ######################### */
/**
* @brief This is the HAL system configuration section
*/
#if !defined (VDD_VALUE)
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
#endif
#if !defined (TICK_INT_PRIORITY)
#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */
#endif
#if !defined (USE_RTOS)
#define USE_RTOS 0U
#endif
#if !defined (PREFETCH_ENABLE)
#define PREFETCH_ENABLE 1U
#endif
#if !defined (INSTRUCTION_CACHE_ENABLE)
#define INSTRUCTION_CACHE_ENABLE 1U
#endif
#if !defined (DATA_CACHE_ENABLE)
#define DATA_CACHE_ENABLE 1U
#endif
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
/* #define USE_FULL_ASSERT 1U */
/* ################## Ethernet peripheral configuration ##################### */
/* Section 1 : Ethernet peripheral configuration */
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
#define MAC_ADDR0 2U
#define MAC_ADDR1 0U
#define MAC_ADDR2 0U
#define MAC_ADDR3 0U
#define MAC_ADDR4 0U
#define MAC_ADDR5 0U
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
#define ETH_RXBUFNB (5U) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */
#define ETH_TXBUFNB (5U) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */
/* Section 2: PHY configuration section */
/* LAN8742A PHY Address*/
////////////////////////////////
//#define LAN8742A_PHY_ADDRESS 0x00U
/* Section 2: PHY configuration section */
#if !defined (LAN8742A_PHY_ADDRESS)
/* KH, LAN8742A PHY Address*/
#define LAN8742A_PHY_ADDRESS 0x00U
#endif
////////////////////////////////
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
#define PHY_RESET_DELAY 0x000000FFU
/* PHY Configuration delay */
#define PHY_CONFIG_DELAY 0x00000FFFU
#define PHY_READ_TO 0x0000FFFFU
#define PHY_WRITE_TO 0x0000FFFFU
/* Section 3: Common PHY Registers */
#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
/* Section 4: Extended PHY Registers */
#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */
#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */
#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */
#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */
#define PHY_IMR ((uint16_t)0x1E) /*!< PHY Interrupt Mask register Offset */
#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */
/* ################## SPI peripheral configuration ########################## */
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
* Activated: CRC code is present inside driver
* Deactivated: CRC code cleaned from driver
*/
#if !defined (USE_SPI_CRC)
#define USE_SPI_CRC 0U
#endif
/* Includes ------------------------------------------------------------------*/
/**
* @brief Include module's header file
*/
#ifdef HAL_RCC_MODULE_ENABLED
#include "stm32f4xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED
#include "stm32f4xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f4xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_DMA_MODULE_ENABLED
#include "stm32f4xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
#ifdef HAL_CORTEX_MODULE_ENABLED
#include "stm32f4xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */
#ifdef HAL_ADC_MODULE_ENABLED
#include "stm32f4xx_hal_adc.h"
#endif /* HAL_ADC_MODULE_ENABLED */
#ifdef HAL_CAN_MODULE_ENABLED
#include "stm32f4xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
#include "stm32f4xx_hal_can_legacy.h"
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
#ifdef HAL_CRC_MODULE_ENABLED
#include "stm32f4xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */
#ifdef HAL_CRYP_MODULE_ENABLED
#include "stm32f4xx_hal_cryp.h"
#endif /* HAL_CRYP_MODULE_ENABLED */
#ifdef HAL_DMA2D_MODULE_ENABLED
#include "stm32f4xx_hal_dma2d.h"
#endif /* HAL_DMA2D_MODULE_ENABLED */
#ifdef HAL_DAC_MODULE_ENABLED
#include "stm32f4xx_hal_dac.h"
#endif /* HAL_DAC_MODULE_ENABLED */
#ifdef HAL_DCMI_MODULE_ENABLED
#include "stm32f4xx_hal_dcmi.h"
#endif /* HAL_DCMI_MODULE_ENABLED */
#ifdef HAL_ETH_MODULE_ENABLED
#include "stm32f4xx_hal_eth.h"
#endif /* HAL_ETH_MODULE_ENABLED */
#ifdef HAL_FLASH_MODULE_ENABLED
#include "stm32f4xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */
#ifdef HAL_SRAM_MODULE_ENABLED
#include "stm32f4xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */
#ifdef HAL_NOR_MODULE_ENABLED
#include "stm32f4xx_hal_nor.h"
#endif /* HAL_NOR_MODULE_ENABLED */
#ifdef HAL_NAND_MODULE_ENABLED
#include "stm32f4xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */
#ifdef HAL_PCCARD_MODULE_ENABLED
#include "stm32f4xx_hal_pccard.h"
#endif /* HAL_PCCARD_MODULE_ENABLED */
#ifdef HAL_SDRAM_MODULE_ENABLED
#include "stm32f4xx_hal_sdram.h"
#endif /* HAL_SDRAM_MODULE_ENABLED */
#ifdef HAL_HASH_MODULE_ENABLED
#include "stm32f4xx_hal_hash.h"
#endif /* HAL_HASH_MODULE_ENABLED */
#ifdef HAL_I2C_MODULE_ENABLED
#include "stm32f4xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */
#ifdef HAL_SMBUS_MODULE_ENABLED
#include "stm32f4xx_hal_smbus.h"
#endif /* HAL_SMBUS_MODULE_ENABLED */
#ifdef HAL_I2S_MODULE_ENABLED
#include "stm32f4xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */
#ifdef HAL_IWDG_MODULE_ENABLED
#include "stm32f4xx_hal_iwdg.h"
#endif /* HAL_IWDG_MODULE_ENABLED */
#ifdef HAL_LTDC_MODULE_ENABLED
#include "stm32f4xx_hal_ltdc.h"
#endif /* HAL_LTDC_MODULE_ENABLED */
#ifdef HAL_PWR_MODULE_ENABLED
#include "stm32f4xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */
#ifdef HAL_RNG_MODULE_ENABLED
#include "stm32f4xx_hal_rng.h"
#endif /* HAL_RNG_MODULE_ENABLED */
#ifdef HAL_RTC_MODULE_ENABLED
#include "stm32f4xx_hal_rtc.h"
#endif /* HAL_RTC_MODULE_ENABLED */
#ifdef HAL_SAI_MODULE_ENABLED
#include "stm32f4xx_hal_sai.h"
#endif /* HAL_SAI_MODULE_ENABLED */
#ifdef HAL_SD_MODULE_ENABLED
#include "stm32f4xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_SPI_MODULE_ENABLED
#include "stm32f4xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */
#ifdef HAL_TIM_MODULE_ENABLED
#include "stm32f4xx_hal_tim.h"
#endif /* HAL_TIM_MODULE_ENABLED */
#ifdef HAL_UART_MODULE_ENABLED
#include "stm32f4xx_hal_uart.h"
#endif /* HAL_UART_MODULE_ENABLED */
#ifdef HAL_USART_MODULE_ENABLED
#include "stm32f4xx_hal_usart.h"
#endif /* HAL_USART_MODULE_ENABLED */
#ifdef HAL_IRDA_MODULE_ENABLED
#include "stm32f4xx_hal_irda.h"
#endif /* HAL_IRDA_MODULE_ENABLED */
#ifdef HAL_SMARTCARD_MODULE_ENABLED
#include "stm32f4xx_hal_smartcard.h"
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
#ifdef HAL_WWDG_MODULE_ENABLED
#include "stm32f4xx_hal_wwdg.h"
#endif /* HAL_WWDG_MODULE_ENABLED */
#ifdef HAL_PCD_MODULE_ENABLED
#include "stm32f4xx_hal_pcd.h"
#endif /* HAL_PCD_MODULE_ENABLED */
#ifdef HAL_HCD_MODULE_ENABLED
#include "stm32f4xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */
#ifdef HAL_DSI_MODULE_ENABLED
#include "stm32f4xx_hal_dsi.h"
#endif /* HAL_DSI_MODULE_ENABLED */
#ifdef HAL_QSPI_MODULE_ENABLED
#include "stm32f4xx_hal_qspi.h"
#endif /* HAL_QSPI_MODULE_ENABLED */
#ifdef HAL_CEC_MODULE_ENABLED
#include "stm32f4xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */
#ifdef HAL_FMPI2C_MODULE_ENABLED
#include "stm32f4xx_hal_fmpi2c.h"
#endif /* HAL_FMPI2C_MODULE_ENABLED */
#ifdef HAL_FMPSMBUS_MODULE_ENABLED
#include "stm32f4xx_hal_fmpsmbus.h"
#endif /* HAL_FMPSMBUS_MODULE_ENABLED */
#ifdef HAL_SPDIFRX_MODULE_ENABLED
#include "stm32f4xx_hal_spdifrx.h"
#endif /* HAL_SPDIFRX_MODULE_ENABLED */
#ifdef HAL_DFSDM_MODULE_ENABLED
#include "stm32f4xx_hal_dfsdm.h"
#endif /* HAL_DFSDM_MODULE_ENABLED */
#ifdef HAL_LPTIM_MODULE_ENABLED
#include "stm32f4xx_hal_lptim.h"
#endif /* HAL_LPTIM_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f4xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t *file, uint32_t line);
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_HAL_CONF_DEFAULT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,511 @@
/**
******************************************************************************
* @file stm32f7xx_hal_conf_default.h
* @brief HAL default configuration file.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F7xx_HAL_CONF_DEFAULT_H
#define __STM32F7xx_HAL_CONF_DEFAULT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* ########################## Module Selection ############################## */
/**
* @brief Include the default list of modules to be used in the HAL driver
* and manage module deactivation
*/
#include "stm32yyxx_hal_conf.h"
#if 0
/**
* @brief This is the list of modules to be used in the HAL driver
*/
#define HAL_MODULE_ENABLED
#define HAL_ADC_MODULE_ENABLED
#define HAL_CAN_MODULE_ENABLED
#define HAL_CAN_LEGACY_MODULE_ENABLED
#define HAL_CEC_MODULE_ENABLED
#define HAL_CRC_MODULE_ENABLED
#define HAL_CRYP_MODULE_ENABLED
#define HAL_DAC_MODULE_ENABLED
#define HAL_DCMI_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_DMA2D_MODULE_ENABLED
#define HAL_ETH_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_NAND_MODULE_ENABLED
#define HAL_NOR_MODULE_ENABLED
#define HAL_SRAM_MODULE_ENABLED
#define HAL_SDRAM_MODULE_ENABLED
#define HAL_HASH_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
#define HAL_I2S_MODULE_ENABLED
#define HAL_IWDG_MODULE_ENABLED
#define HAL_LPTIM_MODULE_ENABLED
#define HAL_LTDC_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_QSPI_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_RNG_MODULE_ENABLED
#define HAL_RTC_MODULE_ENABLED
#define HAL_SAI_MODULE_ENABLED
#define HAL_SD_MODULE_ENABLED
#define HAL_SPDIFRX_MODULE_ENABLED
#define HAL_SPI_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
#define HAL_USART_MODULE_ENABLED
#define HAL_IRDA_MODULE_ENABLED
#define HAL_SMARTCARD_MODULE_ENABLED
#define HAL_WWDG_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED
#define HAL_PCD_MODULE_ENABLED
#define HAL_HCD_MODULE_ENABLED
#define HAL_DFSDM_MODULE_ENABLED
#define HAL_DSI_MODULE_ENABLED
#define HAL_JPEG_MODULE_ENABLED
#define HAL_MDIOS_MODULE_ENABLED
#define HAL_SMBUS_MODULE_ENABLED
#define HAL_MMC_MODULE_ENABLED
#endif
/* ########################## HSE/HSI Values adaptation ##################### */
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
/**
* @brief Internal High Speed oscillator (HSI) value.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
in voltage and temperature. */
/**
* @brief External Low Speed oscillator (LSE) value.
*/
#if !defined (LSE_VALUE)
#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
/**
* @brief External clock source for I2S peripheral
* This value is used by the I2S HAL module to compute the I2S clock source
* frequency, this source is inserted directly through I2S_CKIN pad.
*/
#if !defined (EXTERNAL_CLOCK_VALUE)
#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the Internal oscillator in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */
/* Tip: To avoid modifying this file each time you need to use different HSE,
=== you can define the HSE value in your toolchain compiler preprocessor. */
/* ########################### System Configuration ######################### */
/**
* @brief This is the HAL system configuration section
*/
#if !defined (VDD_VALUE)
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
#endif
#if !defined (TICK_INT_PRIORITY)
#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */
#endif
#if !defined (USE_RTOS)
#define USE_RTOS 0U
#endif
#if !defined (PREFETCH_ENABLE)
#define PREFETCH_ENABLE 1U /* To enable prefetch */
#endif
#if !defined (ART_ACCLERATOR_ENABLE)
#define ART_ACCLERATOR_ENABLE 1U /* To enable ART Accelerator */
#endif
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
/* #define USE_FULL_ASSERT 1 */
/* ################## Ethernet peripheral configuration ##################### */
/* Section 1 : Ethernet peripheral configuration */
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
#define MAC_ADDR0 2U
#define MAC_ADDR1 0U
#define MAC_ADDR2 0U
#define MAC_ADDR3 0U
#define MAC_ADDR4 0U
#define MAC_ADDR5 0U
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
/* Section 2: PHY configuration section */
/* LAN8742A PHY Address*/
////////////////////////////////
//#define LAN8742A_PHY_ADDRESS 0x00U
/* Section 2: PHY configuration section */
#if !defined (LAN8742A_PHY_ADDRESS)
/* KH, LAN8742A PHY Address*/
#define LAN8742A_PHY_ADDRESS 0x00U
#endif
////////////////////////////////
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
#define PHY_RESET_DELAY 0x00000FFFU
/* PHY Configuration delay */
#define PHY_CONFIG_DELAY 0x00000FFFU
#define PHY_READ_TO 0x0000FFFFU
#define PHY_WRITE_TO 0x0000FFFFU
/* Section 3: Common PHY Registers */
#define PHY_BCR ((uint16_t)0x00U) /*!< Transceiver Basic Control Register */
#define PHY_BSR ((uint16_t)0x01U) /*!< Transceiver Basic Status Register */
#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
/* Section 4: Extended PHY Registers */
#define PHY_SR ((uint16_t)0x1FU) /*!< PHY special control/ status register Offset */
#define PHY_SPEED_STATUS ((uint16_t)0x0004U) /*!< PHY Speed mask */
#define PHY_DUPLEX_STATUS ((uint16_t)0x0010U) /*!< PHY Duplex mask */
#define PHY_ISFR ((uint16_t)0x01DU) /*!< PHY Interrupt Source Flag register Offset */
#define PHY_IMR ((uint16_t)0x001E) /*!< PHY Interrupt Mask register Offset */
#define PHY_ISFR_INT4 ((uint16_t)0x0010U) /*!< PHY Link down inturrupt */
/* ################## SPI peripheral configuration ########################## */
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
* Activated: CRC code is present inside driver
* Deactivated: CRC code cleaned from driver
*/
#if !defined (USE_SPI_CRC)
#define USE_SPI_CRC 0U
#endif
/* Includes ------------------------------------------------------------------*/
/**
* @brief Include module's header file
*/
#ifdef HAL_RCC_MODULE_ENABLED
#include "stm32f7xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED
#include "stm32f7xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
#ifdef HAL_DMA_MODULE_ENABLED
#include "stm32f7xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
#ifdef HAL_CORTEX_MODULE_ENABLED
#include "stm32f7xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */
#ifdef HAL_ADC_MODULE_ENABLED
#include "stm32f7xx_hal_adc.h"
#endif /* HAL_ADC_MODULE_ENABLED */
#ifdef HAL_CAN_MODULE_ENABLED
#include "stm32f7xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
#include "stm32f7xx_hal_can_legacy.h"
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
#ifdef HAL_CEC_MODULE_ENABLED
#include "stm32f7xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */
#ifdef HAL_CRC_MODULE_ENABLED
#include "stm32f7xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */
#ifdef HAL_CRYP_MODULE_ENABLED
#include "stm32f7xx_hal_cryp.h"
#endif /* HAL_CRYP_MODULE_ENABLED */
#ifdef HAL_DMA2D_MODULE_ENABLED
#include "stm32f7xx_hal_dma2d.h"
#endif /* HAL_DMA2D_MODULE_ENABLED */
#ifdef HAL_DAC_MODULE_ENABLED
#include "stm32f7xx_hal_dac.h"
#endif /* HAL_DAC_MODULE_ENABLED */
#ifdef HAL_DCMI_MODULE_ENABLED
#include "stm32f7xx_hal_dcmi.h"
#endif /* HAL_DCMI_MODULE_ENABLED */
#ifdef HAL_ETH_MODULE_ENABLED
#include "stm32f7xx_hal_eth.h"
#endif /* HAL_ETH_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f7xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_FLASH_MODULE_ENABLED
#include "stm32f7xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */
#ifdef HAL_SRAM_MODULE_ENABLED
#include "stm32f7xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */
#ifdef HAL_NOR_MODULE_ENABLED
#include "stm32f7xx_hal_nor.h"
#endif /* HAL_NOR_MODULE_ENABLED */
#ifdef HAL_NAND_MODULE_ENABLED
#include "stm32f7xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */
#ifdef HAL_SDRAM_MODULE_ENABLED
#include "stm32f7xx_hal_sdram.h"
#endif /* HAL_SDRAM_MODULE_ENABLED */
#ifdef HAL_HASH_MODULE_ENABLED
#include "stm32f7xx_hal_hash.h"
#endif /* HAL_HASH_MODULE_ENABLED */
#ifdef HAL_I2C_MODULE_ENABLED
#include "stm32f7xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */
#ifdef HAL_I2S_MODULE_ENABLED
#include "stm32f7xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */
#ifdef HAL_IWDG_MODULE_ENABLED
#include "stm32f7xx_hal_iwdg.h"
#endif /* HAL_IWDG_MODULE_ENABLED */
#ifdef HAL_LPTIM_MODULE_ENABLED
#include "stm32f7xx_hal_lptim.h"
#endif /* HAL_LPTIM_MODULE_ENABLED */
#ifdef HAL_LTDC_MODULE_ENABLED
#include "stm32f7xx_hal_ltdc.h"
#endif /* HAL_LTDC_MODULE_ENABLED */
#ifdef HAL_PWR_MODULE_ENABLED
#include "stm32f7xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */
#ifdef HAL_QSPI_MODULE_ENABLED
#include "stm32f7xx_hal_qspi.h"
#endif /* HAL_QSPI_MODULE_ENABLED */
#ifdef HAL_RNG_MODULE_ENABLED
#include "stm32f7xx_hal_rng.h"
#endif /* HAL_RNG_MODULE_ENABLED */
#ifdef HAL_RTC_MODULE_ENABLED
#include "stm32f7xx_hal_rtc.h"
#endif /* HAL_RTC_MODULE_ENABLED */
#ifdef HAL_SAI_MODULE_ENABLED
#include "stm32f7xx_hal_sai.h"
#endif /* HAL_SAI_MODULE_ENABLED */
#ifdef HAL_SD_MODULE_ENABLED
#include "stm32f7xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_SPDIFRX_MODULE_ENABLED
#include "stm32f7xx_hal_spdifrx.h"
#endif /* HAL_SPDIFRX_MODULE_ENABLED */
#ifdef HAL_SPI_MODULE_ENABLED
#include "stm32f7xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */
#ifdef HAL_TIM_MODULE_ENABLED
#include "stm32f7xx_hal_tim.h"
#endif /* HAL_TIM_MODULE_ENABLED */
#ifdef HAL_UART_MODULE_ENABLED
#include "stm32f7xx_hal_uart.h"
#endif /* HAL_UART_MODULE_ENABLED */
#ifdef HAL_USART_MODULE_ENABLED
#include "stm32f7xx_hal_usart.h"
#endif /* HAL_USART_MODULE_ENABLED */
#ifdef HAL_IRDA_MODULE_ENABLED
#include "stm32f7xx_hal_irda.h"
#endif /* HAL_IRDA_MODULE_ENABLED */
#ifdef HAL_SMARTCARD_MODULE_ENABLED
#include "stm32f7xx_hal_smartcard.h"
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
#ifdef HAL_WWDG_MODULE_ENABLED
#include "stm32f7xx_hal_wwdg.h"
#endif /* HAL_WWDG_MODULE_ENABLED */
#ifdef HAL_PCD_MODULE_ENABLED
#include "stm32f7xx_hal_pcd.h"
#endif /* HAL_PCD_MODULE_ENABLED */
#ifdef HAL_HCD_MODULE_ENABLED
#include "stm32f7xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */
#ifdef HAL_DFSDM_MODULE_ENABLED
#include "stm32f7xx_hal_dfsdm.h"
#endif /* HAL_DFSDM_MODULE_ENABLED */
#ifdef HAL_DSI_MODULE_ENABLED
#include "stm32f7xx_hal_dsi.h"
#endif /* HAL_DSI_MODULE_ENABLED */
#ifdef HAL_JPEG_MODULE_ENABLED
#include "stm32f7xx_hal_jpeg.h"
#endif /* HAL_JPEG_MODULE_ENABLED */
#ifdef HAL_MDIOS_MODULE_ENABLED
#include "stm32f7xx_hal_mdios.h"
#endif /* HAL_MDIOS_MODULE_ENABLED */
#ifdef HAL_SMBUS_MODULE_ENABLED
#include "stm32f7xx_hal_smbus.h"
#endif /* HAL_SMBUS_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f7xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t *file, uint32_t line);
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F7xx_HAL_CONF_DEFAULT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,274 @@
/*
*******************************************************************************
* Copyright (c) 2020-2021, STMicroelectronics
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
*******************************************************************************
*/
#pragma once
/*----------------------------------------------------------------------------
* Pins
*----------------------------------------------------------------------------*/
#define PG9 0
#define PG14 1
#define PF15 2
#define PE13 3
#define PF14 4
#define PE11 5
#define PE9 6
#define PF13 7
#define PF12 8
#define PD15 9
#define PD14 10
#define PA7 PIN_A10
#define PA6 PIN_A11
#define PA5 PIN_A12
#define PB9 14
#define PB8 15
#define PC6 16
#define PB15 17
#define PB13 18
#define PB12 19
#define PA15 20
#define PC7 21
#define PB5 22
#define PB3 23
#define PA4 PIN_A13
#define PB4 25
#define PB6 26
#define PB2 27
#define PD13 28
#define PD12 29
#define PD11 30
#define PE2 31
#define PA0 PIN_A14
#define PB0 PIN_A23 // LED_GREEN
#define PE0 34
#define PB11 35
#define PB10 36
#define PE15 37
#define PE14 38
#define PE12 39
#define PE10 40
#define PE7 41
#define PE8 42
#define PC8 43
#define PC9 44
#define PC10 45
#define PC11 46
#define PC12 47
#define PD2 48
#define PG2 49
#define PG3 50
#define PD7 51
#define PD6 52
#define PD5 53
#define PD4 54
#define PD3 55
// 56 is PE2 (31)
#define PE4 57
#define PE5 58
#define PE6 59
#define PE3 60
#define PF8 PIN_A15
#define PF7 PIN_A16
#define PF9 PIN_A17
#define PG1 64
#define PG0 65
#define PD1 66
#define PD0 67
#define PF0 68
#define PF1 69
#define PF2 70
// 71 is PA7 (11)
// 72 is NC
#define PB7 73 // LED_BLUE
#define PB14 74 // LED_RED
#define PC13 75 // USER_BTN
#define PD9 76 // Serial Rx
#define PD8 77 // Serial Tx
#define PA3 PIN_A0
#define PC0 PIN_A1
#define PC3 PIN_A2
#define PF3 PIN_A3
#define PF5 PIN_A4
#define PF10 PIN_A5
#define PB1 PIN_A6
#define PC2 PIN_A7
#define PF4 PIN_A8
#define PF6 PIN_A9
// ST Morpho
#define PA1 PIN_A18
#define PA2 PIN_A19
#define PA8 90
#define PA9 91
#define PA10 92
#define PA11 93
#define PA12 94
#define PA13 95 // SWD
#define PA14 96 // SWD
#define PC1 PIN_A20
#define PC4 PIN_A21
#define PC5 PIN_A22
#define PC14 100
#define PC15 101
#define PD10 102
#define PE1 103
#define PF11 104
#define PG4 105
#define PG5 106
#define PG6 107
#define PG7 108
#define PG8 109
#define PG10 110
#define PG11 111
#define PG12 112
#define PG13 113
#define PG15 114
#define PH0 115 // MCO
#define PH1 116
// Alternate pins number
#define PA0_ALT1 (PA0 | ALT1)
#define PA0_ALT2 (PA0 | ALT2)
#define PA1_ALT1 (PA1 | ALT1)
#define PA1_ALT2 (PA1 | ALT2)
#define PA2_ALT1 (PA2 | ALT1)
#define PA2_ALT2 (PA2 | ALT2)
#define PA3_ALT1 (PA3 | ALT1)
#define PA3_ALT2 (PA3 | ALT2)
#define PA4_ALT1 (PA4 | ALT1)
#define PA5_ALT1 (PA5 | ALT1)
#define PA6_ALT1 (PA6 | ALT1)
#define PA7_ALT1 (PA7 | ALT1)
#define PA7_ALT2 (PA7 | ALT2)
#define PA7_ALT3 (PA7 | ALT3)
#define PA15_ALT1 (PA15 | ALT1)
#define PB0_ALT1 (PB0 | ALT1)
#define PB0_ALT2 (PB0 | ALT2)
#define PB1_ALT1 (PB1 | ALT1)
#define PB1_ALT2 (PB1 | ALT2)
#define PB3_ALT1 (PB3 | ALT1)
#define PB4_ALT1 (PB4 | ALT1)
#define PB5_ALT1 (PB5 | ALT1)
#define PB8_ALT1 (PB8 | ALT1)
#define PB9_ALT1 (PB9 | ALT1)
#define PB14_ALT1 (PB14 | ALT1)
#define PB14_ALT2 (PB14 | ALT2)
#define PB15_ALT1 (PB15 | ALT1)
#define PB15_ALT2 (PB15 | ALT2)
#define PC0_ALT1 (PC0 | ALT1)
#define PC0_ALT2 (PC0 | ALT2)
#define PC1_ALT1 (PC1 | ALT1)
#define PC1_ALT2 (PC1 | ALT2)
#define PC2_ALT1 (PC2 | ALT1)
#define PC2_ALT2 (PC2 | ALT2)
#define PC3_ALT1 (PC3 | ALT1)
#define PC3_ALT2 (PC3 | ALT2)
#define PC4_ALT1 (PC4 | ALT1)
#define PC5_ALT1 (PC5 | ALT1)
#define PC6_ALT1 (PC6 | ALT1)
#define PC7_ALT1 (PC7 | ALT1)
#define PC8_ALT1 (PC8 | ALT1)
#define PC9_ALT1 (PC9 | ALT1)
#define PC10_ALT1 (PC10 | ALT1)
#define PC11_ALT1 (PC11 | ALT1)
// This must be a literal
#define NUM_DIGITAL_PINS 117
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS 24
// On-board LED pin number
#ifndef LED_BUILTIN
#define LED_BUILTIN PB0
#endif
#define LED_GREEN LED_BUILTIN
#define LED_BLUE PB7
#define LED_RED PB14
// On-board user button
#ifndef USER_BTN
#define USER_BTN PC13
#endif
// Timer Definitions
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
#ifndef TIMER_TONE
#define TIMER_TONE TIM6
#endif
#ifndef TIMER_SERVO
#define TIMER_SERVO TIM7
#endif
// UART Definitions
#ifndef SERIAL_UART_INSTANCE
#define SERIAL_UART_INSTANCE 3 //Connected to ST-Link
#endif
// Serial pin used for console (ex: stlink)
// Rerquired by Firmata
#ifndef PIN_SERIAL_RX
#define PIN_SERIAL_RX PD9
#endif
#ifndef PIN_SERIAL_TX
#define PIN_SERIAL_TX PD8
#endif
// Value of the External oscillator in Hz
#define HSE_VALUE 8000000U
/* Extra HAL modules */
#if !defined(HAL_DAC_MODULE_DISABLED)
#define HAL_DAC_MODULE_ENABLED
#endif
#if !defined(HAL_ETH_MODULE_DISABLED)
#define HAL_ETH_MODULE_ENABLED
#endif
#if !defined(HAL_QSPI_MODULE_DISABLED)
#define HAL_QSPI_MODULE_ENABLED
#endif
#if !defined(HAL_SD_MODULE_DISABLED)
#define HAL_SD_MODULE_ENABLED
#endif
// Last Flash sector used for EEPROM emulation, address/sector depends on single/dual bank configuration.
// By default 2MB single bank
#define FLASH_BASE_ADDRESS 0x081C0000
#define FLASH_DATA_SECTOR 11
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#ifdef __cplusplus
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#ifndef SERIAL_PORT_MONITOR
#define SERIAL_PORT_MONITOR Serial
#endif
#ifndef SERIAL_PORT_HARDWARE
// KH mod to add Serial1, for ESP-AT
//#define SERIAL_PORT_HARDWARE Serial
#define SERIAL_PORT_HARDWARE Serial1
#endif
#endif
@@ -0,0 +1,173 @@
/*
*******************************************************************************
* Copyright (c) 2020-2021, STMicroelectronics
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
*******************************************************************************
*/
#pragma once
/*----------------------------------------------------------------------------
* STM32 pins number
*----------------------------------------------------------------------------*/
#define PA0 PIN_A0
#define PA1 PIN_A1
#define PA2 PIN_A2
#define PA3 PIN_A3
#define PA4 PIN_A4
#define PA5 PIN_A5
#define PA6 PIN_A6
#define PA7 PIN_A7
#define PA8 8
#define PA9 9
#define PA10 10
#define PA11 11
#define PA12 12
#define PA13 13
#define PA14 14
#define PA15 15
#define PB0 PIN_A8
#define PB1 PIN_A9
#define PB2 18
#define PB3 19
#define PB4 20
#define PB5 21
#define PB6 22
#define PB7 23
#define PB8 24
#define PB9 25
#define PB10 26
#define PB11 27
#define PB12 28
#define PB13 29
#define PB14 30
#define PB15 31
#define PC0 PIN_A10
#define PC1 PIN_A11
#define PC2 PIN_A12
#define PC4 PIN_A13
#define PC5 PIN_A14
#define PC6 37
#define PC7 38
#define PC8 39
#define PC9 40
#define PC10 41
#define PC11 42
#define PC12 43
#define PC13 44
#define PC14 45
#define PC15 46
#define PD2 47
#define PH0 48
#define PH1 49
// Alternate pins number
#define PA2_ALT1 (PA2 | ALT1)
#define PA3_ALT1 (PA3 | ALT1)
#define NUM_DIGITAL_PINS 50
#define NUM_ANALOG_INPUTS 15
// On-board LED pin number
#ifndef LED_BUILTIN
#define LED_BUILTIN PNUM_NOT_DEFINED
#endif
// On-board user button
#ifndef USER_BTN
#define USER_BTN PNUM_NOT_DEFINED
#endif
// SPI definitions
#ifndef PIN_SPI_SS
#define PIN_SPI_SS PA4
#endif
#ifndef PIN_SPI_SS1
#define PIN_SPI_SS1 PA15
#endif
#ifndef PIN_SPI_SS2
#define PIN_SPI_SS2 PNUM_NOT_DEFINED
#endif
#ifndef PIN_SPI_SS3
#define PIN_SPI_SS3 PNUM_NOT_DEFINED
#endif
#ifndef PIN_SPI_MOSI
#define PIN_SPI_MOSI PA7
#endif
#ifndef PIN_SPI_MISO
#define PIN_SPI_MISO PA6
#endif
#ifndef PIN_SPI_SCK
#define PIN_SPI_SCK PA5
#endif
// I2C definitions
#ifndef PIN_WIRE_SDA
#define PIN_WIRE_SDA PB7
#endif
#ifndef PIN_WIRE_SCL
#define PIN_WIRE_SCL PB6
#endif
// Timer Definitions
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
#ifndef TIMER_TONE
#define TIMER_TONE TIM6
#endif
#ifndef TIMER_SERVO
#define TIMER_SERVO TIM21
#endif
// UART Definitions
#ifndef SERIAL_UART_INSTANCE
#define SERIAL_UART_INSTANCE 2
#endif
// Default pin used for generic 'Serial' instance
// Mandatory for Firmata
#ifndef PIN_SERIAL_RX
#define PIN_SERIAL_RX PA3
#endif
#ifndef PIN_SERIAL_TX
#define PIN_SERIAL_TX PA2
#endif
// Extra HAL modules
#if !defined(HAL_DAC_MODULE_DISABLED)
#define HAL_DAC_MODULE_ENABLED
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#ifdef __cplusplus
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#ifndef SERIAL_PORT_MONITOR
#define SERIAL_PORT_MONITOR Serial
#endif
#ifndef SERIAL_PORT_HARDWARE
// KH mod to add Serial1, for ESP-AT
//#define SERIAL_PORT_HARDWARE Serial
#define SERIAL_PORT_HARDWARE Serial1
#endif
#endif
@@ -20,6 +20,7 @@
#include <inttypes.h>
#include <stdio.h> // for size_t
#include <stdarg.h> // for printf
#include "WString.h"
#include "Printable.h"
@@ -20,6 +20,7 @@
#include <inttypes.h>
#include <stdio.h> // for size_t
#include <stdarg.h> // for printf
#include "WString.h"
#include "Printable.h"
@@ -20,6 +20,7 @@
#include <inttypes.h>
#include <stdio.h> // for size_t
#include <stdarg.h> // for printf
#include "WString.h"
#include "Printable.h"
@@ -20,6 +20,7 @@
#include <inttypes.h>
#include <stdio.h> // for size_t
#include <stdarg.h> // for printf
#include "WString.h"
#include "Printable.h"
@@ -20,6 +20,7 @@
#include <inttypes.h>
#include <stdio.h> // for size_t
#include <stdarg.h> // for printf
#include "WString.h"
#include "Printable.h"
@@ -0,0 +1,420 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
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 <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
//using namespace arduino;
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(long long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printULLNumber(n, 10) + t;
}
return printULLNumber(n, 10);
} else {
return printULLNumber(n, base);
}
}
size_t Print::print(unsigned long long n, int base)
{
if (base == 0) return write(n);
else return printULLNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char * format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, 256, format, ap);
this->write(buf, len);
va_end(ap);
return len;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
// REFERENCE IMPLEMENTATION FOR ULL
// size_t Print::printULLNumber(unsigned long long n, uint8_t base)
// {
// // if limited to base 10 and 16 the bufsize can be smaller
// char buf[65];
// char *str = &buf[64];
// *str = '\0';
// // prevent crash if called with base == 1
// if (base < 2) base = 10;
// do {
// unsigned long long t = n / base;
// char c = n - t * base; // faster than c = n%base;
// n = t;
// *--str = c < 10 ? c + '0' : c + 'A' - 10;
// } while(n);
// return write(str);
// }
// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
// if limited to base 10 and 16 the bufsize can be 20
char buf[64];
uint8_t i = 0;
uint8_t innerLoops = 0;
// prevent crash if called with base == 1
if (base < 2) base = 10;
// process chunks that fit in "16 bit math".
uint16_t top = 0xFFFF / base;
uint16_t th16 = 1;
while (th16 < top)
{
th16 *= base;
innerLoops++;
}
while (n64 > th16)
{
// 64 bit math part
uint64_t q = n64 / th16;
uint16_t r = n64 - q*th16;
n64 = q;
// 16 bit math loop to do remainder. (note buffer is filled reverse)
for (uint8_t j=0; j < innerLoops; j++)
{
uint16_t qq = r/base;
buf[i++] = r - qq*base;
r = qq;
}
}
uint16_t n16 = n64;
while (n16 > 0)
{
uint16_t qq = n16/base;
buf[i++] = n16 - qq*base;
n16 = qq;
}
size_t bytes = i;
for (; i > 0; i--)
write((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
return bytes;
}
size_t Print::printFloat(double number, int digits)
{
if (digits < 0)
digits = 2;
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if ( i != 0 ) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[i]);
}
return (len*3 - 1);
}
size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if (i != 0) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[len-1-i]);
}
return (len*3 - 1);
}
@@ -0,0 +1,107 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
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
*/
#pragma once
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printULLNumber(unsigned long long, uint8_t);
size_t printFloat(double, int);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
size_t printf(const char * format, ...);
size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBuffer((uint8_t const*) buffer, size, delim, byteline);
}
size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
}
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
@@ -0,0 +1,420 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
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 <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
//using namespace arduino;
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(long long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printULLNumber(n, 10) + t;
}
return printULLNumber(n, 10);
} else {
return printULLNumber(n, base);
}
}
size_t Print::print(unsigned long long n, int base)
{
if (base == 0) return write(n);
else return printULLNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char * format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, 256, format, ap);
this->write(buf, len);
va_end(ap);
return len;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
// REFERENCE IMPLEMENTATION FOR ULL
// size_t Print::printULLNumber(unsigned long long n, uint8_t base)
// {
// // if limited to base 10 and 16 the bufsize can be smaller
// char buf[65];
// char *str = &buf[64];
// *str = '\0';
// // prevent crash if called with base == 1
// if (base < 2) base = 10;
// do {
// unsigned long long t = n / base;
// char c = n - t * base; // faster than c = n%base;
// n = t;
// *--str = c < 10 ? c + '0' : c + 'A' - 10;
// } while(n);
// return write(str);
// }
// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
// if limited to base 10 and 16 the bufsize can be 20
char buf[64];
uint8_t i = 0;
uint8_t innerLoops = 0;
// prevent crash if called with base == 1
if (base < 2) base = 10;
// process chunks that fit in "16 bit math".
uint16_t top = 0xFFFF / base;
uint16_t th16 = 1;
while (th16 < top)
{
th16 *= base;
innerLoops++;
}
while (n64 > th16)
{
// 64 bit math part
uint64_t q = n64 / th16;
uint16_t r = n64 - q*th16;
n64 = q;
// 16 bit math loop to do remainder. (note buffer is filled reverse)
for (uint8_t j=0; j < innerLoops; j++)
{
uint16_t qq = r/base;
buf[i++] = r - qq*base;
r = qq;
}
}
uint16_t n16 = n64;
while (n16 > 0)
{
uint16_t qq = n16/base;
buf[i++] = n16 - qq*base;
n16 = qq;
}
size_t bytes = i;
for (; i > 0; i--)
write((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
return bytes;
}
size_t Print::printFloat(double number, int digits)
{
if (digits < 0)
digits = 2;
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if ( i != 0 ) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[i]);
}
return (len*3 - 1);
}
size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if (i != 0) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[len-1-i]);
}
return (len*3 - 1);
}
@@ -0,0 +1,107 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
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
*/
#pragma once
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printULLNumber(unsigned long long, uint8_t);
size_t printFloat(double, int);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
size_t printf(const char * format, ...);
size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBuffer((uint8_t const*) buffer, size, delim, byteline);
}
size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
}
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
@@ -206,7 +206,7 @@ itsybitsy52840.upload.maximum_data_size=237568
# Build
itsybitsy52840.build.mcu=cortex-m4
itsybitsy52840.build.f_cpu=64000000
itsybitsy52840.build.board=NRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY
itsybitsy52840.build.board=NRF52840_ITSYBITSY
itsybitsy52840.build.core=nRF5
itsybitsy52840.build.variant=itsybitsy_nrf52840_express
itsybitsy52840.build.usb_manufacturer="Adafruit"
@@ -0,0 +1,765 @@
menu.softdevice=SoftDevice
menu.debug=Debug
menu.debug_output=Debug Output
# -----------------------------------
# Adafruit Feather nRF52832
# -----------------------------------
feather52832.name=Adafruit Feather nRF52832
# VID/PID for Bootloader, Arduino & CircuitPython
# Upload
feather52832.bootloader.tool=bootburn
feather52832.upload.tool=nrfutil
feather52832.upload.protocol=nrfutil
feather52832.upload.use_1200bps_touch=false
feather52832.upload.wait_for_upload_port=false
feather52832.upload.native_usb=false
feather52832.upload.maximum_size=290816
feather52832.upload.maximum_data_size=52224
# Build
feather52832.build.mcu=cortex-m4
feather52832.build.f_cpu=64000000
feather52832.build.board=NRF52832_FEATHER
feather52832.build.core=nRF5
feather52832.build.variant=feather_nrf52832
feather52832.build.usb_manufacturer="Adafruit"
feather52832.build.usb_product="Feather nRF52832"
feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52
feather52832.build.ldscript=nrf52832_s132_v6.ld
# SoftDevice Menu
feather52832.menu.softdevice.s132v6=S132 6.1.1
feather52832.menu.softdevice.s132v6.build.sd_name=s132
feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1
feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7
# Debug Menu
feather52832.menu.debug.l0=Level 0 (Release)
feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
feather52832.menu.debug.l1=Level 1 (Error Message)
feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
feather52832.menu.debug.l2=Level 2 (Full Debug)
feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
feather52832.menu.debug.l3=Level 3 (Segger SystemView)
feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
feather52832.menu.debug_output.serial=Serial
feather52832.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
feather52832.menu.debug_output.serial1=Serial1
feather52832.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
feather52832.menu.debug_output.rtt=Segger RTT
feather52832.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Adafruit Feather nRF52840 Express
# -----------------------------------
feather52840.name=Adafruit Feather nRF52840 Express
# VID/PID for Bootloader, Arduino & CircuitPython
feather52840.vid.0=0x239A
feather52840.pid.0=0x8029
feather52840.vid.1=0x239A
feather52840.pid.1=0x0029
feather52840.vid.2=0x239A
feather52840.pid.2=0x002A
feather52840.vid.3=0x239A
feather52840.pid.3=0x802A
# Upload
feather52840.bootloader.tool=bootburn
feather52840.upload.tool=nrfutil
feather52840.upload.protocol=nrfutil
feather52840.upload.use_1200bps_touch=true
feather52840.upload.wait_for_upload_port=true
feather52840.upload.maximum_size=815104
feather52840.upload.maximum_data_size=237568
# Build
feather52840.build.mcu=cortex-m4
feather52840.build.f_cpu=64000000
feather52840.build.board=NRF52840_FEATHER
feather52840.build.core=nRF5
feather52840.build.variant=feather_nrf52840_express
feather52840.build.usb_manufacturer="Adafruit"
feather52840.build.usb_product="Feather nRF52840 Express"
feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
feather52840.build.ldscript=nrf52840_s140_v6.ld
feather52840.build.vid=0x239A
feather52840.build.pid=0x8029
# SoftDevice Menu
feather52840.menu.softdevice.s140v6=S140 6.1.1
feather52840.menu.softdevice.s140v6.build.sd_name=s140
feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1
feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
feather52840.menu.debug.l0=Level 0 (Release)
feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
feather52840.menu.debug.l1=Level 1 (Error Message)
feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
feather52840.menu.debug.l2=Level 2 (Full Debug)
feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
feather52840.menu.debug.l3=Level 3 (Segger SystemView)
feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
feather52840.menu.debug_output.serial=Serial
feather52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
feather52840.menu.debug_output.serial1=Serial1
feather52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
feather52840.menu.debug_output.rtt=Segger RTT
feather52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Adafruit Feather nRF52840 Sense
# -----------------------------------
feather52840sense.name=Adafruit Feather nRF52840 Sense
# VID/PID for Bootloader, Arduino & CircuitPython
feather52840sense.vid.0=0x239A
feather52840sense.pid.0=0x8087
feather52840sense.vid.1=0x239A
feather52840sense.pid.1=0x0087
feather52840sense.vid.2=0x239A
feather52840sense.pid.2=0x0088
feather52840sense.vid.3=0x239A
feather52840sense.pid.3=0x8088
# Upload
feather52840sense.bootloader.tool=bootburn
feather52840sense.upload.tool=nrfutil
feather52840sense.upload.protocol=nrfutil
feather52840sense.upload.use_1200bps_touch=true
feather52840sense.upload.wait_for_upload_port=true
feather52840sense.upload.maximum_size=815104
feather52840sense.upload.maximum_data_size=237568
# Build
feather52840sense.build.mcu=cortex-m4
feather52840sense.build.f_cpu=64000000
feather52840sense.build.board=NRF52840_FEATHER_SENSE
feather52840sense.build.core=nRF5
feather52840sense.build.variant=feather_nrf52840_sense
feather52840sense.build.usb_manufacturer="Adafruit"
feather52840sense.build.usb_product="Feather nRF52840 Sense"
feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
feather52840sense.build.ldscript=nrf52840_s140_v6.ld
feather52840sense.build.vid=0x239A
feather52840sense.build.pid=0x8087
# SoftDevice Menu
feather52840sense.menu.softdevice.s140v6=S140 6.1.1
feather52840sense.menu.softdevice.s140v6.build.sd_name=s140
feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1
feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
feather52840sense.menu.debug.l0=Level 0 (Release)
feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
feather52840sense.menu.debug.l1=Level 1 (Error Message)
feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
feather52840sense.menu.debug.l2=Level 2 (Full Debug)
feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
feather52840sense.menu.debug.l3=Level 3 (Segger SystemView)
feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
feather52840sense.menu.debug_output.serial=Serial
feather52840sense.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
feather52840sense.menu.debug_output.serial1=Serial1
feather52840sense.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
feather52840sense.menu.debug_output.rtt=Segger RTT
feather52840sense.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Adafruit ItsyBitsy nRF52840 Express
# -----------------------------------
itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express
# VID/PID for Bootloader, Arduino & CircuitPython
itsybitsy52840.vid.0=0x239A
itsybitsy52840.pid.0=0x8051
itsybitsy52840.vid.1=0x239A
itsybitsy52840.pid.1=0x0051
itsybitsy52840.vid.2=0x239A
itsybitsy52840.pid.2=0x0052
itsybitsy52840.vid.3=0x239A
itsybitsy52840.pid.3=0x8052
# Upload
itsybitsy52840.bootloader.tool=bootburn
itsybitsy52840.upload.tool=nrfutil
itsybitsy52840.upload.protocol=nrfutil
itsybitsy52840.upload.use_1200bps_touch=true
itsybitsy52840.upload.wait_for_upload_port=true
itsybitsy52840.upload.maximum_size=815104
itsybitsy52840.upload.maximum_data_size=237568
# Build
itsybitsy52840.build.mcu=cortex-m4
itsybitsy52840.build.f_cpu=64000000
itsybitsy52840.build.board=NRF52840_ITSYBITSY
itsybitsy52840.build.core=nRF5
itsybitsy52840.build.variant=itsybitsy_nrf52840_express
itsybitsy52840.build.usb_manufacturer="Adafruit"
itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express"
itsybitsy52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld
itsybitsy52840.build.vid=0x239A
itsybitsy52840.build.pid=0x8051
# SoftDevice Menu
itsybitsy52840.menu.softdevice.s140v6=S140 6.1.1
itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140
itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1
itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
itsybitsy52840.menu.debug.l0=Level 0 (Release)
itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
itsybitsy52840.menu.debug.l1=Level 1 (Error Message)
itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
itsybitsy52840.menu.debug.l2=Level 2 (Full Debug)
itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView)
itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
itsybitsy52840.menu.debug_output.serial=Serial
itsybitsy52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
itsybitsy52840.menu.debug_output.serial1=Serial1
itsybitsy52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
itsybitsy52840.menu.debug_output.rtt=Segger RTT
itsybitsy52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Adafruit Circuit Playground Bluefruit
# -----------------------------------
cplaynrf52840.name=Adafruit Circuit Playground Bluefruit
# VID/PID for Bootloader, Arduino & CircuitPython
cplaynrf52840.vid.0=0x239A
cplaynrf52840.pid.0=0x8045
cplaynrf52840.vid.1=0x239A
cplaynrf52840.pid.1=0x0045
cplaynrf52840.vid.2=0x239A
cplaynrf52840.pid.2=0x8046
# Upload
cplaynrf52840.bootloader.tool=bootburn
cplaynrf52840.upload.tool=nrfutil
cplaynrf52840.upload.protocol=nrfutil
cplaynrf52840.upload.use_1200bps_touch=true
cplaynrf52840.upload.wait_for_upload_port=true
cplaynrf52840.upload.maximum_size=815104
cplaynrf52840.upload.maximum_data_size=237568
# Build
cplaynrf52840.build.mcu=cortex-m4
cplaynrf52840.build.f_cpu=64000000
cplaynrf52840.build.board=NRF52840_CIRCUITPLAY
cplaynrf52840.build.core=nRF5
cplaynrf52840.build.variant=circuitplayground_nrf52840
cplaynrf52840.build.usb_manufacturer="Adafruit"
cplaynrf52840.build.usb_product="Circuit Playground Bluefruit"
cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld
cplaynrf52840.build.vid=0x239A
cplaynrf52840.build.pid=0x8045
# SoftDevice Menu
cplaynrf52840.menu.softdevice.s140v6=S140 6.1.1
cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140
cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
cplaynrf52840.menu.debug.l0=Level 0 (Release)
cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
cplaynrf52840.menu.debug.l1=Level 1 (Error Message)
cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
cplaynrf52840.menu.debug.l2=Level 2 (Full Debug)
cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView)
cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
cplaynrf52840.menu.debug_output.serial=Serial
cplaynrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
cplaynrf52840.menu.debug_output.serial1=Serial1
cplaynrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
cplaynrf52840.menu.debug_output.rtt=Segger RTT
cplaynrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Adafruit CLUE
# -----------------------------------
cluenrf52840.name=Adafruit CLUE
# VID/PID for Bootloader, Arduino & CircuitPython
cluenrf52840.vid.0=0x239A
cluenrf52840.pid.0=0x8071
cluenrf52840.vid.1=0x239A
cluenrf52840.pid.1=0x0071
cluenrf52840.vid.2=0x239A
cluenrf52840.pid.2=0x8072
# Upload
cluenrf52840.bootloader.tool=bootburn
cluenrf52840.upload.tool=nrfutil
cluenrf52840.upload.protocol=nrfutil
cluenrf52840.upload.use_1200bps_touch=true
cluenrf52840.upload.wait_for_upload_port=true
cluenrf52840.upload.maximum_size=815104
cluenrf52840.upload.maximum_data_size=237568
# Build
cluenrf52840.build.mcu=cortex-m4
cluenrf52840.build.f_cpu=64000000
cluenrf52840.build.board=NRF52840_CLUE
cluenrf52840.build.core=nRF5
cluenrf52840.build.variant=clue_nrf52840
cluenrf52840.build.usb_manufacturer="Adafruit"
cluenrf52840.build.usb_product="CLUE"
cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
cluenrf52840.build.ldscript=nrf52840_s140_v6.ld
cluenrf52840.build.vid=0x239A
cluenrf52840.build.pid=0x8071
# SoftDevice Menu
cluenrf52840.menu.softdevice.s140v6=S140 6.1.1
cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140
cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
cluenrf52840.menu.debug.l0=Level 0 (Release)
cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
cluenrf52840.menu.debug.l1=Level 1 (Error Message)
cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
cluenrf52840.menu.debug.l2=Level 2 (Full Debug)
cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView)
cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
cluenrf52840.menu.debug_output.serial=Serial
cluenrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
cluenrf52840.menu.debug_output.serial1=Serial1
cluenrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
cluenrf52840.menu.debug_output.rtt=Segger RTT
cluenrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Adafruit LED Glasses Driver nRF52840
# -----------------------------------
ledglasses_nrf52840.name=Adafruit LED Glasses Driver nRF52840
# VID/PID for Bootloader, Arduino & CircuitPython
ledglasses_nrf52840.vid.0=0x239A
ledglasses_nrf52840.pid.0=0x810D
ledglasses_nrf52840.vid.1=0x239A
ledglasses_nrf52840.pid.1=0x010D
ledglasses_nrf52840.vid.2=0x239A
ledglasses_nrf52840.pid.2=0x810E
# Upload
ledglasses_nrf52840.bootloader.tool=bootburn
ledglasses_nrf52840.upload.tool=nrfutil
ledglasses_nrf52840.upload.protocol=nrfutil
ledglasses_nrf52840.upload.use_1200bps_touch=true
ledglasses_nrf52840.upload.wait_for_upload_port=true
ledglasses_nrf52840.upload.maximum_size=815104
ledglasses_nrf52840.upload.maximum_data_size=237568
# Build
ledglasses_nrf52840.build.mcu=cortex-m4
ledglasses_nrf52840.build.f_cpu=64000000
ledglasses_nrf52840.build.board=NRF52840_LED_GLASSES
ledglasses_nrf52840.build.core=nRF5
ledglasses_nrf52840.build.variant=ledglasses_nrf52840
ledglasses_nrf52840.build.usb_manufacturer="Adafruit"
ledglasses_nrf52840.build.usb_product="LED Glasses Driver nRF52840"
ledglasses_nrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
ledglasses_nrf52840.build.ldscript=nrf52840_s140_v6.ld
ledglasses_nrf52840.build.vid=0x239A
ledglasses_nrf52840.build.pid=0x810D
# SoftDevice Menu
ledglasses_nrf52840.menu.softdevice.s140v6=S140 6.1.1
ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_name=s140
ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
ledglasses_nrf52840.menu.debug.l0=Level 0 (Release)
ledglasses_nrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
ledglasses_nrf52840.menu.debug.l1=Level 1 (Error Message)
ledglasses_nrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
ledglasses_nrf52840.menu.debug.l2=Level 2 (Full Debug)
ledglasses_nrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
ledglasses_nrf52840.menu.debug.l3=Level 3 (Segger SystemView)
ledglasses_nrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
ledglasses_nrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
ledglasses_nrf52840.menu.debug_output.serial=Serial
ledglasses_nrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
ledglasses_nrf52840.menu.debug_output.serial1=Serial1
ledglasses_nrf52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
ledglasses_nrf52840.menu.debug_output.rtt=Segger RTT
ledglasses_nrf52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Raytac nRF52840 Dongle
# -----------------------------------
mdbt50qrx.name=Raytac nRF52840 Dongle
# VID/PID for Bootloader, Arduino & CircuitPython
mdbt50qrx.vid.0=0x239A
mdbt50qrx.pid.0=0x810B
mdbt50qrx.vid.1=0x239A
mdbt50qrx.pid.1=0x010B
mdbt50qrx.vid.2=0x239A
mdbt50qrx.pid.2=0x810C
# Upload
mdbt50qrx.bootloader.tool=bootburn
mdbt50qrx.upload.tool=nrfutil
mdbt50qrx.upload.protocol=nrfutil
mdbt50qrx.upload.use_1200bps_touch=true
mdbt50qrx.upload.wait_for_upload_port=true
mdbt50qrx.upload.maximum_size=815104
mdbt50qrx.upload.maximum_data_size=237568
# Build
mdbt50qrx.build.mcu=cortex-m4
mdbt50qrx.build.f_cpu=64000000
mdbt50qrx.build.board=MDBT50Q_RX
mdbt50qrx.build.core=nRF5
mdbt50qrx.build.variant=raytac_mdbt50q_rx
mdbt50qrx.build.usb_manufacturer="Raytac"
mdbt50qrx.build.usb_product="nRF52840 Dongle"
mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld
mdbt50qrx.build.vid=0x239A
mdbt50qrx.build.pid=0x810B
# SoftDevice Menu
mdbt50qrx.menu.softdevice.s140v6=S140 6.1.1
mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140
mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1
mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
mdbt50qrx.menu.debug.l0=Level 0 (Release)
mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
mdbt50qrx.menu.debug.l1=Level 1 (Error Message)
mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
mdbt50qrx.menu.debug.l2=Level 2 (Full Debug)
mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView)
mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
mdbt50qrx.menu.debug_output.serial=Serial
mdbt50qrx.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
mdbt50qrx.menu.debug_output.serial1=Serial1
mdbt50qrx.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
mdbt50qrx.menu.debug_output.rtt=Segger RTT
mdbt50qrx.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Adafruit Metro nRF52840 Express
# -----------------------------------
metro52840.name=Adafruit Metro nRF52840 Express
# VID/PID for Bootloader, Arduino & CircuitPython
metro52840.vid.0=0x239A
metro52840.pid.0=0x803F
metro52840.vid.1=0x239A
metro52840.pid.1=0x003F
metro52840.vid.2=0x239A
metro52840.pid.2=0x0040
metro52840.vid.3=0x239A
metro52840.pid.3=0x8040
# Upload
metro52840.bootloader.tool=bootburn
metro52840.upload.tool=nrfutil
metro52840.upload.protocol=nrfutil
metro52840.upload.use_1200bps_touch=true
metro52840.upload.wait_for_upload_port=true
metro52840.upload.maximum_size=815104
metro52840.upload.maximum_data_size=237568
# Build
metro52840.build.mcu=cortex-m4
metro52840.build.f_cpu=64000000
metro52840.build.board=NRF52840_METRO
metro52840.build.core=nRF5
metro52840.build.variant=metro_nrf52840_express
metro52840.build.usb_manufacturer="Adafruit"
metro52840.build.usb_product="Metro nRF52840 Express"
metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
metro52840.build.ldscript=nrf52840_s140_v6.ld
metro52840.build.vid=0x239A
metro52840.build.pid=0x803F
# SoftDevice Menu
metro52840.menu.softdevice.s140v6=S140 6.1.1
metro52840.menu.softdevice.s140v6.build.sd_name=s140
metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1
metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
metro52840.menu.debug.l0=Level 0 (Release)
metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
metro52840.menu.debug.l1=Level 1 (Error Message)
metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
metro52840.menu.debug.l2=Level 2 (Full Debug)
metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
metro52840.menu.debug.l3=Level 3 (Segger SystemView)
metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
metro52840.menu.debug_output.serial=Serial
metro52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
metro52840.menu.debug_output.serial1=Serial1
metro52840.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
metro52840.menu.debug_output.rtt=Segger RTT
metro52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -------------------------------------------------------
#
# Boards that aren't made by Adafruit
#
# -------------------------------------------------------
# -----------------------------------
# Nordic nRF52840 DK
# -----------------------------------
pca10056.name=Nordic nRF52840 DK
# VID/PID for Bootloader, Arduino & CircuitPython
pca10056.vid.0=0x239A
pca10056.pid.0=0x8029
pca10056.vid.1=0x239A
pca10056.pid.1=0x0029
# Upload
pca10056.bootloader.tool=bootburn
pca10056.upload.tool=nrfutil
pca10056.upload.protocol=nrfutil
pca10056.upload.use_1200bps_touch=true
pca10056.upload.wait_for_upload_port=true
pca10056.upload.maximum_size=815104
pca10056.upload.maximum_data_size=237568
# Build
pca10056.build.mcu=cortex-m4
pca10056.build.f_cpu=64000000
pca10056.build.board=NRF52840_PCA10056
pca10056.build.core=nRF5
pca10056.build.variant=pca10056
pca10056.build.usb_manufacturer="Nordic"
pca10056.build.usb_product="nRF52840 DK"
pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
pca10056.build.ldscript=nrf52840_s140_v6.ld
pca10056.build.vid=0x239A
pca10056.build.pid=0x8029
# SoftDevice Menu
pca10056.menu.softdevice.s140v6=S140 6.1.1
pca10056.menu.softdevice.s140v6.build.sd_name=s140
pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1
pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
pca10056.menu.debug.l0=Level 0 (Release)
pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
pca10056.menu.debug.l1=Level 1 (Error Message)
pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
pca10056.menu.debug.l2=Level 2 (Full Debug)
pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
pca10056.menu.debug.l3=Level 3 (Segger SystemView)
pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
pca10056.menu.debug_output.serial=Serial
pca10056.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
pca10056.menu.debug_output.serial1=Serial1
pca10056.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
pca10056.menu.debug_output.rtt=Segger RTT
pca10056.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# -----------------------------------
# Particle Xenon
# -----------------------------------
particle_xenon.name=Particle Xenon
# VID/PID for Bootloader, Arduino & CircuitPython
particle_xenon.vid.0=0x239A
particle_xenon.pid.0=0x8029
particle_xenon.vid.1=0x239A
particle_xenon.pid.1=0x0029
# Upload
particle_xenon.bootloader.tool=bootburn
particle_xenon.upload.tool=nrfutil
particle_xenon.upload.protocol=nrfutil
particle_xenon.upload.use_1200bps_touch=true
particle_xenon.upload.wait_for_upload_port=true
particle_xenon.upload.maximum_size=815104
particle_xenon.upload.maximum_data_size=237568
# Build
particle_xenon.build.mcu=cortex-m4
particle_xenon.build.f_cpu=64000000
particle_xenon.build.board=PARTICLE_XENON
particle_xenon.build.core=nRF5
particle_xenon.build.variant=particle_xenon
particle_xenon.build.usb_manufacturer="Particle"
particle_xenon.build.usb_product="Xenon"
particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
particle_xenon.build.ldscript=nrf52840_s140_v6.ld
particle_xenon.build.vid=0x239A
particle_xenon.build.pid=0x8029
# SoftDevice Menu
particle_xenon.menu.softdevice.s140v6=S140 6.1.1
particle_xenon.menu.softdevice.s140v6.build.sd_name=s140
particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1
particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
particle_xenon.menu.debug.l0=Level 0 (Release)
particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
particle_xenon.menu.debug.l1=Level 1 (Error Message)
particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
particle_xenon.menu.debug.l2=Level 2 (Full Debug)
particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
particle_xenon.menu.debug.l3=Level 3 (Segger SystemView)
particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# Debug Output Menu
particle_xenon.menu.debug_output.serial=Serial
particle_xenon.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
particle_xenon.menu.debug_output.serial1=Serial1
particle_xenon.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG
particle_xenon.menu.debug_output.rtt=Segger RTT
particle_xenon.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
# ----------------------------------
# NINA B302
# ----------------------------------
ninab302.name=NINA B302 ublox
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
ninab302.vid.0=0x239A
ninab302.pid.0=0x8029
ninab302.vid.1=0x239A
ninab302.pid.1=0x0029
ninab302.vid.2=0x7239A
ninab302.pid.2=0x002A
ninab302.vid.3=0x239A
ninab302.pid.3=0x802A
# Upload
ninab302.bootloader.tool=bootburn
ninab302.upload.tool=nrfutil
ninab302.upload.protocol=nrfutil
ninab302.upload.use_1200bps_touch=true
ninab302.upload.wait_for_upload_port=true
ninab302.upload.maximum_size=815104
ninab302.upload.maximum_data_size=237568
# Build
ninab302.build.mcu=cortex-m4
ninab302.build.f_cpu=64000000
ninab302.build.board=NINA_B302_ublox
ninab302.build.core=nRF5
ninab302.build.variant=NINA_B302_ublox
ninab302.build.usb_manufacturer="Nordic"
ninab302.build.usb_product="NINA B302 ublox"
ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb}
ninab302.build.ldscript=nrf52840_s140_v6.ld
ninab302.build.vid=0x239A
ninab302.build.pid=0x8029
# SofDevice Menu
ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
ninab302.menu.softdevice.s140v6.build.sd_name=s140
ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1
ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6
# Debug Menu
ninab302.menu.debug.l0=Level 0 (Release)
ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
ninab302.menu.debug.l1=Level 1 (Error Message)
ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
ninab302.menu.debug.l2=Level 2 (Full Debug)
ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
ninab302.menu.debug.l3=Level 3 (Segger SystemView)
ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
# ----------------------------------
# NINA B112
# ----------------------------------
ninab112.name=NINA B112 ublox
ninab112.bootloader.tool=bootburn
# Upload
ninab112.upload.tool=nrfutil
ninab112.upload.protocol=nrfutil
ninab112.upload.use_1200bps_touch=false
ninab112.upload.wait_for_upload_port=false
ninab112.upload.native_usb=false
ninab112.upload.maximum_size=290816
ninab112.upload.maximum_data_size=52224
# Build
ninab112.build.mcu=cortex-m4
ninab112.build.f_cpu=64000000
ninab112.build.board=NINA_B112_ublox
ninab112.build.core=nRF5
ninab112.build.variant=NINA_B112_ublox
feather52840.build.usb_manufacturer="Adafruit LLC"
feather52840.build.usb_product="Feather nRF52832"
ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52
ninab112.build.ldscript=nrf52832_s132_v6.ld
# SofDevice Menu
ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1
ninab112.menu.softdevice.s132v6.build.sd_name=s132
ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1
ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7
# Debug Menu
ninab112.menu.debug.l0=Level 0 (Release)
ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
ninab112.menu.debug.l1=Level 1 (Error Message)
ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
ninab112.menu.debug.l2=Level 2 (Full Debug)
ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
ninab112.menu.debug.l3=Level 3 (Segger SystemView)
ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
@@ -0,0 +1,420 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
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 <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
//using namespace arduino;
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(long long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printULLNumber(n, 10) + t;
}
return printULLNumber(n, 10);
} else {
return printULLNumber(n, base);
}
}
size_t Print::print(unsigned long long n, int base)
{
if (base == 0) return write(n);
else return printULLNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char * format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, 256, format, ap);
this->write(buf, len);
va_end(ap);
return len;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
// REFERENCE IMPLEMENTATION FOR ULL
// size_t Print::printULLNumber(unsigned long long n, uint8_t base)
// {
// // if limited to base 10 and 16 the bufsize can be smaller
// char buf[65];
// char *str = &buf[64];
// *str = '\0';
// // prevent crash if called with base == 1
// if (base < 2) base = 10;
// do {
// unsigned long long t = n / base;
// char c = n - t * base; // faster than c = n%base;
// n = t;
// *--str = c < 10 ? c + '0' : c + 'A' - 10;
// } while(n);
// return write(str);
// }
// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
// if limited to base 10 and 16 the bufsize can be 20
char buf[64];
uint8_t i = 0;
uint8_t innerLoops = 0;
// prevent crash if called with base == 1
if (base < 2) base = 10;
// process chunks that fit in "16 bit math".
uint16_t top = 0xFFFF / base;
uint16_t th16 = 1;
while (th16 < top)
{
th16 *= base;
innerLoops++;
}
while (n64 > th16)
{
// 64 bit math part
uint64_t q = n64 / th16;
uint16_t r = n64 - q*th16;
n64 = q;
// 16 bit math loop to do remainder. (note buffer is filled reverse)
for (uint8_t j=0; j < innerLoops; j++)
{
uint16_t qq = r/base;
buf[i++] = r - qq*base;
r = qq;
}
}
uint16_t n16 = n64;
while (n16 > 0)
{
uint16_t qq = n16/base;
buf[i++] = n16 - qq*base;
n16 = qq;
}
size_t bytes = i;
for (; i > 0; i--)
write((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
return bytes;
}
size_t Print::printFloat(double number, int digits)
{
if (digits < 0)
digits = 2;
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if ( i != 0 ) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[i]);
}
return (len*3 - 1);
}
size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if (i != 0) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[len-1-i]);
}
return (len*3 - 1);
}
@@ -0,0 +1,107 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
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
*/
#pragma once
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printULLNumber(unsigned long long, uint8_t);
size_t printFloat(double, int);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
size_t printf(const char * format, ...);
size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBuffer((uint8_t const*) buffer, size, delim, byteline);
}
size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
}
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
@@ -0,0 +1,92 @@
/*
* Udp.cpp: Library to send/receive UDP packets.
*
* NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these)
* 1) UDP does not guarantee the order in which assembled UDP packets are received. This
* might not happen often in practice, but in larger network topologies, a UDP
* packet can be received out of sequence.
* 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being
* aware of it. Again, this may not be a concern in practice on small local networks.
* For more information, see http://www.cafeaulait.org/course/week12/35.html
*
* MIT License:
* Copyright (c) 2008 Bjoern Hartmann
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* bjoern@cs.stanford.edu 12/30/2008
*/
#ifndef udp_h
#define udp_h
#include <Stream.h>
#include <IPAddress.h>
class UDP : public Stream {
public:
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
// KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.)
virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure
virtual void stop() =0; // Finish with the UDP socket
// Sending UDP packets
// Start building up a packet to send to the remote host specific in ip and port
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
virtual int beginPacket(IPAddress ip, uint16_t port) =0;
// Start building up a packet to send to the remote host specific in host and port
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
virtual int beginPacket(const char *host, uint16_t port) =0;
// Finish off this packet and send it
// Returns 1 if the packet was sent successfully, 0 if there was an error
virtual int endPacket() =0;
// Write a single byte into the packet
virtual size_t write(uint8_t) =0;
// Write size bytes from buffer into the packet
virtual size_t write(const uint8_t *buffer, size_t size) =0;
// Start processing the next available incoming packet
// Returns the size of the packet in bytes, or 0 if no packets are available
virtual int parsePacket() =0;
// Number of bytes remaining in the current packet
virtual int available() =0;
// Read a single byte from the current packet
virtual int read() =0;
// Read up to len bytes from the current packet and place them into buffer
// Returns the number of bytes read, or 0 if none are available
virtual int read(unsigned char* buffer, size_t len) =0;
// Read up to len characters from the current packet and place them into buffer
// Returns the number of characters read, or 0 if none are available
virtual int read(char* buffer, size_t len) =0;
// Return the next byte from the current packet without moving on to the next byte
virtual int peek() =0;
virtual void flush() =0; // Finish reading the current packet
// Return the IP address of the host who sent the current incoming packet
virtual IPAddress remoteIP() =0;
// Return the port of the host who sent the current incoming packet
virtual uint16_t remotePort() =0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};
#endif
@@ -0,0 +1,166 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
# Copyright (c) 2016 Sandeep Mistry All right reserved.
# Copyright (c) 2017 Adafruit Industries. All rights reserved.
#
# 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
name=Adafruit nRF52 Boards
version=1.3.0
# Compile variables
# -----------------
compiler.warning_flags=-Werror=return-type
compiler.warning_flags.none=-Werror=return-type
compiler.warning_flags.default=-Werror=return-type
compiler.warning_flags.more=-Wall -Werror=return-type
compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith
# Allow changing optimization settings via platform.local.txt / boards.local.txt
compiler.optimization_flag=-Ofast
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD
# KH, Error here to use gcc, must use g++
#compiler.c.elf.cmd=arm-none-eabi-gcc
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2bin.flags=-O binary
compiler.elf2bin.cmd=arm-none-eabi-objcopy
compiler.elf2hex.flags=-O ihex
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--wrap=malloc -Wl,--wrap=free --specs=nano.specs --specs=nosys.specs
compiler.size.cmd=arm-none-eabi-size
# this can be overriden in boards.txt
# Logger 0: Serial (CDC), 1 Serial1 (UART), 2 Segger RTT
build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float
build.debug_flags=-DCFG_DEBUG=0
build.logger_flags=-DCFG_LOGGER=0
build.sysview_flags=-DCFG_SYSVIEW=0
# USB flags
build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.libraries.ldflags=
compiler.elf2bin.extra_flags=
compiler.elf2hex.extra_flags=
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Include/"
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.7.0.path}/CMSIS/DSP/Lib/GCC/" -larm_cortexM4lf_math
# common compiler for nrf
rtos.path={build.core.path}/freertos
nordic.path={build.core.path}/nordic
build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} {compiler.arm.cmsis.c.flags} "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
# Compile patterns
# ----------------
## Compile c files
## KH Add '-DBOARD_NAME="{build.board}"'
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
## KH Add '-DBOARD_NAME="{build.board}"'
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
## Compile S files
## KH Add '-DBOARD_NAME="{build.board}"'
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} '-DBOARD_NAME="{build.board}"' -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group
## Create output (bin file)
#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Create output (hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
## Create dfu package zip file
recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip"
## Create uf2 file
#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex"
## Save bin
recipe.output.tmp_file_bin={build.project_name}.bin
recipe.output.save_file_bin={build.project_name}.save.bin
## Save hex
recipe.output.tmp_file_hex={build.project_name}.hex
recipe.output.save_file_hexu={build.project_name}.save.hex
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).*
## Export Compiled Binary
recipe.output.tmp_file={build.project_name}.hex
recipe.output.save_file={build.project_name}.{build.variant}.hex
#***************************************************
# adafruit-nrfutil for uploading
# https://github.com/adafruit/Adafruit_nRF52_nrfutil
# pre-built binaries are provided for macos and windows
#***************************************************
tools.nrfutil.cmd=adafruit-nrfutil
tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe
tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil
tools.nrfutil.upload.params.verbose=--verbose
tools.nrfutil.upload.params.quiet=
tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank
#***************************************************
# Burning bootloader with either jlink or nrfutil
#***************************************************
# Bootloader version
tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.2_{build.sd_name}_{build.sd_version}
tools.bootburn.bootloader.params.verbose=
tools.bootburn.bootloader.params.quiet=
tools.bootburn.bootloader.pattern={program.burn_pattern}
# erase flash page while programming
tools.bootburn.erase.params.verbose=
tools.bootburn.erase.params.quiet=
tools.bootburn.erase.pattern=
@@ -0,0 +1,17 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
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
*/
// API compatibility
#include "variant.h"
@@ -0,0 +1,59 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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 "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf
//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf
const uint32_t g_ADigitalPinMap[] = {
// D0 .. D13
5, // D0 is P0.05 (UART RX)
6, // D1 is P0.06 (UART TX)
7, // D2 is P0.07
31, // D3 is P0.31
18, // D4 is P0.18 (LED Blue)
99, // D5 (NC)
9, // D6 is P0.09 NFC1
10, // D7 is P0.10 (Button) NFC2
99, // D8 (NC)
8, // D9 is P0.08
11, // D10 is P0.11 CS
13, // D11 is P0.13 MOSI
12, // D12 is P0.12 MISO
14, // D13 is P0.14 SCK
//I2C
2, // D14 is P0.2 (SDA)
3, // D15 is P0.3 (SCL)
// D16 .. D21 (aka A0 .. A5)
3, // D16 is P0.03 (A0)
2, // D17 is P0.02 (A1)
4, // D18 is P0.04 (A2)
30, // D19 is P0.30 (A3) SW2
29, // D20 is P0.29 (A4)
28, // D21 is P0.28 (A5)
9, // P0.09 NFC
10, // P0.10 NFC
16, // SW1 (LED Green)
};
@@ -0,0 +1,172 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
//https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf
//https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf
#ifndef _VARIANT_NINA_B112_UBLOX_
#define _VARIANT_NINA_B112_UBLOX_
#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \
.rc_ctiv = 0, \
.rc_temp_ctiv = 0, \
.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
// define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (32u)
#define NUM_DIGITAL_PINS (32u)
#define NUM_ANALOG_INPUTS (6u)
#define NUM_ANALOG_OUTPUTS (0u)
// LEDs
#define PIN_LED LED1
#define LED_BUILTIN PIN_LED
//LEDs onboard
#define LED1 (0) // Red
#define LED2 (24) // Green/SW1
#define LED3 (4) // Blue
#define LED_STATE_ON 1 // State when LED is litted
//Switch
#define SW1 (24)
#define SW2 (19)
// NFC
#define PIN_NFC_1 (6) // P0.9
#define PIN_NFC_2 (7) // P0.10
/*
* Analog pins
*/
#define PIN_A0 (16) // P0.03
#define PIN_A1 (17) // P0.02
#define PIN_A2 (18) // P0.04
#define PIN_A3 (19) // P0.30
#define PIN_A4 (20) // P0.29
#define PIN_A5 (21) // P0.28
static const uint8_t A0 = PIN_A0 ;
static const uint8_t A1 = PIN_A1 ;
static const uint8_t A2 = PIN_A2 ;
static const uint8_t A3 = PIN_A3 ;
static const uint8_t A4 = PIN_A4 ;
static const uint8_t A5 = PIN_A5 ;
#define ADC_RESOLUTION 14
#define PIN_D0 (0) // P0.05
#define PIN_D1 (1) // P0.06
#define PIN_D2 (2) // P0.07
#define PIN_D3 (4) // P0.31
#define PIN_D4 (5) // P0.18
#define PIN_D6 (6) // P0.09
#define PIN_D7 (7) // P0.10
#define PIN_D9 (9) // P0.08
#define PIN_D10 (11) // P0.11
#define PIN_D11 (13) // P0.13
#define PIN_D12 (12) // P0.12
#define PIN_D13 (14) // P0.14
#define PIN_D14 (2) // P0.02
#define PIN_D15 (3) // P0.03
static const uint8_t D0 = PIN_D0 ;
static const uint8_t D1 = PIN_D1 ;
static const uint8_t D2 = PIN_D2 ;
static const uint8_t D3 = PIN_D3 ;
static const uint8_t D4 = PIN_D4 ;
static const uint8_t D6 = PIN_D6 ;
static const uint8_t D7 = PIN_D7 ;
static const uint8_t D9 = PIN_D9 ;
static const uint8_t D10 = PIN_D10 ;
static const uint8_t D11 = PIN_D11 ;
static const uint8_t D12 = PIN_D12 ;
static const uint8_t D13 = PIN_D13 ;
static const uint8_t D14 = PIN_D14 ;
static const uint8_t D15 = PIN_D15 ;
// Other pins
//static const uint8_t AREF = PIN_AREF;
//#define PIN_AREF (24)
//#define PIN_VBAT PIN_A7
/*
* Serial interfaces
*/
#define PIN_SERIAL_RX (0) // P0.05
#define PIN_SERIAL_TX (1) // P0.06
#define PIN_SERIAL_CTS (2) // P0.07
#define PIN_SERIAL_RTS (3) // P0.31
#define PIN_SERIAL_DTR (28) // P0.28
#define PIN_SERIAL_DSR (29) // P0.29
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (12) // P0.12
#define PIN_SPI_MOSI (11) // P0.13
#define PIN_SPI_SCK (13) // P0.14
static const uint8_t SS = 10 ; // P0.11
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK = PIN_SPI_SCK ;
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (14) // P0.02
#define PIN_WIRE_SCL (15) // P0.03
static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif //_VARIANT_NINA_B112_UBLOX_
@@ -0,0 +1,17 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
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
*/
// API compatibility
#include "variant.h"
@@ -0,0 +1,87 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip).
// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1)
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
const uint32_t g_ADigitalPinMap[] =
{
// D0 .. D13
29, // D0 is P0.29 (UART RX)
45, // D1 is P1.13 (UART TX)
44, // D2 is P1.12 (NFC2)
31, // D3 is P0.31 (LED1)
13, // D4 is P0.13 (LED2)
11, // D5 is P0.11
9, // D6 is P0.09
10, // D7 is P0.10 (Button)
41, // D8 is P1.09
12, // D9 is P0.12
14, // D10 is P0.14
15, // D11 is P0.15
32, // D12 is P1.00
7, // D13 is P0.07
// D14 .. D21 (aka A0 .. A5)
4, // D14 is P0.04 (A0)
30, // D15 is P0.30 (A1)
5, // D16 is P0.05 (A2)
2, // D17 is P0.02 (A3)
28, // D18 is P0.28 (A4)
3, // D19 is P0.03 (A5)
// D20 .. D21 (aka I2C pins)
16, // D20 is P0.16 (SDA)
24, // D21 is P0.24 (SCL)
// QSPI pins (not exposed via any header / test point)
19, // D22 is P0.19 (QSPI CLK)
17, // D23 is P0.17 (QSPI CS)
20, // D24 is P0.20 (QSPI Data 0)
21, // D25 is P0.21 (QSPI Data 1)
22, // D26 is P0.22 (QSPI Data 2)
26, // D27 is P0.23 (QSPI Data 3)
40, // D28 is P1.08 - IO34
41, // D29 is P1.01 - IO35
44, // D30 is P1.02 - IO36
45, // D31 is P1.03 - IO37
42, // D32 is P1.10 - IO38
43, // D33 is P1.11 - IO39
47, // D34 is P1.15 - IO40
46, // D35 is P1.14 - IO41
26, // D36 is P0.26 - IO42
6, // D37 is P0.6 - IO43
27, // D38 is P0.27 - IO44
};
void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
}
@@ -0,0 +1,149 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip).
// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1)
#ifndef _VARIANT_NINA_B302_UBLOX_
#define _VARIANT_NINA_B302_UBLOX_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
// define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (40)
#define NUM_DIGITAL_PINS (34)
#define NUM_ANALOG_INPUTS (6)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (3)
#define PIN_LED2 (4)
#define LED_BUILTIN PIN_LED1
#define LED_CONN PIN_LED2
#define LED_RED PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_STATE_ON 1 // State when LED is litted
/*
* Buttons
*/
#define PIN_BUTTON1 (7)
/*
* Analog pins
*/
#define PIN_A0 (14)
#define PIN_A1 (15)
#define PIN_A2 (16)
#define PIN_A3 (17)
#define PIN_A4 (18)
#define PIN_A5 (19)
#define D0 (0)
#define D1 (1)
#define D2 (2)
#define D3 (3)
#define D4 (4)
#define D5 (5)
#define D6 (6)
#define D7 (7)
#define D8 (8)
#define D9 (9)
#define D10 (10)
#define D11 (11)
#define D12 (12)
#define D13 (13)
static const uint8_t A0 = PIN_A0 ;
static const uint8_t A1 = PIN_A1 ;
static const uint8_t A2 = PIN_A2 ;
static const uint8_t A3 = PIN_A3 ;
static const uint8_t A4 = PIN_A4 ;
static const uint8_t A5 = PIN_A5 ;
#define ADC_RESOLUTION 14
#define PIN_NFC1 (31)
#define PIN_NFC2 (2)
/*
* Serial interfaces
*/
#define PIN_SERIAL1_RX (0)
#define PIN_SERIAL1_TX (1)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (22) //24 original
#define PIN_SPI_MOSI (23) //25 original
#define PIN_SPI_SCK (24) //26 original
static const uint8_t SS = (13);
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (20)
#define PIN_WIRE_SCL (21)
// QSPI Pins
#define PIN_QSPI_SCK 22
#define PIN_QSPI_CS 23
#define PIN_QSPI_IO0 24
#define PIN_QSPI_IO1 25
#define PIN_QSPI_IO2 26
#define PIN_QSPI_IO3 27
// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES GD25Q16C
#define EXTERNAL_FLASH_USE_QSPI
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif //_VARIANT_NINA_B302_UBLOX_
@@ -0,0 +1,420 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
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 <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
//using namespace arduino;
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(long long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printULLNumber(n, 10) + t;
}
return printULLNumber(n, 10);
} else {
return printULLNumber(n, base);
}
}
size_t Print::print(unsigned long long n, int base)
{
if (base == 0) return write(n);
else return printULLNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char * format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, 256, format, ap);
this->write(buf, len);
va_end(ap);
return len;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
// REFERENCE IMPLEMENTATION FOR ULL
// size_t Print::printULLNumber(unsigned long long n, uint8_t base)
// {
// // if limited to base 10 and 16 the bufsize can be smaller
// char buf[65];
// char *str = &buf[64];
// *str = '\0';
// // prevent crash if called with base == 1
// if (base < 2) base = 10;
// do {
// unsigned long long t = n / base;
// char c = n - t * base; // faster than c = n%base;
// n = t;
// *--str = c < 10 ? c + '0' : c + 'A' - 10;
// } while(n);
// return write(str);
// }
// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
// if limited to base 10 and 16 the bufsize can be 20
char buf[64];
uint8_t i = 0;
uint8_t innerLoops = 0;
// prevent crash if called with base == 1
if (base < 2) base = 10;
// process chunks that fit in "16 bit math".
uint16_t top = 0xFFFF / base;
uint16_t th16 = 1;
while (th16 < top)
{
th16 *= base;
innerLoops++;
}
while (n64 > th16)
{
// 64 bit math part
uint64_t q = n64 / th16;
uint16_t r = n64 - q*th16;
n64 = q;
// 16 bit math loop to do remainder. (note buffer is filled reverse)
for (uint8_t j=0; j < innerLoops; j++)
{
uint16_t qq = r/base;
buf[i++] = r - qq*base;
r = qq;
}
}
uint16_t n16 = n64;
while (n16 > 0)
{
uint16_t qq = n16/base;
buf[i++] = n16 - qq*base;
n16 = qq;
}
size_t bytes = i;
for (; i > 0; i--)
write((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
return bytes;
}
size_t Print::printFloat(double number, int digits)
{
if (digits < 0)
digits = 2;
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if ( i != 0 ) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[i]);
}
return (len*3 - 1);
}
size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if (i != 0) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[len-1-i]);
}
return (len*3 - 1);
}
@@ -0,0 +1,107 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
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
*/
#pragma once
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printULLNumber(unsigned long long, uint8_t);
size_t printFloat(double, int);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
size_t printf(const char * format, ...);
size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBuffer((uint8_t const*) buffer, size, delim, byteline);
}
size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
}
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
@@ -0,0 +1,226 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# 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
# Arduino SAMD Core and platform.
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
version=1.7.10
# Compile variables
# -----------------
compiler.warning_flags=-Werror=return-type
compiler.warning_flags.none=-Werror=return-type
compiler.warning_flags.default=-Werror=return-type
compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.bin.flags=-O binary
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
compiler.readelf.cmd=arm-none-eabi-readelf
# this can be overriden in boards.txt
build.extra_flags=
build.cache_flags=
build.flags.optimize=
build.flags.maxspi=
build.flags.maxqspi=
build.flags.usbstack=
build.flags.debug=
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
#compiler.c.elf.extra_flags=-v
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/"
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
compiler.libraries.ldflags=
# USB Flags
# ---------
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
# Default advertised device power setting in mA
build.usb_power=100
# Default usb manufacturer will be replaced at compile time using
# numeric vendor ID if available or by board's specific value.
build.usb_manufacturer="Unknown"
# Compile patterns
# ----------------
## Compile c files
## KH Add -DBOARD_NAME="{build.board}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
## KH Add -DBOARD_NAME="{build.board}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
## KH Add -DBOARD_NAME="{build.board}"
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
## Create output (bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Create output (hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
build.preferred_out_format=bin
## Save hex
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=\.text\s+([0-9]+).*
#
# BOSSA
#
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossac.cmd=bossac
tools.bossac.cmd.windows=bossac.exe
tools.bossac.upload.params.verbose=-i -d
tools.bossac.upload.params.quiet=
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# v1.8.0
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
tools.bossac18.cmd=bossac
tools.bossac18.upload.params.verbose=-i -d
tools.bossac18.upload.params.quiet=
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# BOSSA (ignore binary size)
#
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossacI.cmd=bossac
tools.bossacI.cmd.windows=bossac.exe
tools.bossacI.upload.params.verbose=-i -d
tools.bossacI.upload.params.quiet=
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# OpenOCD sketch upload
#
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd.cmd=bin/openocd
tools.openocd.cmd.windows=bin/openocd.exe
tools.openocd.upload.params.verbose=-d2
tools.openocd.upload.params.quiet=-d0
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd.program.params.verbose=-d2
tools.openocd.program.params.quiet=-d0
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd.erase.params.verbose=-d3
tools.openocd.erase.params.quiet=-d0
tools.openocd.erase.pattern=
tools.openocd.bootloader.params.verbose=-d2
tools.openocd.bootloader.params.quiet=-d0
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
#
# OpenOCD sketch upload - version with configurable bootloader size
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
#
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd-withbootsize.cmd=bin/openocd
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
tools.openocd-withbootsize.upload.params.verbose=-d2
tools.openocd-withbootsize.upload.params.quiet=-d0
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd-withbootsize.program.params.verbose=-d2
tools.openocd-withbootsize.program.params.quiet=-d0
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd-withbootsize.erase.params.verbose=-d3
tools.openocd-withbootsize.erase.params.quiet=-d0
tools.openocd-withbootsize.erase.pattern=
tools.openocd-withbootsize.bootloader.params.verbose=-d2
tools.openocd-withbootsize.bootloader.params.quiet=-d0
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
@@ -0,0 +1,420 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
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 <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
//using namespace arduino;
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(long long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printULLNumber(n, 10) + t;
}
return printULLNumber(n, 10);
} else {
return printULLNumber(n, base);
}
}
size_t Print::print(unsigned long long n, int base)
{
if (base == 0) return write(n);
else return printULLNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char * format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, 256, format, ap);
this->write(buf, len);
va_end(ap);
return len;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
// REFERENCE IMPLEMENTATION FOR ULL
// size_t Print::printULLNumber(unsigned long long n, uint8_t base)
// {
// // if limited to base 10 and 16 the bufsize can be smaller
// char buf[65];
// char *str = &buf[64];
// *str = '\0';
// // prevent crash if called with base == 1
// if (base < 2) base = 10;
// do {
// unsigned long long t = n / base;
// char c = n - t * base; // faster than c = n%base;
// n = t;
// *--str = c < 10 ? c + '0' : c + 'A' - 10;
// } while(n);
// return write(str);
// }
// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
// if limited to base 10 and 16 the bufsize can be 20
char buf[64];
uint8_t i = 0;
uint8_t innerLoops = 0;
// prevent crash if called with base == 1
if (base < 2) base = 10;
// process chunks that fit in "16 bit math".
uint16_t top = 0xFFFF / base;
uint16_t th16 = 1;
while (th16 < top)
{
th16 *= base;
innerLoops++;
}
while (n64 > th16)
{
// 64 bit math part
uint64_t q = n64 / th16;
uint16_t r = n64 - q*th16;
n64 = q;
// 16 bit math loop to do remainder. (note buffer is filled reverse)
for (uint8_t j=0; j < innerLoops; j++)
{
uint16_t qq = r/base;
buf[i++] = r - qq*base;
r = qq;
}
}
uint16_t n16 = n64;
while (n16 > 0)
{
uint16_t qq = n16/base;
buf[i++] = n16 - qq*base;
n16 = qq;
}
size_t bytes = i;
for (; i > 0; i--)
write((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
return bytes;
}
size_t Print::printFloat(double number, int digits)
{
if (digits < 0)
digits = 2;
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if ( i != 0 ) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[i]);
}
return (len*3 - 1);
}
size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if (i != 0) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[len-1-i]);
}
return (len*3 - 1);
}
@@ -0,0 +1,107 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
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
*/
#pragma once
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printULLNumber(unsigned long long, uint8_t);
size_t printFloat(double, int);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
size_t printf(const char * format, ...);
size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBuffer((uint8_t const*) buffer, size, delim, byteline);
}
size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
}
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
@@ -0,0 +1,226 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# 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
# Arduino SAMD Core and platform.
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
version=1.7.6
# Compile variables
# -----------------
compiler.warning_flags=-Werror=return-type
compiler.warning_flags.none=-Werror=return-type
compiler.warning_flags.default=-Werror=return-type
compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.bin.flags=-O binary
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
compiler.readelf.cmd=arm-none-eabi-readelf
# this can be overriden in boards.txt
build.extra_flags=
build.cache_flags=
build.flags.optimize=
build.flags.maxspi=
build.flags.maxqspi=
build.flags.usbstack=
build.flags.debug=
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
#compiler.c.elf.extra_flags=-v
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/"
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
compiler.libraries.ldflags=
# USB Flags
# ---------
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
# Default advertised device power setting in mA
build.usb_power=100
# Default usb manufacturer will be replaced at compile time using
# numeric vendor ID if available or by board's specific value.
build.usb_manufacturer="Unknown"
# Compile patterns
# ----------------
## Compile c files
## KH Add -DBOARD_NAME="{build.board}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
## KH Add -DBOARD_NAME="{build.board}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
## KH Add -DBOARD_NAME="{build.board}"
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
## Create output (bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Create output (hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
build.preferred_out_format=bin
## Save hex
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=\.text\s+([0-9]+).*
#
# BOSSA
#
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossac.cmd=bossac
tools.bossac.cmd.windows=bossac.exe
tools.bossac.upload.params.verbose=-i -d
tools.bossac.upload.params.quiet=
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# v1.8.0
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
tools.bossac18.cmd=bossac
tools.bossac18.upload.params.verbose=-i -d
tools.bossac18.upload.params.quiet=
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# BOSSA (ignore binary size)
#
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossacI.cmd=bossac
tools.bossacI.cmd.windows=bossac.exe
tools.bossacI.upload.params.verbose=-i -d
tools.bossacI.upload.params.quiet=
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# OpenOCD sketch upload
#
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd.cmd=bin/openocd
tools.openocd.cmd.windows=bin/openocd.exe
tools.openocd.upload.params.verbose=-d2
tools.openocd.upload.params.quiet=-d0
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd.program.params.verbose=-d2
tools.openocd.program.params.quiet=-d0
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd.erase.params.verbose=-d3
tools.openocd.erase.params.quiet=-d0
tools.openocd.erase.pattern=
tools.openocd.bootloader.params.verbose=-d2
tools.openocd.bootloader.params.quiet=-d0
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
#
# OpenOCD sketch upload - version with configurable bootloader size
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
#
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd-withbootsize.cmd=bin/openocd
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
tools.openocd-withbootsize.upload.params.verbose=-d2
tools.openocd-withbootsize.upload.params.quiet=-d0
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd-withbootsize.program.params.verbose=-d2
tools.openocd-withbootsize.program.params.quiet=-d0
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd-withbootsize.erase.params.verbose=-d3
tools.openocd-withbootsize.erase.params.quiet=-d0
tools.openocd-withbootsize.erase.pattern=
tools.openocd-withbootsize.bootloader.params.verbose=-d2
tools.openocd-withbootsize.bootloader.params.quiet=-d0
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
@@ -0,0 +1,420 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
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 <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
//using namespace arduino;
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(long long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printULLNumber(n, 10) + t;
}
return printULLNumber(n, 10);
} else {
return printULLNumber(n, base);
}
}
size_t Print::print(unsigned long long n, int base)
{
if (base == 0) return write(n);
else return printULLNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char * format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, 256, format, ap);
this->write(buf, len);
va_end(ap);
return len;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
// REFERENCE IMPLEMENTATION FOR ULL
// size_t Print::printULLNumber(unsigned long long n, uint8_t base)
// {
// // if limited to base 10 and 16 the bufsize can be smaller
// char buf[65];
// char *str = &buf[64];
// *str = '\0';
// // prevent crash if called with base == 1
// if (base < 2) base = 10;
// do {
// unsigned long long t = n / base;
// char c = n - t * base; // faster than c = n%base;
// n = t;
// *--str = c < 10 ? c + '0' : c + 'A' - 10;
// } while(n);
// return write(str);
// }
// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
// if limited to base 10 and 16 the bufsize can be 20
char buf[64];
uint8_t i = 0;
uint8_t innerLoops = 0;
// prevent crash if called with base == 1
if (base < 2) base = 10;
// process chunks that fit in "16 bit math".
uint16_t top = 0xFFFF / base;
uint16_t th16 = 1;
while (th16 < top)
{
th16 *= base;
innerLoops++;
}
while (n64 > th16)
{
// 64 bit math part
uint64_t q = n64 / th16;
uint16_t r = n64 - q*th16;
n64 = q;
// 16 bit math loop to do remainder. (note buffer is filled reverse)
for (uint8_t j=0; j < innerLoops; j++)
{
uint16_t qq = r/base;
buf[i++] = r - qq*base;
r = qq;
}
}
uint16_t n16 = n64;
while (n16 > 0)
{
uint16_t qq = n16/base;
buf[i++] = n16 - qq*base;
n16 = qq;
}
size_t bytes = i;
for (; i > 0; i--)
write((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
return bytes;
}
size_t Print::printFloat(double number, int digits)
{
if (digits < 0)
digits = 2;
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if ( i != 0 ) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[i]);
}
return (len*3 - 1);
}
size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if (i != 0) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[len-1-i]);
}
return (len*3 - 1);
}
@@ -0,0 +1,107 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
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
*/
#pragma once
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printULLNumber(unsigned long long, uint8_t);
size_t printFloat(double, int);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
size_t printf(const char * format, ...);
size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBuffer((uint8_t const*) buffer, size, delim, byteline);
}
size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
}
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
@@ -0,0 +1,226 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# 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
# Arduino SAMD Core and platform.
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
version=1.7.7
# Compile variables
# -----------------
compiler.warning_flags=-Werror=return-type
compiler.warning_flags.none=-Werror=return-type
compiler.warning_flags.default=-Werror=return-type
compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.bin.flags=-O binary
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
compiler.readelf.cmd=arm-none-eabi-readelf
# this can be overriden in boards.txt
build.extra_flags=
build.cache_flags=
build.flags.optimize=
build.flags.maxspi=
build.flags.maxqspi=
build.flags.usbstack=
build.flags.debug=
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
#compiler.c.elf.extra_flags=-v
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/"
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
compiler.libraries.ldflags=
# USB Flags
# ---------
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
# Default advertised device power setting in mA
build.usb_power=100
# Default usb manufacturer will be replaced at compile time using
# numeric vendor ID if available or by board's specific value.
build.usb_manufacturer="Unknown"
# Compile patterns
# ----------------
## Compile c files
## KH Add -DBOARD_NAME="{build.board}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
## KH Add -DBOARD_NAME="{build.board}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
## KH Add -DBOARD_NAME="{build.board}"
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
## Create output (bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Create output (hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
build.preferred_out_format=bin
## Save hex
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=\.text\s+([0-9]+).*
#
# BOSSA
#
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossac.cmd=bossac
tools.bossac.cmd.windows=bossac.exe
tools.bossac.upload.params.verbose=-i -d
tools.bossac.upload.params.quiet=
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# v1.8.0
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
tools.bossac18.cmd=bossac
tools.bossac18.upload.params.verbose=-i -d
tools.bossac18.upload.params.quiet=
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# BOSSA (ignore binary size)
#
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossacI.cmd=bossac
tools.bossacI.cmd.windows=bossac.exe
tools.bossacI.upload.params.verbose=-i -d
tools.bossacI.upload.params.quiet=
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# OpenOCD sketch upload
#
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd.cmd=bin/openocd
tools.openocd.cmd.windows=bin/openocd.exe
tools.openocd.upload.params.verbose=-d2
tools.openocd.upload.params.quiet=-d0
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd.program.params.verbose=-d2
tools.openocd.program.params.quiet=-d0
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd.erase.params.verbose=-d3
tools.openocd.erase.params.quiet=-d0
tools.openocd.erase.pattern=
tools.openocd.bootloader.params.verbose=-d2
tools.openocd.bootloader.params.quiet=-d0
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
#
# OpenOCD sketch upload - version with configurable bootloader size
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
#
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd-withbootsize.cmd=bin/openocd
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
tools.openocd-withbootsize.upload.params.verbose=-d2
tools.openocd-withbootsize.upload.params.quiet=-d0
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd-withbootsize.program.params.verbose=-d2
tools.openocd-withbootsize.program.params.quiet=-d0
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd-withbootsize.erase.params.verbose=-d3
tools.openocd-withbootsize.erase.params.quiet=-d0
tools.openocd-withbootsize.erase.pattern=
tools.openocd-withbootsize.bootloader.params.verbose=-d2
tools.openocd-withbootsize.bootloader.params.quiet=-d0
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
@@ -0,0 +1,420 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
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 <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
//using namespace arduino;
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(long long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printULLNumber(n, 10) + t;
}
return printULLNumber(n, 10);
} else {
return printULLNumber(n, base);
}
}
size_t Print::print(unsigned long long n, int base)
{
if (base == 0) return write(n);
else return printULLNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char * format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, 256, format, ap);
this->write(buf, len);
va_end(ap);
return len;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
// REFERENCE IMPLEMENTATION FOR ULL
// size_t Print::printULLNumber(unsigned long long n, uint8_t base)
// {
// // if limited to base 10 and 16 the bufsize can be smaller
// char buf[65];
// char *str = &buf[64];
// *str = '\0';
// // prevent crash if called with base == 1
// if (base < 2) base = 10;
// do {
// unsigned long long t = n / base;
// char c = n - t * base; // faster than c = n%base;
// n = t;
// *--str = c < 10 ? c + '0' : c + 'A' - 10;
// } while(n);
// return write(str);
// }
// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
// if limited to base 10 and 16 the bufsize can be 20
char buf[64];
uint8_t i = 0;
uint8_t innerLoops = 0;
// prevent crash if called with base == 1
if (base < 2) base = 10;
// process chunks that fit in "16 bit math".
uint16_t top = 0xFFFF / base;
uint16_t th16 = 1;
while (th16 < top)
{
th16 *= base;
innerLoops++;
}
while (n64 > th16)
{
// 64 bit math part
uint64_t q = n64 / th16;
uint16_t r = n64 - q*th16;
n64 = q;
// 16 bit math loop to do remainder. (note buffer is filled reverse)
for (uint8_t j=0; j < innerLoops; j++)
{
uint16_t qq = r/base;
buf[i++] = r - qq*base;
r = qq;
}
}
uint16_t n16 = n64;
while (n16 > 0)
{
uint16_t qq = n16/base;
buf[i++] = n16 - qq*base;
n16 = qq;
}
size_t bytes = i;
for (; i > 0; i--)
write((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
return bytes;
}
size_t Print::printFloat(double number, int digits)
{
if (digits < 0)
digits = 2;
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if ( i != 0 ) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[i]);
}
return (len*3 - 1);
}
size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if (i != 0) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[len-1-i]);
}
return (len*3 - 1);
}
@@ -0,0 +1,107 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
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
*/
#pragma once
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printULLNumber(unsigned long long, uint8_t);
size_t printFloat(double, int);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
size_t printf(const char * format, ...);
size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBuffer((uint8_t const*) buffer, size, delim, byteline);
}
size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
}
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
@@ -0,0 +1,238 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# 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
# Arduino SAMD Core and platform.
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
version=1.7.8
# Compile variables
# -----------------
compiler.warning_flags=-Werror=return-type
compiler.warning_flags.none=-Werror=return-type
compiler.warning_flags.default=-Werror=return-type
compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.bin.flags=-O binary
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
compiler.readelf.cmd=arm-none-eabi-readelf
# this can be overriden in boards.txt
build.extra_flags=
build.cache_flags=
build.flags.optimize=
build.flags.maxspi=
build.flags.maxqspi=
build.flags.usbstack=
build.flags.debug=
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
#compiler.c.elf.extra_flags=-v
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/"
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
compiler.libraries.ldflags=
# USB Flags
# ---------
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
# Default advertised device power setting in mA
build.usb_power=100
# Default usb manufacturer will be replaced at compile time using
# numeric vendor ID if available or by board's specific value.
build.usb_manufacturer="Unknown"
# Compile patterns
# ----------------
## Compile c files
## KH Add -DBOARD_NAME="{build.board}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
## KH Add -DBOARD_NAME="{build.board}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
## KH Add -DBOARD_NAME="{build.board}"
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
## Create output (bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Create output (hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
build.preferred_out_format=bin
## Save hex
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=\.text\s+([0-9]+).*
#
# BOSSA
#
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossac.cmd=bossac
tools.bossac.cmd.windows=bossac.exe
tools.bossac.upload.params.verbose=-i -d
tools.bossac.upload.params.quiet=
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# v1.8.0
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
tools.bossac18.cmd=bossac
tools.bossac18.upload.params.verbose=-i -d
tools.bossac18.upload.params.quiet=
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# v1.9.1
tools.bossac19.path={runtime.tools.bossac-1.9.1-arduino2.path}
tools.bossac19.cmd=bossac
tools.bossac19.upload.params.verbose=-i -d
tools.bossac19.upload.params.quiet=
tools.bossac19.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac19.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac19.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# BOSSA (ignore binary size)
#
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossacI.cmd=bossac
tools.bossacI.cmd.windows=bossac.exe
tools.bossacI.upload.params.verbose=-i -d
tools.bossacI.upload.params.quiet=
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# OpenOCD sketch upload
#
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd.cmd=bin/openocd
tools.openocd.cmd.windows=bin/openocd.exe
tools.openocd.upload.params.verbose=-d2
tools.openocd.upload.params.quiet=-d0
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd.program.params.verbose=-d2
tools.openocd.program.params.quiet=-d0
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd.erase.params.verbose=-d3
tools.openocd.erase.params.quiet=-d0
tools.openocd.erase.pattern=
tools.openocd.bootloader.params.verbose=-d2
tools.openocd.bootloader.params.quiet=-d0
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
#
# OpenOCD sketch upload - version with configurable bootloader size
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
#
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd-withbootsize.cmd=bin/openocd
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
tools.openocd-withbootsize.upload.params.verbose=-d2
tools.openocd-withbootsize.upload.params.quiet=-d0
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd-withbootsize.program.params.verbose=-d2
tools.openocd-withbootsize.program.params.quiet=-d0
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd-withbootsize.erase.params.verbose=-d3
tools.openocd-withbootsize.erase.params.quiet=-d0
tools.openocd-withbootsize.erase.pattern=
tools.openocd-withbootsize.bootloader.params.verbose=-d2
tools.openocd-withbootsize.bootloader.params.quiet=-d0
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
@@ -0,0 +1,420 @@
/*
Copyright (c) 2014 Arduino. All right reserved.
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 <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
//using namespace arduino;
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(long long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printULLNumber(n, 10) + t;
}
return printULLNumber(n, 10);
} else {
return printULLNumber(n, base);
}
}
size_t Print::print(unsigned long long n, int base)
{
if (base == 0) return write(n);
else return printULLNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char * format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, 256, format, ap);
this->write(buf, len);
va_end(ap);
return len;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
// REFERENCE IMPLEMENTATION FOR ULL
// size_t Print::printULLNumber(unsigned long long n, uint8_t base)
// {
// // if limited to base 10 and 16 the bufsize can be smaller
// char buf[65];
// char *str = &buf[64];
// *str = '\0';
// // prevent crash if called with base == 1
// if (base < 2) base = 10;
// do {
// unsigned long long t = n / base;
// char c = n - t * base; // faster than c = n%base;
// n = t;
// *--str = c < 10 ? c + '0' : c + 'A' - 10;
// } while(n);
// return write(str);
// }
// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
// if limited to base 10 and 16 the bufsize can be 20
char buf[64];
uint8_t i = 0;
uint8_t innerLoops = 0;
// prevent crash if called with base == 1
if (base < 2) base = 10;
// process chunks that fit in "16 bit math".
uint16_t top = 0xFFFF / base;
uint16_t th16 = 1;
while (th16 < top)
{
th16 *= base;
innerLoops++;
}
while (n64 > th16)
{
// 64 bit math part
uint64_t q = n64 / th16;
uint16_t r = n64 - q*th16;
n64 = q;
// 16 bit math loop to do remainder. (note buffer is filled reverse)
for (uint8_t j=0; j < innerLoops; j++)
{
uint16_t qq = r/base;
buf[i++] = r - qq*base;
r = qq;
}
}
uint16_t n16 = n64;
while (n16 > 0)
{
uint16_t qq = n16/base;
buf[i++] = n16 - qq*base;
n16 = qq;
}
size_t bytes = i;
for (; i > 0; i--)
write((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
return bytes;
}
size_t Print::printFloat(double number, int digits)
{
if (digits < 0)
digits = 2;
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if ( i != 0 ) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[i]);
}
return (len*3 - 1);
}
size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline)
{
if (buffer == NULL || len == 0) return 0;
for(int i=0; i<len; i++)
{
if (i != 0) print(delim);
if ( byteline && (i%byteline == 0) ) println();
this->printf("%02X", buffer[len-1-i]);
}
return (len*3 - 1);
}
@@ -0,0 +1,107 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
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
*/
#pragma once
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printULLNumber(unsigned long long, uint8_t);
size_t printFloat(double, int);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
size_t printf(const char * format, ...);
size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBuffer((uint8_t const*) buffer, size, delim, byteline);
}
size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0);
size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0)
{
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline);
}
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
@@ -0,0 +1,238 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# 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
# Arduino SAMD Core and platform.
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
version=1.7.9
# Compile variables
# -----------------
compiler.warning_flags=-Werror=return-type
compiler.warning_flags.none=-Werror=return-type
compiler.warning_flags.default=-Werror=return-type
compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.bin.flags=-O binary
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
compiler.readelf.cmd=arm-none-eabi-readelf
# this can be overriden in boards.txt
build.extra_flags=
build.cache_flags=
build.flags.optimize=
build.flags.maxspi=
build.flags.maxqspi=
build.flags.usbstack=
build.flags.debug=
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
#compiler.c.elf.extra_flags=-v
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/"
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
compiler.libraries.ldflags=
# USB Flags
# ---------
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
# Default advertised device power setting in mA
build.usb_power=100
# Default usb manufacturer will be replaced at compile time using
# numeric vendor ID if available or by board's specific value.
build.usb_manufacturer="Unknown"
# Compile patterns
# ----------------
## Compile c files
## KH Add -DBOARD_NAME="{build.board}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
## KH Add -DBOARD_NAME="{build.board}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
## KH Add -DBOARD_NAME="{build.board}"
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
## Create output (bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Create output (hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
build.preferred_out_format=bin
## Save hex
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=\.text\s+([0-9]+).*
#
# BOSSA
#
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossac.cmd=bossac
tools.bossac.cmd.windows=bossac.exe
tools.bossac.upload.params.verbose=-i -d
tools.bossac.upload.params.quiet=
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# v1.8.0
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
tools.bossac18.cmd=bossac
tools.bossac18.upload.params.verbose=-i -d
tools.bossac18.upload.params.quiet=
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# v1.9.1
tools.bossac19.path={runtime.tools.bossac-1.9.1-arduino2.path}
tools.bossac19.cmd=bossac
tools.bossac19.upload.params.verbose=-i -d
tools.bossac19.upload.params.quiet=
tools.bossac19.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac19.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac19.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# BOSSA (ignore binary size)
#
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossacI.cmd=bossac
tools.bossacI.cmd.windows=bossac.exe
tools.bossacI.upload.params.verbose=-i -d
tools.bossacI.upload.params.quiet=
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# OpenOCD sketch upload
#
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd.cmd=bin/openocd
tools.openocd.cmd.windows=bin/openocd.exe
tools.openocd.upload.params.verbose=-d2
tools.openocd.upload.params.quiet=-d0
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd.program.params.verbose=-d2
tools.openocd.program.params.quiet=-d0
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd.erase.params.verbose=-d3
tools.openocd.erase.params.quiet=-d0
tools.openocd.erase.pattern=
tools.openocd.bootloader.params.verbose=-d2
tools.openocd.bootloader.params.quiet=-d0
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
#
# OpenOCD sketch upload - version with configurable bootloader size
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
#
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd-withbootsize.cmd=bin/openocd
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
tools.openocd-withbootsize.upload.params.verbose=-d2
tools.openocd-withbootsize.upload.params.quiet=-d0
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd-withbootsize.program.params.verbose=-d2
tools.openocd-withbootsize.program.params.quiet=-d0
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd-withbootsize.erase.params.verbose=-d3
tools.openocd-withbootsize.erase.params.quiet=-d0
tools.openocd-withbootsize.erase.pattern=
tools.openocd-withbootsize.bootloader.params.verbose=-d2
tools.openocd-withbootsize.bootloader.params.quiet=-d0
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
@@ -0,0 +1,347 @@
/* Copyright (C) 2012 mbed.org, MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LWIPOPTS_H
#define LWIPOPTS_H
// Workaround for Linux timeval
#if defined (TOOLCHAIN_GCC)
#define LWIP_TIMEVAL_PRIVATE 0
#include <sys/time.h>
#endif
#include "nsapi_types.h"
#include "mbed_retarget.h"
// KH fix
#include <mbed_config.h>
/////////////////////////
// Operating System
#define NO_SYS 0
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
#error "Either IPv4 or IPv6 must be enabled."
#endif
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED
#define LWIP_PROVIDE_ERRNO 0
// On dual stack configuration how long to wait for both or preferred stack
// addresses before completing bring up.
#if LWIP_IPV4 && LWIP_IPV6
#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE
#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT
#define PREF_ADDR_TIMEOUT 0
#else
#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT
#define BOTH_ADDR_TIMEOUT 0
#endif
#else
#define PREF_ADDR_TIMEOUT 0
#define BOTH_ADDR_TIMEOUT 0
#endif
#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT
#define LINK_TIMEOUT 60
#define PREF_IPV4 1
#define PREF_IPV6 2
#if MBED_CONF_LWIP_IP_VER_PREF == 6
#define IP_VERSION_PREF PREF_IPV6
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
#define IP_VERSION_PREF PREF_IPV4
#else
#error "Either IPv4 or IPv6 must be preferred."
#endif
#undef LWIP_DEBUG
#if MBED_CONF_LWIP_DEBUG_ENABLED
#define LWIP_DEBUG 1
#endif
#if NO_SYS == 0
#include "cmsis_os2.h"
#define SYS_LIGHTWEIGHT_PROT 1
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
// Thread stacks use 8-byte alignment
#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
#ifdef LWIP_DEBUG
// For LWIP debug, double the stack
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8)
#elif MBED_DEBUG
// When debug is enabled on the build increase stack 25 percent
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8)
#else
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8)
#endif
// Thread priority (osPriorityNormal by default)
#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY)
#ifdef LWIP_DEBUG
#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8)
#else
#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8)
#endif
#define MEMP_NUM_SYS_TIMEOUT 16
#define sys_msleep(ms) sys_msleep(ms)
#endif
// 32-bit alignment
#define MEM_ALIGNMENT 4
#define LWIP_RAM_HEAP_POINTER lwip_ram_heap
// Number of simultaneously queued TCP segments.
#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG
// TCP Maximum segment size.
#define TCP_MSS MBED_CONF_LWIP_TCP_MSS
// TCP sender buffer space (bytes).
#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF
// TCP sender buffer space (bytes).
#define TCP_WND MBED_CONF_LWIP_TCP_WND
#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX
#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX
// Number of pool pbufs.
// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS)
#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE
#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE
#undef PBUF_POOL_BUFSIZE
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE)
#else
#ifndef PBUF_POOL_BUFSIZE
#if LWIP_IPV6
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#elif LWIP_IPV4
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#endif
#endif
#endif
#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE
// One tcp_pcb_listen is needed for each TCP server.
// Each requires 72 bytes of RAM.
#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX
// One is tcp_pcb needed for each TCPSocket.
// Each requires 196 bytes of RAM.
#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX
// One udp_pcb is needed for each UDPSocket.
// Each requires 84 bytes of RAM (total rounded to multiple of 512).
#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX
// Number of non-pool pbufs.
// Each requires 92 bytes of RAM.
#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF
// Each netbuf requires 64 bytes of RAM.
#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF
// One netconn is needed for each UDPSocket or TCPSocket.
// Each requires 236 bytes of RAM (total rounded to multiple of 512).
#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX
#if MBED_CONF_LWIP_TCP_ENABLED
#define LWIP_TCP 1
#define TCP_OVERSIZE 0
#define LWIP_TCP_KEEPALIVE 1
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
#else
#define LWIP_TCP 0
#endif
#define LWIP_DNS 1
// Only DNS address storage is enabled
#define LWIP_FULL_DNS 0
#define LWIP_SOCKET 0
#define SO_REUSE 1
// Support Multicast
#include "stdlib.h"
#define LWIP_IGMP LWIP_IPV4
#define LWIP_RAND() lwip_get_random()
#define LWIP_COMPAT_SOCKETS 0
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
#define LWIP_BROADCAST_PING 1
// Fragmentation on, as per IPv4 default
#define LWIP_IPV6_FRAG LWIP_IPV6
// Queuing, default is "disabled", as per IPv4 default (so actually queues 1)
#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING
// Debug Options
#define NETIF_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
#define API_LIB_DEBUG LWIP_DBG_OFF
#define API_MSG_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TIMERS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_FR_DEBUG LWIP_DBG_OFF
#define TCP_RTO_DEBUG LWIP_DBG_OFF
#define TCP_CWND_DEBUG LWIP_DBG_OFF
#define TCP_WND_DEBUG LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#define ETHARP_DEBUG LWIP_DBG_OFF
#define UDP_LPC_EMAC LWIP_DBG_OFF
#ifdef LWIP_DEBUG
#define MEMP_OVERFLOW_CHECK 1
#define MEMP_SANITY_CHECK 1
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#else
#define LWIP_NOASSERT 1
#define LWIP_STATS 0
#endif
#define TRACE_TO_ASCII_HEX_DUMP 0
#define LWIP_PLATFORM_BYTESWAP 1
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1
// Interface type configuration
#if MBED_CONF_LWIP_ETHERNET_ENABLED
#define LWIP_ARP 1
#define LWIP_ETHERNET 1
#define LWIP_DHCP LWIP_IPV4
#else
#define LWIP_ARP 0
#define LWIP_ETHERNET 0
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
#if MBED_CONF_LWIP_L3IP_ENABLED
#define LWIP_L3IP 1
#else
#define LWIP_L3IP 0
#endif
//Maximum size of network interface name
#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE
// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED
// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available.
// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration
#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED
#define PPP_SUPPORT 1
#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED
#define LWIP 0x11991199
#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED
#error LWIP: IPv4 PPP enabled but not IPv4
#endif
#undef LWIP
#define PPP_IPV4_SUPPORT 1
#endif
#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED
#define LWIP 0x11991199
#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED
#error LWIP: IPv6 PPP enabled but not IPv6
#endif
#undef LWIP
#define PPP_IPV6_SUPPORT 1
// Later to be dynamic for use for multiple interfaces
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0
#endif
#endif
#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED
// Make sure we default these to off, so
// LWIP doesn't default to on
#ifndef LWIP_ARP
#define LWIP_ARP 0
#endif
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
#define LWIP_CHECKSUM_ON_COPY 0
#define LWIP_NETIF_HOSTNAME 1
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define DNS_TABLE_SIZE 2
#define DNS_MAX_NAME_LENGTH 128
#include "lwip_random.h"
#include "lwip_tcp_isn.h"
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
#ifdef MBEDTLS_MD5_C
#define LWIP_USE_EXTERNAL_MBEDTLS 1
#else
#define LWIP_USE_EXTERNAL_MBEDTLS 0
#endif
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
#endif /* LWIPOPTS_H_ */
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
portenta_h7_rules () {
echo ""
echo "# Portenta H7 bootloader mode UDEV rules"
echo ""
cat <<EOF
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"
EOF
}
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
portenta_h7_rules > /etc/udev/rules.d/49-portenta_h7.rules
# reload udev rules
echo "Reload rules..."
udevadm trigger
udevadm control --reload-rules
@@ -0,0 +1,266 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# 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
# Arduino SAMD Core and platform.
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards
version=1.8.13
# Compile variables
# -----------------
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra
# EXPERIMENTAL feature: optimization flags
# - this is alpha and may be subject to change without notice
compiler.optimization_flags=-Os
compiler.optimization_flags.release=-Os
compiler.optimization_flags.debug=-Og -g3
compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-mcpu={build.mcu} -mthumb -c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.bin.flags=-O binary
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
compiler.readelf.cmd=arm-none-eabi-readelf
# this can be overriden in boards.txt
build.extra_flags=
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
#compiler.c.elf.extra_flags=-v
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/"
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
compiler.libraries.ldflags=
# USB Flags
# ---------
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
# Default usb manufacturer will be replaced at compile time using
# numeric vendor ID if available or by board's specific value.
build.usb_manufacturer="Unknown"
# Compile patterns
# ----------------
## Compile c files
## KH Add -DBOARD_NAME="{build.board}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
## KH Add -DBOARD_NAME="{build.board}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}"
## Compile S files
## KH Add -DBOARD_NAME="{build.board}"
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "{source_file}" -o "{object_file}"
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group
## Create output (bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Create output (hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
build.preferred_out_format=bin
## Save hex
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).*
# Required discoveries and monitors
# ---------------------------------
pluggable_discovery.required.0=builtin:serial-discovery
pluggable_discovery.required.1=builtin:mdns-discovery
pluggable_monitor.required.serial=builtin:serial-monitor
# Debugger configuration (general options)
# ----------------------------------------
# EXPERIMENTAL feature:
# - this is alpha and may be subject to change without notice
debug.executable={build.path}/{build.project_name}.elf
debug.toolchain=gcc
debug.toolchain.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
debug.toolchain.prefix=arm-none-eabi-
debug.server=openocd
debug.server.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}/bin/openocd
debug.server.openocd.scripts_dir={runtime.tools.openocd-0.10.0-arduino7.path}/share/openocd/scripts/
debug.server.openocd.script={runtime.platform.path}/variants/{build.variant}/{build.openocdscript}
# Upload/Debug tools
# ------------------
#
# AVRDUDE
#
tools.avrdude.path={runtime.tools.avrdude.path}
tools.avrdude.cmd={path}/bin/avrdude
tools.avrdude.config.path={path}/etc/avrdude.conf
tools.avrdude.upload.params.verbose=-v -v
tools.avrdude.upload.params.quiet=-q -q
tools.avrdude.upload.params.noverify=-V
tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex"
# The following rule is deprecated by pluggable discovery.
# We keep it to avoid breaking compatibility with the Arduino Java IDE.
tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# BOSSA
#
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossac.cmd=bossac
tools.bossac.cmd.windows=bossac.exe
tools.bossac.upload.params.verbose=-i -d
tools.bossac.upload.params.quiet=
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
# The following rule is deprecated by pluggable discovery.
# We keep it to avoid breaking compatibility with the Arduino Java IDE.
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags}
#
# BOSSA (ignore binary size)
#
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
tools.bossacI.cmd=bossac
tools.bossacI.cmd.windows=bossac.exe
tools.bossacI.upload.params.verbose=-i -d
tools.bossacI.upload.params.quiet=
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
# The following rule is deprecated by pluggable discovery.
# We keep it to avoid breaking compatibility with the Arduino Java IDE.
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
#
# OpenOCD sketch upload
#
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd.cmd=bin/openocd
tools.openocd.cmd.windows=bin/openocd.exe
tools.openocd.upload.params.verbose=-d2
tools.openocd.upload.params.quiet=-d0
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
# The following rule is deprecated by pluggable discovery.
# We keep it to avoid breaking compatibility with the Arduino Java IDE.
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
tools.openocd.program.params.verbose=-d2
tools.openocd.program.params.quiet=-d0
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "interface/{protocol}" -c "set telnet_port 0" {extra_params} -f "target/at91samdXX.cfg" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown"
tools.openocd.erase.params.verbose=-d3
tools.openocd.erase.params.quiet=-d0
tools.openocd.erase.pattern=
tools.openocd.bootloader.params.verbose=-d2
tools.openocd.bootloader.params.quiet=-d0
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "interface/{protocol}" -c "set telnet_port 0" {extra_params} -f "target/at91samdXX.cfg" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
#
# OpenOCD sketch upload - version with configurable bootloader size
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
#
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd-withbootsize.cmd=bin/openocd
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
tools.openocd-withbootsize.upload.params.verbose=-d2
tools.openocd-withbootsize.upload.params.quiet=-d0
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd-withbootsize.program.params.verbose=-d2
tools.openocd-withbootsize.program.params.quiet=-d0
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
tools.openocd-withbootsize.erase.params.verbose=-d3
tools.openocd-withbootsize.erase.params.quiet=-d0
tools.openocd-withbootsize.erase.pattern=
tools.openocd-withbootsize.bootloader.params.verbose=-d2
tools.openocd-withbootsize.bootloader.params.quiet=-d0
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
#
# Arduino OTA
#
arduinoota.extraflags=
tools.arduino_ota.cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.arduino_ota.upload.field.password=Password
tools.arduino_ota.upload.field.password.secret=true
tools.arduino_ota.upload.pattern="{cmd}" -address "{upload.port.address}" -port 65280 -username arduino -password "{upload.field.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags}
+238 -29
View File
@@ -4,12 +4,20 @@ menu.opt=Optimize
menu.keys=Keyboard Layout
# TODO: consider whether these compiler warnings are worthwhile
# -Wno-error=unused-function
# -Wno-error=unused-but-set-variable
# -Wno-error=unused-variable
# -Wno-unused-parameter
# -Wno-unused-but-set-parameter
# -Wno-sign-compare
teensy41.name=Teensy 4.1
teensy41.upload.maximum_size=8126464
#teensy41.upload.maximum_size=8126464
teensy41.build.board=TEENSY41
teensy41.build.flags.ld=-Wl,--gc-sections,--relax "-T{build.core.path}/imxrt1062_t41.ld"
teensy41.upload.maximum_data_size=524288
#teensy41.upload.maximum_data_size=1048576
#teensy41.upload.maximum_data_size=524288
teensy41.upload.tool=teensyloader
teensy41.upload.protocol=halfkay
teensy41.build.core=teensy4
@@ -27,7 +35,7 @@ teensy41.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensy41.build.flags.dep=-MMD
teensy41.build.flags.optimize=-Os
teensy41.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=152
teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=156
teensy41.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
teensy41.build.flags.c=
teensy41.build.flags.S=-x assembler-with-cpp
@@ -203,11 +211,212 @@ teensy41.menu.keys.usint.build.keylayout=US_INTERNATIONAL
teensyMM.name=Teensy MicroMod
#teensyMM.upload.maximum_size=16515072
teensyMM.build.board=TEENSY_MICROMOD
teensyMM.build.flags.ld=-Wl,--gc-sections,--relax "-T{build.core.path}/imxrt1062_mm.ld"
#teensyMM.upload.maximum_data_size=524288
#teensyMM.upload.maximum_data_size=1048576
teensyMM.upload.tool=teensyloader
teensyMM.upload.protocol=halfkay
teensyMM.build.core=teensy4
teensyMM.build.mcu=imxrt1062
teensyMM.build.warn_data_percentage=99
teensyMM.build.toolchain=arm/bin/
teensyMM.build.command.gcc=arm-none-eabi-gcc
teensyMM.build.command.g++=arm-none-eabi-g++
teensyMM.build.command.ar=arm-none-eabi-gcc-ar
teensyMM.build.command.objcopy=arm-none-eabi-objcopy
teensyMM.build.command.objdump=arm-none-eabi-objdump
teensyMM.build.command.linker=arm-none-eabi-gcc
teensyMM.build.command.size=arm-none-eabi-size
teensyMM.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib
teensyMM.build.flags.dep=-MMD
teensyMM.build.flags.optimize=-Os
teensyMM.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
teensyMM.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=156
teensyMM.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
teensyMM.build.flags.c=
teensyMM.build.flags.S=-x assembler-with-cpp
teensyMM.build.flags.libs=-larm_cortexM7lfsp_math -lm -lstdc++
teensyMM.serial.restart_cmd=false
teensyMM.menu.usb.serial=Serial
teensyMM.menu.usb.serial.build.usbtype=USB_SERIAL
teensyMM.menu.usb.serial2=Dual Serial
teensyMM.menu.usb.serial2.build.usbtype=USB_DUAL_SERIAL
teensyMM.menu.usb.serial3=Triple Serial
teensyMM.menu.usb.serial3.build.usbtype=USB_TRIPLE_SERIAL
teensyMM.menu.usb.keyboard=Keyboard
teensyMM.menu.usb.keyboard.build.usbtype=USB_KEYBOARDONLY
teensyMM.menu.usb.keyboard.fake_serial=teensy_gateway
teensyMM.menu.usb.touch=Keyboard + Touch Screen
teensyMM.menu.usb.touch.build.usbtype=USB_TOUCHSCREEN
teensyMM.menu.usb.touch.fake_serial=teensy_gateway
teensyMM.menu.usb.hidtouch=Keyboard + Mouse + Touch Screen
teensyMM.menu.usb.hidtouch.build.usbtype=USB_HID_TOUCHSCREEN
teensyMM.menu.usb.hidtouch.fake_serial=teensy_gateway
teensyMM.menu.usb.hid=Keyboard + Mouse + Joystick
teensyMM.menu.usb.hid.build.usbtype=USB_HID
teensyMM.menu.usb.hid.fake_serial=teensy_gateway
teensyMM.menu.usb.serialhid=Serial + Keyboard + Mouse + Joystick
teensyMM.menu.usb.serialhid.build.usbtype=USB_SERIAL_HID
teensyMM.menu.usb.midi=MIDI
teensyMM.menu.usb.midi.build.usbtype=USB_MIDI
teensyMM.menu.usb.midi.fake_serial=teensy_gateway
teensyMM.menu.usb.midi4=MIDIx4
teensyMM.menu.usb.midi4.build.usbtype=USB_MIDI4
teensyMM.menu.usb.midi4.fake_serial=teensy_gateway
teensyMM.menu.usb.midi16=MIDIx16
teensyMM.menu.usb.midi16.build.usbtype=USB_MIDI16
teensyMM.menu.usb.midi16.fake_serial=teensy_gateway
teensyMM.menu.usb.serialmidi=Serial + MIDI
teensyMM.menu.usb.serialmidi.build.usbtype=USB_MIDI_SERIAL
teensyMM.menu.usb.serialmidi4=Serial + MIDIx4
teensyMM.menu.usb.serialmidi4.build.usbtype=USB_MIDI4_SERIAL
teensyMM.menu.usb.serialmidi16=Serial + MIDIx16
teensyMM.menu.usb.serialmidi16.build.usbtype=USB_MIDI16_SERIAL
teensyMM.menu.usb.audio=Audio
teensyMM.menu.usb.audio.build.usbtype=USB_AUDIO
teensyMM.menu.usb.audio.fake_serial=teensy_gateway
teensyMM.menu.usb.serialmidiaudio=Serial + MIDI + Audio
teensyMM.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL
teensyMM.menu.usb.serialmidi16audio=Serial + MIDIx16 + Audio
teensyMM.menu.usb.serialmidi16audio.build.usbtype=USB_MIDI16_AUDIO_SERIAL
teensyMM.menu.usb.mtp=MTP Disk (Experimental)
teensyMM.menu.usb.mtp.build.usbtype=USB_MTPDISK
teensyMM.menu.usb.mtp.fake_serial=teensy_gateway
teensyMM.menu.usb.rawhid=Raw HID
teensyMM.menu.usb.rawhid.build.usbtype=USB_RAWHID
teensyMM.menu.usb.rawhid.fake_serial=teensy_gateway
teensyMM.menu.usb.flightsim=Flight Sim Controls
teensyMM.menu.usb.flightsim.build.usbtype=USB_FLIGHTSIM
teensyMM.menu.usb.flightsim.fake_serial=teensy_gateway
teensyMM.menu.usb.flightsimjoystick=Flight Sim Controls + Joystick
teensyMM.menu.usb.flightsimjoystick.build.usbtype=USB_FLIGHTSIM_JOYSTICK
teensyMM.menu.usb.flightsimjoystick.fake_serial=teensy_gateway
#teensyMM.menu.usb.disable=No USB
#teensyMM.menu.usb.disable.build.usbtype=USB_DISABLED
teensyMM.menu.speed.600=600 MHz
teensyMM.menu.speed.528=528 MHz
teensyMM.menu.speed.450=450 MHz
teensyMM.menu.speed.396=396 MHz
teensyMM.menu.speed.150=150 MHz
teensyMM.menu.speed.24=24 MHz
teensyMM.menu.speed.720=720 MHz (overclock)
teensyMM.menu.speed.816=816 MHz (overclock)
teensyMM.menu.speed.912=912 MHz (overclock, cooling req'd)
teensyMM.menu.speed.960=960 MHz (overclock, cooling req'd)
teensyMM.menu.speed.1008=1.008 GHz (overclock, cooling req'd)
teensyMM.menu.speed.1008.build.fcpu=1008000000
teensyMM.menu.speed.960.build.fcpu=960000000
teensyMM.menu.speed.912.build.fcpu=912000000
teensyMM.menu.speed.816.build.fcpu=816000000
teensyMM.menu.speed.720.build.fcpu=720000000
teensyMM.menu.speed.600.build.fcpu=600000000
teensyMM.menu.speed.528.build.fcpu=528000000
teensyMM.menu.speed.450.build.fcpu=450000000
teensyMM.menu.speed.396.build.fcpu=396000000
teensyMM.menu.speed.150.build.fcpu=150000000
teensyMM.menu.speed.24.build.fcpu=24000000
teensyMM.menu.opt.o2std=Faster
teensyMM.menu.opt.o2std.build.flags.optimize=-O2
teensyMM.menu.opt.o2std.build.flags.ldspecs=
#teensyMM.menu.opt.o2lto=Faster with LTO
#teensyMM.menu.opt.o2lto.build.flags.optimize=-O2 -flto -fno-fat-lto-objects
#teensyMM.menu.opt.o2lto.build.flags.ldspecs=-fuse-linker-plugin
teensyMM.menu.opt.o1std=Fast
teensyMM.menu.opt.o1std.build.flags.optimize=-O1
teensyMM.menu.opt.o1std.build.flags.ldspecs=
#teensyMM.menu.opt.o1lto=Fast with LTO
#teensyMM.menu.opt.o1lto.build.flags.optimize=-O1 -flto -fno-fat-lto-objects
#teensyMM.menu.opt.o1lto.build.flags.ldspecs=-fuse-linker-plugin
teensyMM.menu.opt.o3std=Fastest
teensyMM.menu.opt.o3std.build.flags.optimize=-O3
teensyMM.menu.opt.o3std.build.flags.ldspecs=
#teensyMM.menu.opt.o3purestd=Fastest + pure-code
#teensyMM.menu.opt.o3purestd.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__
#teensyMM.menu.opt.o3purestd.build.flags.ldspecs=
#teensyMM.menu.opt.o3lto=Fastest with LTO
#teensyMM.menu.opt.o3lto.build.flags.optimize=-O3 -flto -fno-fat-lto-objects
#teensyMM.menu.opt.o3lto.build.flags.ldspecs=-fuse-linker-plugin
#teensyMM.menu.opt.o3purelto=Fastest + pure-code with LTO
#teensyMM.menu.opt.o3purelto.build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -flto -fno-fat-lto-objects
#teensyMM.menu.opt.o3purelto.build.flags.ldspecs=-fuse-linker-plugin
teensyMM.menu.opt.ogstd=Debug
teensyMM.menu.opt.ogstd.build.flags.optimize=-Og
teensyMM.menu.opt.ogstd.build.flags.ldspecs=
#teensyMM.menu.opt.oglto=Debug with LTO
#teensyMM.menu.opt.oglto.build.flags.optimize=-Og -flto -fno-fat-lto-objects
#teensyMM.menu.opt.oglto.build.flags.ldspecs=-fuse-linker-plugin
teensyMM.menu.opt.osstd=Smallest Code
teensyMM.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs
teensyMM.menu.opt.osstd.build.flags.ldspecs=
#teensyMM.menu.opt.oslto=Smallest Code with LTO
#teensyMM.menu.opt.oslto.build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs
#teensyMM.menu.opt.oslto.build.flags.ldspecs=-fuse-linker-plugin
teensyMM.menu.keys.en-us=US English
teensyMM.menu.keys.en-us.build.keylayout=US_ENGLISH
teensyMM.menu.keys.fr-ca=Canadian French
teensyMM.menu.keys.fr-ca.build.keylayout=CANADIAN_FRENCH
teensyMM.menu.keys.xx-ca=Canadian Multilingual
teensyMM.menu.keys.xx-ca.build.keylayout=CANADIAN_MULTILINGUAL
teensyMM.menu.keys.cz-cz=Czech
teensyMM.menu.keys.cz-cz.build.keylayout=CZECH
teensyMM.menu.keys.da-da=Danish
teensyMM.menu.keys.da-da.build.keylayout=DANISH
teensyMM.menu.keys.fi-fi=Finnish
teensyMM.menu.keys.fi-fi.build.keylayout=FINNISH
teensyMM.menu.keys.fr-fr=French
teensyMM.menu.keys.fr-fr.build.keylayout=FRENCH
teensyMM.menu.keys.fr-be=French Belgian
teensyMM.menu.keys.fr-be.build.keylayout=FRENCH_BELGIAN
teensyMM.menu.keys.fr-ch=French Swiss
teensyMM.menu.keys.fr-ch.build.keylayout=FRENCH_SWISS
teensyMM.menu.keys.de-de=German
teensyMM.menu.keys.de-de.build.keylayout=GERMAN
teensyMM.menu.keys.de-dm=German (Mac)
teensyMM.menu.keys.de-dm.build.keylayout=GERMAN_MAC
teensyMM.menu.keys.de-ch=German Swiss
teensyMM.menu.keys.de-ch.build.keylayout=GERMAN_SWISS
teensyMM.menu.keys.is-is=Icelandic
teensyMM.menu.keys.is-is.build.keylayout=ICELANDIC
teensyMM.menu.keys.en-ie=Irish
teensyMM.menu.keys.en-ie.build.keylayout=IRISH
teensyMM.menu.keys.it-it=Italian
teensyMM.menu.keys.it-it.build.keylayout=ITALIAN
teensyMM.menu.keys.no-no=Norwegian
teensyMM.menu.keys.no-no.build.keylayout=NORWEGIAN
teensyMM.menu.keys.pt-pt=Portuguese
teensyMM.menu.keys.pt-pt.build.keylayout=PORTUGUESE
teensyMM.menu.keys.pt-br=Portuguese Brazilian
teensyMM.menu.keys.pt-br.build.keylayout=PORTUGUESE_BRAZILIAN
teensyMM.menu.keys.rs-rs=Serbian (Latin Only)
teensyMM.menu.keys.rs-rs.build.keylayout=SERBIAN_LATIN_ONLY
teensyMM.menu.keys.es-es=Spanish
teensyMM.menu.keys.es-es.build.keylayout=SPANISH
teensyMM.menu.keys.es-mx=Spanish Latin America
teensyMM.menu.keys.es-mx.build.keylayout=SPANISH_LATIN_AMERICA
teensyMM.menu.keys.sv-se=Swedish
teensyMM.menu.keys.sv-se.build.keylayout=SWEDISH
teensyMM.menu.keys.tr-tr=Turkish (partial)
teensyMM.menu.keys.tr-tr.build.keylayout=TURKISH
teensyMM.menu.keys.en-gb=United Kingdom
teensyMM.menu.keys.en-gb.build.keylayout=UNITED_KINGDOM
teensyMM.menu.keys.usint=US International
teensyMM.menu.keys.usint.build.keylayout=US_INTERNATIONAL
teensy40.name=Teensy 4.0
teensy40.upload.maximum_size=2031616
#teensy40.upload.maximum_size=2031616
teensy40.build.board=TEENSY40
teensy40.build.flags.ld=-Wl,--gc-sections,--relax "-T{build.core.path}/imxrt1062.ld"
teensy40.upload.maximum_data_size=524288
#teensy40.upload.maximum_data_size=524288
#teensy40.upload.maximum_data_size=1048576
teensy40.upload.tool=teensyloader
teensy40.upload.protocol=halfkay
@@ -226,7 +435,7 @@ teensy40.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
teensy40.build.flags.dep=-MMD
teensy40.build.flags.optimize=-Os
teensy40.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=152
teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=156
teensy40.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
teensy40.build.flags.c=
teensy40.build.flags.S=-x assembler-with-cpp
@@ -422,16 +631,16 @@ teensy36.build.command.objdump=arm-none-eabi-objdump
teensy36.build.command.linker=arm-none-eabi-g++
teensy36.build.command.size=arm-none-eabi-size
teensy36.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib
teensy36.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access
teensy36.build.flags.dep=-MMD
teensy36.build.flags.optimize=-Os
teensy36.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=152
teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=156
teensy36.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensy36.build.flags.c=
teensy36.build.flags.S=-x assembler-with-cpp
teensy36.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk66fx1m0.ld" -lstdc++
teensy36.build.flags.libs=-larm_cortexM4lf_math -lm
teensy36.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk66fx1m0.ld"
teensy36.build.flags.libs=-larm_cortexM4lf_math -lm -lstdc++
teensy36.serial.restart_cmd=false
teensy36.menu.usb.serial=Serial
teensy36.menu.usb.serial.build.usbtype=USB_SERIAL
@@ -635,16 +844,16 @@ teensy35.build.command.objdump=arm-none-eabi-objdump
teensy35.build.command.linker=arm-none-eabi-g++
teensy35.build.command.size=arm-none-eabi-size
teensy35.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib
teensy35.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access
teensy35.build.flags.dep=-MMD
teensy35.build.flags.optimize=-Os
teensy35.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=152
teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=156
teensy35.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensy35.build.flags.c=
teensy35.build.flags.S=-x assembler-with-cpp
teensy35.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk64fx512.ld" -lstdc++
teensy35.build.flags.libs=-larm_cortexM4lf_math -lm
teensy35.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk64fx512.ld"
teensy35.build.flags.libs=-larm_cortexM4lf_math -lm -lstdc++
teensy35.serial.restart_cmd=false
teensy35.menu.usb.serial=Serial
teensy35.menu.usb.serial.build.usbtype=USB_SERIAL
@@ -838,16 +1047,16 @@ teensy31.build.command.objdump=arm-none-eabi-objdump
teensy31.build.command.linker=arm-none-eabi-g++
teensy31.build.command.size=arm-none-eabi-size
teensy31.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib
teensy31.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access
teensy31.build.flags.dep=-MMD
teensy31.build.flags.optimize=-Os
teensy31.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant
teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=152
teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=156
teensy31.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensy31.build.flags.c=
teensy31.build.flags.S=-x assembler-with-cpp
teensy31.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk20dx256.ld" -lstdc++
teensy31.build.flags.libs=-larm_cortexM4l_math -lm
teensy31.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk20dx256.ld"
teensy31.build.flags.libs=-larm_cortexM4l_math -lm -lstdc++
teensy31.serial.restart_cmd=false
teensy31.menu.usb.serial=Serial
teensy31.menu.usb.serial.build.usbtype=USB_SERIAL
@@ -1052,17 +1261,17 @@ teensy30.build.command.objdump=arm-none-eabi-objdump
teensy30.build.command.linker=arm-none-eabi-g++
teensy30.build.command.size=arm-none-eabi-size
teensy30.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib
teensy30.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access
teensy30.build.flags.dep=-MMD
teensy30.build.flags.optimize=-Os
teensy30.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant
teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=152
teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=156
teensy30.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensy30.build.flags.c=
teensy30.build.flags.S=-x assembler-with-cpp
teensy30.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk20dx128.ld" -lstdc++
teensy30.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk20dx128.ld"
teensy30.build.flags.ldspecs=--specs=nano.specs
teensy30.build.flags.libs=-larm_cortexM4l_math -lm
teensy30.build.flags.libs=-larm_cortexM4l_math -lm -lstdc++
teensy30.serial.restart_cmd=false
teensy30.menu.usb.serial=Serial
@@ -1216,15 +1425,15 @@ teensyLC.build.command.objdump=arm-none-eabi-objdump
teensyLC.build.command.linker=arm-none-eabi-g++
teensyLC.build.command.size=arm-none-eabi-size
teensyLC.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib
teensyLC.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access
teensyLC.build.flags.dep=-MMD
teensyLC.build.flags.cpu=-mthumb -mcpu=cortex-m0plus -fsingle-precision-constant
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=152
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=156
teensyLC.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensyLC.build.flags.c=
teensyLC.build.flags.S=-x assembler-with-cpp
teensyLC.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mkl26z64.ld" -lstdc++
teensyLC.build.flags.libs=-larm_cortexM0l_math -lm
teensyLC.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mkl26z64.ld"
teensyLC.build.flags.libs=-larm_cortexM0l_math -lm -lstdc++
teensyLC.serial.restart_cmd=false
teensyLC.menu.usb.serial=Serial
teensyLC.menu.usb.serial.build.usbtype=USB_SERIAL
@@ -1374,7 +1583,7 @@ teensypp2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections
teensypp2.build.flags.dep=-MMD
teensypp2.build.flags.optimize=-Os
teensypp2.build.flags.cpu=-mmcu=at90usb1286
teensypp2.build.flags.defs=-DTEENSYDUINO=152 -DARDUINO_ARCH_AVR
teensypp2.build.flags.defs=-DTEENSYDUINO=156 -DARDUINO_ARCH_AVR
teensypp2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11
teensypp2.build.flags.c=
teensypp2.build.flags.S=-x assembler-with-cpp
@@ -1491,7 +1700,7 @@ teensy2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections
teensy2.build.flags.dep=-MMD
teensy2.build.flags.optimize=-Os
teensy2.build.flags.cpu=-mmcu=atmega32u4
teensy2.build.flags.defs=-DTEENSYDUINO=152 -DARDUINO_ARCH_AVR
teensy2.build.flags.defs=-DTEENSYDUINO=156 -DARDUINO_ARCH_AVR
teensy2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11
teensy2.build.flags.c=
teensy2.build.flags.S=-x assembler-with-cpp
@@ -0,0 +1,446 @@
/*
Stream.cpp - adds parsing methods to Stream class
Copyright (c) 2008 David A. Mellis. All right reserved.
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
Created July 2011
parsing functions based on TextFinder library by Michael Margolis
*/
#include <Arduino.h>
#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait
#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field
// private method to read stream with timeout
int Stream::timedRead()
{
int c;
unsigned long startMillis = millis();
do
{
c = read();
if (c >= 0)
return c;
yield();
} while (millis() - startMillis < _timeout);
Serial.print(("timedRead timeout = "));
Serial.println(_timeout);
return -1; // -1 indicates timeout
}
// private method to peek stream with timeout
int Stream::timedPeek()
{
int c;
unsigned long startMillis = millis();
do
{
c = peek();
if (c >= 0)
return c;
yield();
} while (millis() - startMillis < _timeout);
return -1; // -1 indicates timeout
}
// returns peek of the next digit in the stream or -1 if timeout
// discards non-numeric characters
int Stream::peekNextDigit()
{
int c;
while (1)
{
c = timedPeek();
if (c < 0)
return c; // timeout
if (c == '-')
return c;
if (c >= '0' && c <= '9')
return c;
read(); // discard non-numeric
}
}
// Public Methods
//////////////////////////////////////////////////////////////
void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait
{
_timeout = timeout;
}
// find returns true if the target string is found
bool Stream::find(const char *target)
{
return findUntil(target, NULL);
}
// reads data from the stream until the target string of given length is found
// returns true if target string is found, false if timed out
bool Stream::find(const char *target, size_t length)
{
return findUntil(target, length, NULL, 0);
}
// as find but search ends if the terminator string is found
bool Stream::findUntil(const char *target, const char *terminator)
{
if (target == nullptr)
return true;
size_t tlen = (terminator == nullptr) ? 0 : strlen(terminator);
return findUntil(target, strlen(target), terminator, tlen);
}
// reads data from the stream until the target string of the given length is found
// search terminated if the terminator string is found
// returns true if target string is found, false if terminated or timed out
bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen)
{
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;
int c;
if ( target == nullptr)
return true;
if ( *target == 0)
return true; // return true if target is a null string
if (terminator == nullptr)
termLen = 0;
while ( (c = timedRead()) > 0)
{
if ( c == target[index])
{
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
if (++index >= targetLen)
{
// return true if all chars in the target match
return true;
}
}
else
{
index = 0; // reset index if any char does not match
}
if (termLen > 0 && c == terminator[termIndex])
{
if (++termIndex >= termLen)
return false; // return false if terminate string found before target string
}
else
termIndex = 0;
}
return false;
}
// returns the first valid (long) integer value from the current position.
// initial characters that are not digits (or the minus sign) are skipped
// function is terminated by the first character that is not a digit.
long Stream::parseInt()
{
return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout)
}
// as above but a given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
long Stream::parseInt(char skipChar)
{
boolean isNegative = false;
long value = 0;
int c;
c = peekNextDigit();
// ignore non numeric leading characters
if (c < 0)
return 0; // zero returned if timeout
do
{
if (c == skipChar)
; // ignore this charactor
else if (c == '-')
isNegative = true;
else if (c >= '0' && c <= '9') // is c a digit?
value = value * 10 + c - '0';
read(); // consume the character we got with peek
c = timedPeek();
}
while ( (c >= '0' && c <= '9') || c == skipChar );
if (isNegative)
value = -value;
return value;
}
// as parseInt but returns a floating point value
float Stream::parseFloat()
{
return parseFloat(NO_SKIP_CHAR);
}
// as above but the given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
float Stream::parseFloat(char skipChar)
{
boolean isNegative = false;
boolean isFraction = false;
long value = 0;
int c;
float fraction = 1.0;
c = peekNextDigit();
// ignore non numeric leading characters
if (c < 0)
return 0; // zero returned if timeout
do
{
if (c == skipChar)
; // ignore
else if (c == '-')
isNegative = true;
else if (c == '.')
isFraction = true;
else if (c >= '0' && c <= '9')
{
// is c a digit?
value = value * 10 + c - '0';
if (isFraction)
fraction *= 0.1f;
}
read(); // consume the character we got with peek
c = timedPeek();
}
while ( (c >= '0' && c <= '9') || c == '.' || c == skipChar );
if (isNegative)
value = -value;
if (isFraction)
return value * fraction;
else
return value;
}
// read characters from stream into buffer
// terminates if length characters have been read, or timeout (see setTimeout)
// returns the number of characters placed in the buffer
// the buffer is NOT null terminated.
//
size_t Stream::readBytes(char *buffer, size_t length)
{
if (buffer == nullptr)
return 0;
size_t count = 0;
while (count < length)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break;
}
*buffer++ = (char)c;
count++;
}
return count;
}
// as readBytes with terminator character
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
{
if (buffer == nullptr)
return 0;
if (length < 1)
return 0;
length--;
size_t index = 0;
while (index < length)
{
int c = timedRead();
if (c == terminator)
break;
if (c < 0)
{
setReadError();
break;
}
*buffer++ = (char)c;
index++;
}
*buffer = 0;
return index; // return number of characters, not including null terminator
}
#if 1
// From nRF52
String Stream::readString(size_t max)
{
String ret;
int c = timedRead();
while (c >= 0)
{
ret += (char)c;
c = timedRead();
}
return ret;
}
char readStringBuffer[2048];
char* Stream::readCharsUntil(char terminator, size_t max)
{
uint16_t offset = 0;
int c = timedRead();
readStringBuffer[offset++] = c;
while (c >= 0 && c != terminator)
{
c = timedRead();
readStringBuffer[offset++] = c;
}
readStringBuffer[offset] = 0;
return readStringBuffer;
}
String Stream::readStringUntil(char terminator, size_t max)
{
String ret;
uint16_t offset = 0;
int c = timedRead();
readStringBuffer[offset++] = c;
while (c >= 0 && c != terminator)
{
c = timedRead();
readStringBuffer[offset++] = c;
}
readStringBuffer[offset] = 0;
ret = String(readStringBuffer);
return String(readStringBuffer);
}
#else
String Stream::readString(size_t max)
{
String str;
size_t length = 0;
while (length < max)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break; // timeout
}
if (c == 0)
break;
str += (char)c;
length++;
}
return str;
}
String Stream::readStringUntil(char terminator, size_t max)
{
String str;
size_t length = 0;
while (length < max)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break; // timeout
}
if (c == 0 || c == terminator)
break;
str += (char)c;
length++;
}
return str;
}
#endif
@@ -26,48 +26,124 @@
class Stream : public Print
{
public:
Stream() : _timeout(1000), read_error(0) {}
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
virtual void flush() = 0;
constexpr Stream() : _timeout(1000), read_error(0) {}
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
void setTimeout(unsigned long timeout);
bool find(const char *target);
bool find(const uint8_t *target) { return find ((const char *)target); }
bool find(const char *target, size_t length);
bool find(const uint8_t *target, size_t length) { return find ((const char *)target, length); }
bool findUntil(const char *target, char *terminator);
bool findUntil(const uint8_t *target, char *terminator) { return findUntil((const char *)target, terminator); }
bool findUntil(const char *target, size_t targetLen, char *terminate, size_t termLen);
bool findUntil(const uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((const char *)target, targetLen, terminate, termLen); }
long parseInt();
long parseInt(char skipChar);
float parseFloat();
float parseFloat(char skipChar);
size_t readBytes(char *buffer, size_t length);
size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
String readString(size_t max = 120);
String readStringUntil(char terminator, size_t max = 120);
int getReadError() { return read_error; }
void clearReadError() { setReadError(0); }
void setTimeout(unsigned long timeout);
bool find(const char *target);
bool find(const uint8_t *target)
{
return find ((const char *)target);
}
bool find(const String &target)
{
return find(target.c_str());
}
bool find(const char *target, size_t length);
bool find(const uint8_t *target, size_t length)
{
return find ((const char *)target, length);
}
bool find(const String &target, size_t length)
{
return find(target.c_str(), length);
}
bool findUntil(const char *target, const char *terminator);
bool findUntil(const uint8_t *target, const char *terminator)
{
return findUntil((const char *)target, terminator);
}
bool findUntil(const String &target, const char *terminator)
{
return findUntil(target.c_str(), terminator);
}
bool findUntil(const char *target, const String &terminator)
{
return findUntil(target, terminator.c_str());
}
bool findUntil(const String &target, const String &terminator)
{
return findUntil(target.c_str(), terminator.c_str());
}
bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)
{
return findUntil((const char *)target, targetLen, terminate, termLen);
}
bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen);
bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen);
long parseInt();
long parseInt(char skipChar);
float parseFloat();
float parseFloat(char skipChar);
size_t readBytes(char *buffer, size_t length);
size_t readBytes(uint8_t *buffer, size_t length)
{
return readBytes((char *)buffer, length);
}
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length)
{
return readBytesUntil(terminator, (char *)buffer, length);
}
////////////////////////////////////////////////////////////
String readString(size_t max = 512);
String readStringUntil(char terminator, size_t max = 512);
// KH, to not use String
char* readCharsUntil(char terminator, size_t max = 512);
////////////////////////////////////////////////////////////
int getReadError()
{
return read_error;
}
void clearReadError()
{
setReadError(0);
}
protected:
void setReadError(int err = 1) { read_error = err; }
unsigned long _timeout;
// KH
int timedRead();
//////
void setReadError(int err = 1)
{
read_error = err;
}
unsigned long _timeout;
// KH
int timedRead();
int timedPeek();
int peekNextDigit();
//////
private:
char read_error;
//int timedRead();
int timedPeek();
int peekNextDigit();
char read_error;
};
#endif
#endif
@@ -0,0 +1,446 @@
/*
Stream.cpp - adds parsing methods to Stream class
Copyright (c) 2008 David A. Mellis. All right reserved.
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
Created July 2011
parsing functions based on TextFinder library by Michael Margolis
*/
#include <Arduino.h>
#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait
#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field
// private method to read stream with timeout
int Stream::timedRead()
{
int c;
unsigned long startMillis = millis();
do
{
c = read();
if (c >= 0)
return c;
yield();
} while (millis() - startMillis < _timeout);
Serial.print(("timedRead timeout = "));
Serial.println(_timeout);
return -1; // -1 indicates timeout
}
// private method to peek stream with timeout
int Stream::timedPeek()
{
int c;
unsigned long startMillis = millis();
do
{
c = peek();
if (c >= 0)
return c;
yield();
} while (millis() - startMillis < _timeout);
return -1; // -1 indicates timeout
}
// returns peek of the next digit in the stream or -1 if timeout
// discards non-numeric characters
int Stream::peekNextDigit()
{
int c;
while (1)
{
c = timedPeek();
if (c < 0)
return c; // timeout
if (c == '-')
return c;
if (c >= '0' && c <= '9')
return c;
read(); // discard non-numeric
}
}
// Public Methods
//////////////////////////////////////////////////////////////
void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait
{
_timeout = timeout;
}
// find returns true if the target string is found
bool Stream::find(const char *target)
{
return findUntil(target, NULL);
}
// reads data from the stream until the target string of given length is found
// returns true if target string is found, false if timed out
bool Stream::find(const char *target, size_t length)
{
return findUntil(target, length, NULL, 0);
}
// as find but search ends if the terminator string is found
bool Stream::findUntil(const char *target, const char *terminator)
{
if (target == nullptr)
return true;
size_t tlen = (terminator == nullptr) ? 0 : strlen(terminator);
return findUntil(target, strlen(target), terminator, tlen);
}
// reads data from the stream until the target string of the given length is found
// search terminated if the terminator string is found
// returns true if target string is found, false if terminated or timed out
bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen)
{
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;
int c;
if ( target == nullptr)
return true;
if ( *target == 0)
return true; // return true if target is a null string
if (terminator == nullptr)
termLen = 0;
while ( (c = timedRead()) > 0)
{
if ( c == target[index])
{
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
if (++index >= targetLen)
{
// return true if all chars in the target match
return true;
}
}
else
{
index = 0; // reset index if any char does not match
}
if (termLen > 0 && c == terminator[termIndex])
{
if (++termIndex >= termLen)
return false; // return false if terminate string found before target string
}
else
termIndex = 0;
}
return false;
}
// returns the first valid (long) integer value from the current position.
// initial characters that are not digits (or the minus sign) are skipped
// function is terminated by the first character that is not a digit.
long Stream::parseInt()
{
return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout)
}
// as above but a given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
long Stream::parseInt(char skipChar)
{
boolean isNegative = false;
long value = 0;
int c;
c = peekNextDigit();
// ignore non numeric leading characters
if (c < 0)
return 0; // zero returned if timeout
do
{
if (c == skipChar)
; // ignore this charactor
else if (c == '-')
isNegative = true;
else if (c >= '0' && c <= '9') // is c a digit?
value = value * 10 + c - '0';
read(); // consume the character we got with peek
c = timedPeek();
}
while ( (c >= '0' && c <= '9') || c == skipChar );
if (isNegative)
value = -value;
return value;
}
// as parseInt but returns a floating point value
float Stream::parseFloat()
{
return parseFloat(NO_SKIP_CHAR);
}
// as above but the given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
float Stream::parseFloat(char skipChar)
{
boolean isNegative = false;
boolean isFraction = false;
long value = 0;
int c;
float fraction = 1.0;
c = peekNextDigit();
// ignore non numeric leading characters
if (c < 0)
return 0; // zero returned if timeout
do
{
if (c == skipChar)
; // ignore
else if (c == '-')
isNegative = true;
else if (c == '.')
isFraction = true;
else if (c >= '0' && c <= '9')
{
// is c a digit?
value = value * 10 + c - '0';
if (isFraction)
fraction *= 0.1f;
}
read(); // consume the character we got with peek
c = timedPeek();
}
while ( (c >= '0' && c <= '9') || c == '.' || c == skipChar );
if (isNegative)
value = -value;
if (isFraction)
return value * fraction;
else
return value;
}
// read characters from stream into buffer
// terminates if length characters have been read, or timeout (see setTimeout)
// returns the number of characters placed in the buffer
// the buffer is NOT null terminated.
//
size_t Stream::readBytes(char *buffer, size_t length)
{
if (buffer == nullptr)
return 0;
size_t count = 0;
while (count < length)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break;
}
*buffer++ = (char)c;
count++;
}
return count;
}
// as readBytes with terminator character
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
{
if (buffer == nullptr)
return 0;
if (length < 1)
return 0;
length--;
size_t index = 0;
while (index < length)
{
int c = timedRead();
if (c == terminator)
break;
if (c < 0)
{
setReadError();
break;
}
*buffer++ = (char)c;
index++;
}
*buffer = 0;
return index; // return number of characters, not including null terminator
}
#if 1
// From nRF52
String Stream::readString(size_t max)
{
String ret;
int c = timedRead();
while (c >= 0)
{
ret += (char)c;
c = timedRead();
}
return ret;
}
char readStringBuffer[2048];
char* Stream::readCharsUntil(char terminator, size_t max)
{
uint16_t offset = 0;
int c = timedRead();
readStringBuffer[offset++] = c;
while (c >= 0 && c != terminator)
{
c = timedRead();
readStringBuffer[offset++] = c;
}
readStringBuffer[offset] = 0;
return readStringBuffer;
}
String Stream::readStringUntil(char terminator, size_t max)
{
String ret;
uint16_t offset = 0;
int c = timedRead();
readStringBuffer[offset++] = c;
while (c >= 0 && c != terminator)
{
c = timedRead();
readStringBuffer[offset++] = c;
}
readStringBuffer[offset] = 0;
ret = String(readStringBuffer);
return String(readStringBuffer);
}
#else
String Stream::readString(size_t max)
{
String str;
size_t length = 0;
while (length < max)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break; // timeout
}
if (c == 0)
break;
str += (char)c;
length++;
}
return str;
}
String Stream::readStringUntil(char terminator, size_t max)
{
String str;
size_t length = 0;
while (length < max)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break; // timeout
}
if (c == 0 || c == terminator)
break;
str += (char)c;
length++;
}
return str;
}
#endif
@@ -26,55 +26,124 @@
class Stream : public Print
{
public:
constexpr Stream() : _timeout(1000), read_error(0) {}
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
constexpr Stream() : _timeout(1000), read_error(0) {}
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
void setTimeout(unsigned long timeout);
bool find(const char *target);
bool find(const uint8_t *target) { return find ((const char *)target); }
bool find(const String &target) { return find(target.c_str()); }
bool find(const char *target, size_t length);
bool find(const uint8_t *target, size_t length) { return find ((const char *)target, length); }
bool find(const String &target, size_t length) { return find(target.c_str(), length); }
bool findUntil(const char *target, const char *terminator);
bool findUntil(const uint8_t *target, const char *terminator) { return findUntil((const char *)target, terminator); }
bool findUntil(const String &target, const char *terminator) { return findUntil(target.c_str(), terminator); }
bool findUntil(const char *target, const String &terminator) { return findUntil(target, terminator.c_str()); }
bool findUntil(const String &target, const String &terminator) { return findUntil(target.c_str(), terminator.c_str()); }
bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) {return findUntil((const char *)target, targetLen, terminate, termLen); }
bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen);
bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen);
long parseInt();
long parseInt(char skipChar);
float parseFloat();
float parseFloat(char skipChar);
size_t readBytes(char *buffer, size_t length);
size_t readBytes(uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
String readString(size_t max = 120);
String readStringUntil(char terminator, size_t max = 120);
int getReadError() { return read_error; }
void clearReadError() { setReadError(0); }
void setTimeout(unsigned long timeout);
bool find(const char *target);
bool find(const uint8_t *target)
{
return find ((const char *)target);
}
bool find(const String &target)
{
return find(target.c_str());
}
bool find(const char *target, size_t length);
bool find(const uint8_t *target, size_t length)
{
return find ((const char *)target, length);
}
bool find(const String &target, size_t length)
{
return find(target.c_str(), length);
}
bool findUntil(const char *target, const char *terminator);
bool findUntil(const uint8_t *target, const char *terminator)
{
return findUntil((const char *)target, terminator);
}
bool findUntil(const String &target, const char *terminator)
{
return findUntil(target.c_str(), terminator);
}
bool findUntil(const char *target, const String &terminator)
{
return findUntil(target, terminator.c_str());
}
bool findUntil(const String &target, const String &terminator)
{
return findUntil(target.c_str(), terminator.c_str());
}
bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)
{
return findUntil((const char *)target, targetLen, terminate, termLen);
}
bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen);
bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen);
long parseInt();
long parseInt(char skipChar);
float parseFloat();
float parseFloat(char skipChar);
size_t readBytes(char *buffer, size_t length);
size_t readBytes(uint8_t *buffer, size_t length)
{
return readBytes((char *)buffer, length);
}
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length)
{
return readBytesUntil(terminator, (char *)buffer, length);
}
////////////////////////////////////////////////////////////
String readString(size_t max = 512);
String readStringUntil(char terminator, size_t max = 512);
// KH, to not use String
char* readCharsUntil(char terminator, size_t max = 512);
////////////////////////////////////////////////////////////
int getReadError()
{
return read_error;
}
void clearReadError()
{
setReadError(0);
}
protected:
void setReadError(int err = 1) { read_error = err; }
unsigned long _timeout;
// KH
int timedRead();
//////
void setReadError(int err = 1)
{
read_error = err;
}
unsigned long _timeout;
// KH
int timedRead();
int timedPeek();
int peekNextDigit();
//////
private:
char read_error;
//int timedRead();
int timedPeek();
int peekNextDigit();
char read_error;
};
#endif
@@ -0,0 +1,446 @@
/*
Stream.cpp - adds parsing methods to Stream class
Copyright (c) 2008 David A. Mellis. All right reserved.
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
Created July 2011
parsing functions based on TextFinder library by Michael Margolis
*/
#include <Arduino.h>
#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait
#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field
// private method to read stream with timeout
int Stream::timedRead()
{
int c;
unsigned long startMillis = millis();
do
{
c = read();
if (c >= 0)
return c;
yield();
} while (millis() - startMillis < _timeout);
Serial.print(("timedRead timeout = "));
Serial.println(_timeout);
return -1; // -1 indicates timeout
}
// private method to peek stream with timeout
int Stream::timedPeek()
{
int c;
unsigned long startMillis = millis();
do
{
c = peek();
if (c >= 0)
return c;
yield();
} while (millis() - startMillis < _timeout);
return -1; // -1 indicates timeout
}
// returns peek of the next digit in the stream or -1 if timeout
// discards non-numeric characters
int Stream::peekNextDigit()
{
int c;
while (1)
{
c = timedPeek();
if (c < 0)
return c; // timeout
if (c == '-')
return c;
if (c >= '0' && c <= '9')
return c;
read(); // discard non-numeric
}
}
// Public Methods
//////////////////////////////////////////////////////////////
void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait
{
_timeout = timeout;
}
// find returns true if the target string is found
bool Stream::find(const char *target)
{
return findUntil(target, NULL);
}
// reads data from the stream until the target string of given length is found
// returns true if target string is found, false if timed out
bool Stream::find(const char *target, size_t length)
{
return findUntil(target, length, NULL, 0);
}
// as find but search ends if the terminator string is found
bool Stream::findUntil(const char *target, const char *terminator)
{
if (target == nullptr)
return true;
size_t tlen = (terminator == nullptr) ? 0 : strlen(terminator);
return findUntil(target, strlen(target), terminator, tlen);
}
// reads data from the stream until the target string of the given length is found
// search terminated if the terminator string is found
// returns true if target string is found, false if terminated or timed out
bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen)
{
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;
int c;
if ( target == nullptr)
return true;
if ( *target == 0)
return true; // return true if target is a null string
if (terminator == nullptr)
termLen = 0;
while ( (c = timedRead()) > 0)
{
if ( c == target[index])
{
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
if (++index >= targetLen)
{
// return true if all chars in the target match
return true;
}
}
else
{
index = 0; // reset index if any char does not match
}
if (termLen > 0 && c == terminator[termIndex])
{
if (++termIndex >= termLen)
return false; // return false if terminate string found before target string
}
else
termIndex = 0;
}
return false;
}
// returns the first valid (long) integer value from the current position.
// initial characters that are not digits (or the minus sign) are skipped
// function is terminated by the first character that is not a digit.
long Stream::parseInt()
{
return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout)
}
// as above but a given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
long Stream::parseInt(char skipChar)
{
boolean isNegative = false;
long value = 0;
int c;
c = peekNextDigit();
// ignore non numeric leading characters
if (c < 0)
return 0; // zero returned if timeout
do
{
if (c == skipChar)
; // ignore this charactor
else if (c == '-')
isNegative = true;
else if (c >= '0' && c <= '9') // is c a digit?
value = value * 10 + c - '0';
read(); // consume the character we got with peek
c = timedPeek();
}
while ( (c >= '0' && c <= '9') || c == skipChar );
if (isNegative)
value = -value;
return value;
}
// as parseInt but returns a floating point value
float Stream::parseFloat()
{
return parseFloat(NO_SKIP_CHAR);
}
// as above but the given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
float Stream::parseFloat(char skipChar)
{
boolean isNegative = false;
boolean isFraction = false;
long value = 0;
int c;
float fraction = 1.0;
c = peekNextDigit();
// ignore non numeric leading characters
if (c < 0)
return 0; // zero returned if timeout
do
{
if (c == skipChar)
; // ignore
else if (c == '-')
isNegative = true;
else if (c == '.')
isFraction = true;
else if (c >= '0' && c <= '9')
{
// is c a digit?
value = value * 10 + c - '0';
if (isFraction)
fraction *= 0.1f;
}
read(); // consume the character we got with peek
c = timedPeek();
}
while ( (c >= '0' && c <= '9') || c == '.' || c == skipChar );
if (isNegative)
value = -value;
if (isFraction)
return value * fraction;
else
return value;
}
// read characters from stream into buffer
// terminates if length characters have been read, or timeout (see setTimeout)
// returns the number of characters placed in the buffer
// the buffer is NOT null terminated.
//
size_t Stream::readBytes(char *buffer, size_t length)
{
if (buffer == nullptr)
return 0;
size_t count = 0;
while (count < length)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break;
}
*buffer++ = (char)c;
count++;
}
return count;
}
// as readBytes with terminator character
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
{
if (buffer == nullptr)
return 0;
if (length < 1)
return 0;
length--;
size_t index = 0;
while (index < length)
{
int c = timedRead();
if (c == terminator)
break;
if (c < 0)
{
setReadError();
break;
}
*buffer++ = (char)c;
index++;
}
*buffer = 0;
return index; // return number of characters, not including null terminator
}
#if 1
// From nRF52
String Stream::readString(size_t max)
{
String ret;
int c = timedRead();
while (c >= 0)
{
ret += (char)c;
c = timedRead();
}
return ret;
}
char readStringBuffer[2048];
char* Stream::readCharsUntil(char terminator, size_t max)
{
uint16_t offset = 0;
int c = timedRead();
readStringBuffer[offset++] = c;
while (c >= 0 && c != terminator)
{
c = timedRead();
readStringBuffer[offset++] = c;
}
readStringBuffer[offset] = 0;
return readStringBuffer;
}
String Stream::readStringUntil(char terminator, size_t max)
{
String ret;
uint16_t offset = 0;
int c = timedRead();
readStringBuffer[offset++] = c;
while (c >= 0 && c != terminator)
{
c = timedRead();
readStringBuffer[offset++] = c;
}
readStringBuffer[offset] = 0;
ret = String(readStringBuffer);
return String(readStringBuffer);
}
#else
String Stream::readString(size_t max)
{
String str;
size_t length = 0;
while (length < max)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break; // timeout
}
if (c == 0)
break;
str += (char)c;
length++;
}
return str;
}
String Stream::readStringUntil(char terminator, size_t max)
{
String str;
size_t length = 0;
while (length < max)
{
int c = timedRead();
if (c < 0)
{
setReadError();
break; // timeout
}
if (c == 0 || c == terminator)
break;
str += (char)c;
length++;
}
return str;
}
#endif
@@ -26,55 +26,124 @@
class Stream : public Print
{
public:
constexpr Stream() : _timeout(1000), read_error(0) {}
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
constexpr Stream() : _timeout(1000), read_error(0) {}
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
void setTimeout(unsigned long timeout);
bool find(const char *target);
bool find(const uint8_t *target) { return find ((const char *)target); }
bool find(const String &target) { return find(target.c_str()); }
bool find(const char *target, size_t length);
bool find(const uint8_t *target, size_t length) { return find ((const char *)target, length); }
bool find(const String &target, size_t length) { return find(target.c_str(), length); }
bool findUntil(const char *target, const char *terminator);
bool findUntil(const uint8_t *target, const char *terminator) { return findUntil((const char *)target, terminator); }
bool findUntil(const String &target, const char *terminator) { return findUntil(target.c_str(), terminator); }
bool findUntil(const char *target, const String &terminator) { return findUntil(target, terminator.c_str()); }
bool findUntil(const String &target, const String &terminator) { return findUntil(target.c_str(), terminator.c_str()); }
bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) {return findUntil((const char *)target, targetLen, terminate, termLen); }
bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen);
bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen);
long parseInt();
long parseInt(char skipChar);
float parseFloat();
float parseFloat(char skipChar);
size_t readBytes(char *buffer, size_t length);
size_t readBytes(uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
String readString(size_t max = 120);
String readStringUntil(char terminator, size_t max = 120);
int getReadError() { return read_error; }
void clearReadError() { setReadError(0); }
void setTimeout(unsigned long timeout);
bool find(const char *target);
bool find(const uint8_t *target)
{
return find ((const char *)target);
}
bool find(const String &target)
{
return find(target.c_str());
}
bool find(const char *target, size_t length);
bool find(const uint8_t *target, size_t length)
{
return find ((const char *)target, length);
}
bool find(const String &target, size_t length)
{
return find(target.c_str(), length);
}
bool findUntil(const char *target, const char *terminator);
bool findUntil(const uint8_t *target, const char *terminator)
{
return findUntil((const char *)target, terminator);
}
bool findUntil(const String &target, const char *terminator)
{
return findUntil(target.c_str(), terminator);
}
bool findUntil(const char *target, const String &terminator)
{
return findUntil(target, terminator.c_str());
}
bool findUntil(const String &target, const String &terminator)
{
return findUntil(target.c_str(), terminator.c_str());
}
bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)
{
return findUntil((const char *)target, targetLen, terminate, termLen);
}
bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen);
bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen);
bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen);
long parseInt();
long parseInt(char skipChar);
float parseFloat();
float parseFloat(char skipChar);
size_t readBytes(char *buffer, size_t length);
size_t readBytes(uint8_t *buffer, size_t length)
{
return readBytes((char *)buffer, length);
}
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length)
{
return readBytesUntil(terminator, (char *)buffer, length);
}
////////////////////////////////////////////////////////////
String readString(size_t max = 512);
String readStringUntil(char terminator, size_t max = 512);
// KH, to not use String
char* readCharsUntil(char terminator, size_t max = 512);
////////////////////////////////////////////////////////////
int getReadError()
{
return read_error;
}
void clearReadError()
{
setReadError(0);
}
protected:
void setReadError(int err = 1) { read_error = err; }
unsigned long _timeout;
// KH
int timedRead();
//////
void setReadError(int err = 1)
{
read_error = err;
}
unsigned long _timeout;
// KH
int timedRead();
int timedPeek();
int peekNextDigit();
//////
private:
char read_error;
//int timedRead();
int timedPeek();
int peekNextDigit();
char read_error;
};
#endif
@@ -0,0 +1,89 @@
/*
* Udp.cpp: Library to send/receive UDP packets.
*
* NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these)
* 1) UDP does not guarantee the order in which assembled UDP packets are received. This
* might not happen often in practice, but in larger network topologies, a UDP
* packet can be received out of sequence.
* 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being
* aware of it. Again, this may not be a concern in practice on small local networks.
* For more information, see http://www.cafeaulait.org/course/week12/35.html
*
* MIT License:
* Copyright (c) 2008 Bjoern Hartmann
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* bjoern@cs.stanford.edu 12/30/2008
*/
#ifndef udp_h
#define udp_h
#include <Stream.h>
#include <IPAddress.h>
class UDP : public Stream {
public:
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure
virtual void stop() =0; // Finish with the UDP socket
// Sending UDP packets
// Start building up a packet to send to the remote host specific in ip and port
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
virtual int beginPacket(IPAddress ip, uint16_t port) =0;
// Start building up a packet to send to the remote host specific in host and port
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
virtual int beginPacket(const char *host, uint16_t port) =0;
// Finish off this packet and send it
// Returns 1 if the packet was sent successfully, 0 if there was an error
virtual int endPacket() =0;
// Write a single byte into the packet
virtual size_t write(uint8_t) =0;
// Write size bytes from buffer into the packet
virtual size_t write(const uint8_t *buffer, size_t size) =0;
// Start processing the next available incoming packet
// Returns the size of the packet in bytes, or 0 if no packets are available
virtual int parsePacket() =0;
// Number of bytes remaining in the current packet
virtual int available() =0;
// Read a single byte from the current packet
virtual int read() =0;
// Read up to len bytes from the current packet and place them into buffer
// Returns the number of bytes read, or 0 if none are available
virtual int read(unsigned char* buffer, size_t len) =0;
// Read up to len characters from the current packet and place them into buffer
// Returns the number of characters read, or 0 if none are available
virtual int read(char* buffer, size_t len) =0;
// Return the next byte from the current packet without moving on to the next byte
virtual int peek() =0;
virtual void flush() =0; // Finish reading the current packet
// Return the IP address of the host who sent the current incoming packet
virtual IPAddress remoteIP() =0;
// Return the port of the host who sent the current incoming packet
virtual uint16_t remotePort() =0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};
#endif
@@ -0,0 +1,89 @@
/*
* Udp.cpp: Library to send/receive UDP packets.
*
* NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these)
* 1) UDP does not guarantee the order in which assembled UDP packets are received. This
* might not happen often in practice, but in larger network topologies, a UDP
* packet can be received out of sequence.
* 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being
* aware of it. Again, this may not be a concern in practice on small local networks.
* For more information, see http://www.cafeaulait.org/course/week12/35.html
*
* MIT License:
* Copyright (c) 2008 Bjoern Hartmann
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* bjoern@cs.stanford.edu 12/30/2008
*/
#ifndef udp_h
#define udp_h
#include <Stream.h>
#include <IPAddress.h>
class UDP : public Stream {
public:
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure
virtual void stop() =0; // Finish with the UDP socket
// Sending UDP packets
// Start building up a packet to send to the remote host specific in ip and port
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
virtual int beginPacket(IPAddress ip, uint16_t port) =0;
// Start building up a packet to send to the remote host specific in host and port
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
virtual int beginPacket(const char *host, uint16_t port) =0;
// Finish off this packet and send it
// Returns 1 if the packet was sent successfully, 0 if there was an error
virtual int endPacket() =0;
// Write a single byte into the packet
virtual size_t write(uint8_t) =0;
// Write size bytes from buffer into the packet
virtual size_t write(const uint8_t *buffer, size_t size) =0;
// Start processing the next available incoming packet
// Returns the size of the packet in bytes, or 0 if no packets are available
virtual int parsePacket() =0;
// Number of bytes remaining in the current packet
virtual int available() =0;
// Read a single byte from the current packet
virtual int read() =0;
// Read up to len bytes from the current packet and place them into buffer
// Returns the number of bytes read, or 0 if none are available
virtual int read(unsigned char* buffer, size_t len) =0;
// Read up to len characters from the current packet and place them into buffer
// Returns the number of characters read, or 0 if none are available
virtual int read(char* buffer, size_t len) =0;
// Return the next byte from the current packet without moving on to the next byte
virtual int peek() =0;
virtual void flush() =0; // Finish reading the current packet
// Return the IP address of the host who sent the current incoming packet
virtual IPAddress remoteIP() =0;
// Return the port of the host who sent the current incoming packet
virtual uint16_t remotePort() =0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};
#endif
@@ -0,0 +1,122 @@
/*
pgmspace.h - Definitions for compatibility with AVR pgmspace macros
Copyright (c) 2015 Arduino LLC
Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE
*/
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
#define _SFR_BYTE(n) (n)
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
typedef int64_t prog_int64_t;
typedef uint64_t prog_uint64_t;
typedef const void* int_farptr_t;
typedef const void* uint_farptr_t;
#define memchr_P(s, c, n) memchr((s), (c), (n))
#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n))
#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n))
#define memcpy_P(dest, src, n) memcpy((dest), (src), (n))
#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen))
#define memrchr_P(s, c, n) memrchr((s), (c), (n))
#define strcat_P(dest, src) strcat((dest), (src))
#define strchr_P(s, c) strchr((s), (c))
#define strchrnul_P(s, c) strchrnul((s), (c))
#define strcmp_P(a, b) strcmp((a), (b))
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2))
#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle))
#define strcspn_P(s, accept) strcspn((s), (accept))
#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n))
#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n))
#define strlen_P(a) strlen((a))
#define strnlen_P(s, n) strnlen((s), (n))
#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n))
#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strncat_P(s1, s2, n) strncat((s1), (s2), (n))
#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n))
#define strpbrk_P(s, accept) strpbrk((s), (accept))
#define strrchr_P(s, c) strrchr((s), (c))
#define strsep_P(sp, delim) strsep((sp), (delim))
#define strspn_P(s, accept) strspn((s), (accept))
#define strstr_P(a, b) strstr((a), (b))
#define strtok_P(s, delim) strtok((s), (delim))
#define strtok_rP(s, delim, last) strtok((s), (delim), (last))
#define strlen_PF(a) strlen((a))
#define strnlen_PF(src, len) strnlen((src), (len))
#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len))
#define strcpy_PF(dest, src) strcpy((dest), (src))
#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len))
#define strcat_PF(dest, src) strcat((dest), (src))
#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len))
#define strncat_PF(dest, src, len) strncat((dest), (src), (len))
#define strcmp_PF(s1, s2) strcmp((s1), (s2))
#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n))
#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2))
#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strstr_PF(s1, s2) strstr((s1), (s2))
#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n))
#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_ptr(addr) (*(const void **)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_ptr_near(addr) pgm_read_ptr(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#define pgm_read_ptr_far(addr) pgm_read_ptr(addr)
#define pgm_get_far_address(addr) (&(addr))
#endif
@@ -0,0 +1,122 @@
/*
pgmspace.h - Definitions for compatibility with AVR pgmspace macros
Copyright (c) 2015 Arduino LLC
Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE
*/
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
#define _SFR_BYTE(n) (n)
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
typedef int64_t prog_int64_t;
typedef uint64_t prog_uint64_t;
typedef const void* int_farptr_t;
typedef const void* uint_farptr_t;
#define memchr_P(s, c, n) memchr((s), (c), (n))
#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n))
#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n))
#define memcpy_P(dest, src, n) memcpy((dest), (src), (n))
#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen))
#define memrchr_P(s, c, n) memrchr((s), (c), (n))
#define strcat_P(dest, src) strcat((dest), (src))
#define strchr_P(s, c) strchr((s), (c))
#define strchrnul_P(s, c) strchrnul((s), (c))
#define strcmp_P(a, b) strcmp((a), (b))
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2))
#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle))
#define strcspn_P(s, accept) strcspn((s), (accept))
#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n))
#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n))
#define strlen_P(a) strlen((a))
#define strnlen_P(s, n) strnlen((s), (n))
#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n))
#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strncat_P(s1, s2, n) strncat((s1), (s2), (n))
#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n))
#define strpbrk_P(s, accept) strpbrk((s), (accept))
#define strrchr_P(s, c) strrchr((s), (c))
#define strsep_P(sp, delim) strsep((sp), (delim))
#define strspn_P(s, accept) strspn((s), (accept))
#define strstr_P(a, b) strstr((a), (b))
#define strtok_P(s, delim) strtok((s), (delim))
#define strtok_rP(s, delim, last) strtok((s), (delim), (last))
#define strlen_PF(a) strlen((a))
#define strnlen_PF(src, len) strnlen((src), (len))
#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len))
#define strcpy_PF(dest, src) strcpy((dest), (src))
#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len))
#define strcat_PF(dest, src) strcat((dest), (src))
#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len))
#define strncat_PF(dest, src, len) strncat((dest), (src), (len))
#define strcmp_PF(s1, s2) strcmp((s1), (s2))
#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n))
#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2))
#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strstr_PF(s1, s2) strstr((s1), (s2))
#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n))
#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_ptr(addr) (*(const void **)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_ptr_near(addr) pgm_read_ptr(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#define pgm_read_ptr_far(addr) pgm_read_ptr(addr)
#define pgm_get_far_address(addr) (&(addr))
#endif
@@ -0,0 +1,122 @@
/*
pgmspace.h - Definitions for compatibility with AVR pgmspace macros
Copyright (c) 2015 Arduino LLC
Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE
*/
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
#define _SFR_BYTE(n) (n)
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
typedef int64_t prog_int64_t;
typedef uint64_t prog_uint64_t;
typedef const void* int_farptr_t;
typedef const void* uint_farptr_t;
#define memchr_P(s, c, n) memchr((s), (c), (n))
#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n))
#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n))
#define memcpy_P(dest, src, n) memcpy((dest), (src), (n))
#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen))
#define memrchr_P(s, c, n) memrchr((s), (c), (n))
#define strcat_P(dest, src) strcat((dest), (src))
#define strchr_P(s, c) strchr((s), (c))
#define strchrnul_P(s, c) strchrnul((s), (c))
#define strcmp_P(a, b) strcmp((a), (b))
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2))
#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle))
#define strcspn_P(s, accept) strcspn((s), (accept))
#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n))
#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n))
#define strlen_P(a) strlen((a))
#define strnlen_P(s, n) strnlen((s), (n))
#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n))
#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strncat_P(s1, s2, n) strncat((s1), (s2), (n))
#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n))
#define strpbrk_P(s, accept) strpbrk((s), (accept))
#define strrchr_P(s, c) strrchr((s), (c))
#define strsep_P(sp, delim) strsep((sp), (delim))
#define strspn_P(s, accept) strspn((s), (accept))
#define strstr_P(a, b) strstr((a), (b))
#define strtok_P(s, delim) strtok((s), (delim))
#define strtok_rP(s, delim, last) strtok((s), (delim), (last))
#define strlen_PF(a) strlen((a))
#define strnlen_PF(src, len) strnlen((src), (len))
#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len))
#define strcpy_PF(dest, src) strcpy((dest), (src))
#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len))
#define strcat_PF(dest, src) strcat((dest), (src))
#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len))
#define strncat_PF(dest, src, len) strncat((dest), (src), (len))
#define strcmp_PF(s1, s2) strcmp((s1), (s2))
#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n))
#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2))
#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strstr_PF(s1, s2) strstr((s1), (s2))
#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n))
#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_ptr(addr) (*(const void **)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_ptr_near(addr) pgm_read_ptr(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#define pgm_read_ptr_far(addr) pgm_read_ptr(addr)
#define pgm_get_far_address(addr) (&(addr))
#endif
@@ -0,0 +1,122 @@
/*
pgmspace.h - Definitions for compatibility with AVR pgmspace macros
Copyright (c) 2015 Arduino LLC
Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE
*/
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
#define _SFR_BYTE(n) (n)
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
typedef int64_t prog_int64_t;
typedef uint64_t prog_uint64_t;
typedef const void* int_farptr_t;
typedef const void* uint_farptr_t;
#define memchr_P(s, c, n) memchr((s), (c), (n))
#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n))
#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n))
#define memcpy_P(dest, src, n) memcpy((dest), (src), (n))
#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen))
#define memrchr_P(s, c, n) memrchr((s), (c), (n))
#define strcat_P(dest, src) strcat((dest), (src))
#define strchr_P(s, c) strchr((s), (c))
#define strchrnul_P(s, c) strchrnul((s), (c))
#define strcmp_P(a, b) strcmp((a), (b))
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2))
#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle))
#define strcspn_P(s, accept) strcspn((s), (accept))
#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n))
#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n))
#define strlen_P(a) strlen((a))
#define strnlen_P(s, n) strnlen((s), (n))
#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n))
#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strncat_P(s1, s2, n) strncat((s1), (s2), (n))
#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n))
#define strpbrk_P(s, accept) strpbrk((s), (accept))
#define strrchr_P(s, c) strrchr((s), (c))
#define strsep_P(sp, delim) strsep((sp), (delim))
#define strspn_P(s, accept) strspn((s), (accept))
#define strstr_P(a, b) strstr((a), (b))
#define strtok_P(s, delim) strtok((s), (delim))
#define strtok_rP(s, delim, last) strtok((s), (delim), (last))
#define strlen_PF(a) strlen((a))
#define strnlen_PF(src, len) strnlen((src), (len))
#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len))
#define strcpy_PF(dest, src) strcpy((dest), (src))
#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len))
#define strcat_PF(dest, src) strcat((dest), (src))
#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len))
#define strncat_PF(dest, src, len) strncat((dest), (src), (len))
#define strcmp_PF(s1, s2) strcmp((s1), (s2))
#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n))
#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2))
#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strstr_PF(s1, s2) strstr((s1), (s2))
#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n))
#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_ptr(addr) (*(const void **)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_ptr_near(addr) pgm_read_ptr(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#define pgm_read_ptr_far(addr) pgm_read_ptr(addr)
#define pgm_get_far_address(addr) (&(addr))
#endif
@@ -0,0 +1,122 @@
/*
pgmspace.h - Definitions for compatibility with AVR pgmspace macros
Copyright (c) 2015 Arduino LLC
Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE
*/
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
#define _SFR_BYTE(n) (n)
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
typedef int64_t prog_int64_t;
typedef uint64_t prog_uint64_t;
typedef const void* int_farptr_t;
typedef const void* uint_farptr_t;
#define memchr_P(s, c, n) memchr((s), (c), (n))
#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n))
#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n))
#define memcpy_P(dest, src, n) memcpy((dest), (src), (n))
#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen))
#define memrchr_P(s, c, n) memrchr((s), (c), (n))
#define strcat_P(dest, src) strcat((dest), (src))
#define strchr_P(s, c) strchr((s), (c))
#define strchrnul_P(s, c) strchrnul((s), (c))
#define strcmp_P(a, b) strcmp((a), (b))
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2))
#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle))
#define strcspn_P(s, accept) strcspn((s), (accept))
#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n))
#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n))
#define strlen_P(a) strlen((a))
#define strnlen_P(s, n) strnlen((s), (n))
#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n))
#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strncat_P(s1, s2, n) strncat((s1), (s2), (n))
#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n))
#define strpbrk_P(s, accept) strpbrk((s), (accept))
#define strrchr_P(s, c) strrchr((s), (c))
#define strsep_P(sp, delim) strsep((sp), (delim))
#define strspn_P(s, accept) strspn((s), (accept))
#define strstr_P(a, b) strstr((a), (b))
#define strtok_P(s, delim) strtok((s), (delim))
#define strtok_rP(s, delim, last) strtok((s), (delim), (last))
#define strlen_PF(a) strlen((a))
#define strnlen_PF(src, len) strnlen((src), (len))
#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len))
#define strcpy_PF(dest, src) strcpy((dest), (src))
#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len))
#define strcat_PF(dest, src) strcat((dest), (src))
#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len))
#define strncat_PF(dest, src, len) strncat((dest), (src), (len))
#define strcmp_PF(s1, s2) strcmp((s1), (s2))
#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n))
#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2))
#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n))
#define strstr_PF(s1, s2) strstr((s1), (s2))
#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n))
#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_ptr(addr) (*(const void **)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_ptr_near(addr) pgm_read_ptr(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#define pgm_read_ptr_far(addr) pgm_read_ptr(addr)
#define pgm_get_far_address(addr) (&(addr))
#endif
+327 -320
View File
@@ -6,12 +6,15 @@
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncHTTPRequest_Generic.svg)](http://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues)
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
---
---
## Table of Contents
* [Important Change from v1.6.0](#Important-Change-from-v160)
* [Why do we need the new Async AsyncHTTPRequest_Generic library](#why-do-we-need-this-async-asynchttprequest_generic-library)
* [Features](#features)
* [Supports](#supports)
@@ -42,6 +45,7 @@
* [1. AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP)
* [2. AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager)
* [3. AsyncHTTPMultiRequests_ESP](examples/AsyncHTTPMultiRequests_ESP)
* [4. AsyncHTTPRequest_ESP_Multi](examples/AsyncHTTPRequest_ESP_Multi) **New**
* [For STM32 using LAN8742A](#for-stm32-using-lan8742a)
* [1. AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
* [2. AsyncCustomHeader_STM32](examples/AsyncCustomHeader_STM32)
@@ -59,6 +63,8 @@
* [For WT32_ETH01](#for-wt32_eth01)
* [1. AsyncHTTPRequest_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01)
* [2. AsyncHTTPMultiRequests_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01)
* [For ESP or STM32](#For-ESP-or-STM32)
* [1. **multiFileProject**](examples/multiFileProject) **New**
* [Example AsyncHTTPRequest_STM32](#example-asynchttprequest_stm32)
* [1. File AsyncHTTPRequest_STM32.ino](#1-file-asynchttprequest_stm32ino)
* [2. File defines.h](#2-file-definesh)
@@ -71,6 +77,9 @@
* [6. AsyncWebClientRepeating_STM32_LAN8720 running on STM32F4 BLACK_F407VE using LAN8720](#6-asyncwebclientrepeating_stm32_lan8720-running-on-stm32f4-black_f407ve-using-lan8720)
* [7. AsyncHTTPMultiRequests_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720](#7-asynchttpmultirequests_wt32_eth01-on-esp32_dev-with-eth_phy_lan8720)
* [8. AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720](#8-asynchttprequest_wt32_eth01-on-esp32_dev-with-eth_phy_lan8720)
* [9. AsyncHTTPRequest_ESP_WiFiManager running on ESP32C3_DEV](#9-asynchttprequest_esp_wifimanager-running-on-ESP32C3_DEV) **New**
* [10. AsyncHTTPRequest_ESP_WiFiManager running on ESP32S3_DEV](#10-asynchttprequest_esp_wifimanager-running-on-ESP32S3_DEV) **New**
* [11. AsyncHTTPRequest_ESP_Multi running on ESP32_DEV](#11-AsyncHTTPRequest_ESP_Multi-running-on-ESP32_DEV) **New**
* [Debug](#debug)
* [Troubleshooting](#troubleshooting)
* [Issues](#issues)
@@ -84,6 +93,13 @@
---
---
### Important Change from v1.6.0
Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
---
---
## Why do we need this Async [AsyncHTTPRequest_Generic library](https://github.com/khoih-prog/AsyncHTTPRequest_Generic)
### Features
@@ -125,7 +141,11 @@ This library is based on, modified from:
### Currently Supported Boards
#### 1. ESP32 including ESP32-S2 (ESP32-S2 Saola, AI-Thinker ESP-12K, etc.)
#### 1. ESP32 including ESP32_S2 (ESP32_S2 Saola, AI-Thinker ESP-12K, etc.), ESP32_S3 and ESP32_C3
1. **ESP32-S2 (ESP32-S2 Saola, AI-Thinker ESP-12K, etc.) using EEPROM, SPIFFS or LittleFS**.
2. **ESP32-C3 (ARDUINO_ESP32C3_DEV) using EEPROM, SPIFFS or LittleFS**.
3. **ESP32-S3 (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.) using EEPROM, SPIFFS or LittleFS**.
#### 2. ESP8266
@@ -149,16 +169,16 @@ This library is based on, modified from:
## Prerequisites
1. [`Arduino IDE 1.8.16+` for Arduino](https://www.arduino.cc/en/Main/Software)
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
2. [`ESP8266 Core 3.0.2+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/)
3. [`ESP32 Core 2.0.1+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [Latest stable release ![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32.svg?style=plastic)
5. [`Arduino Core for STM32 2.1.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for for STM32 using built-in Ethernet LAN8742A. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
3. [`ESP32 Core 2.0.2+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [Latest stable release ![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32.svg?style=plastic)
5. [`Arduino Core for STM32 2.2.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for for STM32 using built-in Ethernet LAN8742A. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
6. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266.
7. [`AsyncTCP v1.1.1+`](https://github.com/me-no-dev/AsyncTCP) for ESP32.
8. [`STM32Ethernet library v1.2.0+`](https://github.com/stm32duino/STM32Ethernet) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/STM32Ethernet.svg)](https://github.com/stm32duino/STM32Ethernet/releases/latest)
9. [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/LwIP.svg)](https://github.com/stm32duino/LwIP/releases/latest)
10. [`STM32AsyncTCP library v1.0.1+`](https://github.com/khoih-prog/STM32AsyncTCP) for built-in Ethernet on (Nucleo-144, Discovery). To install manually for Arduino IDE.
11. [`ESPAsync_WiFiManager library v1.9.6+`](https://github.com/khoih-prog/ESPAsync_WiFiManager) for ESP32/ESP8266 using some examples. [![GitHub release](https://img.shields.io/github/release/khoih-prog/ESPAsync_WiFiManager.svg)](https://github.com/khoih-prog/ESPAsync_WiFiManager/releases)
11. [`ESPAsync_WiFiManager library v1.12.1+`](https://github.com/khoih-prog/ESPAsync_WiFiManager) for ESP32/ESP8266 using some examples. [![GitHub release](https://img.shields.io/github/release/khoih-prog/ESPAsync_WiFiManager.svg)](https://github.com/khoih-prog/ESPAsync_WiFiManager/releases)
12. [`LittleFS_esp32 v1.0.6+`](https://github.com/lorol/LITTLEFS) for ESP32-based boards using LittleFS. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/LittleFS_esp32.svg?)](https://www.ardu-badge.com/LittleFS_esp32).
13. [`WebServer_WT32_ETH01 library v1.4.1+`](https://github.com/khoih-prog/WebServer_WT32_ETH01) if necessary to use WT32_ETH01 boards. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/WebServer_WT32_ETH01.svg?)](https://www.ardu-badge.com/WebServer_WT32_ETH01)
@@ -180,7 +200,7 @@ The best and easiest way is to use `Arduino Library Manager`. Search for `AsyncH
1. Install [VS Code](https://code.visualstudio.com/)
2. Install [PlatformIO](https://platformio.org/platformio-ide)
3. Install [**AsyncHTTPRequest_Generic** library](https://platformio.org/lib/show/11235/AsyncHTTPRequest_Generic) by using [Library Manager](https://platformio.org/lib/show/11235/AsyncHTTPRequest_Generic/installation). Search for AsyncHTTPRequest_Generic in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
3. Install [**AsyncHTTPRequest_Generic** library](https://registry.platformio.org/libraries/khoih-prog/AsyncHTTPRequest_Generic) by using [Library Manager](https://registry.platformio.org/libraries/khoih-prog/AsyncHTTPRequest_Generic/installation). Search for AsyncHTTPRequest_Generic in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
4. Use included [platformio.ini](platformio/platformio.ini) file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html)
---
@@ -196,12 +216,12 @@ To use LAN8720 on some STM32 boards
- **Discovery (DISCO_F746NG)**
- **STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)**
you have to copy the files [stm32f4xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.1.0/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.1.0/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.1.0/system) to overwrite the old files.
you have to copy the files [stm32f4xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system) to overwrite the old files.
Supposing the STM32 stm32 core version is 2.1.0. These files must be copied into the directory:
Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:
- `~/.arduino15/packages/STM32/hardware/stm32/2.1.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
- `~/.arduino15/packages/STM32/hardware/stm32/2.1.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7.
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7.
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz,
theses files must be copied into the corresponding directory:
@@ -212,12 +232,12 @@ theses files must be copied into the corresponding directory:
#### 2. For STM32 boards to use Serial1
**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/2.1.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.1.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.
**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/2.2.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.
Supposing the STM32 stm32 core version is 2.1.0. These files must be copied into the directory:
Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:
- `~/.arduino15/packages/STM32/hardware/stm32/2.1.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
- `~/.arduino15/packages/STM32/hardware/stm32/2.1.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz,
theses files must be copied into the corresponding directory:
@@ -254,13 +274,25 @@ Thanks to [Roshan](https://github.com/solroshan) to report the issue in [Error e
### HOWTO Fix `Multiple Definitions` Linker Error
The current library implementation, using xyz-Impl.h instead of standard xyz.cpp, possibly creates certain `Multiple Definitions` Linker error in certain use cases. Although it's simple to just modify several lines of code, either in the library or in the application, the library is adding a separate source directory, named src_cpp, besides the standard src directory.
The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.
To use the old standard cpp way, just
You can include this `.hpp` file
1. **Rename the h-only src directory into src_h.**
2. **Then rename the cpp src_cpp directory into src.**
3. Close then reopen the application code in Arduino IDE, etc. to recompile from scratch.
```
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
#include "AsyncHTTPRequest_Generic.hpp" //https://github.com/khoih-prog/AsyncHTTPRequest_Generic
```
in many files. But be sure to use the following `.h` file **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
```
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "AsyncHTTPRequest_Generic.h" //https://github.com/khoih-prog/AsyncHTTPRequest_Generic
```
Check the new [**multiFileProject** example](examples/multiFileProject) for a `HOWTO` demo.
Have a look at the discussion in [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80)
---
---
@@ -394,6 +426,7 @@ Connect FDTI (USB to Serial) as follows:
1. [AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP)
2. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager)
3. [AsyncHTTPMultiRequests_ESP](examples/AsyncHTTPMultiRequests_ESP)
4. [AsyncHTTPRequest_ESP_Multi](examples/AsyncHTTPRequest_ESP_Multi) **New**
#### For STM32 using LAN8742A
@@ -418,6 +451,11 @@ Connect FDTI (USB to Serial) as follows:
1. [AsyncHTTPRequest_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01)
2. [AsyncHTTPMultiRequests_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPMultiRequests_ESP)
#### For ESP or STM32
1. [**multiFileProject**](examples/multiFileProject) **New**
---
### Example [AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
@@ -426,219 +464,15 @@ Please take a look at other examples, as well.
#### 1. File [AsyncHTTPRequest_STM32.ino](examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino)
```cpp
#include "defines.h"
https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/98733a6c4a1906ff53f6de0d19a239c672c4569a/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino#L1-L144
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
AsyncHTTPRequest request;
void sendRequest(void);
// Repeat forever, millis() resolution
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
void sendRequest(void)
{
static bool requestOpenResult;
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
{
//requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt");
requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
if (requestOpenResult)
{
// Only send() if open() returns true, or crash
request.send();
}
else
{
Serial.println("Can't send bad request");
}
}
else
{
Serial.println("Can't send request");
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(request->responseText());
Serial.println("**************************************");
request->setDebug(false);
}
}
void setup(void)
{
Serial.begin(115200);
while (!Serial);
Serial.println("\nStart AsyncHTTPRequest_STM32 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
// Use Static IP
//Ethernet.begin(mac[index], ip);
// Use DHCP dynamic IP and random mac
Ethernet.begin(mac[index]);
Serial.print(F("AsyncHTTPRequest @ IP : "));
Serial.println(Ethernet.localIP());
Serial.println();
request.setDebug(false);
request.onReadyStateChange(requestCB);
sendHTTPRequest.start(); //start the ticker.
// Send first request now
//delay(60);
sendRequest();
}
void loop(void)
{
sendHTTPRequest.update();
}
```
---
#### 2. File [defines.h](examples/AsyncHTTPRequest_STM32/defines.h)
https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/98733a6c4a1906ff53f6de0d19a239c672c4569a/examples/AsyncHTTPRequest_STM32/defines.h#L1-L134
```cpp
/*
Currently support
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
- Nucleo-144 (F429ZI, F767ZI)
- Discovery (STM32F746G-DISCOVERY)
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
*/
#ifndef defines_h
#define defines_h
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
defined(STM32WB) || defined(STM32MP1) )
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
#endif
#define ASYNC_HTTP_DEBUG_PORT Serial
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
#define _ASYNC_HTTP_LOGLEVEL_ 1
#if defined(STM32F0)
#warning STM32F0 board selected
#define BOARD_TYPE "STM32F0"
#elif defined(STM32F1)
#warning STM32F1 board selected
#define BOARD_TYPE "STM32F1"
#elif defined(STM32F2)
#warning STM32F2 board selected
#define BOARD_TYPE "STM32F2"
#elif defined(STM32F3)
#warning STM32F3 board selected
#define BOARD_TYPE "STM32F3"
#elif defined(STM32F4)
#warning STM32F4 board selected
#define BOARD_TYPE "STM32F4"
#elif defined(STM32F7)
#warning STM32F7 board selected
#define BOARD_TYPE "STM32F7"
#elif defined(STM32L0)
#warning STM32L0 board selected
#define BOARD_TYPE "STM32L0"
#elif defined(STM32L1)
#warning STM32L1 board selected
#define BOARD_TYPE "STM32L1"
#elif defined(STM32L4)
#warning STM32L4 board selected
#define BOARD_TYPE "STM32L4"
#elif defined(STM32H7)
#warning STM32H7 board selected
#define BOARD_TYPE "STM32H7"
#elif defined(STM32G0)
#warning STM32G0 board selected
#define BOARD_TYPE "STM32G0"
#elif defined(STM32G4)
#warning STM32G4 board selected
#define BOARD_TYPE "STM32G4"
#elif defined(STM32WB)
#warning STM32WB board selected
#define BOARD_TYPE "STM32WB"
#elif defined(STM32MP1)
#warning STM32MP1 board selected
#define BOARD_TYPE "STM32MP1"
#else
#warning STM32 unknown board selected
#define BOARD_TYPE "STM32 Unknown"
#endif
#ifndef BOARD_NAME
#define BOARD_NAME BOARD_TYPE
#endif
#include <LwIP.h>
#include <STM32Ethernet.h>
//#include <AsyncUDP_STM32.h>
// Enter a MAC address and IP address for your controller below.
#define NUMBER_OF_MAC 20
byte mac[][NUMBER_OF_MAC] =
{
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x01 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
};
// Select the static IP address according to your local network
IPAddress ip(192, 168, 2, 232);
#endif //defines_h
```
---
---
@@ -649,43 +483,43 @@ IPAddress ip(192, 168, 2, 232);
```
Start AsyncHTTPRequest_STM32 on NUCLEO_F767ZI
AsyncHTTPRequest_Generic v1.4.1
AsyncHTTPRequest @ IP : 192.168.2.72
AsyncHTTPRequest_Generic v1.7.1
AsyncHTTPRequest @ IP : 192.168.2.178
**************************************
abbreviation: EDT
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2020-09-13T18:22:59.555816-04:00
datetime: 2022-01-23T19:06:29.846071-05:00
day_of_week: 0
day_of_year: 257
dst: true
dst_from: 2020-03-08T07:00:00+00:00
dst_offset: 3600
dst_until: 2020-11-01T06:00:00+00:00
day_of_year: 23
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1600035779
utc_datetime: 2020-09-13T22:22:59.555816+00:00
utc_offset: -04:00
week_number: 37
unixtime: 1642982789
utc_datetime: 2022-01-24T00:06:29.846071+00:00
utc_offset: -05:00
week_number: 3
*********************
**************************************
abbreviation: EDT
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2020-09-13T18:27:57.586325-04:00
datetime: 2022-01-23T19:08:29.871390-05:00
day_of_week: 0
day_of_year: 257
dst: true
dst_from: 2020-03-08T07:00:00+00:00
dst_offset: 3600
dst_until: 2020-11-01T06:00:00+00:00
day_of_year: 23
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1600036077
utc_datetime: 2020-09-13T22:27:57.586325+00:00
utc_offset: -04:00
week_number: 37
**************************************
unixtime: 1642982909
utc_datetime: 2022-01-24T00:08:29.871390+00:00
utc_offset: -05:00
week_number: 3
```
---
@@ -694,31 +528,30 @@ week_number: 37
```
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP8266_NODEMCU
AsyncHTTPRequest_Generic v1.4.1
AsyncHTTPRequest_Generic v1.7.1
Stored: SSID = HueNet1, Pass = 12345678
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
After waiting 3.43 secs more in setup(), connection result is connected. Local IP: 192.168.2.186
H
**************************************
abbreviation: EDT
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2020-09-13T19:35:37.951609-04:00
datetime: 2022-01-23T19:08:29.871390-05:00
day_of_week: 0
day_of_year: 257
dst: true
dst_from: 2020-03-08T07:00:00+00:00
dst_offset: 3600
dst_until: 2020-11-01T06:00:00+00:00
day_of_year: 23
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1600040137
utc_datetime: 2020-09-13T23:35:37.951609+00:00
utc_offset: -04:00
week_number: 37
unixtime: 1642982909
utc_datetime: 2022-01-24T00:08:29.871390+00:00
utc_offset: -05:00
week_number: 3
**************************************
HHHHHH
```
---
@@ -727,49 +560,48 @@ HHHHHH
```
Starting AsyncHTTPRequest_ESP_WiFiManager using SPIFFS on ESP32_DEV
AsyncHTTPRequest_Generic v1.4.1
AsyncHTTPRequest_Generic v1.7.1
Stored: SSID = HueNet1, Pass = 12345678
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
After waiting 2.35 secs more in setup(), connection result is connected. Local IP: 192.168.2.232
H
**************************************
abbreviation: EDT
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2020-09-13T19:37:02.118166-04:00
datetime: 2022-01-23T19:06:29.846071-05:00
day_of_week: 0
day_of_year: 257
dst: true
dst_from: 2020-03-08T07:00:00+00:00
dst_offset: 3600
dst_until: 2020-11-01T06:00:00+00:00
day_of_year: 23
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1600040222
utc_datetime: 2020-09-13T23:37:02.118166+00:00
utc_offset: -04:00
week_number: 37
unixtime: 1642982789
utc_datetime: 2022-01-24T00:06:29.846071+00:00
utc_offset: -05:00
week_number: 3
**************************************
HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
**************************************
abbreviation: EDT
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2020-09-13T19:42:01.507586-04:00
datetime: 2022-01-23T19:08:29.871390-05:00
day_of_week: 0
day_of_year: 257
dst: true
dst_from: 2020-03-08T07:00:00+00:00
dst_offset: 3600
dst_until: 2020-11-01T06:00:00+00:00
day_of_year: 23
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1600040521
utc_datetime: 2020-09-13T23:42:01.507586+00:00
utc_offset: -04:00
week_number: 37
unixtime: 1642982909
utc_datetime: 2022-01-24T00:08:29.871390+00:00
utc_offset: -05:00
week_number: 3
**************************************
HHHHHHHHH HHHHHHHHHH HHHHHHHHHH
```
---
@@ -778,27 +610,28 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH
```
Starting AsyncHTTPRequest_ESP using ESP8266_NODEMCU
AsyncHTTPRequest_Generic v1.4.1
AsyncHTTPRequest_Generic v1.7.1
Connecting to WiFi SSID: HueNet1
...........
HTTP WebServer is @ IP : 192.168.2.81
**************************************
abbreviation: EDT
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2020-09-13T19:56:28.295033-04:00
datetime: 2022-01-23T19:08:29.871390-05:00
day_of_week: 0
day_of_year: 257
dst: true
dst_from: 2020-03-08T07:00:00+00:00
dst_offset: 3600
dst_until: 2020-11-01T06:00:00+00:00
day_of_year: 23
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1600041388
utc_datetime: 2020-09-13T23:56:28.295033+00:00
utc_offset: -04:00
week_number: 37
unixtime: 1642982909
utc_datetime: 2022-01-24T00:08:29.871390+00:00
utc_offset: -05:00
week_number: 3
**************************************
HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
```
@@ -810,7 +643,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
```
Start AsyncWebClientRepeating_STM32 on NUCLEO_F767ZI
AsyncHTTPRequest_Generic v1.4.1
AsyncHTTPRequest_Generic v1.7.1
AsyncHTTPRequest @ IP : 192.168.2.72
**************************************
@@ -854,8 +687,6 @@ AsyncHTTPRequest @ IP : 192.168.2.72
,;;;;; ;;`;; ;; ;; .;; ;; ,;, ;; ;;;, ;; ;;
;; ,;, ;; .;; ;;;;;: ;;;;;: ,;;;;;: ;; ;;, ;;;;;;
;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;;
```
---
@@ -865,7 +696,7 @@ AsyncHTTPRequest @ IP : 192.168.2.72
```
Start AsyncWebClientRepeating_STM32_LAN8720 on BLACK_F407VE
AsyncHTTPRequest_Generic v1.4.1
AsyncHTTPRequest_Generic v1.7.1
AsyncHTTPRequest @ IP : 192.168.2.150
@@ -921,7 +752,7 @@ AsyncHTTPRequest @ IP : 192.168.2.150
```
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.4.1
AsyncHTTPRequest_Generic v1.4.1
AsyncHTTPRequest_Generic v1.7.1
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
AsyncHTTPRequest @ IP : 192.168.2.232
@@ -947,29 +778,192 @@ H
```
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.4.1
AsyncHTTPRequest_Generic v1.4.1
AsyncHTTPRequest_Generic v1.7.1
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
AsyncHTTPRequest @ IP : 192.168.2.232
**************************************
abbreviation: EDT
client_ip: 45.72.193.56
datetime: 2021-07-09T23:16:50.506413-04:00
day_of_week: 5
day_of_year: 190
dst: true
dst_from: 2021-03-14T07:00:00+00:00
dst_offset: 3600
dst_until: 2021-11-07T06:00:00+00:00
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2021-12-30T14:08:41.290808-05:00
day_of_week: 4
day_of_year: 364
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1625887010
utc_datetime: 2021-07-10T03:16:50.506413+00:00
utc_offset: -04:00
week_number: 27
unixtime: 1640891321
utc_datetime: 2021-12-30T19:08:41.290808+00:00
utc_offset: -05:00
week_number: 52
**************************************
```
---
#### 9. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager) running on ESP32C3_DEV
```
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP32C3_DEV
ESPAsync_WiFiManager v1.12.1
AsyncHTTPRequest_Generic v1.7.1
Stored: SSID = HueNet1, Pass = password
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
After waiting 9.23 secs more in setup(), connection result is connected. Local IP: 192.168.2.85
H
**************************************
abbreviation: EST
client_ip: 45.72.193.77
datetime: 2022-02-11T22:20:36.434352-05:00
day_of_week: 5
day_of_year: 42
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1644636036
utc_datetime: 2022-02-12T03:20:36.434352+00:00
utc_offset: -05:00
week_number: 6
**************************************
HHHHHH
**************************************
abbreviation: EST
client_ip: 45.72.193.77
datetime: 2022-02-11T22:21:36.398307-05:00
day_of_week: 5
day_of_year: 42
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1644636096
utc_datetime: 2022-02-12T03:21:36.398307+00:00
utc_offset: -05:00
week_number: 6
**************************************
```
---
#### 10. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager) running on ESP32S3_DEV
```
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP32S3_DEV
ESPAsync_WiFiManager v1.12.1
AsyncHTTPRequest_Generic v1.7.1
Stored: SSID = HueNet1, Pass = password
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
After waiting 7.77 secs more in setup(), connection result is connected. Local IP: 192.168.2.83
H
**************************************
abbreviation: EST
client_ip: 45.72.193.77
datetime: 2022-02-11T22:58:46.055783-05:00
day_of_week: 5
day_of_year: 42
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1644638326
utc_datetime: 2022-02-12T03:58:46.055783+00:00
utc_offset: -05:00
week_number: 6
**************************************
HHHHHH
**************************************
abbreviation: EST
client_ip: 45.72.193.77
datetime: 2022-02-11T22:59:45.988493-05:00
day_of_week: 5
day_of_year: 42
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1644638385
utc_datetime: 2022-02-12T03:59:45.988493+00:00
utc_offset: -05:00
week_number: 6
**************************************
```
---
#### 11. [AsyncHTTPRequest_ESP_Multi](examples/AsyncHTTPRequest_ESP_Multi) running on ESP32_DEV
The terminal output of [AsyncHTTPRequest_ESP_Multi example](examples/AsyncHTTPRequest_ESP_Multi) running on `ESP32_DEV` to demonstrate how to send requests to multiple addresses and receive responses from them.
```
Starting AsyncHTTPRequest_ESP_Multi using ESP32_DEV
AsyncHTTPRequest_Generic v1.7.1
Connecting to WiFi SSID: HueNet1
.......
AsyncHTTPSRequest @ IP : 192.168.2.88
Sending request: http://worldtimeapi.org/api/timezone/Europe/Prague.txt
Sending request: http://www.myexternalip.com/raw
**************************************
abbreviation: CET
client_ip: aaa.bbb.ccc.ddd
datetime: 2022-02-26T01:54:15.753826+01:00
day_of_week: 6
day_of_year: 57
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: 3600
timezone: Europe/Prague
unixtime: 1645836855
utc_datetime: 2022-02-26T00:54:15.753826+00:00
utc_offset: +01:00
week_number: 8
**************************************
**************************************
aaa.bbb.ccc.ddd
**************************************
Sending request: http://worldtimeapi.org/api/timezone/America/Toronto.txt
**************************************
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2022-02-25T19:54:15.822746-05:00
day_of_week: 5
day_of_year: 56
dst: false
dst_from:
dst_offset: 0
dst_until:
raw_offset: -18000
timezone: America/Toronto
unixtime: 1645836855
utc_datetime: 2022-02-26T00:54:15.822746+00:00
utc_offset: -05:00
week_number: 8
**************************************
HHH
```
---
---
@@ -1021,6 +1015,14 @@ Submit issues to: [AsyncHTTPRequest_Generic issues](https://github.com/khoih-pro
6. Add support to **WT32_ETH01** using ESP32-based boards and LAN8720 Ethernet
7. Auto detect ESP32 core to use for WT32_ETH01
8. Fix bug in WT32_ETH01 examples to reduce connection time
9. Fix `multiple-definitions` linker error and weird bug related to `src_cpp`.
10. Optimize library code by using `reference-passing` instead of `value-passing`
11. Enable compatibility with old code to include only `AsyncHTTPRequest_Generic.h`
12. Add support to **ESP32-S3 (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.) using EEPROM, SPIFFS or LittleFS**
13. Add `LittleFS` support to **ESP32-C3**
14. Use `ESP32-core's LittleFS` library instead of `Lorol's LITTLEFS` library for ESP32 core v2.0.0+
15. Add example [AsyncHTTPRequest_ESP_Multi](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/tree/master/examples/AsyncHTTPRequest_ESP_Multi) to demonstrate how to send requests to multiple addresses and receive responses from them.
---
---
@@ -1041,6 +1043,8 @@ This library is based on, modified, bug-fixed and improved from:
6. Thanks to [andrewk123](https://github.com/andrewk123) to report [**Http GET polling causes crash when host disconnected #22**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/22) leading to new release v1.4.0 to fix bug.
7. Thanks to [DavidAntonin](https://github.com/DavidAntonin) to report [Cannot send requests to different addresses #4](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/4) leading to new release v1.7.1 to demonstrate how to send requests to multiple addresses and receive responses from them.
<table>
<tr>
@@ -1050,7 +1054,10 @@ This library is based on, modified, bug-fixed and improved from:
<td align="center"><a href="https://github.com/baddwarf"><img src="https://github.com/baddwarf.png" width="100px;" alt="baddwarf"/><br /><sub><b>BadDwarf</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/spdi"><img src="https://github.com/spdi.png" width="100px;" alt="spdi"/><br /><sub><b>spdi</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/andrewk123"><img src="https://github.com/andrewk123.png" width="100px;" alt="andrewk123"/><br /><sub><b>andrewk123</b></sub></a><br /></td>
</tr>
</tr>
<tr>
<td align="center"><a href="https://github.com/DavidAntonin"><img src="https://github.com/DavidAntonin.png" width="100px;" alt="DavidAntonin"/><br /><sub><b>DavidAntonin</b></sub></a><br /></td>
</tr>
</table>
---
+26
View File
@@ -12,6 +12,10 @@
## Table of Contents
* [Changelog](#changelog)
* [Releases v1.7.1](#releases-v171)
* [Releases v1.7.0](#releases-v170)
* [Releases v1.6.0](#releases-v160)
* [Releases v1.5.0](#releases-v150)
* [Releases v1.4.1](#releases-v141)
* [Releases v1.4.0](#releases-v140)
* [Releases v1.3.1](#releases-v131)
@@ -32,6 +36,28 @@
## Changelog
### Releases v1.7.1
1. Add example [AsyncHTTPRequest_ESP_Multi](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/tree/master/examples/AsyncHTTPRequest_ESP_Multi) to demo connection to multiple addresses.
2. Update `Packages' Patches`
### Releases v1.7.0
1. Add support to new `ESP32-S3`
2. Add `LittleFS` support to `ESP32-C3`
3. Use ESP32-core's LittleFS library instead of Lorol's LITTLEFS library for v2.0.0+
### Releases v1.6.0
1. Reduce the breaking effect of v1.5.0 by enabling compatibility with old code to include only `AsyncHTTPRequest_Generic.h`
2. Update `Packages' Patches`
### Releases v1.5.0
1. Fix `multiple-definitions` linker error and weird bug related to `src_cpp`. Check [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80)
2. Optimize library code by using `reference-passing` instead of `value-passing`
3. Update all examples
#### Releases v1.4.1
##### Warning: Releases v1.4.1+ can be used and autodetect ESP32 core v2.0.0+ or v1.0.6- for WT32_ETH01
@@ -24,10 +24,14 @@
//char GET_ServerAddress[] = "192.168.2.110/";
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -86,6 +90,14 @@ void setup(void)
Serial.println("\nStart AsyncCustomHeader_STM32 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -35,10 +35,16 @@ const char GET_ServerAddress[] = "dweet.io";
// use your own thing name here
String dweetName = "/dweet/for/currentSecond?second=";
// 60s = 60 seconds to not flooding the server
#define HTTP_REQUEST_INTERVAL_MS 60000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Impl_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -134,6 +140,14 @@ void setup(void)
Serial.println("\nStart AsyncDweetGET_STM32 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -29,10 +29,14 @@ const char POST_ServerAddress[] = "dweet.io";
// use your own thing name here
String dweetName = "/dweet/for/pinA0-Read?";
// 60s = 60 seconds to not flooding the server
#define HTTP_REQUEST_INTERVAL_MS 10000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -133,6 +137,14 @@ void setup(void)
Serial.println("\nStart AsyncDweetPOST_STM32 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -44,6 +44,9 @@
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
#endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial
#define _ASYNC_HTTP_LOGLEVEL_ 1
@@ -65,7 +68,11 @@ const char* password = "your_pass";
#include <WiFi.h>
#endif
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Impl_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
@@ -128,12 +135,12 @@ void sendRequest()
}
else
{
Serial.println("Can't send bad request");
Serial.println(F("Can't send bad request"));
}
}
else
{
Serial.println("Can't send request");
Serial.println(F("Can't send request"));
}
}
@@ -143,9 +150,9 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
if (readyState == readyStateDone)
{
Serial.print("\n***************"); Serial.print(requestName[ requestIndex ]); Serial.println("***************");
Serial.print(F("\n***************")); Serial.print(requestName[ requestIndex ]); Serial.println(F("***************"));
Serial.println(request->responseText());
Serial.println("**************************************");
Serial.println(F("**************************************"));
#if 1
// Bypass hourly
@@ -170,19 +177,27 @@ void setup()
delay(200);
Serial.println("\nStarting AsyncHTTPMultiRequests using " + String(ARDUINO_BOARD));
Serial.print(F("\nStarting AsyncHTTPMultiRequests using ")); Serial.println(ARDUINO_BOARD);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print(F("Warning. Must use this example on Version equal or later than : "));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi SSID: " + String(ssid));
Serial.print(F("Connecting to WiFi SSID: ")); Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
Serial.print(F("."));
}
Serial.print(F("AsyncHTTPRequest @ IP : "));
@@ -65,14 +65,19 @@ const char* password = "your_pass";
#include <WiFi.h>
#endif
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
Ticker ticker;
Ticker ticker1;
void heartBeatPrint(void)
void heartBeatPrint()
{
static int num = 1;
@@ -108,12 +113,12 @@ void sendRequest()
}
else
{
Serial.println("Can't send bad request");
Serial.println(F("Can't send bad request"));
}
}
else
{
Serial.println("Can't send request");
Serial.println(F("Can't send request"));
}
}
@@ -123,9 +128,9 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println("**************************************");
Serial.println(F("**************************************"));
request->setDebug(false);
}
@@ -136,23 +141,25 @@ void setup()
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
delay(200);
Serial.println("\nStarting AsyncHTTPRequest_ESP using " + String(ARDUINO_BOARD));
Serial.print(F("\nStarting AsyncHTTPRequest_ESP using ")); Serial.println(ARDUINO_BOARD);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi SSID: " + String(ssid));
Serial.print(F("Connecting to WiFi SSID: ")); Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
Serial.print(F("."));
}
Serial.print(F("AsyncHTTPRequest @ IP : "));
Serial.print(F("\nAsyncHTTPRequest @ IP : "));
Serial.println(WiFi.localIP());
request.setDebug(false);
@@ -0,0 +1,206 @@
#if !( defined(ESP8266) || defined(ESP32) )
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
#endif
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial
#define _ASYNC_HTTP_LOGLEVEL_ 1
// 300s = 5 minutes to not flooding
#define HTTP_REQUEST_INTERVAL 300
// 10s
#define HEARTBEAT_INTERVAL 10
int status; // the Wifi radio's status
const char* ssid = "your_ssid";
const char* password = "your_pass";
#if (ESP8266)
#include <ESP8266WiFi.h>
#elif (ESP32)
#include <WiFi.h>
#endif
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // http://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
#define NUM_DIFFERENT_SITES 2
const char* addreses[][NUM_DIFFERENT_SITES] =
{
{"http://worldtimeapi.org/api/timezone/America/Toronto.txt", "http://worldtimeapi.org/api/timezone/Europe/Prague.txt"},
{"http://www.myexternalip.com/raw"}
};
#define NUM_ENTRIES_SITE_0 2
#define NUM_ENTRIES_SITE_1 1
byte reqCount[NUM_DIFFERENT_SITES] = { NUM_ENTRIES_SITE_0, NUM_ENTRIES_SITE_1 };
bool readySend[NUM_DIFFERENT_SITES] = { true, true };
AsyncHTTPRequest request[NUM_DIFFERENT_SITES];
void requestCB0(void* optParm, AsyncHTTPRequest* thisRequest, int readyState);
void requestCB1(void* optParm, AsyncHTTPRequest* thisRequest, int readyState);
void sendRequest0();
void sendRequest1();
typedef void (*requestCallback)(void* optParm, AsyncHTTPRequest* thisRequest, int readyState);
typedef void (*sendCallback)();
requestCallback requestCB [NUM_DIFFERENT_SITES] = { requestCB0, requestCB1 };
sendCallback sendRequestCB [NUM_DIFFERENT_SITES] = { sendRequest0, sendRequest1 };
Ticker ticker;
Ticker ticker1;
void heartBeatPrint()
{
static int num = 1;
if (WiFi.status() == WL_CONNECTED)
Serial.print(F("H")); // H means connected to WiFi
else
Serial.print(F("F")); // F means not connected to WiFi
if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(F(" "));
}
}
void sendRequest(uint16_t index)
{
static bool requestOpenResult;
reqCount[index]--;
readySend[index] = false;
requestOpenResult = request[index].open("GET", addreses[index][reqCount[index]]);
if (requestOpenResult)
{
// Only send() if open() returns true, or crash
Serial.print("\nSending request: ");
request[index].send();
}
else
{
Serial.print("\nCan't send bad request : ");
}
Serial.println(addreses[index][reqCount[index]]);
}
void sendRequest0()
{
sendRequest(0);
}
void sendRequest1()
{
sendRequest(1);
}
void sendRequests()
{
for (int index = 0; index < NUM_DIFFERENT_SITES; index++)
{
reqCount[index] = 2;
}
reqCount[0] = NUM_ENTRIES_SITE_0;
reqCount[1] = NUM_ENTRIES_SITE_1;
}
void requestCB0(void* optParm, AsyncHTTPRequest* thisRequest, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(thisRequest->responseText());
Serial.println("**************************************");
thisRequest->setDebug(false);
readySend[0] = true;
}
}
void requestCB1(void* optParm, AsyncHTTPRequest* thisRequest, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(thisRequest->responseText());
Serial.println("**************************************");
thisRequest->setDebug(false);
readySend[1] = true;
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
Serial.println("\nStarting AsyncHTTPRequest_ESP_Multi using " + String(ARDUINO_BOARD));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi SSID: " + String(ssid));
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.print(F("\nAsyncHTTPSRequest @ IP : "));
Serial.println(WiFi.localIP());
for (int index = 0; index < NUM_DIFFERENT_SITES; index++)
{
request[index].setDebug(false);
request[index].onReadyStateChange(requestCB[index]);
}
ticker.attach(HTTP_REQUEST_INTERVAL, sendRequests);
ticker1.attach(HEARTBEAT_INTERVAL, heartBeatPrint);
}
void loop()
{
for (int index = 0; index < NUM_DIFFERENT_SITES; index++)
{
if ((reqCount[index] > 0) && readySend[index])
// OK but have to use delay(100)
//if ( reqCount[index] > 0 )
{
sendRequestCB[index]();
//delay(100);
}
}
}
@@ -46,6 +46,12 @@
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
#endif
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.12.1"
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1012001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial
@@ -75,10 +81,25 @@
// The library will be depreciated after being merged to future major Arduino esp32 core release 2.x
// At that time, just remove this library inclusion
#include <LITTLEFS.h> // https://github.com/lorol/LITTLEFS
FS* filesystem = &LITTLEFS;
#define FileFS LITTLEFS
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) )
#warning Using ESP32 Core 1.0.6 or 2.0.0+ and core LittleFS library
// The library has been merged into esp32 core from release 1.0.6
#include <LittleFS.h> // https://github.com/espressif/arduino-esp32/tree/master/libraries/LittleFS
//#define FileFS LittleFS
//#define FS_Name "LittleFS"
FS* filesystem = &LittleFS;
#define FileFS LittleFS
#else
#warning Using ESP32 Core 1.0.5-. You must install LITTLEFS library
// The library has been merged into esp32 core from release 1.0.6
#include <LITTLEFS.h> // https://github.com/lorol/LITTLEFS
//#define FileFS LITTLEFS
FS* filesystem = &LITTLEFS;
#define FileFS LITTLEFS
#endif
#define FS_Name "LittleFS"
#elif USE_SPIFFS
#include <SPIFFS.h>
@@ -203,8 +224,8 @@ bool initialConfig = false;
#define USE_DHCP_IP true
#else
// You can select DHCP or Static IP here
//#define USE_DHCP_IP true
#define USE_DHCP_IP false
#define USE_DHCP_IP true
//#define USE_DHCP_IP false
#endif
#if ( USE_DHCP_IP || ( defined(USE_STATIC_IP_CONFIG_IN_CP) && !USE_STATIC_IP_CONFIG_IN_CP ) )
@@ -232,18 +253,27 @@ bool initialConfig = false;
IPAddress dns1IP = gatewayIP;
IPAddress dns2IP = IPAddress(8, 8, 8, 8);
#define USE_CUSTOM_AP_IP false
IPAddress APStaticIP = IPAddress(192, 168, 100, 1);
IPAddress APStaticGW = IPAddress(192, 168, 100, 1);
IPAddress APStaticSN = IPAddress(255, 255, 255, 0);
#include <ESPAsync_WiFiManager.h> //https://github.com/khoih-prog/ESPAsync_WiFiManager
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
//#include <ESPAsync_WiFiManager-Impl.h> //https://github.com/khoih-prog/ESPAsync_WiFiManager
#define HTTP_PORT 80
AsyncWebServer webServer(HTTP_PORT);
DNSServer dnsServer;
//AsyncWebServer webServer(HTTP_PORT);
//DNSServer dnsServer;
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
//#include <AsyncHTTPRequest_Impl_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
@@ -296,10 +326,10 @@ void initSTAIPConfigStruct(WiFi_STA_IPConfig &in_WM_STA_IPconfig)
void displayIPConfigStruct(WiFi_STA_IPConfig in_WM_STA_IPconfig)
{
LOGERROR3(F("stationIP ="), in_WM_STA_IPconfig._sta_static_ip, ", gatewayIP =", in_WM_STA_IPconfig._sta_static_gw);
LOGERROR3(F("stationIP ="), in_WM_STA_IPconfig._sta_static_ip, F(", gatewayIP ="), in_WM_STA_IPconfig._sta_static_gw);
LOGERROR1(F("netMask ="), in_WM_STA_IPconfig._sta_static_sn);
#if USE_CONFIGURABLE_DNS
LOGERROR3(F("dns1IP ="), in_WM_STA_IPconfig._sta_static_dns1, ", dns2IP =", in_WM_STA_IPconfig._sta_static_dns2);
LOGERROR3(F("dns1IP ="), in_WM_STA_IPconfig._sta_static_dns1, F(", dns2IP ="), in_WM_STA_IPconfig._sta_static_dns2);
#endif
}
@@ -389,7 +419,7 @@ uint8_t connectMultiWiFi()
return status;
}
void heartBeatPrint(void)
void heartBeatPrint()
{
static int num = 1;
@@ -409,7 +439,7 @@ void heartBeatPrint(void)
}
}
void check_WiFi(void)
void check_WiFi()
{
if ( (WiFi.status() != WL_CONNECTED) )
{
@@ -418,7 +448,7 @@ void check_WiFi(void)
}
}
void check_status(void)
void check_status()
{
static ulong checkstatus_timeout = 0;
static ulong checkwifi_timeout = 0;
@@ -515,12 +545,12 @@ void sendRequest()
}
else
{
Serial.println("Can't send bad request");
Serial.println(F("Can't send bad request"));
}
}
else
{
Serial.println("Can't send request");
Serial.println(F("Can't send request"));
}
}
@@ -530,9 +560,9 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println("**************************************");
Serial.println(F("**************************************"));
request->setDebug(false);
}
@@ -543,12 +573,30 @@ void setup()
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
delay(200);
Serial.print("\nStarting AsyncHTTPRequest_ESP_WiFiManager using " + String(FS_Name));
Serial.println(" on " + String(ARDUINO_BOARD));
Serial.print(F("\nStarting AsyncHTTPRequest_ESP_WiFiManager using ")); Serial.print(FS_Name);
Serial.print(F(" on ")); Serial.println(ARDUINO_BOARD);
Serial.println(ESP_ASYNC_WIFIMANAGER_VERSION);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ESP_ASYNC_WIFIMANAGER_VERSION_INT)
if (ESP_ASYNC_WIFIMANAGER_VERSION_INT < ESP_ASYNC_WIFIMANAGER_VERSION_MIN)
{
Serial.print(F("Warning. Must use this example on Version later than : "));
Serial.println(ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET);
}
#endif
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print(F("Warning. Must use this example on Version equal or later than : "));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
if (FORMAT_FILESYSTEM)
FileFS.format();
@@ -578,17 +626,28 @@ void setup()
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
//ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer);
// Use this to personalize DHCP hostname (RFC952 conformed)
ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "AutoConnectAP");
AsyncWebServer webServer(HTTP_PORT);
//ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "AutoConnectAP");
#if ( USING_ESP32_S2 || USING_ESP32_C3 )
ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, NULL, "AutoConnectAP");
#else
DNSServer dnsServer;
ESPAsync_wifiManager.setDebugOutput(true);
ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "AutoConnectAP");
#endif
//ESPAsync_wifiManager.setDebugOutput(true);
//reset settings - for testing
//ESPAsync_wifiManager.resetSettings();
#if USE_CUSTOM_AP_IP
//set custom ip for portal
// New in v1.4.0
ESPAsync_wifiManager.setAPStaticIPConfig(WM_AP_IPconfig);
//////
#endif
ESPAsync_wifiManager.setMinimumSignalQuality(-1);
@@ -616,16 +675,17 @@ void setup()
Router_Pass = ESPAsync_wifiManager.WiFi_Pass();
//Remove this line if you do not want to see WiFi password printed
Serial.println("Stored: SSID = " + Router_SSID + ", Pass = " + Router_Pass);
Serial.print(F("Stored: SSID = ")); Serial.print(Router_SSID);
Serial.print(F(", Pass = ")); Serial.println(Router_Pass);
if (Router_SSID != "")
{
ESPAsync_wifiManager.setConfigPortalTimeout(120); //If no access point name has been previously entered disable timeout.
Serial.println("Got stored Credentials. Timeout 120s");
Serial.println(F("Got stored Credentials. Timeout 120s"));
}
else
{
Serial.println("No stored Credentials. No timeout");
Serial.println(F("No stored Credentials. No timeout"));
}
String chipID = String(ESP_getChipId(), HEX);
@@ -638,16 +698,29 @@ void setup()
// From v1.1.0, Don't permit NULL password
if ( (Router_SSID == "") || (Router_Pass == "") )
{
Serial.println("We haven't got any access point credentials, so get them now");
Serial.println(F("We haven't got any access point credentials, so get them now"));
initialConfig = true;
Serial.print(F("Starting configuration portal @ "));
#if USE_CUSTOM_AP_IP
Serial.print(APStaticIP);
#else
Serial.print(F("192.168.4.1"));
#endif
Serial.print(F(", SSID = "));
Serial.print(AP_SSID);
Serial.print(F(", PASS = "));
Serial.println(AP_PASS);
// Starts an access point
//if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password))
if ( !ESPAsync_wifiManager.startConfigPortal(AP_SSID.c_str(), AP_PASS.c_str()) )
Serial.println("Not connected to WiFi but continuing anyway.");
Serial.println(F("Not connected to WiFi but continuing anyway."));
else
Serial.println("WiFi connected...yeey :)");
Serial.println(F("WiFi connected...yeey :)"));
// Stored for later usage, from v1.1.0, but clear first
memset(&WM_config, 0, sizeof(WM_config));
@@ -706,19 +779,19 @@ void setup()
if ( WiFi.status() != WL_CONNECTED )
{
Serial.println("ConnectMultiWiFi in setup");
Serial.println(F("ConnectMultiWiFi in setup"));
connectMultiWiFi();
}
}
Serial.print("After waiting ");
Serial.print(F("After waiting "));
Serial.print((float) (millis() - startedAt) / 1000L);
Serial.print(" secs more in setup(), connection result is ");
Serial.print(F(" secs more in setup(), connection result is "));
if (WiFi.status() == WL_CONNECTED)
{
Serial.print("connected. Local IP: ");
Serial.print(F("connected. Local IP: "));
Serial.println(WiFi.localIP());
}
else
@@ -42,10 +42,14 @@
#include "defines.h"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -103,6 +107,14 @@ void setup(void)
Serial.println("\nStart AsyncHTTPRequest_STM32 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -24,10 +24,14 @@
//char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/";
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -84,6 +88,14 @@ void setup(void)
Serial.println("\nStart AsyncSimpleGET_STM32 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -26,10 +26,14 @@ const char GET_ServerAddress[] = "arduino.cc";
// GET location
String GET_Location = "/asciilogo.txt";
// 60s = 60 seconds to not flooding the server
#define HTTP_REQUEST_INTERVAL_MS 60000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -86,6 +90,13 @@ void setup(void)
Serial.println("\nStart AsyncWebClientRepeating_STM32 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -24,10 +24,14 @@
//char GET_ServerAddress[] = "192.168.2.110/";
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -86,6 +90,14 @@ void setup(void)
Serial.println("\nStart AsyncCustomHeader_STM32_LAN8720 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -35,10 +35,14 @@ const char GET_ServerAddress[] = "dweet.io";
// use your own thing name here
String dweetName = "/dweet/for/currentSecond?second=";
// 60s = 60 seconds to not flooding the server
#define HTTP_REQUEST_INTERVAL_MS 60000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -134,6 +138,14 @@ void setup(void)
Serial.println("\nStart AsyncDweetGET_STM32_LAN8720 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -29,10 +29,14 @@ const char POST_ServerAddress[] = "dweet.io";
// use your own thing name here
String dweetName = "/dweet/for/pinA0-Read?";
// 60s = 60 seconds to not flooding the server
#define HTTP_REQUEST_INTERVAL_MS 10000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -133,6 +137,14 @@ void setup(void)
Serial.println("\nStart AsyncDweetPOST_STM32_LAN8720 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -42,10 +42,14 @@
#include "defines.h"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -103,6 +107,14 @@ void setup(void)
Serial.println("\nStart AsyncHTTPRequest_STM32_LAN8720 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -24,10 +24,14 @@
//char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/";
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -84,6 +88,14 @@ void setup(void)
Serial.println("\nStart AsyncSimpleGET_STM32_LAN8720 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -26,10 +26,14 @@ const char GET_ServerAddress[] = "arduino.cc";
// GET location
String GET_Location = "/asciilogo.txt";
// 60s = 60 seconds to not flooding the server
#define HTTP_REQUEST_INTERVAL_MS 60000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h> // https://github.com/sstaub/Ticker
@@ -86,6 +90,14 @@ void setup(void)
Serial.println("\nStart AsyncWebClientRepeating_STM32_LAN8720 on " + String(BOARD_NAME));
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -57,7 +57,12 @@
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
@@ -184,6 +189,14 @@ void setup()
Serial.setDebugOutput(true);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// To be called before ETH.begin()
WT32_ETH01_onEvent();
@@ -57,7 +57,12 @@
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
@@ -150,6 +155,14 @@ void setup()
Serial.setDebugOutput(true);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
// To be called before ETH.begin()
WT32_ETH01_onEvent();
@@ -0,0 +1,15 @@
/****************************************************************************************************************************
multiFileProject.cpp
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
*****************************************************************************************************************************/
// To demo how to include files in multi-file Projects
#include "multiFileProject.h"
@@ -0,0 +1,18 @@
/****************************************************************************************************************************
multiFileProject.h
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
*****************************************************************************************************************************/
// To demo how to include files in multi-file Projects
#pragma once
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
#include "AsyncHTTPRequest_Generic.hpp"
@@ -0,0 +1,50 @@
/****************************************************************************************************************************
multiFileProject.ino
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
*****************************************************************************************************************************/
// To demo how to include files in multi-file Projects
#if !( defined(ESP8266) || defined(ESP32) || \
( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
defined(STM32WB) || defined(STM32MP1) ) )
#error This code is intended to run on the ESP8266, ESP32 or STM32 platform! Please check your Tools->Board setting.
#endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#include "multiFileProject.h"
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
#include "AsyncHTTPRequest_Generic.h"
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println("\nStart multiFileProject");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
}
void loop()
{
// put your main code here, to run repeatedly:
}
+6
View File
@@ -40,6 +40,12 @@ version KEYWORD2
# Constants (LITERAL1)
#######################################
ASYNC_HTTP_REQUEST_GENERIC_VERSION LITERAL1
ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR LITERAL1
ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR LITERAL1
ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH LITERAL1
ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT LITERAL1
HTTPCODE_CONNECTION_REFUSED LITERAL1
HTTPCODE_SEND_HEADER_FAILED LITERAL1
HTTPCODE_SEND_PAYLOAD_FAILED LITERAL1
+6 -6
View File
@@ -1,8 +1,8 @@
{
"name":"AsyncHTTPRequest_Generic",
"version": "1.4.1",
"description":"Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32-S2), WT32_ETH01 (ESP32 + LAN8720), ESP8266 and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.",
"keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, wt32-eth01, ESPAsyncTCP, AsyncTCP, stm32, ethernet, wifi, lan8742a, lan8720, f407ve, nucleo, nucleo-144, stm32f7, stm32f4",
"version": "1.7.1",
"description":"Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32_S2, ESP32_S3 and ESP32_C3), WT32_ETH01 (ESP32 + LAN8720), ESP8266 and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.",
"keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, ESP32-S3, ESP32-C3, wt32-eth01, ESPAsyncTCP, AsyncTCP, stm32, ethernet, wifi, lan8742a, lan8720, f407ve, nucleo, nucleo-144, stm32f7, stm32f4",
"authors": [
{
"name": "Bob Lemaire",
@@ -11,7 +11,7 @@
{
"name": "Khoi Hoang",
"url": "https://github.com/khoih-prog",
"email": "khoih.prog@gmail.com",
"email": "khoih-dot-prog@gmail.com",
"maintainer": true
}
],
@@ -45,7 +45,7 @@
{
"owner": "khoih-prog",
"name": "ESPAsync_WiFiManager",
"version": ">=1.9.6",
"version": ">=1.12.1",
"platforms": ["espressif8266", "espressif32"]
},
{
@@ -81,5 +81,5 @@
"frameworks": "arduino",
"platforms": ["espressif8266", "espressif32", "ststm32"],
"examples": "examples/*/*/*.ino",
"headers": "AsyncHTTPRequest_Generic.h"
"headers": ["AsyncHTTPRequest_Generic.h", "AsyncHTTPRequest_Generic.hpp"]
}
+4 -4
View File
@@ -1,12 +1,12 @@
name=AsyncHTTPRequest_Generic
version=1.4.1
version=1.7.1
author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com>
maintainer=Khoi Hoang <khoih.prog@gmail.com>
license=MIT
sentence=Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32-S2), WT32_ETH01 (ESP32 + LAN8720), ESP8266 and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.
icense=GPLv3
sentence=Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32_S2, ESP32_S3 and ESP32_C3), WT32_ETH01 (ESP32 + LAN8720), ESP8266 and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.
paragraph=This AsyncHTTPRequest_Generic Library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, for ESP32 (including ESP32-S2), ESP8266 and STM32 with LAN8720 or built-in LAN8742A Ethernet, such as Nucleo-144 F767ZI, F407VE, etc.
category=Communication,AsyncTCP,AsyncHTTP
url=https://github.com/khoih-prog/AsyncHTTPRequest_Generic
architectures=*
depends=AsyncTCP,ESPAsyncTCP,ESPAsync_WiFiManager,STM32duino LwIP,STM32duino STM32Ethernet,WebServer_WT32_ETH01
includes=AsyncHTTPRequest_Generic.h
includes=AsyncHTTPRequest_Generic.h,AsyncHTTPRequest_Generic.hpp
+2 -2
View File
@@ -43,7 +43,7 @@ lib_deps =
; https://github.com/khoih-prog/STM32AsyncTCP.git
; STM32duino LwIP@>=2.1.2
; STM32duino STM32Ethernet@>=1.2.0
; ESPAsync_WiFiManager@>=1.9.6
; ESPAsync_WiFiManager@>=1.12.1
; LittleFS_esp32@>=1.0.6
; WebServer_WT32_ETH01@>=1.4.1
; PlatformIO 5.x
@@ -53,7 +53,7 @@ lib_deps =
; https://github.com/khoih-prog/STM32AsyncTCP.git
; stm32duino/STM32duino LwIP@>=2.1.2
; stm32duino/STM32duino STM32Ethernet@>=1.2.0
khoih-prog/ESPAsync_WiFiManager@>=1.9.6
khoih-prog/ESPAsync_WiFiManager@>=1.12.1
lorol/LittleFS_esp32@>=1.0.6
; khoih-prog/WebServer_WT32_ETH01@>=1.4.1
+5 -1
View File
@@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version: 1.7.1
Version Modified By Date Comments
------- ----------- ---------- -----------
@@ -35,6 +35,10 @@
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
1.5.0 K Hoang 30/12/2021 Fix `multiple-definitions` linker error
1.6.0 K Hoang 23/01/2022 Enable compatibility with old code to include only AsyncHTTPRequest_Generic.h
1.7.0 K Hoang 10/02/2022 Add support to new ESP32-S3. Add LittleFS support to ESP32-C3. Use core LittleFS
1.7.1 K Hoang 25/02/2022 Add example AsyncHTTPRequest_ESP_Multi to demo connection to multiple addresses
*****************************************************************************************************************************/
#pragma once
+6 -271
View File
@@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version: 1.7.1
Version Modified By Date Comments
------- ----------- ---------- -----------
@@ -35,6 +35,10 @@
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
1.5.0 K Hoang 30/12/2021 Fix `multiple-definitions` linker error
1.6.0 K Hoang 23/01/2022 Enable compatibility with old code to include only AsyncHTTPRequest_Generic.h
1.7.0 K Hoang 10/02/2022 Add support to new ESP32-S3. Add LittleFS support to ESP32-C3. Use core LittleFS
1.7.1 K Hoang 25/02/2022 Add example AsyncHTTPRequest_ESP_Multi to demo connection to multiple addresses
*****************************************************************************************************************************/
#pragma once
@@ -42,276 +46,7 @@
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
#define ASYNC_HTTP_REQUEST_GENERIC_H
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.4.1"
#include <Arduino.h>
#include "AsyncHTTPRequest_Debug_Generic.h"
#ifndef DEBUG_IOTA_PORT
#define DEBUG_IOTA_PORT Serial
#endif
#ifdef DEBUG_IOTA_HTTP
#define DEBUG_IOTA_HTTP_SET true
#else
#define DEBUG_IOTA_HTTP_SET false
#endif
// KH add
#define SAFE_DELETE(object) if (object) { delete object;}
#define SAFE_DELETE_ARRAY(object) if (object) { delete[] object;}
#if ESP32
#include <AsyncTCP.h>
// KH mod
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
#define _AHTTP_lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
#define _AHTTP_unlock xSemaphoreGiveRecursive(threadLock)
#elif ESP8266
#include <ESPAsyncTCP.h>
#define MUTEX_LOCK_NR
#define MUTEX_LOCK(returnVal)
#define _AHTTP_lock
#define _AHTTP_unlock
#elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
defined(STM32WB) || defined(STM32MP1) )
#include "STM32AsyncTCP.h"
#define MUTEX_LOCK_NR
#define MUTEX_LOCK(returnVal)
#define _AHTTP_lock
#define _AHTTP_unlock
#endif
#include <pgmspace.h>
#include <utility/xbuf.h>
#define DEBUG_HTTP(format,...) if(_debug){\
DEBUG_IOTA_PORT.printf("Debug(%3ld): ", millis()-_requestStartTime);\
DEBUG_IOTA_PORT.printf_P(PSTR(format),##__VA_ARGS__);}
#define DEFAULT_RX_TIMEOUT 3 // Seconds for timeout
#define HTTPCODE_CONNECTION_REFUSED (-1)
#define HTTPCODE_SEND_HEADER_FAILED (-2)
#define HTTPCODE_SEND_PAYLOAD_FAILED (-3)
#define HTTPCODE_NOT_CONNECTED (-4)
#define HTTPCODE_CONNECTION_LOST (-5)
#define HTTPCODE_NO_STREAM (-6)
#define HTTPCODE_NO_HTTP_SERVER (-7)
#define HTTPCODE_TOO_LESS_RAM (-8)
#define HTTPCODE_ENCODING (-9)
#define HTTPCODE_STREAM_WRITE (-10)
#define HTTPCODE_TIMEOUT (-11)
typedef enum
{
readyStateUnsent = 0, // Client created, open not yet called
readyStateOpened = 1, // open() has been called, connected
readyStateHdrsRecvd = 2, // send() called, response headers available
readyStateLoading = 3, // receiving, partial data available
readyStateDone = 4 // Request complete, all data available.
} reqStates;
class AsyncHTTPRequest
{
struct header
{
header* next;
char* name;
char* value;
header(): next(nullptr), name(nullptr), value(nullptr)
{};
~header()
{
SAFE_DELETE_ARRAY(name)
SAFE_DELETE_ARRAY(value)
SAFE_DELETE(next)
//delete[] name;
//delete[] value;
//delete next;
}
};
struct URL
{
char* scheme;
char* user;
char* pwd;
char* host;
int port;
char* path;
char* query;
char* fragment;
URL(): scheme(nullptr), user(nullptr), pwd(nullptr), host(nullptr),
port(80), path(nullptr), query(nullptr), fragment(nullptr)
{};
~URL()
{
SAFE_DELETE_ARRAY(scheme)
SAFE_DELETE_ARRAY(user)
SAFE_DELETE_ARRAY(pwd)
SAFE_DELETE_ARRAY(host)
SAFE_DELETE_ARRAY(path)
SAFE_DELETE_ARRAY(query)
SAFE_DELETE_ARRAY(fragment)
}
};
typedef std::function<void(void*, AsyncHTTPRequest*, int readyState)> readyStateChangeCB;
typedef std::function<void(void*, AsyncHTTPRequest*, size_t available)> onDataCB;
public:
AsyncHTTPRequest();
~AsyncHTTPRequest();
//External functions in typical order of use:
//__________________________________________________________________________________________________________*/
void setDebug(bool); // Turn debug message on/off
bool debug(); // is debug on or off?
bool open(const char* /*GET/POST*/, const char* URL); // Initiate a request
void onReadyStateChange(readyStateChangeCB, void* arg = 0); // Optional event handler for ready state change
// or you can simply poll readyState()
void setTimeout(int); // overide default timeout (seconds)
void setReqHeader(const char* name, const char* value); // add a request header
void setReqHeader(const char* name, int32_t value); // overload to use integer value
#if (ESP32 || ESP8266)
void setReqHeader(const char* name, const __FlashStringHelper* value);
void setReqHeader(const __FlashStringHelper *name, const char* value);
void setReqHeader(const __FlashStringHelper *name, const __FlashStringHelper* value);
void setReqHeader(const __FlashStringHelper *name, int32_t value);
#endif
bool send(); // Send the request (GET)
bool send(String body); // Send the request (POST)
bool send(const char* body); // Send the request (POST)
bool send(const uint8_t* buffer, size_t len); // Send the request (POST) (binary data?)
bool send(xbuf* body, size_t len); // Send the request (POST) data in an xbuf
void abort(); // Abort the current operation
reqStates readyState(); // Return the ready state
int respHeaderCount(); // Retrieve count of response headers
char* respHeaderName(int index); // Return header name by index
char* respHeaderValue(int index); // Return header value by index
char* respHeaderValue(const char* name); // Return header value by name
bool respHeaderExists(const char* name); // Does header exist by name?
#if (ESP32 || ESP8266)
char* respHeaderValue(const __FlashStringHelper *name);
bool respHeaderExists(const __FlashStringHelper *name);
#endif
String headers(); // Return all headers as String
void onData(onDataCB, void* arg = 0); // Notify when min data is available
size_t available(); // response available
size_t responseLength(); // indicated response length or sum of chunks to date
int responseHTTPcode(); // HTTP response code or (negative) error code
String responseText(); // response (whole* or partial* as string)
char* responseLongText(); // response long (whole* or partial* as string)
size_t responseRead(uint8_t* buffer, size_t len); // Read response into buffer
uint32_t elapsedTime(); // Elapsed time of in progress transaction or last completed (ms)
String version(); // Version of AsyncHTTPRequest
//___________________________________________________________________________________________________________________________________
private:
// New in v1.1.1
bool _requestReadyToSend;
//////
// New in v1.1.0
typedef enum { HTTPmethodGET, HTTPmethodPOST, HTTPmethodPUT, HTTPmethodPATCH, HTTPmethodDELETE, HTTPmethodHEAD, HTTPmethodMAX } HTTPmethod;
HTTPmethod _HTTPmethod;
const char* _HTTPmethodStringwithSpace[HTTPmethodMAX] = {"GET ", "POST ", "PUT ", "PATCH ", "DELETE ", "HEAD "};
//////
reqStates _readyState;
int16_t _HTTPcode; // HTTP response code or (negative) exception code
bool _chunked; // Processing chunked response
bool _debug; // Debug state
uint32_t _timeout; // Default or user overide RxTimeout in seconds
uint32_t _lastActivity; // Time of last activity
uint32_t _requestStartTime; // Time last open() issued
uint32_t _requestEndTime; // Time of last disconnect
URL* _URL; // -> URL data structure
char* _connectedHost; // Host when connected
int _connectedPort; // Port when connected
AsyncClient* _client; // ESPAsyncTCP AsyncClient instance
size_t _contentLength; // content-length header value or sum of chunk headers
size_t _contentRead; // number of bytes retrieved by user since last open()
readyStateChangeCB _readyStateChangeCB; // optional callback for readyState change
void* _readyStateChangeCBarg; // associated user argument
onDataCB _onDataCB; // optional callback when data received
void* _onDataCBarg; // associated user argument
#ifdef ESP32
SemaphoreHandle_t threadLock;
#endif
// request and response String buffers and header list (same queue for request and response).
xbuf* _request; // Tx data buffer
xbuf* _response; // Rx data buffer for headers
xbuf* _chunks; // First stage for chunked response
header* _headers; // request or (readyState > readyStateHdrsRcvd) response headers
// Protected functions
header* _addHeader(const char*, const char*);
header* _getHeader(const char*);
header* _getHeader(int);
bool _buildRequest();
bool _parseURL(const char*);
bool _parseURL(String);
void _processChunks();
bool _connect();
size_t _send();
void _setReadyState(reqStates);
#if (ESP32 || ESP8266)
char* _charstar(const __FlashStringHelper *str);
#endif
// callbacks
void _onConnect(AsyncClient*);
void _onDisconnect(AsyncClient*);
void _onData(void*, size_t);
void _onError(AsyncClient*, int8_t);
void _onPoll(AsyncClient*);
bool _collectHeaders();
};
#include "AsyncHTTPRequest_Generic.hpp"
#include "AsyncHTTPRequest_Impl_Generic.h"
#endif // ASYNC_HTTP_REQUEST_GENERIC_H
@@ -1,5 +1,5 @@
/****************************************************************************************************************************
AsyncHTTPRequest_Generic.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
AsyncHTTPRequest_Generic.hpp - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
@@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version: 1.7.1
Version Modified By Date Comments
------- ----------- ---------- -----------
@@ -35,14 +35,24 @@
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
1.5.0 K Hoang 30/12/2021 Fix `multiple-definitions` linker error
1.6.0 K Hoang 23/01/2022 Enable compatibility with old code to include only AsyncHTTPRequest_Generic.h
1.7.0 K Hoang 10/02/2022 Add support to new ESP32-S3. Add LittleFS support to ESP32-C3. Use core LittleFS
1.7.1 K Hoang 25/02/2022 Add example AsyncHTTPRequest_ESP_Multi to demo connection to multiple addresses
*****************************************************************************************************************************/
#pragma once
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
#define ASYNC_HTTP_REQUEST_GENERIC_H
#ifndef ASYNC_HTTP_REQUEST_GENERIC_HPP
#define ASYNC_HTTP_REQUEST_GENERIC_HPP
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.4.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.7.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 7
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 1
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1007001
#include <Arduino.h>
@@ -98,7 +108,110 @@
#endif
#include <pgmspace.h>
#include <utility/xbuf.h>
// Merge xbuf
////////////////////////////////////////////////////////////////////////////
struct xseg
{
xseg *next;
uint8_t data[];
};
class xbuf: public Print
{
public:
xbuf(const uint16_t segSize = 64);
virtual ~xbuf();
size_t write(const uint8_t);
size_t write(const char*);
size_t write(const uint8_t*, const size_t);
size_t write(xbuf*, const size_t);
size_t write(const String& string);
size_t available();
int indexOf(const char, const size_t begin = 0);
int indexOf(const char*, const size_t begin = 0);
uint8_t read();
size_t read(uint8_t*, size_t);
String readStringUntil(const char);
String readStringUntil(const char*);
String readString(int);
String readString()
{
return readString(available());
}
void flush();
uint8_t peek();
size_t peek(uint8_t*, const size_t);
String peekStringUntil(const char target)
{
return peekString(indexOf(target, 0));
}
String peekStringUntil(const char* target)
{
return peekString(indexOf(target, 0));
}
String peekString()
{
return peekString(_used);
}
String peekString(int);
/* In addition to the above functions,
the following inherited functions from the Print class are available.
size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3)));
size_t printf_P(PGM_P format, ...) __attribute__((format(printf, 2, 3)));
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
*/
protected:
xseg *_head;
xseg *_tail;
uint16_t _used;
uint16_t _free;
uint16_t _offset;
uint16_t _segSize;
void addSeg();
void remSeg();
};
////////////////////////////////////////////////////////////////////////////
#define DEBUG_HTTP(format,...) if(_debug){\
DEBUG_IOTA_PORT.printf("Debug(%3ld): ", millis()-_requestStartTime);\
@@ -205,7 +318,7 @@ class AsyncHTTPRequest
#endif
bool send(); // Send the request (GET)
bool send(String body); // Send the request (POST)
bool send(const String& body); // Send the request (POST)
bool send(const char* body); // Send the request (POST)
bool send(const uint8_t* buffer, size_t len); // Send the request (POST) (binary data?)
bool send(xbuf* body, size_t len); // Send the request (POST) data in an xbuf
@@ -292,7 +405,7 @@ class AsyncHTTPRequest
header* _getHeader(int);
bool _buildRequest();
bool _parseURL(const char*);
bool _parseURL(String);
bool _parseURL(const String& url);
void _processChunks();
bool _connect();
size_t _send();
@@ -312,6 +425,4 @@ class AsyncHTTPRequest
bool _collectHeaders();
};
#endif // ASYNC_HTTP_REQUEST_GENERIC_H
#endif // ASYNC_HTTP_REQUEST_GENERIC_HPP
+396 -7
View File
@@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version: 1.7.1
Version Modified By Date Comments
------- ----------- ---------- -----------
@@ -35,6 +35,10 @@
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
1.5.0 K Hoang 30/12/2021 Fix `multiple-definitions` linker error
1.6.0 K Hoang 23/01/2022 Enable compatibility with old code to include only AsyncHTTPRequest_Generic.h
1.7.0 K Hoang 10/02/2022 Add support to new ESP32-S3. Add LittleFS support to ESP32-C3. Use core LittleFS
1.7.1 K Hoang 25/02/2022 Add example AsyncHTTPRequest_ESP_Multi to demo connection to multiple addresses
*****************************************************************************************************************************/
#pragma once
@@ -44,6 +48,394 @@
#define CANT_SEND_BAD_REQUEST F("Can't send() bad request")
// Merge xbuf
////////////////////////////////////////////////////////////////////////////
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
{
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
}
//*******************************************************************************************************************
xbuf::~xbuf()
{
flush();
}
//*******************************************************************************************************************
size_t xbuf::write(const uint8_t byte)
{
return write((uint8_t*) &byte, 1);
}
//*******************************************************************************************************************
size_t xbuf::write(const char* buf)
{
return write((uint8_t*)buf, strlen(buf));
}
//*******************************************************************************************************************
size_t xbuf::write(const String& string)
{
return write((uint8_t*)string.c_str(), string.length());
}
//*******************************************************************************************************************
size_t xbuf::write(const uint8_t* buf, const size_t len)
{
size_t supply = len;
while (supply)
{
if (!_free)
{
addSeg();
}
size_t demand = _free < supply ? _free : supply;
memcpy(_tail->data + ((_offset + _used) % _segSize), buf + (len - supply), demand);
_free -= demand;
_used += demand;
supply -= demand;
}
return len;
}
//*******************************************************************************************************************
size_t xbuf::write(xbuf* buf, const size_t len)
{
size_t supply = len;
if (supply > buf->available())
{
supply = buf->available();
}
size_t read = 0;
while (supply)
{
if (!_free)
{
addSeg();
}
size_t demand = _free < supply ? _free : supply;
read += buf->read(_tail->data + ((_offset + _used) % _segSize), demand);
_free -= demand;
_used += demand;
supply -= demand;
}
return read;
}
//*******************************************************************************************************************
uint8_t xbuf::read()
{
uint8_t byte = 0;
read((uint8_t*) &byte, 1);
return byte;
}
//*******************************************************************************************************************
uint8_t xbuf::peek()
{
uint8_t byte = 0;
peek((uint8_t*) &byte, 1);
return byte;
}
//*******************************************************************************************************************
size_t xbuf::read(uint8_t* buf, const size_t len)
{
size_t read = 0;
while (read < len && _used)
{
size_t supply = (_offset + _used) > _segSize ? _segSize - _offset : _used;
size_t demand = len - read;
size_t chunk = supply < demand ? supply : demand;
memcpy(buf + read, _head->data + _offset, chunk);
_offset += chunk;
_used -= chunk;
read += chunk;
if (_offset == _segSize)
{
remSeg();
_offset = 0;
}
}
if ( ! _used)
{
flush();
}
return read;
}
//*******************************************************************************************************************
size_t xbuf::peek(uint8_t* buf, const size_t len)
{
size_t read = 0;
xseg* seg = _head;
size_t offset = _offset;
size_t used = _used;
while (read < len && used)
{
size_t supply = (offset + used) > _segSize ? _segSize - offset : used;
size_t demand = len - read;
size_t chunk = supply < demand ? supply : demand;
memcpy(buf + read, seg->data + offset, chunk);
offset += chunk;
used -= chunk;
read += chunk;
if (offset == _segSize)
{
seg = seg->next;
offset = 0;
}
}
return read;
}
//*******************************************************************************************************************
size_t xbuf::available()
{
return _used;
}
//*******************************************************************************************************************
int xbuf::indexOf(const char target, const size_t begin)
{
char targetstr[2] = " ";
targetstr[0] = target;
return indexOf(targetstr, begin);
}
//*******************************************************************************************************************
int xbuf::indexOf(const char* target, const size_t begin)
{
size_t targetLen = strlen(target);
if (targetLen > _segSize || targetLen > _used)
return -1;
size_t searchPos = _offset + begin;
size_t searchEnd = _offset + _used - targetLen;
if (searchPos > searchEnd)
return -1;
size_t searchSeg = searchPos / _segSize;
xseg* seg = _head;
while (searchSeg)
{
seg = seg->next;
searchSeg --;
}
size_t segPos = searchPos % _segSize;
while (searchPos <= searchEnd)
{
size_t compLen = targetLen;
if (compLen <= (_segSize - segPos))
{
if (memcmp(target, seg->data + segPos, compLen) == 0)
{
return searchPos - _offset;
}
}
else
{
size_t compLen = _segSize - segPos;
if (memcmp(target, seg->data + segPos, compLen) == 0)
{
compLen = targetLen - compLen;
if (memcmp(target + targetLen - compLen, seg->next->data, compLen) == 0)
{
return searchPos - _offset;
}
}
}
searchPos++;
segPos++;
if (segPos == _segSize)
{
seg = seg->next;
segPos = 0;
}
}
return -1;
}
//*******************************************************************************************************************
String xbuf::readStringUntil(const char target)
{
return readString(indexOf(target) + 1);
}
//*******************************************************************************************************************
String xbuf::readStringUntil(const char* target)
{
int index = indexOf(target);
if (index < 0)
return String();
return readString(index + strlen(target));
}
//*******************************************************************************************************************
String xbuf::readString(int endPos)
{
String result;
if ( ! result.reserve(endPos + 1))
{
// KH, to remove
AHTTP_LOGDEBUG1("xbuf::readString: can't reserve size = ", endPos + 1);
///////
return result;
}
// KH, to remove
AHTTP_LOGDEBUG1("xbuf::readString: Reserved size = ", endPos + 1);
///////
if (endPos > _used)
{
endPos = _used;
}
if (endPos > 0 && result.reserve(endPos + 1))
{
while (endPos--)
{
result += (char)_head->data[_offset++];
_used--;
if (_offset >= _segSize)
{
remSeg();
}
}
}
return result;
}
//*******************************************************************************************************************
String xbuf::peekString(int endPos)
{
String result;
xseg* seg = _head;
size_t offset = _offset;
if (endPos > _used)
{
endPos = _used;
}
if (endPos > 0 && result.reserve(endPos + 1))
{
while (endPos--)
{
result += (char)seg->data[offset++];
if ( offset >= _segSize)
{
seg = seg->next;
offset = 0;
}
}
}
return result;
}
//*******************************************************************************************************************
void xbuf::flush()
{
while (_head)
remSeg();
_tail = nullptr;
_offset = 0;
_used = 0;
_free = 0;
}
//*******************************************************************************************************************
void xbuf::addSeg()
{
if (_tail)
{
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail->next == NULL)
AHTTP_LOGERROR("xbuf::addSeg: error new 1");
// KH, Must check NULL here
_tail = _tail->next;
}
else
{
// KH, Must check NULL here
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail == NULL)
AHTTP_LOGERROR("xbuf::addSeg: error new 2");
}
// KH, Must check NULL here
if (_tail)
_tail->next = nullptr;
_free += _segSize;
}
//*******************************************************************************************************************
void xbuf::remSeg()
{
if (_head)
{
xseg *next = _head->next;
delete[] (uint32_t*) _head;
_head = next;
if ( ! _head)
{
_tail = nullptr;
}
}
_offset = 0;
}
////////////////////////////////////////////////////////////////////////////
//**************************************************************************************************************
AsyncHTTPRequest::AsyncHTTPRequest(): _readyState(readyStateUnsent), _HTTPcode(0), _chunked(false), _debug(DEBUG_IOTA_HTTP_SET)
, _timeout(DEFAULT_RX_TIMEOUT), _lastActivity(0), _requestStartTime(0), _requestEndTime(0), _URL(nullptr)
@@ -248,7 +640,7 @@ bool AsyncHTTPRequest::send()
}
//**************************************************************************************************************
bool AsyncHTTPRequest::send(String body)
bool AsyncHTTPRequest::send(const String& body)
{
// New in v1.1.1
if (_requestReadyToSend)
@@ -465,8 +857,6 @@ String AsyncHTTPRequest::responseText()
//**************************************************************************************************************
#if 1
#if (ESP32)
#define GLOBAL_STR_LEN (32 * 1024)
#elif (ESP8266)
@@ -508,7 +898,6 @@ char* AsyncHTTPRequest::responseLongText()
return globalLongString;
}
#endif
//**************************************************************************************************************
size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
@@ -602,7 +991,7 @@ bool AsyncHTTPRequest::_parseURL(const char* url)
}
//**************************************************************************************************************
bool AsyncHTTPRequest::_parseURL(String url)
bool AsyncHTTPRequest::_parseURL(const String& url)
{
SAFE_DELETE(_URL)
@@ -1539,7 +1928,7 @@ char* AsyncHTTPRequest::_charstar(const __FlashStringHelper * str)
strcpy_P(ptr, (PGM_P)str);
}
// Rturn good ptr or nullptr
// Return good ptr or nullptr
return ptr;
}
-167
View File
@@ -1,167 +0,0 @@
/****************************************************************************************************************************
xbuf.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
*****************************************************************************************************************************/
/********************************************************************************************
xbuf is a dynamic buffering system that supports reading and writing much like cbuf.
The class has it's own provision for writing from buffers, Strings and other xbufs
as well as the inherited Print functions.
Rather than use a large contiguous heap allocation, xbuf uses a linked chain of segments
to dynamically grow and shrink with the contents.
There are other benefits as well to using smaller heap allocation units:
1) A buffer can work fine in a fragmented heap environment (admittedly contributing to it)
2) xbuf contents can be copied from one buffer to another without the need for
2x heap during the copy.
The segment size defaults to 64 but can be dynamically set in the constructor at creation.
The inclusion of indexOf and read/peek until functions make it useful for handling
data streams like HTTP, and in fact is why it was created.
NOTE: The size of the indexOf() search string is limited to the segment size.
It could be extended but didn't seem to be a practical consideration.
********************************************************************************************/
#pragma once
#ifndef XBUF_H
#define XBUF_H
#include <Arduino.h>
struct xseg
{
xseg *next;
uint8_t data[];
};
class xbuf: public Print
{
public:
xbuf(const uint16_t segSize = 64);
virtual ~xbuf();
size_t write(const uint8_t);
size_t write(const char*);
size_t write(const uint8_t*, const size_t);
size_t write(xbuf*, const size_t);
size_t write(String);
size_t available();
int indexOf(const char, const size_t begin = 0);
int indexOf(const char*, const size_t begin = 0);
uint8_t read();
size_t read(uint8_t*, size_t);
String readStringUntil(const char);
String readStringUntil(const char*);
String readString(int);
String readString()
{
return readString(available());
}
void flush();
uint8_t peek();
size_t peek(uint8_t*, const size_t);
String peekStringUntil(const char target)
{
return peekString(indexOf(target, 0));
}
String peekStringUntil(const char* target)
{
return peekString(indexOf(target, 0));
}
String peekString()
{
return peekString(_used);
}
String peekString(int);
/* In addition to the above functions,
the following inherited functions from the Print class are available.
size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3)));
size_t printf_P(PGM_P format, ...) __attribute__((format(printf, 2, 3)));
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
*/
protected:
xseg *_head;
xseg *_tail;
uint16_t _used;
uint16_t _free;
uint16_t _offset;
uint16_t _segSize;
void addSeg();
void remSeg();
};
#include "utility/xbuf_Impl.h"
#endif // XBUF_H
-429
View File
@@ -1,429 +0,0 @@
/****************************************************************************************************************************
xbuf_Impl.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
*****************************************************************************************************************************/
#pragma once
#ifndef XBUF_IMPL_H
#define XBUF_IMPL_H
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
{
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
}
//*******************************************************************************************************************
xbuf::~xbuf()
{
flush();
}
//*******************************************************************************************************************
size_t xbuf::write(const uint8_t byte)
{
return write((uint8_t*) &byte, 1);
}
//*******************************************************************************************************************
size_t xbuf::write(const char* buf)
{
return write((uint8_t*)buf, strlen(buf));
}
//*******************************************************************************************************************
size_t xbuf::write(String string)
{
return write((uint8_t*)string.c_str(), string.length());
}
//*******************************************************************************************************************
size_t xbuf::write(const uint8_t* buf, const size_t len)
{
size_t supply = len;
while (supply)
{
if (!_free)
{
addSeg();
}
size_t demand = _free < supply ? _free : supply;
memcpy(_tail->data + ((_offset + _used) % _segSize), buf + (len - supply), demand);
_free -= demand;
_used += demand;
supply -= demand;
}
return len;
}
//*******************************************************************************************************************
size_t xbuf::write(xbuf* buf, const size_t len)
{
size_t supply = len;
if (supply > buf->available())
{
supply = buf->available();
}
size_t read = 0;
while (supply)
{
if (!_free)
{
addSeg();
}
size_t demand = _free < supply ? _free : supply;
read += buf->read(_tail->data + ((_offset + _used) % _segSize), demand);
_free -= demand;
_used += demand;
supply -= demand;
}
return read;
}
//*******************************************************************************************************************
uint8_t xbuf::read()
{
uint8_t byte = 0;
read((uint8_t*) &byte, 1);
return byte;
}
//*******************************************************************************************************************
uint8_t xbuf::peek()
{
uint8_t byte = 0;
peek((uint8_t*) &byte, 1);
return byte;
}
//*******************************************************************************************************************
size_t xbuf::read(uint8_t* buf, const size_t len)
{
size_t read = 0;
while (read < len && _used)
{
size_t supply = (_offset + _used) > _segSize ? _segSize - _offset : _used;
size_t demand = len - read;
size_t chunk = supply < demand ? supply : demand;
memcpy(buf + read, _head->data + _offset, chunk);
_offset += chunk;
_used -= chunk;
read += chunk;
if (_offset == _segSize)
{
remSeg();
_offset = 0;
}
}
if ( ! _used)
{
flush();
}
return read;
}
//*******************************************************************************************************************
size_t xbuf::peek(uint8_t* buf, const size_t len)
{
size_t read = 0;
xseg* seg = _head;
size_t offset = _offset;
size_t used = _used;
while (read < len && used)
{
size_t supply = (offset + used) > _segSize ? _segSize - offset : used;
size_t demand = len - read;
size_t chunk = supply < demand ? supply : demand;
memcpy(buf + read, seg->data + offset, chunk);
offset += chunk;
used -= chunk;
read += chunk;
if (offset == _segSize)
{
seg = seg->next;
offset = 0;
}
}
return read;
}
//*******************************************************************************************************************
size_t xbuf::available()
{
return _used;
}
//*******************************************************************************************************************
int xbuf::indexOf(const char target, const size_t begin)
{
char targetstr[2] = " ";
targetstr[0] = target;
return indexOf(targetstr, begin);
}
//*******************************************************************************************************************
int xbuf::indexOf(const char* target, const size_t begin)
{
size_t targetLen = strlen(target);
if (targetLen > _segSize || targetLen > _used)
return -1;
size_t searchPos = _offset + begin;
size_t searchEnd = _offset + _used - targetLen;
if (searchPos > searchEnd)
return -1;
size_t searchSeg = searchPos / _segSize;
xseg* seg = _head;
while (searchSeg)
{
seg = seg->next;
searchSeg --;
}
size_t segPos = searchPos % _segSize;
while (searchPos <= searchEnd)
{
size_t compLen = targetLen;
if (compLen <= (_segSize - segPos))
{
if (memcmp(target, seg->data + segPos, compLen) == 0)
{
return searchPos - _offset;
}
}
else
{
size_t compLen = _segSize - segPos;
if (memcmp(target, seg->data + segPos, compLen) == 0)
{
compLen = targetLen - compLen;
if (memcmp(target + targetLen - compLen, seg->next->data, compLen) == 0)
{
return searchPos - _offset;
}
}
}
searchPos++;
segPos++;
if (segPos == _segSize)
{
seg = seg->next;
segPos = 0;
}
}
return -1;
}
//*******************************************************************************************************************
String xbuf::readStringUntil(const char target)
{
return readString(indexOf(target) + 1);
}
//*******************************************************************************************************************
String xbuf::readStringUntil(const char* target)
{
int index = indexOf(target);
if (index < 0)
return String();
return readString(index + strlen(target));
}
//*******************************************************************************************************************
String xbuf::readString(int endPos)
{
String result;
if ( ! result.reserve(endPos + 1))
{
// KH, to remove
AHTTP_LOGDEBUG1("xbuf::readString: can't reserve size = ", endPos + 1);
///////
return result;
}
// KH, to remove
AHTTP_LOGDEBUG1("xbuf::readString: Reserved size = ", endPos + 1);
///////
if (endPos > _used)
{
endPos = _used;
}
if (endPos > 0 && result.reserve(endPos + 1))
{
while (endPos--)
{
result += (char)_head->data[_offset++];
_used--;
if (_offset >= _segSize)
{
remSeg();
}
}
}
return result;
}
//*******************************************************************************************************************
String xbuf::peekString(int endPos)
{
String result;
xseg* seg = _head;
size_t offset = _offset;
if (endPos > _used)
{
endPos = _used;
}
if (endPos > 0 && result.reserve(endPos + 1))
{
while (endPos--)
{
result += (char)seg->data[offset++];
if ( offset >= _segSize)
{
seg = seg->next;
offset = 0;
}
}
}
return result;
}
//*******************************************************************************************************************
void xbuf::flush()
{
while (_head)
remSeg();
_tail = nullptr;
_offset = 0;
_used = 0;
_free = 0;
}
//*******************************************************************************************************************
void xbuf::addSeg()
{
if (_tail)
{
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail->next == NULL)
AHTTP_LOGERROR("xbuf::addSeg: error new 1");
// KH, Must check NULL here
_tail = _tail->next;
}
else
{
// KH, Must check NULL here
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail == NULL)
AHTTP_LOGERROR("xbuf::addSeg: error new 2");
}
// KH, Must check NULL here
if (_tail)
_tail->next = nullptr;
_free += _segSize;
}
//*******************************************************************************************************************
void xbuf::remSeg()
{
if (_head)
{
xseg *next = _head->next;
delete[] (uint32_t*) _head;
_head = next;
if ( ! _head)
{
_tail = nullptr;
}
}
_offset = 0;
}
#endif // XBUF_IMPL_H
-107
View File
@@ -1,107 +0,0 @@
/****************************************************************************************************************************
AsyncHTTPRequest_Debug_Generic.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
*****************************************************************************************************************************/
#pragma once
#ifndef ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
#define ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
#ifdef ASYNC_HTTP_DEBUG_PORT
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
#else
#define A_DBG_PORT Serial
#endif
// Change _ASYNC_HTTP_LOGLEVEL_ to set tracing and logging verbosity
// 0: DISABLED: no logging
// 1: ERROR: errors
// 2: WARN: errors and warnings
// 3: INFO: errors, warnings and informational (default)
// 4: DEBUG: errors, warnings, informational and debug
#ifndef _ASYNC_HTTP_LOGLEVEL_
#define _ASYNC_HTTP_LOGLEVEL_ 0
#endif
/////////////////////////////////////////////////////////
const char AHTTP_MARK[] = "[AHTTP] ";
#define AHTTP_PRINT_MARK AHTTP_PRINT(AHTTP_MARK)
#define AHTTP_PRINT_SP A_DBG_PORT.print(" ")
#define AHTTP_PRINT A_DBG_PORT.print
#define AHTTP_PRINTLN A_DBG_PORT.println
/////////////////////////////////////////////////////////
#define AHTTP_LOGERROR(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT_MARK; AHTTP_PRINTLN(x); }
#define AHTTP_LOGERROR0(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT(x); }
#define AHTTP_LOGERROR1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINTLN(y); }
#define AHTTP_LOGERROR2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINTLN(z); }
#define AHTTP_LOGERROR3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINT(z); AHTTP_PRINT_SP; AHTTP_PRINTLN(w); }
/////////////////////////////////////////////////////////
#define AHTTP_LOGWARN(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT_MARK; AHTTP_PRINTLN(x); }
#define AHTTP_LOGWARN0(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT(x); }
#define AHTTP_LOGWARN1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINTLN(y); }
#define AHTTP_LOGWARN2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINTLN(z); }
#define AHTTP_LOGWARN3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINT(z); AHTTP_PRINT_SP; AHTTP_PRINTLN(w); }
/////////////////////////////////////////////////////////
#define AHTTP_LOGINFO(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT_MARK; AHTTP_PRINTLN(x); }
#define AHTTP_LOGINFO0(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT(x); }
#define AHTTP_LOGINFO1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINTLN(y); }
#define AHTTP_LOGINFO2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINTLN(z); }
#define AHTTP_LOGINFO3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINT(z); AHTTP_PRINT_SP; AHTTP_PRINTLN(w); }
/////////////////////////////////////////////////////////
#define AHTTP_LOGDEBUG(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT_MARK; AHTTP_PRINTLN(x); }
#define AHTTP_LOGDEBUG0(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT(x); }
#define AHTTP_LOGDEBUG1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINTLN(y); }
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINTLN(z); }
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINT(z); AHTTP_PRINT_SP; AHTTP_PRINTLN(w); }
/////////////////////////////////////////////////////////
#endif // ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
File diff suppressed because it is too large Load Diff
-410
View File
@@ -1,410 +0,0 @@
/****************************************************************************************************************************
xbuf_Impl.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
*****************************************************************************************************************************/
#include "utility/xbuf.h"
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
{
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
}
//*******************************************************************************************************************
xbuf::~xbuf()
{
flush();
}
//*******************************************************************************************************************
size_t xbuf::write(const uint8_t byte)
{
return write((uint8_t*) &byte, 1);
}
//*******************************************************************************************************************
size_t xbuf::write(const char* buf)
{
return write((uint8_t*)buf, strlen(buf));
}
//*******************************************************************************************************************
size_t xbuf::write(String string)
{
return write((uint8_t*)string.c_str(), string.length());
}
//*******************************************************************************************************************
size_t xbuf::write(const uint8_t* buf, const size_t len)
{
size_t supply = len;
while (supply)
{
if (!_free)
{
addSeg();
}
size_t demand = _free < supply ? _free : supply;
memcpy(_tail->data + ((_offset + _used) % _segSize), buf + (len - supply), demand);
_free -= demand;
_used += demand;
supply -= demand;
}
return len;
}
//*******************************************************************************************************************
size_t xbuf::write(xbuf* buf, const size_t len)
{
size_t supply = len;
if (supply > buf->available())
{
supply = buf->available();
}
size_t read = 0;
while (supply)
{
if (!_free)
{
addSeg();
}
size_t demand = _free < supply ? _free : supply;
read += buf->read(_tail->data + ((_offset + _used) % _segSize), demand);
_free -= demand;
_used += demand;
supply -= demand;
}
return read;
}
//*******************************************************************************************************************
uint8_t xbuf::read()
{
uint8_t byte = 0;
read((uint8_t*) &byte, 1);
return byte;
}
//*******************************************************************************************************************
uint8_t xbuf::peek()
{
uint8_t byte = 0;
peek((uint8_t*) &byte, 1);
return byte;
}
//*******************************************************************************************************************
size_t xbuf::read(uint8_t* buf, const size_t len)
{
size_t read = 0;
while (read < len && _used)
{
size_t supply = (_offset + _used) > _segSize ? _segSize - _offset : _used;
size_t demand = len - read;
size_t chunk = supply < demand ? supply : demand;
memcpy(buf + read, _head->data + _offset, chunk);
_offset += chunk;
_used -= chunk;
read += chunk;
if (_offset == _segSize)
{
remSeg();
_offset = 0;
}
}
if ( ! _used)
{
flush();
}
return read;
}
//*******************************************************************************************************************
size_t xbuf::peek(uint8_t* buf, const size_t len)
{
size_t read = 0;
xseg* seg = _head;
size_t offset = _offset;
size_t used = _used;
while (read < len && used)
{
size_t supply = (offset + used) > _segSize ? _segSize - offset : used;
size_t demand = len - read;
size_t chunk = supply < demand ? supply : demand;
memcpy(buf + read, seg->data + offset, chunk);
offset += chunk;
used -= chunk;
read += chunk;
if (offset == _segSize)
{
seg = seg->next;
offset = 0;
}
}
return read;
}
//*******************************************************************************************************************
size_t xbuf::available()
{
return _used;
}
//*******************************************************************************************************************
int xbuf::indexOf(const char target, const size_t begin)
{
char targetstr[2] = " ";
targetstr[0] = target;
return indexOf(targetstr, begin);
}
//*******************************************************************************************************************
int xbuf::indexOf(const char* target, const size_t begin)
{
size_t targetLen = strlen(target);
if (targetLen > _segSize || targetLen > _used)
return -1;
size_t searchPos = _offset + begin;
size_t searchEnd = _offset + _used - targetLen;
if (searchPos > searchEnd)
return -1;
size_t searchSeg = searchPos / _segSize;
xseg* seg = _head;
while (searchSeg)
{
seg = seg->next;
searchSeg --;
}
size_t segPos = searchPos % _segSize;
while (searchPos <= searchEnd)
{
size_t compLen = targetLen;
if (compLen <= (_segSize - segPos))
{
if (memcmp(target, seg->data + segPos, compLen) == 0)
{
return searchPos - _offset;
}
}
else
{
size_t compLen = _segSize - segPos;
if (memcmp(target, seg->data + segPos, compLen) == 0)
{
compLen = targetLen - compLen;
if (memcmp(target + targetLen - compLen, seg->next->data, compLen) == 0)
{
return searchPos - _offset;
}
}
}
searchPos++;
segPos++;
if (segPos == _segSize)
{
seg = seg->next;
segPos = 0;
}
}
return -1;
}
//*******************************************************************************************************************
String xbuf::readStringUntil(const char target)
{
return readString(indexOf(target) + 1);
}
//*******************************************************************************************************************
String xbuf::readStringUntil(const char* target)
{
int index = indexOf(target);
if (index < 0)
return String();
return readString(index + strlen(target));
}
//*******************************************************************************************************************
String xbuf::readString(int endPos)
{
String result;
if ( ! result.reserve(endPos + 1))
{
return result;
}
if (endPos > _used)
{
endPos = _used;
}
if (endPos > 0 && result.reserve(endPos + 1))
{
while (endPos--)
{
result += (char)_head->data[_offset++];
_used--;
if (_offset >= _segSize)
{
remSeg();
}
}
}
return result;
}
//*******************************************************************************************************************
String xbuf::peekString(int endPos)
{
String result;
xseg* seg = _head;
size_t offset = _offset;
if (endPos > _used)
{
endPos = _used;
}
if (endPos > 0 && result.reserve(endPos + 1))
{
while (endPos--)
{
result += (char)seg->data[offset++];
if ( offset >= _segSize)
{
seg = seg->next;
offset = 0;
}
}
}
return result;
}
//*******************************************************************************************************************
void xbuf::flush()
{
while (_head)
remSeg();
_tail = nullptr;
_offset = 0;
_used = 0;
_free = 0;
}
//*******************************************************************************************************************
void xbuf::addSeg()
{
if (_tail)
{
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
// KH, Must check NULL here
_tail = _tail->next;
}
else
{
// KH, Must check NULL here
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
}
// KH, Must check NULL here
if (_tail)
_tail->next = nullptr;
_free += _segSize;
}
//*******************************************************************************************************************
void xbuf::remSeg()
{
if (_head)
{
xseg *next = _head->next;
delete[] (uint32_t*) _head;
_head = next;
if ( ! _head)
{
_tail = nullptr;
}
}
_offset = 0;
}
-166
View File
@@ -1,166 +0,0 @@
/****************************************************************************************************************************
xbuf.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
*****************************************************************************************************************************/
/********************************************************************************************
xbuf is a dynamic buffering system that supports reading and writing much like cbuf.
The class has it's own provision for writing from buffers, Strings and other xbufs
as well as the inherited Print functions.
Rather than use a large contiguous heap allocation, xbuf uses a linked chain of segments
to dynamically grow and shrink with the contents.
There are other benefits as well to using smaller heap allocation units:
1) A buffer can work fine in a fragmented heap environment (admittedly contributing to it)
2) xbuf contents can be copied from one buffer to another without the need for
2x heap during the copy.
The segment size defaults to 64 but can be dynamically set in the constructor at creation.
The inclusion of indexOf and read/peek until functions make it useful for handling
data streams like HTTP, and in fact is why it was created.
NOTE: The size of the indexOf() search string is limited to the segment size.
It could be extended but didn't seem to be a practical consideration.
********************************************************************************************/
#pragma once
#ifndef XBUF_H
#define XBUF_H
#include <Arduino.h>
struct xseg
{
xseg *next;
uint8_t data[];
};
class xbuf: public Print
{
public:
xbuf(const uint16_t segSize = 64);
virtual ~xbuf();
size_t write(const uint8_t);
size_t write(const char*);
size_t write(const uint8_t*, const size_t);
size_t write(xbuf*, const size_t);
size_t write(String);
size_t available();
int indexOf(const char, const size_t begin = 0);
int indexOf(const char*, const size_t begin = 0);
uint8_t read();
size_t read(uint8_t*, size_t);
String readStringUntil(const char);
String readStringUntil(const char*);
String readString(int);
String readString()
{
return readString(available());
}
void flush();
uint8_t peek();
size_t peek(uint8_t*, const size_t);
String peekStringUntil(const char target)
{
return peekString(indexOf(target, 0));
}
String peekStringUntil(const char* target)
{
return peekString(indexOf(target, 0));
}
String peekString()
{
return peekString(_used);
}
String peekString(int);
/* In addition to the above functions,
the following inherited functions from the Print class are available.
size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3)));
size_t printf_P(PGM_P format, ...) __attribute__((format(printf, 2, 3)));
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
*/
protected:
xseg *_head;
xseg *_tail;
uint16_t _used;
uint16_t _free;
uint16_t _offset;
uint16_t _segSize;
void addSeg();
void remSeg();
};
#endif // XBUF_H
-107
View File
@@ -1,107 +0,0 @@
/****************************************************************************************************************************
AsyncHTTPRequest_Debug_Generic.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.4.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
1.4.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
*****************************************************************************************************************************/
#pragma once
#ifndef ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
#define ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
#ifdef ASYNC_HTTP_DEBUG_PORT
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
#else
#define A_DBG_PORT Serial
#endif
// Change _ASYNC_HTTP_LOGLEVEL_ to set tracing and logging verbosity
// 0: DISABLED: no logging
// 1: ERROR: errors
// 2: WARN: errors and warnings
// 3: INFO: errors, warnings and informational (default)
// 4: DEBUG: errors, warnings, informational and debug
#ifndef _ASYNC_HTTP_LOGLEVEL_
#define _ASYNC_HTTP_LOGLEVEL_ 0
#endif
/////////////////////////////////////////////////////////
const char AHTTP_MARK[] = "[AHTTP] ";
#define AHTTP_PRINT_MARK AHTTP_PRINT(AHTTP_MARK)
#define AHTTP_PRINT_SP A_DBG_PORT.print(" ")
#define AHTTP_PRINT A_DBG_PORT.print
#define AHTTP_PRINTLN A_DBG_PORT.println
/////////////////////////////////////////////////////////
#define AHTTP_LOGERROR(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT_MARK; AHTTP_PRINTLN(x); }
#define AHTTP_LOGERROR0(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT(x); }
#define AHTTP_LOGERROR1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINTLN(y); }
#define AHTTP_LOGERROR2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINTLN(z); }
#define AHTTP_LOGERROR3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>0) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINT(z); AHTTP_PRINT_SP; AHTTP_PRINTLN(w); }
/////////////////////////////////////////////////////////
#define AHTTP_LOGWARN(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT_MARK; AHTTP_PRINTLN(x); }
#define AHTTP_LOGWARN0(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT(x); }
#define AHTTP_LOGWARN1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINTLN(y); }
#define AHTTP_LOGWARN2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINTLN(z); }
#define AHTTP_LOGWARN3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>1) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINT(z); AHTTP_PRINT_SP; AHTTP_PRINTLN(w); }
/////////////////////////////////////////////////////////
#define AHTTP_LOGINFO(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT_MARK; AHTTP_PRINTLN(x); }
#define AHTTP_LOGINFO0(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT(x); }
#define AHTTP_LOGINFO1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINTLN(y); }
#define AHTTP_LOGINFO2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINTLN(z); }
#define AHTTP_LOGINFO3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>2) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINT(z); AHTTP_PRINT_SP; AHTTP_PRINTLN(w); }
/////////////////////////////////////////////////////////
#define AHTTP_LOGDEBUG(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT_MARK; AHTTP_PRINTLN(x); }
#define AHTTP_LOGDEBUG0(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT(x); }
#define AHTTP_LOGDEBUG1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINTLN(y); }
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINTLN(z); }
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { AHTTP_PRINT_MARK; AHTTP_PRINT(x); AHTTP_PRINT_SP; AHTTP_PRINT(y); AHTTP_PRINT_SP; AHTTP_PRINT(z); AHTTP_PRINT_SP; AHTTP_PRINTLN(w); }
/////////////////////////////////////////////////////////
#endif // ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H

Some files were not shown because too many files have changed in this diff Show More