### Releases v1.0.0

1. Initial coding to add support to STM32F/L/H/G/WB/MP1 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
2. Add examples using STM32 boards.
This commit is contained in:
Khoi Hoang
2020-09-13 23:05:46 -04:00
committed by GitHub
commit 34e655efb8
57 changed files with 12835 additions and 0 deletions

51
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,51 @@
## Contributing to ESP_WiFiManager
### Reporting Bugs
Please report bugs in ESP_WiFiManager if you find them.
However, before reporting a bug please check through the following:
* [Existing Open Issues](https://github.com/khoih-prog/ESP_WiFiManager/issues) - someone might have already encountered this.
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/ESP_WiFiManager/issues/new).
### How to submit a bug report
Please ensure to specify the following:
* Arduino IDE version (e.g. 1.8.11) or Platform.io version
* `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v2.6.3 or ESP32 v1.0.4)
* 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:
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a`
* Network configuration
### Example
```
Arduino IDE version: 1.8.11
ESP8266 Core Version 2.6.3
OS: Ubuntu 16.04 LTS
Linux Inspiron 4.4.0-170-generic #199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered an endless loop while trying to connect to Local WiFi.
Steps to reproduce:
1. ...
2. ...
3. ...
4. ...
```
### Sending Feature Requests
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/ESP_WiFiManager/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
### Sending Pull Requests
Pull Requests with changes and fixes are also welcome!

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Khoi Hoang
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.

View File

@ -0,0 +1,185 @@
/*
Copyright (c) 2011 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
*/
#ifndef _VARIANT_ARDUINO_STM32_
#define _VARIANT_ARDUINO_STM32_
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/*----------------------------------------------------------------------------
* 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 A10
#define PA6 A11
#define PA5 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 A13
#define PB4 25
#define PB6 26
#define PB2 27
#define PD13 28
#define PD12 29
#define PD11 30
#define PE2 31
#define PA0 A14
#define PB0 33 // 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 A15
#define PF7 A16
#define PF9 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 A0
#define PC0 A1
#define PC3 A2
#define PF3 A3
#define PF5 A4
#define PF10 A5
#define PB1 A6
#define PC2 A7
#define PF4 A8
#define PF6 A9
// This must be a literal
#define NUM_DIGITAL_PINS 88
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS 18
// On-board LED pin number
#define LED_BUILTIN PB0
#define LED_GREEN LED_BUILTIN
#define LED_BLUE PB7
#define LED_RED PB14
// On-board user button
#define USER_BTN PC13
// Timer Definitions
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
#define TIMER_TONE TIM6
#define TIMER_SERVO TIM7
// UART Definitions
#define SERIAL_UART_INSTANCE 3 //Connected to ST-Link
// Serial pin used for console (ex: stlink)
// Rerquired by Firmata
#define PIN_SERIAL_RX PD9
#define PIN_SERIAL_TX PD8
/* Extra HAL modules */
#define HAL_DAC_MODULE_ENABLED
#define HAL_ETH_MODULE_ENABLED
// 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
#ifdef __cplusplus
} // extern "C"
#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.
#define SERIAL_PORT_MONITOR Serial
// KH mod to add Serial1, for ESP-AT
//#define SERIAL_PORT_HARDWARE Serial
#define SERIAL_PORT_HARDWARE Serial1
#endif
#endif /* _VARIANT_ARDUINO_STM32_ */

View File

@ -0,0 +1,145 @@
/*
Copyright (c) 2011 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
*/
#ifndef _VARIANT_ARDUINO_STM32_
#define _VARIANT_ARDUINO_STM32_
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/*----------------------------------------------------------------------------
* Pins
*----------------------------------------------------------------------------*/
#define PA3 0
#define PA2 1
#define PA10 2
#define PB3 3
#define PB5 4
#define PB4 5
#define PB10 6
#define PA8 7
#define PA9 8
#define PC7 9
#define PB6 10
#define PA7 A6
#define PA6 A7
#define PA5 13
#define PB9 14
#define PB8 15
// ST Morpho
// CN7 Left Side
#define PC10 16
#define PC12 17
// 18 is NC - BOOT0
#define PA13 19 // SWD
#define PA14 20 // SWD
#define PA15 21
#define PB7 22
#define PC13 23
#define PC14 24
#define PC15 25
#define PH0 26
#define PH1 27
#define PC2 A8
#define PC3 A9
// CN7 Right Side
#define PC11 30
#define PD2 31
// CN10 Left Side
#define PC9 32
// CN10 Right side
#define PC8 33
#define PC6 34
#define PC5 A10
#define PA12 36
#define PA11 37
#define PB12 38
#define PB11 39
#define PB2 40
#define PB1 41
#define PB15 42
#define PB14 43
#define PB13 44
#define PC4 A11
#define PA0 A0
#define PA1 A1
#define PA4 A2
#define PB0 A3
#define PC1 A4
#define PC0 A5
// This must be a literal
#define NUM_DIGITAL_PINS 52
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS 12
// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
// On-board user button
#define USER_BTN PC13
// Timer Definitions
// Use TIM6 when possible as servo and tone don't need GPIO output pin
#define TIMER_TONE TIM6
#define TIMER_SERVO TIM2
// UART Definitions
#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link
// Default pin used for 'Serial' instance (ex: ST-Link)
// Mandatory for Firmata
#define PIN_SERIAL_RX 0
#define PIN_SERIAL_TX 1
/* Extra HAL modules */
#define HAL_DAC_MODULE_ENABLED
#ifdef __cplusplus
} // extern "C"
#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.
#define SERIAL_PORT_MONITOR Serial
// KH mod to add Serial1, for ESP-AT
//#define SERIAL_PORT_HARDWARE Serial
#define SERIAL_PORT_HARDWARE Serial1
#endif
#endif /* _VARIANT_ARDUINO_STM32_ */

View File

@ -0,0 +1,234 @@
# 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=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
version=1.7.7
# Compile variables
# -----------------
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
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 -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++14 -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 -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write
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.project_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-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS-Atmel/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_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
# 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} {compiler.c.extra_flags} {build.extra_flags} {build.project_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}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_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} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_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} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_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"

View File

@ -0,0 +1,230 @@
# 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=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
version=1.7.8
# Compile variables
# -----------------
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
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 -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++14 -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 -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write
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.project_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.1.path}/CMSIS-Atmel/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{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
# 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} {compiler.c.extra_flags} {build.extra_flags} {build.project_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}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_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} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_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} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_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"

View File

@ -0,0 +1,649 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
# Copyright (c) 2016 Sandeep Mistry All right reserved.
# Copyright (c) 2017 Adafruit Industries. 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
menu.softdevice=Bootloader
menu.debug=Debug
# ----------------------------------
# Bluefruit Feather nRF52832
# ----------------------------------
feather52832.name=Adafruit Feather nRF52832
feather52832.bootloader.tool=bootburn
# Upload
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
feather52840.build.usb_manufacturer="Adafruit LLC"
feather52840.build.usb_product="Feather nRF52832"
feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52832_FEATHER -DNRF52
feather52832.build.ldscript=nrf52832_s132_v6.ld
# SofDevice Menu
feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice 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
# ----------------------------------
# Bluefruit Feather nRF52840 Express
# ----------------------------------
feather52840.name=Adafruit Feather nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
feather52840.build.usb_product="Feather nRF52840 Express"
feather52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER {build.flags.usb}
feather52840.build.ldscript=nrf52840_s140_v6.ld
feather52840.build.vid=0x239A
feather52840.build.pid=0x8029
# SofDevice Menu
feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Feather Bluefruit sense
# ----------------------------------
feather52840sense.name=Adafruit Feather Bluefruit Sense
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
feather52840sense.build.usb_product="Feather nRF52840 Sense"
feather52840sense.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER_SENSE {build.flags.usb}
feather52840sense.build.ldscript=nrf52840_s140_v6.ld
feather52840sense.build.vid=0x239A
feather52840sense.build.pid=0x8087
# SofDevice Menu
feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ---------------------------------------------
# Bluefruit ItsyBitsy nRF52840 Express
# ---------------------------------------------
itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express"
itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY {build.flags.usb}
itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld
itsybitsy52840.build.vid=0x239A
itsybitsy52840.build.pid=0x8051
# SofDevice Menu
itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice 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
# ---------------------------------------------
# Bluefruit Circuit Playground nRF52840 Express
# ---------------------------------------------
cplaynrf52840.name=Adafruit Circuit Playground Bluefruit
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
cplaynrf52840.vid.0=0x239A
cplaynrf52840.pid.0=0x8045
cplaynrf52840.vid.1=0x239A
cplaynrf52840.pid.1=0x0045
cplaynrf52840.vid.2=0x239A
cplaynrf52840.pid.2=0x0046
cplaynrf52840.vid.3=0x239A
cplaynrf52840.pid.3=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 LLC"
cplaynrf52840.build.usb_product="Circuit Playground Bluefruit"
cplaynrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CIRCUITPLAY {build.flags.usb}
cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld
cplaynrf52840.build.vid=0x239A
cplaynrf52840.build.pid=0x8045
# SofDevice Menu
cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ---------------------------------------------
# Clue nRF52840
# ---------------------------------------------
cluenrf52840.name=Adafruit CLUE
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
cluenrf52840.vid.0=0x239A
cluenrf52840.pid.0=0x8072
cluenrf52840.vid.1=0x239A
cluenrf52840.pid.1=0x0072
cluenrf52840.vid.2=0x239A
cluenrf52840.pid.2=0x0071
cluenrf52840.vid.3=0x239A
cluenrf52840.pid.3=0x8071
# 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 LLC"
cluenrf52840.build.usb_product="CLUE"
cluenrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CLUE {build.flags.usb}
cluenrf52840.build.ldscript=nrf52840_s140_v6.ld
cluenrf52840.build.vid=0x239A
cluenrf52840.build.pid=0x8071
# SofDevice Menu
cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Bluefruit Metro nRF52840 Express
# ----------------------------------
metro52840.name=Adafruit Bluefruit Metro nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
metro52840.build.usb_product="Metro nRF52840 Express"
metro52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_METRO {build.flags.usb}
metro52840.build.ldscript=nrf52840_s140_v6.ld
metro52840.build.vid=0x239A
metro52840.build.pid=0x803F
# SofDevice Menu
metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# -------------------------------------------------------
#
# Boards that aren't made by Adafruit
#
# -------------------------------------------------------
# ----------------------------------
# Nordic nRF52840DK (PCA10056)
# ----------------------------------
pca10056.name=Nordic nRF52840DK (PCA10056)
pca10056.bootloader.tool=bootburn
# Upload
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 -DNRF52840_PCA10056 {build.flags.usb}
pca10056.build.ldscript=nrf52840_s140_v6.ld
pca10056.build.vid=0x239A
pca10056.build.pid=0x8029
# SofDevice Menu
pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Particle Xenon
# ----------------------------------
particle_xenon.name=Particle Xenon
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
particle_xenon.vid.0=0x239A
particle_xenon.pid.0=0x8029
particle_xenon.vid.1=0x239A
particle_xenon.pid.1=0x0029
particle_xenon.vid.2=0x239A
particle_xenon.pid.2=0x002A
particle_xenon.vid.3=0x239A
particle_xenon.pid.3=0x802A
# 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 Industries"
particle_xenon.build.usb_product="Particle Xenon"
particle_xenon.build.extra_flags=-DNRF52840_XXAA -DPARTICLE_XENON {build.flags.usb}
particle_xenon.build.ldscript=nrf52840_s140_v6.ld
particle_xenon.build.vid=0x239A
particle_xenon.build.pid=0x8029
# SofDevice Menu
particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice 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
# ----------------------------------
# Raytac MDBT50Q - RX
# ----------------------------------
mdbt50qrx.name=Raytac MDBT50Q-RX Dongle
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
mdbt50qrx.vid.0=0x239A
mdbt50qrx.pid.0=0x8029
mdbt50qrx.vid.1=0x239A
mdbt50qrx.pid.1=0x0029
mdbt50qrx.vid.2=0x239A
mdbt50qrx.pid.2=0x002A
mdbt50qrx.vid.3=0x239A
mdbt50qrx.pid.3=0x802A
# 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 Corporation"
mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX"
mdbt50qrx.build.extra_flags=-DNRF52840_XXAA -DMDBT50Q_RX {build.flags.usb}
mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld
mdbt50qrx.build.vid=0x239A
mdbt50qrx.build.pid=0x8029
# SofDevice Menu
mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# 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

View File

@ -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, 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

View File

@ -0,0 +1,164 @@
# 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=0.20.5
# 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 -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith
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, mjust use g++
#compiler.c.elf.cmd=arm-none-eabi-gcc
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Ofast -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -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 --specs=nano.specs --specs=nosys.specs
compiler.size.cmd=arm-none-eabi-size
# this can be overriden in boards.txt
build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float
build.debug_flags=-DCFG_DEBUG=0
build.logger_flags=-DCFG_LOGGER=1
build.sysview_flags=-DCFG_SYSVIEW=0
# common compiler for nrf
rtos.path={build.core.path}/freertos
nordic.path={build.core.path}/nordic
# build.logger_flags and build.sysview_flags and intentionally empty,
# to allow modification via a user's own boards.local.txt or platform.local.txt files.
build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-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{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{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
# 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.elf2bin.extra_flags=
compiler.elf2hex.extra_flags=
# 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}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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 -lm "{build.path}/{archive_file}" -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.3.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=

View File

@ -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"

View File

@ -0,0 +1,62 @@
/*
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[] = {
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31
};

View File

@ -0,0 +1,173 @@
/*
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
*/
#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 (8) // Red
#define LED2 (16) // Green/SW1
#define LED3 (18) // Blue
#define LED_STATE_ON 1 // State when LED is litted
//Switch
#define SW1 (16)
#define SW2 (30)
// NFC
#define PIN_NFC_1 (9) // P0.9
#define PIN_NFC_2 (10) // P0.10
/*
* Analog pins
*/
#define PIN_A0 (3) // P0.03
#define PIN_A1 (2) // P0.02
#define PIN_A2 (4) // P0.04
#define PIN_A3 (30) // P0.30
#define PIN_A4 (29) // P0.29
#define PIN_A5 (28) // 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 (5) // P0.05
#define PIN_D1 (6) // P0.06
#define PIN_D2 (7) // P0.07
#define PIN_D3 (31) // P0.31
#define PIN_D4 (18) // P0.18
#define PIN_D6 (9) // P0.09
#define PIN_D7 (10) // P0.10
#define PIN_D9 (8) // P0.8
#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 (8) //used for original Adafruit Bootloader
//#define PIN_SERIAL_TX (6) //used for original Adafruit Bootloader
#define PIN_SERIAL_RX (5) // P0.05
#define PIN_SERIAL_TX (6) // P0.06
#define PIN_SERIAL_CTS (7) // P0.07
#define PIN_SERIAL_RTS (31) // 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 (13) // P0.13
#define PIN_SPI_SCK (14) // P0.14
static const uint8_t SS = 11 ; // 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 (2) // P0.02
#define PIN_WIRE_SCL (3) // 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_

View File

@ -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"

View File

@ -0,0 +1,109 @@
/*
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 TX)
45, // D1 is P1.13 (UART RX
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 (NeoPixel)
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 .. A7)
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)
29, // D20 is P0.29 (A6, Battery) ????
31, // D21 is P0.31 (A7, ARef) ????
// D22 .. D23 (aka I2C pins)
16, // D22 is P0.16 (SDA)
24, // D23 is P0.24 (SCL)
// D24 .. D26 (aka SPI pins)
32, // D24 is P1.00 (SPI MISO)
15, // D25 is P0.15 (SPI MOSI)
7, // D26 is P0.07 (SPI SCK )
// QSPI pins (not exposed via any header / test point)
19, // D27 is P0.19 (QSPI CLK)
17, // D28 is P0.17 (QSPI CS)
20, // D29 is P0.20 (QSPI Data 0)
21, // D30 is P0.21 (QSPI Data 1)
22, // D31 is P0.22 (QSPI Data 2)
23, // D32 is P0.23 (QSPI Data 3)
// The remaining NFC pin
9, // D33 is P0.09 (NFC1, exposed only via test point on bottom of board)
// Thus, there are 34 defined pins
// The remaining pins are not usable:
//
//
// The following pins were never listed as they were considered unusable
// 0, // P0.00 is XL1 (attached to 32.768kHz crystal)
// 1, // P0.01 is XL2 (attached to 32.768kHz crystal)
// 18, // P0.18 is RESET (attached to switch)
// 32, // P1.00 is SWO (attached to debug header)
//
// The remaining pins are not connected (per schematic)
// 33, // P1.01 is not connected per schematic
// 35, // P1.03 is not connected per schematic
// 36, // P1.04 is not connected per schematic
// 37, // P1.05 is not connected per schematic
// 38, // P1.06 is not connected per schematic
// 39, // P1.07 is not connected per schematic
// 43, // P1.11 is not connected per schematic
// 44, // P1.12 is not connected per schematic
// 45, // P1.13 is not connected per schematic
// 46, // P1.14 is not connected per schematic
};
void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
}

View File

@ -0,0 +1,159 @@
/*
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
// (XX) = TABLE INDEX
// Number of pins defined in PinDescription array
#define PINS_COUNT (34)
#define NUM_DIGITAL_PINS (34)
#define NUM_ANALOG_INPUTS (6) // A6 is used for battery, A7 is analog reference
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (3)
#define PIN_LED2 (4)
#define PIN_NEOPIXEL (8)
#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 PIN_A6 (20)
#define PIN_A7 (21)
#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 ;
static const uint8_t A6 = PIN_A6 ;
static const uint8_t A7 = PIN_A7 ;
#define ADC_RESOLUTION 14
// Other pins
#define PIN_AREF PIN_A7
#define PIN_VBAT PIN_A6
#define PIN_NFC1 (33)
#define PIN_NFC2 (2)
static const uint8_t AREF = PIN_AREF;
/*
* Serial interfaces
*/
#define PIN_SERIAL1_RX (1)
#define PIN_SERIAL1_TX (0)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (24) //24 original
#define PIN_SPI_MOSI (25) //25 original
#define PIN_SPI_SCK (26) //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 (22)
#define PIN_WIRE_SCL (23)
// QSPI Pins
#define PIN_QSPI_SCK 27
#define PIN_QSPI_CS 28
#define PIN_QSPI_IO0 29
#define PIN_QSPI_IO1 30
#define PIN_QSPI_IO2 31
#define PIN_QSPI_IO3 32
// 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_

View File

@ -0,0 +1,649 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
# Copyright (c) 2016 Sandeep Mistry All right reserved.
# Copyright (c) 2017 Adafruit Industries. 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
menu.softdevice=Bootloader
menu.debug=Debug
# ----------------------------------
# Bluefruit Feather nRF52832
# ----------------------------------
feather52832.name=Adafruit Feather nRF52832
feather52832.bootloader.tool=bootburn
# Upload
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
feather52840.build.usb_manufacturer="Adafruit LLC"
feather52840.build.usb_product="Feather nRF52832"
feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52832_FEATHER -DNRF52
feather52832.build.ldscript=nrf52832_s132_v6.ld
# SofDevice Menu
feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice 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
# ----------------------------------
# Bluefruit Feather nRF52840 Express
# ----------------------------------
feather52840.name=Adafruit Feather nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
feather52840.build.usb_product="Feather nRF52840 Express"
feather52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER {build.flags.usb}
feather52840.build.ldscript=nrf52840_s140_v6.ld
feather52840.build.vid=0x239A
feather52840.build.pid=0x8029
# SofDevice Menu
feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Feather Bluefruit sense
# ----------------------------------
feather52840sense.name=Adafruit Feather Bluefruit Sense
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
feather52840sense.build.usb_product="Feather nRF52840 Sense"
feather52840sense.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER_SENSE {build.flags.usb}
feather52840sense.build.ldscript=nrf52840_s140_v6.ld
feather52840sense.build.vid=0x239A
feather52840sense.build.pid=0x8087
# SofDevice Menu
feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ---------------------------------------------
# Bluefruit ItsyBitsy nRF52840 Express
# ---------------------------------------------
itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express"
itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY {build.flags.usb}
itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld
itsybitsy52840.build.vid=0x239A
itsybitsy52840.build.pid=0x8051
# SofDevice Menu
itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice 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
# ---------------------------------------------
# Bluefruit Circuit Playground nRF52840 Express
# ---------------------------------------------
cplaynrf52840.name=Adafruit Circuit Playground Bluefruit
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
cplaynrf52840.vid.0=0x239A
cplaynrf52840.pid.0=0x8045
cplaynrf52840.vid.1=0x239A
cplaynrf52840.pid.1=0x0045
cplaynrf52840.vid.2=0x239A
cplaynrf52840.pid.2=0x0046
cplaynrf52840.vid.3=0x239A
cplaynrf52840.pid.3=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 LLC"
cplaynrf52840.build.usb_product="Circuit Playground Bluefruit"
cplaynrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CIRCUITPLAY {build.flags.usb}
cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld
cplaynrf52840.build.vid=0x239A
cplaynrf52840.build.pid=0x8045
# SofDevice Menu
cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ---------------------------------------------
# Clue nRF52840
# ---------------------------------------------
cluenrf52840.name=Adafruit CLUE
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
cluenrf52840.vid.0=0x239A
cluenrf52840.pid.0=0x8072
cluenrf52840.vid.1=0x239A
cluenrf52840.pid.1=0x0072
cluenrf52840.vid.2=0x239A
cluenrf52840.pid.2=0x0071
cluenrf52840.vid.3=0x239A
cluenrf52840.pid.3=0x8071
# 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 LLC"
cluenrf52840.build.usb_product="CLUE"
cluenrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CLUE {build.flags.usb}
cluenrf52840.build.ldscript=nrf52840_s140_v6.ld
cluenrf52840.build.vid=0x239A
cluenrf52840.build.pid=0x8071
# SofDevice Menu
cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Bluefruit Metro nRF52840 Express
# ----------------------------------
metro52840.name=Adafruit Bluefruit Metro nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
metro52840.build.usb_product="Metro nRF52840 Express"
metro52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_METRO {build.flags.usb}
metro52840.build.ldscript=nrf52840_s140_v6.ld
metro52840.build.vid=0x239A
metro52840.build.pid=0x803F
# SofDevice Menu
metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# -------------------------------------------------------
#
# Boards that aren't made by Adafruit
#
# -------------------------------------------------------
# ----------------------------------
# Nordic nRF52840DK (PCA10056)
# ----------------------------------
pca10056.name=Nordic nRF52840DK (PCA10056)
pca10056.bootloader.tool=bootburn
# Upload
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 -DNRF52840_PCA10056 {build.flags.usb}
pca10056.build.ldscript=nrf52840_s140_v6.ld
pca10056.build.vid=0x239A
pca10056.build.pid=0x8029
# SofDevice Menu
pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Particle Xenon
# ----------------------------------
particle_xenon.name=Particle Xenon
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
particle_xenon.vid.0=0x239A
particle_xenon.pid.0=0x8029
particle_xenon.vid.1=0x239A
particle_xenon.pid.1=0x0029
particle_xenon.vid.2=0x239A
particle_xenon.pid.2=0x002A
particle_xenon.vid.3=0x239A
particle_xenon.pid.3=0x802A
# 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 Industries"
particle_xenon.build.usb_product="Particle Xenon"
particle_xenon.build.extra_flags=-DNRF52840_XXAA -DPARTICLE_XENON {build.flags.usb}
particle_xenon.build.ldscript=nrf52840_s140_v6.ld
particle_xenon.build.vid=0x239A
particle_xenon.build.pid=0x8029
# SofDevice Menu
particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice 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
# ----------------------------------
# Raytac MDBT50Q - RX
# ----------------------------------
mdbt50qrx.name=Raytac MDBT50Q-RX Dongle
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
mdbt50qrx.vid.0=0x239A
mdbt50qrx.pid.0=0x8029
mdbt50qrx.vid.1=0x239A
mdbt50qrx.pid.1=0x0029
mdbt50qrx.vid.2=0x239A
mdbt50qrx.pid.2=0x002A
mdbt50qrx.vid.3=0x239A
mdbt50qrx.pid.3=0x802A
# 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 Corporation"
mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX"
mdbt50qrx.build.extra_flags=-DNRF52840_XXAA -DMDBT50Q_RX {build.flags.usb}
mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld
mdbt50qrx.build.vid=0x239A
mdbt50qrx.build.pid=0x8029
# SofDevice Menu
mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# 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

View File

@ -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, 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

View File

@ -0,0 +1,164 @@
# 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=0.20.5
# 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 -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith
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, mjust use g++
#compiler.c.elf.cmd=arm-none-eabi-gcc
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Ofast -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -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 --specs=nano.specs --specs=nosys.specs
compiler.size.cmd=arm-none-eabi-size
# this can be overriden in boards.txt
build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float
build.debug_flags=-DCFG_DEBUG=0
build.logger_flags=-DCFG_LOGGER=1
build.sysview_flags=-DCFG_SYSVIEW=0
# common compiler for nrf
rtos.path={build.core.path}/freertos
nordic.path={build.core.path}/nordic
# build.logger_flags and build.sysview_flags and intentionally empty,
# to allow modification via a user's own boards.local.txt or platform.local.txt files.
build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-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{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{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
# 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.elf2bin.extra_flags=
compiler.elf2hex.extra_flags=
# 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}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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 -lm "{build.path}/{archive_file}" -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.3.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=

View File

@ -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"

View File

@ -0,0 +1,62 @@
/*
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[] = {
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31
};

View File

@ -0,0 +1,173 @@
/*
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
*/
#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 (8) // Red
#define LED2 (16) // Green/SW1
#define LED3 (18) // Blue
#define LED_STATE_ON 1 // State when LED is litted
//Switch
#define SW1 (16)
#define SW2 (30)
// NFC
#define PIN_NFC_1 (9) // P0.9
#define PIN_NFC_2 (10) // P0.10
/*
* Analog pins
*/
#define PIN_A0 (3) // P0.03
#define PIN_A1 (2) // P0.02
#define PIN_A2 (4) // P0.04
#define PIN_A3 (30) // P0.30
#define PIN_A4 (29) // P0.29
#define PIN_A5 (28) // 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 (5) // P0.05
#define PIN_D1 (6) // P0.06
#define PIN_D2 (7) // P0.07
#define PIN_D3 (31) // P0.31
#define PIN_D4 (18) // P0.18
#define PIN_D6 (9) // P0.09
#define PIN_D7 (10) // P0.10
#define PIN_D9 (8) // P0.8
#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 (8) //used for original Adafruit Bootloader
//#define PIN_SERIAL_TX (6) //used for original Adafruit Bootloader
#define PIN_SERIAL_RX (5) // P0.05
#define PIN_SERIAL_TX (6) // P0.06
#define PIN_SERIAL_CTS (7) // P0.07
#define PIN_SERIAL_RTS (31) // 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 (13) // P0.13
#define PIN_SPI_SCK (14) // P0.14
static const uint8_t SS = 11 ; // 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 (2) // P0.02
#define PIN_WIRE_SCL (3) // 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_

View File

@ -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"

View File

@ -0,0 +1,109 @@
/*
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 TX)
45, // D1 is P1.13 (UART RX
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 (NeoPixel)
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 .. A7)
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)
29, // D20 is P0.29 (A6, Battery) ????
31, // D21 is P0.31 (A7, ARef) ????
// D22 .. D23 (aka I2C pins)
16, // D22 is P0.16 (SDA)
24, // D23 is P0.24 (SCL)
// D24 .. D26 (aka SPI pins)
32, // D24 is P1.00 (SPI MISO)
15, // D25 is P0.15 (SPI MOSI)
7, // D26 is P0.07 (SPI SCK )
// QSPI pins (not exposed via any header / test point)
19, // D27 is P0.19 (QSPI CLK)
17, // D28 is P0.17 (QSPI CS)
20, // D29 is P0.20 (QSPI Data 0)
21, // D30 is P0.21 (QSPI Data 1)
22, // D31 is P0.22 (QSPI Data 2)
23, // D32 is P0.23 (QSPI Data 3)
// The remaining NFC pin
9, // D33 is P0.09 (NFC1, exposed only via test point on bottom of board)
// Thus, there are 34 defined pins
// The remaining pins are not usable:
//
//
// The following pins were never listed as they were considered unusable
// 0, // P0.00 is XL1 (attached to 32.768kHz crystal)
// 1, // P0.01 is XL2 (attached to 32.768kHz crystal)
// 18, // P0.18 is RESET (attached to switch)
// 32, // P1.00 is SWO (attached to debug header)
//
// The remaining pins are not connected (per schematic)
// 33, // P1.01 is not connected per schematic
// 35, // P1.03 is not connected per schematic
// 36, // P1.04 is not connected per schematic
// 37, // P1.05 is not connected per schematic
// 38, // P1.06 is not connected per schematic
// 39, // P1.07 is not connected per schematic
// 43, // P1.11 is not connected per schematic
// 44, // P1.12 is not connected per schematic
// 45, // P1.13 is not connected per schematic
// 46, // P1.14 is not connected per schematic
};
void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
}

View File

@ -0,0 +1,159 @@
/*
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
// (XX) = TABLE INDEX
// Number of pins defined in PinDescription array
#define PINS_COUNT (34)
#define NUM_DIGITAL_PINS (34)
#define NUM_ANALOG_INPUTS (6) // A6 is used for battery, A7 is analog reference
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (3)
#define PIN_LED2 (4)
#define PIN_NEOPIXEL (8)
#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 PIN_A6 (20)
#define PIN_A7 (21)
#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 ;
static const uint8_t A6 = PIN_A6 ;
static const uint8_t A7 = PIN_A7 ;
#define ADC_RESOLUTION 14
// Other pins
#define PIN_AREF PIN_A7
#define PIN_VBAT PIN_A6
#define PIN_NFC1 (33)
#define PIN_NFC2 (2)
static const uint8_t AREF = PIN_AREF;
/*
* Serial interfaces
*/
#define PIN_SERIAL1_RX (1)
#define PIN_SERIAL1_TX (0)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (24) //24 original
#define PIN_SPI_MOSI (25) //25 original
#define PIN_SPI_SCK (26) //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 (22)
#define PIN_WIRE_SCL (23)
// QSPI Pins
#define PIN_QSPI_SCK 27
#define PIN_QSPI_CS 28
#define PIN_QSPI_IO0 29
#define PIN_QSPI_IO1 30
#define PIN_QSPI_IO2 31
#define PIN_QSPI_IO3 32
// 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_

View File

@ -0,0 +1,649 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
# Copyright (c) 2016 Sandeep Mistry All right reserved.
# Copyright (c) 2017 Adafruit Industries. 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
menu.softdevice=Bootloader
menu.debug=Debug
# ----------------------------------
# Bluefruit Feather nRF52832
# ----------------------------------
feather52832.name=Adafruit Feather nRF52832
feather52832.bootloader.tool=bootburn
# Upload
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 LLC"
feather52832.build.usb_product="Feather nRF52832"
feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52832_FEATHER -DNRF52
feather52832.build.ldscript=nrf52832_s132_v6.ld
# SofDevice Menu
feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice 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
# ----------------------------------
# Bluefruit Feather nRF52840 Express
# ----------------------------------
feather52840.name=Adafruit Feather nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
feather52840.build.usb_product="Feather nRF52840 Express"
feather52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER {build.flags.usb}
feather52840.build.ldscript=nrf52840_s140_v6.ld
feather52840.build.vid=0x239A
feather52840.build.pid=0x8029
# SofDevice Menu
feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Feather Bluefruit sense
# ----------------------------------
feather52840sense.name=Adafruit Feather Bluefruit Sense
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
feather52840sense.build.usb_product="Feather nRF52840 Sense"
feather52840sense.build.extra_flags=-DNRF52840_XXAA -DNRF52840_FEATHER_SENSE {build.flags.usb}
feather52840sense.build.ldscript=nrf52840_s140_v6.ld
feather52840sense.build.vid=0x239A
feather52840sense.build.pid=0x8087
# SofDevice Menu
feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ---------------------------------------------
# Bluefruit ItsyBitsy nRF52840 Express
# ---------------------------------------------
itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express"
itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY {build.flags.usb}
itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld
itsybitsy52840.build.vid=0x239A
itsybitsy52840.build.pid=0x8051
# SofDevice Menu
itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice 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
# ---------------------------------------------
# Bluefruit Circuit Playground nRF52840 Express
# ---------------------------------------------
cplaynrf52840.name=Adafruit Circuit Playground Bluefruit
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
cplaynrf52840.vid.0=0x239A
cplaynrf52840.pid.0=0x8045
cplaynrf52840.vid.1=0x239A
cplaynrf52840.pid.1=0x0045
cplaynrf52840.vid.2=0x239A
cplaynrf52840.pid.2=0x0046
cplaynrf52840.vid.3=0x239A
cplaynrf52840.pid.3=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 LLC"
cplaynrf52840.build.usb_product="Circuit Playground Bluefruit"
cplaynrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CIRCUITPLAY {build.flags.usb}
cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld
cplaynrf52840.build.vid=0x239A
cplaynrf52840.build.pid=0x8045
# SofDevice Menu
cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ---------------------------------------------
# Clue nRF52840
# ---------------------------------------------
cluenrf52840.name=Adafruit CLUE
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
cluenrf52840.vid.0=0x239A
cluenrf52840.pid.0=0x8072
cluenrf52840.vid.1=0x239A
cluenrf52840.pid.1=0x0072
cluenrf52840.vid.2=0x239A
cluenrf52840.pid.2=0x0071
cluenrf52840.vid.3=0x239A
cluenrf52840.pid.3=0x8071
# 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 LLC"
cluenrf52840.build.usb_product="CLUE"
cluenrf52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_CLUE {build.flags.usb}
cluenrf52840.build.ldscript=nrf52840_s140_v6.ld
cluenrf52840.build.vid=0x239A
cluenrf52840.build.pid=0x8071
# SofDevice Menu
cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Bluefruit Metro nRF52840 Express
# ----------------------------------
metro52840.name=Adafruit Bluefruit Metro nRF52840 Express
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
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 LLC"
metro52840.build.usb_product="Metro nRF52840 Express"
metro52840.build.extra_flags=-DNRF52840_XXAA -DNRF52840_METRO {build.flags.usb}
metro52840.build.ldscript=nrf52840_s140_v6.ld
metro52840.build.vid=0x239A
metro52840.build.pid=0x803F
# SofDevice Menu
metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# -------------------------------------------------------
#
# Boards that aren't made by Adafruit
#
# -------------------------------------------------------
# ----------------------------------
# Nordic nRF52840DK (PCA10056)
# ----------------------------------
pca10056.name=Nordic nRF52840DK (PCA10056)
pca10056.bootloader.tool=bootburn
# Upload
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 -DNRF52840_PCA10056 {build.flags.usb}
pca10056.build.ldscript=nrf52840_s140_v6.ld
pca10056.build.vid=0x239A
pca10056.build.pid=0x8029
# SofDevice Menu
pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# Particle Xenon
# ----------------------------------
particle_xenon.name=Particle Xenon
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
particle_xenon.vid.0=0x239A
particle_xenon.pid.0=0x8029
particle_xenon.vid.1=0x239A
particle_xenon.pid.1=0x0029
particle_xenon.vid.2=0x239A
particle_xenon.pid.2=0x002A
particle_xenon.vid.3=0x239A
particle_xenon.pid.3=0x802A
# 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 Industries"
particle_xenon.build.usb_product="Particle Xenon"
particle_xenon.build.extra_flags=-DNRF52840_XXAA -DPARTICLE_XENON {build.flags.usb}
particle_xenon.build.ldscript=nrf52840_s140_v6.ld
particle_xenon.build.vid=0x239A
particle_xenon.build.pid=0x8029
# SofDevice Menu
particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice 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
# ----------------------------------
# Raytac MDBT50Q - RX
# ----------------------------------
mdbt50qrx.name=Raytac MDBT50Q-RX Dongle
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
mdbt50qrx.vid.0=0x239A
mdbt50qrx.pid.0=0x8029
mdbt50qrx.vid.1=0x239A
mdbt50qrx.pid.1=0x0029
mdbt50qrx.vid.2=0x239A
mdbt50qrx.pid.2=0x002A
mdbt50qrx.vid.3=0x239A
mdbt50qrx.pid.3=0x802A
# 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 Corporation"
mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX"
mdbt50qrx.build.extra_flags=-DNRF52840_XXAA -DMDBT50Q_RX {build.flags.usb}
mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld
mdbt50qrx.build.vid=0x239A
mdbt50qrx.build.pid=0x8029
# SofDevice Menu
mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice 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
# ----------------------------------
# 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

View File

@ -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, 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

View File

@ -0,0 +1,164 @@
# 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=0.20.5
# 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 -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith
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, mjust use g++
#compiler.c.elf.cmd=arm-none-eabi-gcc
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Ofast -Wl,--gc-sections -save-temps
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -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 --specs=nano.specs --specs=nosys.specs
compiler.size.cmd=arm-none-eabi-size
# this can be overriden in boards.txt
build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float
build.debug_flags=-DCFG_DEBUG=0
build.logger_flags=-DCFG_LOGGER=1
build.sysview_flags=-DCFG_SYSVIEW=0
# common compiler for nrf
rtos.path={build.core.path}/freertos
nordic.path={build.core.path}/nordic
# build.logger_flags and build.sysview_flags and intentionally empty,
# to allow modification via a user's own boards.local.txt or platform.local.txt files.
build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-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{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{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
# 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.elf2bin.extra_flags=
compiler.elf2hex.extra_flags=
# 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}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{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 -lm "{build.path}/{archive_file}" -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.3.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=

View File

@ -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"

View File

@ -0,0 +1,62 @@
/*
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[] = {
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31
};

View File

@ -0,0 +1,173 @@
/*
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
*/
#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 (8) // Red
#define LED2 (16) // Green/SW1
#define LED3 (18) // Blue
#define LED_STATE_ON 1 // State when LED is litted
//Switch
#define SW1 (16)
#define SW2 (30)
// NFC
#define PIN_NFC_1 (9) // P0.9
#define PIN_NFC_2 (10) // P0.10
/*
* Analog pins
*/
#define PIN_A0 (3) // P0.03
#define PIN_A1 (2) // P0.02
#define PIN_A2 (4) // P0.04
#define PIN_A3 (30) // P0.30
#define PIN_A4 (29) // P0.29
#define PIN_A5 (28) // 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 (5) // P0.05
#define PIN_D1 (6) // P0.06
#define PIN_D2 (7) // P0.07
#define PIN_D3 (31) // P0.31
#define PIN_D4 (18) // P0.18
#define PIN_D6 (9) // P0.09
#define PIN_D7 (10) // P0.10
#define PIN_D9 (8) // P0.8
#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 (8) //used for original Adafruit Bootloader
//#define PIN_SERIAL_TX (6) //used for original Adafruit Bootloader
#define PIN_SERIAL_RX (5) // P0.05
#define PIN_SERIAL_TX (6) // P0.06
#define PIN_SERIAL_CTS (7) // P0.07
#define PIN_SERIAL_RTS (31) // 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 (13) // P0.13
#define PIN_SPI_SCK (14) // P0.14
static const uint8_t SS = 11 ; // 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 (2) // P0.02
#define PIN_WIRE_SCL (3) // 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_

View File

@ -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"

View File

@ -0,0 +1,109 @@
/*
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 TX)
45, // D1 is P1.13 (UART RX
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 (NeoPixel)
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 .. A7)
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)
29, // D20 is P0.29 (A6, Battery) ????
31, // D21 is P0.31 (A7, ARef) ????
// D22 .. D23 (aka I2C pins)
16, // D22 is P0.16 (SDA)
24, // D23 is P0.24 (SCL)
// D24 .. D26 (aka SPI pins)
32, // D24 is P1.00 (SPI MISO)
15, // D25 is P0.15 (SPI MOSI)
7, // D26 is P0.07 (SPI SCK )
// QSPI pins (not exposed via any header / test point)
19, // D27 is P0.19 (QSPI CLK)
17, // D28 is P0.17 (QSPI CS)
20, // D29 is P0.20 (QSPI Data 0)
21, // D30 is P0.21 (QSPI Data 1)
22, // D31 is P0.22 (QSPI Data 2)
23, // D32 is P0.23 (QSPI Data 3)
// The remaining NFC pin
9, // D33 is P0.09 (NFC1, exposed only via test point on bottom of board)
// Thus, there are 34 defined pins
// The remaining pins are not usable:
//
//
// The following pins were never listed as they were considered unusable
// 0, // P0.00 is XL1 (attached to 32.768kHz crystal)
// 1, // P0.01 is XL2 (attached to 32.768kHz crystal)
// 18, // P0.18 is RESET (attached to switch)
// 32, // P1.00 is SWO (attached to debug header)
//
// The remaining pins are not connected (per schematic)
// 33, // P1.01 is not connected per schematic
// 35, // P1.03 is not connected per schematic
// 36, // P1.04 is not connected per schematic
// 37, // P1.05 is not connected per schematic
// 38, // P1.06 is not connected per schematic
// 39, // P1.07 is not connected per schematic
// 43, // P1.11 is not connected per schematic
// 44, // P1.12 is not connected per schematic
// 45, // P1.13 is not connected per schematic
// 46, // P1.14 is not connected per schematic
};
void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
}

View File

@ -0,0 +1,159 @@
/*
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
// (XX) = TABLE INDEX
// Number of pins defined in PinDescription array
#define PINS_COUNT (34)
#define NUM_DIGITAL_PINS (34)
#define NUM_ANALOG_INPUTS (6) // A6 is used for battery, A7 is analog reference
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (3)
#define PIN_LED2 (4)
#define PIN_NEOPIXEL (8)
#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 PIN_A6 (20)
#define PIN_A7 (21)
#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 ;
static const uint8_t A6 = PIN_A6 ;
static const uint8_t A7 = PIN_A7 ;
#define ADC_RESOLUTION 14
// Other pins
#define PIN_AREF PIN_A7
#define PIN_VBAT PIN_A6
#define PIN_NFC1 (33)
#define PIN_NFC2 (2)
static const uint8_t AREF = PIN_AREF;
/*
* Serial interfaces
*/
#define PIN_SERIAL1_RX (1)
#define PIN_SERIAL1_TX (0)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (24) //24 original
#define PIN_SPI_MOSI (25) //25 original
#define PIN_SPI_SCK (26) //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 (22)
#define PIN_WIRE_SCL (23)
// QSPI Pins
#define PIN_QSPI_SCK 27
#define PIN_QSPI_CS 28
#define PIN_QSPI_IO0 29
#define PIN_QSPI_IO1 30
#define PIN_QSPI_IO2 31
#define PIN_QSPI_IO3 32
// 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_

View File

@ -0,0 +1,232 @@
# 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.5.14
# Compile variables
# -----------------
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
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 -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-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_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
# 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} {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}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {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} {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}"
##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} {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} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {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"

View File

@ -0,0 +1,232 @@
# 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.6.0
# Compile variables
# -----------------
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -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.0.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{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
# 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} {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}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {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} {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}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {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 c 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.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {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"

View File

@ -0,0 +1,110 @@
# Arduino SAM Core and platform.
# ------------------------------
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
name=Arduino ARM (32-bits) Boards
version=1.6.12
# SAM3 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
compiler.path={runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD
# KH, Error here to use gcc, mjust use g++
#compiler.c.elf.cmd=arm-none-eabi-gcc
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections
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=-c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --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.flags=-O binary
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
compiler.combine.flags=-u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
# This can be overridden in boards.txt
build.extra_flags=
# 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.elf2hex.extra_flags=
compiler.libsam.c.flags="-I{build.system.path}/libsam" "-I{build.system.path}/CMSIS/CMSIS/Include/" "-I{build.system.path}/CMSIS/Device/ATMEL/"
# 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"
# SAM3 compile patterns
# ---------------------
## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={build.mcu} -mthumb -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.libsam.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -mthumb -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.libsam.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -mcpu={build.mcu} -mthumb -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.libsam.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}" -mcpu={build.mcu} -mthumb {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group {compiler.combine.flags} {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.path}/{archive_file}" -Wl,--end-group -lm -lgcc
## Create output (.bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Save hex
recipe.output.tmp_file={build.project_name}.bin
recipe.output.save_file={build.project_name}.{build.variant}.bin
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=\.text\s+([0-9]+).*
# SAM3 Uploader tools
# -------------------
# BOSSA
tools.bossac.path={runtime.tools.bossac.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.params.verify=-v
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -e -w {upload.verify} -b "{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 -b /tmp/sketch.bin -R

View File

@ -0,0 +1,160 @@
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2014 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
*/
// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399
// to avoid notorious compiler error while uing STL (min and max macro error)
// It's terrible Arduino has just released new core and still don't merge the PR
#ifndef Arduino_h
#define Arduino_h
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef bool boolean;
typedef uint8_t byte;
typedef uint16_t word;
// some libraries and sketches depend on this AVR stuff,
// assuming Arduino.h or WProgram.h automatically includes it...
//
#include "avr/pgmspace.h"
#include "avr/interrupt.h"
#include "avr/io.h"
#include "binary.h"
#include "itoa.h"
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
// Include Atmel headers
#include "sam.h"
#include "wiring_constants.h"
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
void yield( void ) ;
/* system functions */
int main( void );
void init( void );
/* sketch */
void setup( void ) ;
void loop( void ) ;
#include "WVariant.h"
#ifdef __cplusplus
} // extern "C"
#endif
// The following headers are for C++ only compilation
#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "Tone.h"
#include "WMath.h"
#include "HardwareSerial.h"
#include "pulse.h"
#include <bits/stl_algobase.h>
#endif
#include "delay.h"
#ifdef __cplusplus
#include "Uart.h"
#endif
// Include board variant
#include "variant.h"
#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
#include "wiring_shift.h"
#include "WInterrupts.h"
#ifndef __cplusplus
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif // abs
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#else
//using std::min;
//using std::max;
template<class T, class L>
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
{
return (b < a) ? b : a;
}
template<class T, class L>
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
{
return (a < b) ? b : a;
}
#endif
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))
#define interrupts() __enable_irq()
#define noInterrupts() __disable_irq()
#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
#define bit(b) (1UL << (b))
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
// Interrupts
#define digitalPinToInterrupt(P) ( P )
#endif
// Allows publishing the Beta core under samd-beta / arduino organization
#ifndef ARDUINO_ARCH_SAMD
#define ARDUINO_ARCH_SAMD
#endif
// USB Device
#include "USB/USBDesc.h"
#include "USB/USBCore.h"
#include "USB/USBAPI.h"
#include "USB/USB_host.h"
#ifdef __cplusplus
#include "USB/CDC.h"
#endif
#endif // Arduino_h

View File

@ -0,0 +1,248 @@
# 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.6
# Compile variables
# -----------------
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
# 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=-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} {includes} "{source_file}" -o "{object_file}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {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} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {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} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_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} -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]+).*
# 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"
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
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
#
# 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"
#
# GDB (Debugger)
#
# EXPERIMENTAL feature: debug.pattern
# - this is alpha and may be subject to change without notice
tools.gdb.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
tools.gdb.cmd=arm-none-eabi-gdb
tools.gdb.cmd.windows=arm-none-eabi-gdb.exe
tools.gdb.debug.pattern="{path}/{cmd}" --interpreter=mi2 -ex "set pagination off" -ex 'target extended-remote | {tools.openocd.path}/{tools.openocd.cmd} -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0"' {build.path}/{build.project_name}.elf

View File

@ -0,0 +1,160 @@
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2014 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
*/
// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399
// to avoid notorious compiler error while uing STL (min and max macro error)
// It's terrible Arduino has just released new core and still don't merge the PR
#ifndef Arduino_h
#define Arduino_h
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef bool boolean;
typedef uint8_t byte;
typedef uint16_t word;
// some libraries and sketches depend on this AVR stuff,
// assuming Arduino.h or WProgram.h automatically includes it...
//
#include "avr/pgmspace.h"
#include "avr/interrupt.h"
#include "avr/io.h"
#include "binary.h"
#include "itoa.h"
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
// Include Atmel headers
#include "sam.h"
#include "wiring_constants.h"
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
void yield( void ) ;
/* system functions */
int main( void );
void init( void );
/* sketch */
void setup( void ) ;
void loop( void ) ;
#include "WVariant.h"
#ifdef __cplusplus
} // extern "C"
#endif
// The following headers are for C++ only compilation
#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "Tone.h"
#include "WMath.h"
#include "HardwareSerial.h"
#include "pulse.h"
#include <bits/stl_algobase.h>
#endif
#include "delay.h"
#ifdef __cplusplus
#include "Uart.h"
#endif
// Include board variant
#include "variant.h"
#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
#include "wiring_shift.h"
#include "WInterrupts.h"
#ifndef __cplusplus
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif // abs
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#else
//using std::min;
//using std::max;
template<class T, class L>
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
{
return (b < a) ? b : a;
}
template<class T, class L>
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
{
return (a < b) ? b : a;
}
#endif
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))
#define interrupts() __enable_irq()
#define noInterrupts() __disable_irq()
#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
#define bit(b) (1UL << (b))
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
// Interrupts
#define digitalPinToInterrupt(P) ( P )
#endif
// Allows publishing the Beta core under samd-beta / arduino organization
#ifndef ARDUINO_ARCH_SAMD
#define ARDUINO_ARCH_SAMD
#endif
// USB Device
#include "USB/USBDesc.h"
#include "USB/USBCore.h"
#include "USB/USBAPI.h"
#include "USB/USB_host.h"
#ifdef __cplusplus
#include "USB/CDC.h"
#endif
#endif // Arduino_h

View File

@ -0,0 +1,248 @@
# 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.7
# Compile variables
# -----------------
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
# 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=-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} {includes} "{source_file}" -o "{object_file}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {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} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {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} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_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} -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]+).*
# 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"
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
arduinoota.extraflags=
tools.bossac.network_cmd={runtime.tools.arduinoOTA-1.3.0.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
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
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}.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 "{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"
#
# GDB (Debugger)
#
# EXPERIMENTAL feature: debug.pattern
# - this is alpha and may be subject to change without notice
tools.gdb-openocd.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
tools.gdb-openocd.cmd=arm-none-eabi-gdb
tools.gdb-openocd.cmd.windows=arm-none-eabi-gdb.exe
tools.gdb-openocd.interpreter=console
tools.gdb-openocd.debug.pattern="{path}/{cmd}" --interpreter={interpreter} -ex "set remotetimeout 5" -ex "set pagination off" -ex 'target extended-remote | "{tools.openocd.path}/{tools.openocd.cmd}" -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0"' "{build.path}/{build.project_name}.elf"

View File

@ -0,0 +1,165 @@
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2014 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
*/
// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399
// to avoid notorious compiler error while uing STL (min and max macro error)
// It's terrible Arduino has just released new core and still don't merge the PR
#ifndef Arduino_h
#define Arduino_h
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef bool boolean;
typedef uint8_t byte;
typedef uint16_t word;
// some libraries and sketches depend on this AVR stuff,
// assuming Arduino.h or WProgram.h automatically includes it...
//
#include "avr/pgmspace.h"
#include "avr/interrupt.h"
#include "avr/io.h"
#include "binary.h"
#include "itoa.h"
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
// Include Atmel headers
#include "sam.h"
#include "wiring_constants.h"
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
void yield( void ) ;
/* system functions */
int main( void );
void init( void );
/* sketch */
void setup( void ) ;
void loop( void ) ;
#include "WVariant.h"
#ifdef __cplusplus
} // extern "C"
#endif
// The following headers are for C++ only compilation
#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "Tone.h"
#include "WMath.h"
#include "HardwareSerial.h"
#include "pulse.h"
#include <bits/stl_algobase.h>
#endif
#include "delay.h"
#ifdef __cplusplus
#include "Uart.h"
#endif
// Include board variant
#include "variant.h"
#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
#include "wiring_shift.h"
#include "WInterrupts.h"
#ifndef __cplusplus
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif // abs
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#else
//using std::min;
//using std::max;
template<class T, class L>
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
{
return (b < a) ? b : a;
}
template<class T, class L>
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
{
return (a < b) ? b : a;
}
#endif
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))
#define interrupts() __enable_irq()
#define noInterrupts() __disable_irq()
#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
#define bit(b) (1UL << (b))
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
// Interrupts
#define digitalPinToInterrupt(P) ( P )
#endif
// Allows publishing the Beta core under samd-beta / arduino organization
#ifndef ARDUINO_ARCH_SAMD
#define ARDUINO_ARCH_SAMD
#endif
// USB Device
#include "USB/USBDesc.h"
#include "USB/USBCore.h"
#include "USB/USBAPI.h"
#include "USB/USB_host.h"
#ifdef __cplusplus
#include "USB/CDC.h"
#endif
#endif // Arduino_h

View File

@ -0,0 +1,248 @@
# 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.8
# Compile variables
# -----------------
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
# 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=-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} {includes} "{source_file}" -o "{object_file}"
##recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {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} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {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} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
##recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_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} -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]+).*
# 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"
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
arduinoota.extraflags=
tools.bossac.network_cmd={runtime.tools.arduinoOTA-1.3.0.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
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
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}.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 "{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"
#
# GDB (Debugger)
#
# EXPERIMENTAL feature: debug.pattern
# - this is alpha and may be subject to change without notice
tools.gdb-openocd.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
tools.gdb-openocd.cmd=arm-none-eabi-gdb
tools.gdb-openocd.cmd.windows=arm-none-eabi-gdb.exe
tools.gdb-openocd.interpreter=console
tools.gdb-openocd.debug.pattern="{path}/{cmd}" --interpreter={interpreter} -ex "set remotetimeout 5" -ex "set pagination off" -ex 'target extended-remote | "{tools.openocd.path}/{tools.openocd.cmd}" -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0"' "{build.path}/{build.project_name}.elf"

File diff suppressed because it is too large Load Diff

676
README.md Normal file
View File

@ -0,0 +1,676 @@
# AsyncHTTPRequest_Generic
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncHTTPRequest_Generic.svg?)](https://www.ardu-badge.com/AsyncHTTPRequest_Generic)
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncHTTPRequest_Generic.svg)](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/releases)
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/master/LICENSE)
[![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)
---
---
### Releases v1.0.0
1. Initial coding to add support to STM32F/L/H/G/WB/MP1 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
2. Add examples using STM32 boards.
#### Currently Supported Boards
#### 1. ESP32 and ESP8266
#### 2. STM32F/L/H/G/WB/MP1 with built-in LAN8742A Ethernet.
1. Nucleo-144 (F429ZI, F746ZG, F756ZG, F767ZI)
2. Discovery STM32F746G-DISCOVERY
3. Any STM32 boards with enough flash/memory and already configured to run LAN8742A Ethernet.
---
---
## Why do we need this Async [AsyncHTTPRequest_Generic library](https://github.com/khoih-prog/AsyncHTTPRequest_Generic)
### AsyncHTTPRequest_Generic for ESP32, ESP8266 using built-in WiFi and STM32 boards using built-in LAN8742A Ethernet
This library is based on, modified from:
1. [Bob Lemaire's asyncHTTPrequest Library](https://github.com/boblemaire/asyncHTTPrequest)
#### Features
1. Asynchronous HTTP Request library for ESP8266, ESP32 using built-in WiFi, and STM32 boards using built-in LAN8742A Ethernet.
2. Providing a subset of HTTP.
3. Relying on on **[`ESPAsyncTCP`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266, [`AsyncTCP`](https://github.com/me-no-dev/AsyncTCP) for ESP32** using built-in WiFi
4. Relying on **[`STM32duino LwIP`](https://github.com/stm32duino/LwIP)/[`STM32duino STM32Ethernet`](https://github.com/stm32duino/STM32Ethernet)/[`STM32AsyncTCP`](https://github.com/philbowles/STM32AsyncTCP) for STM32 using built-in LAN8742A Ethernet.**
5. Methods similar in format and usage to XmlHTTPrequest in Javascript.
#### Supports:
1. **GET and POST**
2. Request and response headers
3. Chunked response
4. Single String response for short (<~5K) responses (heap permitting).
5. Optional onData callback.
6. Optional onReadyStatechange callback.
#### Principles of operation
This library adds a simple HTTP layer on top of the ESPAsyncTCP/AsyncTCP/STM32 AsyncTCP library to **facilitate REST communication from a Client to a Server**. The paradigm is similar to the XMLHttpRequest in Javascript, employing the notion of a ready-state progression through the transaction request.
**Synchronization can be accomplished using callbacks on ready-state change, a callback on data receipt, or simply polling for ready-state change**. Data retrieval can be incremental as received, or bulk retrieved when the transaction completes provided there is enough heap to buffer the entire response.
The underlying buffering uses a new xbuf class. It handles both character and binary data. Class xbuf uses a chain of small (64 byte) segments that are allocated and added to the tail as data is added and deallocated from the head as data is read, achieving the same result as a dynamic circular buffer limited only by the size of heap. The xbuf implements indexOf and readUntil functions.
For short transactions, buffer space should not be an issue. In fact, it can be more economical than other methods that use larger fixed length buffers. Data is acked when retrieved by the caller, so there is some limited flow control to limit heap usage for larger transfers.
Request and response headers are handled in the typical fashion.
Chunked responses are recognized and handled transparently.
---
---
## Prerequisite
1. [`Arduino IDE 1.8.12+` for Arduino](https://www.arduino.cc/en/Main/Software)
2. [`ESP8266 Core 2.7.3+`](https://github.com/esp8266/Arduino) for ESP8266-based boards.
3. [`ESP32 Core 1.0.4+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards
4. [`Arduino Core for STM32 1.9.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for for STM32 using built-in Ethernet LAN8742A.
5. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266.
6. [`AsyncTCP v1.1.1+`](https://github.com/me-no-dev/AsyncTCP) for ESP32.
7. [`STM32Ethernet library v1.2.0+`](https://github.com/stm32duino/STM32Ethernet) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery).
8. [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery).
9. [`STM32AsyncTCP library`](https://github.com/philbowles/STM32AsyncTCP) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery).
---
## Installation
### Use Arduino Library Manager
The best and easiest way is to use `Arduino Library Manager`. Search for `AsyncHTTPRequest_Generic`, then select / install the latest version. You can also use this link [![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncHTTPRequest_Generic.svg?)](https://www.ardu-badge.com/AsyncHTTPRequest_Generic) for more detailed instructions.
### Manual Install
1. Navigate to [AsyncHTTPRequest_Generic](https://github.com/khoih-prog/AsyncHTTPRequest_Generic) page.
2. Download the latest release `AsyncHTTPRequest_Generic-master.zip`.
3. Extract the zip file to `AsyncHTTPRequest_Generic-master` directory
4. Copy the whole `AsyncHTTPRequest_Generic-master` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
### VS Code & PlatformIO:
1. Install [VS Code](https://code.visualstudio.com/)
2. Install [PlatformIO](https://platformio.org/platformio-ide)
3. Install **AsyncHTTPRequest_Generic** library by using [Library Manager](https://docs.platformio.org/en/latest/librarymanager/). 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)
---
---
### Packages' Patches
1. ***To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards***, you have to copy the whole [nRF52 0.20.5](Packages_Patches/adafruit/hardware/nrf52/0.20.5) directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5).
Supposing the Adafruit nRF52 version is 0.20.5. These files must be copied into the directory:
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/platform.txt`
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/boards.txt`
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.h`
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.cpp`
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.h`
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.cpp`
- ***`~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Udp.h`***
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z
These files must be copied into the directory:
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt`
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt`
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.h`
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp`
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h`
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp`
- ***`~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h`***
2. ***To be able to compile and run on Teensy boards***, you have to copy the file [Teensy boards.txt](Packages_Patches/hardware/teensy/avr/boards.txt) into Teensy hardware directory (./arduino-1.8.12/hardware/teensy/avr/boards.txt).
Supposing the Arduino version is 1.8.12. This file must be copied into the directory:
- `./arduino-1.8.12/hardware/teensy/avr/boards.txt`
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
- `./arduino-x.yy.zz/hardware/teensy/avr/boards.txt`
3. ***To be able to compile and run on SAM DUE boards***, you have to copy the whole [SAM DUE](Packages_Patches/arduino/hardware/sam/1.6.12) directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).
Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:
- `~/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt`
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
- `~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt`
4. ***To be able to compile without error and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD cores 1.8.8](Packages_Patches/arduino/hardware/samd/1.8.8) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.8).
Supposing the Arduino SAMD version is 1.8.8. These files must be copied into the directory:
- `~/.arduino15/packages/arduino/hardware/samd/1.8.8/platform.txt`
- ***`~/.arduino15/packages/arduino/hardware/samd/1.8.8/cores/arduino/Arduino.h`***
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z
These files must be copied into the directory:
- `~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt`
- ***`~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h`***
This is mandatory to fix the ***notorious Arduino SAMD compiler error***. See [Improve Arduino compatibility with the STL (min and max macro)](https://github.com/arduino/ArduinoCore-samd/pull/399)
```
...\arm-none-eabi\include\c++\7.2.1\bits\stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
```
Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the `Arduino.h` file anymore.
5. ***To be able to automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the file [Adafruit SAMD platform.txt](Packages_Patches/adafruit/hardware/samd/1.6.0) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.6.0).
Supposing the Adafruit SAMD core version is 1.6.0. This file must be copied into the directory:
- `~/.arduino15/packages/adafruit/hardware/samd/1.6.0/platform.txt`
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
- `~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt`
6. ***To be able to automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the file [Seeeduino SAMD platform.txt](Packages_Patches/Seeeduino/hardware/samd/1.7.8) into Adafruit samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.7.8).
Supposing the Seeeduino SAMD core version is 1.7.8. This file must be copied into the directory:
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.7.8/platform.txt`
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt`
7. ***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/1.9.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.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 1.9.0. These files must be copied into the directory:
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/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:
- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_F767ZI/variant.h`
- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_L053R8/variant.h`
---
---
### Examples
Also see examples:
1. [AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP)
2. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager)
3. [AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
---
### Example [AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
Please take a look at other examples, as well.
#### 1. File [AsyncHTTPRequest_STM32.ino](examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino)
```cpp
#include "defines.h"
// 600s = 10 minutes to not flooding
#define HTTP_REQUEST_INTERVAL_MS 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)
{
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
{
//request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt");
request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
request.send();
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
{
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));
// 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)
```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
```
---
---
### Debug Terminal Oouput Samples
#### 1. [AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32) running on STM32F7 Nucleo-144 NUCLEO_F767ZI using built-in LAN8742A
```
Start AsyncHTTPRequest_STM32 on NUCLEO_F767ZI
AsyncHTTPRequest @ IP : 192.168.2.72
**************************************
abbreviation: EDT
client_ip: 216.154.52.212
datetime: 2020-09-13T18:22:59.555816-04: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
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
**************************************
abbreviation: EDT
client_ip: 216.154.52.212
datetime: 2020-09-13T18:27:57.586325-04: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
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
**************************************
```
---
#### 2. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager) running on ESP8266_NODEMCU
```
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP8266_NODEMCU
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
client_ip: 216.154.52.212
datetime: 2020-09-13T19:35:37.951609-04: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
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
**************************************
HHHHHH
```
---
#### 3. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager) running on ESP32_DEV
```
Starting AsyncHTTPRequest_ESP_WiFiManager using SPIFFS on ESP32_DEV
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
client_ip: 216.154.52.212
datetime: 2020-09-13T19:37:02.118166-04: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
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
**************************************
HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
**************************************
abbreviation: EDT
client_ip: 216.154.52.212
datetime: 2020-09-13T19:42:01.507586-04: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
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
**************************************
HHHHHHHHH HHHHHHHHHH HHHHHHHHHH
```
---
#### 4. [AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP) running on ESP8266_NODEMCU
```
Starting AsyncHTTPRequest_ESP using ESP8266_NODEMCU
Connecting to WiFi SSID: HueNet1
...........
HTTP WebServer is @ IP : 192.168.2.81
**************************************
abbreviation: EDT
client_ip: 216.154.52.212
datetime: 2020-09-13T19:56:28.295033-04: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
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
**************************************
HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
```
---
---
### Debug
Debug is enabled by default on Serial.
You can also change the debugging level from 0 to 4
```cpp
#define ASYNC_HTTP_DEBUG_PORT Serial
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
#define _ASYNC_HTTP_LOGLEVEL_ 1
```
---
### Troubleshooting
If you get compilation errors, more often than not, you may need to install a newer version of the `ESP32 / ESP8266 / STM32` core for Arduino.
Sometimes, the library will only work if you update the `ESP32 / ESP8266 / STM32` core to the latest version because I am using newly added functions.
---
### Issues ###
Submit issues to: [AsyncHTTPRequest_Generic issues](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues)
---
## TO DO
1. Fix bug. Add enhancement
2. Add support to more Ethernet / WiFi shields
3. Add support to more boards.
4. Add many more examples.
## DONE
1. Initially add support to STM32 using built-in LAN8742A Etnernet. Tested on **STM32F7 Nucleo-144 F767ZI**.
2. Add more examples.
3. Add debugging features.
---
---
### Releases v1.0.0
1. Initial coding to add support to STM32F/L/H/G/WB/MP1 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
2. Add examples using STM32 boards.
---
---
### Contributions and Thanks
This library is based on, modified, bug-fixed and improved from:
1. [Bob Lemaire's asyncHTTPrequest Library](https://github.com/boblemaire/asyncHTTPrequest)
to use the better **asynchronous** features of these following Async TCP Libraries : ( [`ESPAsyncTCP`](https://github.com/me-no-dev/ESPAsyncTCP), [`AsyncTCP`](https://github.com/me-no-dev/AsyncTCP), and [`STM32AsyncTCP`](https://github.com/philbowles/STM32AsyncTCP) ).
<table>
<tr>
<td align="center"><a href="https://github.com/boblemaire"><img src="https://github.com/boblemaire.png" width="100px;" alt="boblemaire"/><br /><sub><b>⭐️ Bob Lemaire</b></sub></a><br /></td>
</tr>
</table>
### Contributing
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell other people about this library
---
### License and credits ###
- The library is licensed under [MIT](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/master/LICENSE)
---
## Copyright
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
Copyright 2020- Khoi Hoang

View File

@ -0,0 +1,165 @@
/****************************************************************************************************************************
AsyncHTTPRequest_ESP.ino - 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_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
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.0.0
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).
*****************************************************************************************************************************/
//************************************************************************************************************
//
// There are scores of ways to use AsyncHTTPRequest. The important thing to keep in mind is that
// it is asynchronous and just like in JavaScript, everything is event driven. You will have some
// reason to initiate an asynchronous HTTP request in your program, but then sending the request
// headers and payload, gathering the response headers and any payload, and processing
// of that response, can (and probably should) all be done asynchronously.
//
// In this example, a Ticker function is setup to fire every 300 seconds to initiate a request.
// Everything is handled in AsyncHTTPRequest without blocking.
// The callback onReadyStateChange is made progressively and like most JS scripts, we look for
// readyState == 4 (complete) here. At that time the response is retrieved and printed.
//
// Note that there is no code in loop(). A code entered into loop would run oblivious to
// the ongoing HTTP requests. The Ticker could be removed and periodic calls to sendRequest()
// could be made in loop(), resulting in the same asynchronous handling.
//
// For demo purposes, debug is turned on for handling of the first request. These are the
// events that are being handled in AsyncHTTPRequest. They all begin with Debug(nnn) where
// nnn is the elapsed time in milliseconds since the transaction was started.
//
//*************************************************************************************************************
#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
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
Ticker ticker;
void heartBeatPrint(void)
{
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()
{
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
{
//request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt");
request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
request.send();
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
{
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(request->responseText());
Serial.println("**************************************");
request->setDebug(false);
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
Serial.println("\nStarting AsyncHTTPRequest_ESP using " + String(ARDUINO_BOARD));
WiFi.mode(WIFI_STA);
if (WiFi.status() == WL_NO_SHIELD)
{
Serial.println(F("WiFi shield not present"));
// don't continue
while (true);
}
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi SSID: " + String(ssid));
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.print(F("\nHTTP WebServer is @ IP : "));
Serial.println(WiFi.localIP());
request.setDebug(false);
request.onReadyStateChange(requestCB);
ticker.attach(HTTP_REQUEST_INTERVAL, sendRequest);
ticker.attach(HEARTBEAT_INTERVAL, heartBeatPrint);
// Send first request now
sendRequest();
}
void loop()
{
}

View File

@ -0,0 +1,607 @@
/****************************************************************************************************************************
AsyncHTTPRequest_ESP_WiFiManager.ino - 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_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
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.0.0
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).
*****************************************************************************************************************************/
//************************************************************************************************************
//
// There are scores of ways to use AsyncHTTPRequest. The important thing to keep in mind is that
// it is asynchronous and just like in JavaScript, everything is event driven. You will have some
// reason to initiate an asynchronous HTTP request in your program, but then sending the request
// headers and payload, gathering the response headers and any payload, and processing
// of that response, can (and probably should) all be done asynchronously.
//
// In this example, a Ticker function is setup to fire every 300 seconds to initiate a request.
// Everything is handled in AsyncHTTPRequest without blocking.
// The callback onReadyStateChange is made progressively and like most JS scripts, we look for
// readyState == 4 (complete) here. At that time the response is retrieved and printed.
//
// Note that there is no code in loop(). A code entered into loop would run oblivious to
// the ongoing HTTP requests. The Ticker could be removed and periodic calls to sendRequest()
// could be made in loop(), resulting in the same asynchronous handling.
//
// For demo purposes, debug is turned on for handling of the first request. These are the
// events that are being handled in AsyncHTTPRequest. They all begin with Debug(nnn) where
// nnn is the elapsed time in milliseconds since the transaction was started.
//
//*************************************************************************************************************
#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
//Ported to ESP32
#ifdef ESP32
#include <esp_wifi.h>
#include <WiFi.h>
#include <WiFiClient.h>
// From v1.1.1
#include <WiFiMulti.h>
WiFiMulti wifiMulti;
#define USE_SPIFFS true
#if USE_SPIFFS
#include <SPIFFS.h>
FS* filesystem = &SPIFFS;
#define FileFS SPIFFS
#define FS_Name "SPIFFS"
#else
// +Use FFat
#include <FFat.h>
FS* filesystem = &FFat;
#define FileFS FFat
#define FS_Name "FFat"
#endif
//////
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())
#define LED_BUILTIN 2
#define LED_ON HIGH
#define LED_OFF LOW
#else
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
//needed for library
#include <DNSServer.h>
// From v1.1.1
#include <ESP8266WiFiMulti.h>
ESP8266WiFiMulti wifiMulti;
#define USE_LITTLEFS true
#if USE_LITTLEFS
#include <LittleFS.h>
FS* filesystem = &LittleFS;
#define FileFS LittleFS
#define FS_Name "LittleFS"
#else
FS* filesystem = &SPIFFS;
#define FileFS SPIFFS
#define FS_Name "SPIFFS"
#endif
//////
#define ESP_getChipId() (ESP.getChipId())
#define LED_ON LOW
#define LED_OFF HIGH
#endif
// SSID and PW for your Router
String Router_SSID;
String Router_Pass;
// From v1.1.1
// You only need to format the filesystem once
//#define FORMAT_FILESYSTEM true
#define FORMAT_FILESYSTEM false
#define MIN_AP_PASSWORD_SIZE 8
#define SSID_MAX_LEN 32
//From v1.0.10, WPA2 passwords can be up to 63 characters long.
#define PASS_MAX_LEN 64
typedef struct
{
char wifi_ssid[SSID_MAX_LEN];
char wifi_pw [PASS_MAX_LEN];
} WiFi_Credentials;
typedef struct
{
String wifi_ssid;
String wifi_pw;
} WiFi_Credentials_String;
#define NUM_WIFI_CREDENTIALS 2
typedef struct
{
WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS];
} WM_Config;
WM_Config WM_config;
#define CONFIG_FILENAME F("/wifi_cred.dat")
//////
// Indicates whether ESP has WiFi credentials saved from previous session, or double reset detected
bool initialConfig = false;
// Use false if you don't like to display Available Pages in Information Page of Config Portal
// Comment out or use true to display Available Pages in Information Page of Config Portal
// Must be placed before #include <ESP_WiFiManager.h>
#define USE_AVAILABLE_PAGES true
// From v1.0.10 to permit disable/enable StaticIP configuration in Config Portal from sketch. Valid only if DHCP is used.
// You'll loose the feature of dynamically changing from DHCP to static IP, or vice versa
// You have to explicitly specify false to disable the feature.
//#define USE_STATIC_IP_CONFIG_IN_CP false
// Use false to disable NTP config. Advisable when using Cellphone, Tablet to access Config Portal.
// See Issue 23: On Android phone ConfigPortal is unresponsive (https://github.com/khoih-prog/ESP_WiFiManager/issues/23)
#define USE_ESP_WIFIMANAGER_NTP false
// Use true to enable CloudFlare NTP service. System can hang if you don't have Internet access while accessing CloudFlare
// See Issue #21: CloudFlare link in the default portal (https://github.com/khoih-prog/ESP_WiFiManager/issues/21)
#define USE_CLOUDFLARE_NTP false
// New in v1.0.11
#define USING_CORS_FEATURE true
//////
// Use USE_DHCP_IP == true for dynamic DHCP IP, false to use static IP which you have to change accordingly to your network
#if (defined(USE_STATIC_IP_CONFIG_IN_CP) && !USE_STATIC_IP_CONFIG_IN_CP)
// Force DHCP to be true
#if defined(USE_DHCP_IP)
#undef USE_DHCP_IP
#endif
#define USE_DHCP_IP true
#else
// You can select DHCP or Static IP here
//#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 ) )
// Use DHCP
#warning Using DHCP IP
IPAddress stationIP = IPAddress(0, 0, 0, 0);
IPAddress gatewayIP = IPAddress(192, 168, 2, 1);
IPAddress netMask = IPAddress(255, 255, 255, 0);
#else
// Use static IP
#warning Using static IP
#ifdef ESP32
IPAddress stationIP = IPAddress(192, 168, 2, 232);
#else
IPAddress stationIP = IPAddress(192, 168, 2, 186);
#endif
IPAddress gatewayIP = IPAddress(192, 168, 2, 1);
IPAddress netMask = IPAddress(255, 255, 255, 0);
#endif
#define USE_CONFIGURABLE_DNS true
IPAddress dns1IP = gatewayIP;
IPAddress dns2IP = IPAddress(8, 8, 8, 8);
#include <ESPAsync_WiFiManager.h> //https://github.com/khoih-prog/ESPAsync_WiFiManager
#define HTTP_PORT 80
AsyncWebServer webServer(HTTP_PORT);
DNSServer dnsServer;
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
Ticker ticker;
void heartBeatPrint(void)
{
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 check_WiFi(void)
{
if ( (WiFi.status() != WL_CONNECTED) )
{
Serial.println(F("\nWiFi lost. Call connectMultiWiFi in loop"));
connectMultiWiFi();
}
}
void check_status(void)
{
static ulong checkstatus_timeout = 0;
static ulong checkwifi_timeout = 0;
static ulong current_millis;
#define WIFICHECK_INTERVAL 1000L
#define HEARTBEAT_INTERVAL 10000L
current_millis = millis();
// Check WiFi every WIFICHECK_INTERVAL (1) seconds.
if ((current_millis > checkwifi_timeout) || (checkwifi_timeout == 0))
{
check_WiFi();
checkwifi_timeout = current_millis + WIFICHECK_INTERVAL;
}
// Print hearbeat every HEARTBEAT_INTERVAL (10) seconds.
if ((current_millis > checkstatus_timeout) || (checkstatus_timeout == 0))
{
heartBeatPrint();
checkstatus_timeout = current_millis + HEARTBEAT_INTERVAL;
}
}
void loadConfigData(void)
{
File file = FileFS.open(CONFIG_FILENAME, "r");
LOGERROR(F("LoadWiFiCfgFile "));
if (file)
{
file.readBytes((char *) &WM_config, sizeof(WM_config));
file.close();
LOGERROR(F("OK"));
}
else
{
LOGERROR(F("failed"));
}
}
void saveConfigData(void)
{
File file = FileFS.open(CONFIG_FILENAME, "w");
LOGERROR(F("SaveWiFiCfgFile "));
if (file)
{
file.write((uint8_t*) &WM_config, sizeof(WM_config));
file.close();
LOGERROR(F("OK"));
}
else
{
LOGERROR(F("failed"));
}
}
uint8_t connectMultiWiFi(void)
{
#if ESP32
// For ESP32, this better be 0 to shorten the connect time
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 0
#else
// For ESP8266, this better be 2200 to enable connect the 1st time
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 2200L
#endif
#define WIFI_MULTI_CONNECT_WAITING_MS 100L
uint8_t status;
LOGERROR(F("ConnectMultiWiFi with :"));
if ( (Router_SSID != "") && (Router_Pass != "") )
{
LOGERROR3(F("* Flash-stored Router_SSID = "), Router_SSID, F(", Router_Pass = "), Router_Pass );
}
for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++)
{
// Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8)
if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != "") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) )
{
LOGERROR3(F("* Additional SSID = "), WM_config.WiFi_Creds[i].wifi_ssid, F(", PW = "), WM_config.WiFi_Creds[i].wifi_pw );
}
}
LOGERROR(F("Connecting MultiWifi..."));
WiFi.mode(WIFI_STA);
#if !USE_DHCP_IP
#if USE_CONFIGURABLE_DNS
// Set static IP, Gateway, Subnetmask, DNS1 and DNS2. New in v1.0.5
WiFi.config(stationIP, gatewayIP, netMask, dns1IP, dns2IP);
#else
// Set static IP, Gateway, Subnetmask, Use auto DNS1 and DNS2.
WiFi.config(stationIP, gatewayIP, netMask);
#endif
#endif
int i = 0;
status = wifiMulti.run();
delay(WIFI_MULTI_1ST_CONNECT_WAITING_MS);
while ( ( i++ < 20 ) && ( status != WL_CONNECTED ) )
{
status = wifiMulti.run();
if ( status == WL_CONNECTED )
break;
else
delay(WIFI_MULTI_CONNECT_WAITING_MS);
}
if ( status == WL_CONNECTED )
{
LOGERROR1(F("WiFi connected after time: "), i);
LOGERROR3(F("SSID:"), WiFi.SSID(), F(",RSSI="), WiFi.RSSI());
LOGERROR3(F("Channel:"), WiFi.channel(), F(",IP address:"), WiFi.localIP() );
}
else
LOGERROR(F("WiFi not connected"));
return status;
}
void sendRequest()
{
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
{
//request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt");
request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
request.send();
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
{
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(request->responseText());
Serial.println("**************************************");
request->setDebug(false);
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
Serial.print("\nStarting AsyncHTTPRequest_ESP_WiFiManager using " + String(FS_Name));
Serial.println(" on " + String(ARDUINO_BOARD));
if (FORMAT_FILESYSTEM)
FileFS.format();
// Format FileFS if not yet
#ifdef ESP32
if (!FileFS.begin(true))
#else
if (!FileFS.begin())
#endif
{
Serial.print(FS_Name);
Serial.println(F(" failed! AutoFormatting."));
#ifdef ESP8266
FileFS.format();
#endif
}
unsigned long startedAt = millis();
//Local intialization. Once its business is done, there is no need to keep it around
// 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");
ESPAsync_wifiManager.setDebugOutput(true);
//reset settings - for testing
//ESPAsync_wifiManager.resetSettings();
//set custom ip for portal
ESPAsync_wifiManager.setAPStaticIPConfig(IPAddress(192, 168, 100, 1), IPAddress(192, 168, 100, 1), IPAddress(255, 255, 255, 0));
ESPAsync_wifiManager.setMinimumSignalQuality(-1);
// From v1.0.10 only
// Set config portal channel, default = 1. Use 0 => random channel from 1-13
ESPAsync_wifiManager.setConfigPortalChannel(0);
//////
#if !USE_DHCP_IP
#if USE_CONFIGURABLE_DNS
// Set static IP, Gateway, Subnetmask, DNS1 and DNS2. New in v1.0.5
ESPAsync_wifiManager.setSTAStaticIPConfig(stationIP, gatewayIP, netMask, dns1IP, dns2IP);
#else
// Set static IP, Gateway, Subnetmask, Use auto DNS1 and DNS2.
ESPAsync_wifiManager.setSTAStaticIPConfig(stationIP, gatewayIP, netMask);
#endif
#endif
// New from v1.1.1
#if USING_CORS_FEATURE
ESPAsync_wifiManager.setCORSHeader("Your Access-Control-Allow-Origin");
#endif
// We can't use WiFi.SSID() in ESP32 as it's only valid after connected.
// SSID and Password stored in ESP32 wifi_ap_record_t and wifi_config_t are also cleared in reboot
// Have to create a new function to store in EEPROM/SPIFFS for this purpose
Router_SSID = ESPAsync_wifiManager.WiFi_SSID();
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);
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");
}
else
{
Serial.println("No stored Credentials. No timeout");
}
String chipID = String(ESP_getChipId(), HEX);
chipID.toUpperCase();
// SSID and PW for Config Portal
String AP_SSID = "ESP_" + chipID + "_AutoConnectAP";
String AP_PASS = "MyESP_" + chipID;
// 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");
initialConfig = true;
// 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.");
else
Serial.println("WiFi connected...yeey :)");
// Stored for later usage, from v1.1.0, but clear first
memset(&WM_config, 0, sizeof(WM_config));
for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++)
{
String tempSSID = ESPAsync_wifiManager.getSSID(i);
String tempPW = ESPAsync_wifiManager.getPW(i);
if (strlen(tempSSID.c_str()) < sizeof(WM_config.WiFi_Creds[i].wifi_ssid) - 1)
strcpy(WM_config.WiFi_Creds[i].wifi_ssid, tempSSID.c_str());
else
strncpy(WM_config.WiFi_Creds[i].wifi_ssid, tempSSID.c_str(), sizeof(WM_config.WiFi_Creds[i].wifi_ssid) - 1);
if (strlen(tempPW.c_str()) < sizeof(WM_config.WiFi_Creds[i].wifi_pw) - 1)
strcpy(WM_config.WiFi_Creds[i].wifi_pw, tempPW.c_str());
else
strncpy(WM_config.WiFi_Creds[i].wifi_pw, tempPW.c_str(), sizeof(WM_config.WiFi_Creds[i].wifi_pw) - 1);
// Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8)
if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != "") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) )
{
LOGERROR3(F("* Add SSID = "), WM_config.WiFi_Creds[i].wifi_ssid, F(", PW = "), WM_config.WiFi_Creds[i].wifi_pw );
wifiMulti.addAP(WM_config.WiFi_Creds[i].wifi_ssid, WM_config.WiFi_Creds[i].wifi_pw);
}
}
saveConfigData();
}
else
{
wifiMulti.addAP(Router_SSID.c_str(), Router_Pass.c_str());
}
startedAt = millis();
if (!initialConfig)
{
// Load stored data, the addAP ready for MultiWiFi reconnection
loadConfigData();
for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++)
{
// Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8)
if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != "") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) )
{
LOGERROR3(F("* Add SSID = "), WM_config.WiFi_Creds[i].wifi_ssid, F(", PW = "), WM_config.WiFi_Creds[i].wifi_pw );
wifiMulti.addAP(WM_config.WiFi_Creds[i].wifi_ssid, WM_config.WiFi_Creds[i].wifi_pw);
}
}
if ( WiFi.status() != WL_CONNECTED )
{
Serial.println("ConnectMultiWiFi in setup");
connectMultiWiFi();
}
}
Serial.print("After waiting ");
Serial.print((float) (millis() - startedAt) / 1000L);
Serial.print(" secs more in setup(), connection result is ");
if (WiFi.status() == WL_CONNECTED)
{
Serial.print("connected. Local IP: ");
Serial.println(WiFi.localIP());
}
else
Serial.println(ESPAsync_wifiManager.getStatus(WiFi.status()));
request.setDebug(false);
request.onReadyStateChange(requestCB);
ticker.attach(HTTP_REQUEST_INTERVAL, sendRequest);
// Send first request now
sendRequest();
}
void loop()
{
// put your main code here, to run repeatedly
check_status();
}

View File

@ -0,0 +1,120 @@
/****************************************************************************************************************************
AsyncHTTPRequest_STM32.ino - 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_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
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.0.0
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).
*****************************************************************************************************************************/
//************************************************************************************************************
//
// There are scores of ways to use AsyncHTTPRequest. The important thing to keep in mind is that
// it is asynchronous and just like in JavaScript, everything is event driven. You will have some
// reason to initiate an asynchronous HTTP request in your program, but then sending the request
// headers and payload, gathering the response headers and any payload, and processing
// of that response, can (and probably should) all be done asynchronously.
//
// In this example, a Ticker function is setup to fire every 5 seconds to initiate a request.
// Everything is handled in AsyncHTTPRequest without blocking.
// The callback onReadyStateChange is made progressively and like most JS scripts, we look for
// readyState == 4 (complete) here. At that time the response is retrieved and printed.
//
// Note that there is no code in loop(). A code entered into loop would run oblivious to
// the ongoing HTTP requests. The Ticker could be removed and periodic calls to sendRequest()
// could be made in loop(), resulting in the same asynchronous handling.
//
// For demo purposes, debug is turned on for handling of the first request. These are the
// events that are being handled in AsyncHTTPRequest. They all begin with Debug(nnn) where
// nnn is the elapsed time in milliseconds since the transaction was started.
//
//*************************************************************************************************************
#include "defines.h"
// 600s = 10 minutes to not flooding
#define HTTP_REQUEST_INTERVAL_MS 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)
{
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
{
//request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt");
request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
request.send();
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
{
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));
// 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();
}

View File

@ -0,0 +1,140 @@
/****************************************************************************************************************************
defines.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_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
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.0.0
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).
*****************************************************************************************************************************/
/*
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

60
keywords.txt Normal file
View File

@ -0,0 +1,60 @@
#######################################
# Syntax Coloring Map For Ultrasound
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
reqStates KEYWORD1
AsyncHTTPRequest KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
setDebug KEYWORD2
debug KEYWORD2
open KEYWORD2
onReadyStateChange KEYWORD2
setTimeout KEYWORD2
setReqHeader KEYWORD2
send KEYWORD2
abort KEYWORD2
readyState KEYWORD2
respHeaderCount KEYWORD2
respHeaderName KEYWORD2
respHeaderValue KEYWORD2
respHeaderExists KEYWORD2
headers KEYWORD2
onData KEYWORD2
available KEYWORD2
responseLength KEYWORD2
responseHTTPcode KEYWORD2
responseRead KEYWORD2
elapsedTime KEYWORD2
version KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
HTTPCODE_CONNECTION_REFUSED LITERAL1
HTTPCODE_SEND_HEADER_FAILED LITERAL1
HTTPCODE_SEND_PAYLOAD_FAILED LITERAL1
HTTPCODE_NOT_CONNECTED LITERAL1
HTTPCODE_CONNECTION_LOST LITERAL1
HTTPCODE_NO_STREAM LITERAL1
HTTPCODE_NO_HTTP_SERVER LITERAL1
HTTPCODE_TOO_LESS_RAM LITERAL1
HTTPCODE_ENCODING LITERAL1
HTTPCODE_STREAM_WRITE LITERAL1
HTTPCODE_TIMEOUT LITERAL1
readyStateUnsent LITERAL1
readyStateOpened LITERAL1
readyStateHdrsRecvd LITERAL1
readyStateLoading LITERAL1
readyStateDone LITERAL1

52
library.json Normal file
View File

@ -0,0 +1,52 @@
{
"name":"AsyncHTTPRequest_Generic",
"version": "1.0.0",
"description":"Simple Async HTTP Request library, supporting GET and POST, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32, ESP8266 and currently STM32 with built-in LAN8742A Ethernet.",
"keywords":"async,tcp,http,ESP8266,ESP32,ESPAsyncTCP,AsyncTCP_STM32,stm32,ethernet,wifi,lan8742a",
"authors": [
{
"name": "Bob Lemaire",
"url": "https://github.com/boblemaire",
}
{
"name": "Khoi Hoang",
"url": "https://github.com/khoih-prog",
"email": "khoih.prog@gmail.com",
"maintainer": true,
}
],
"repository":
{
"type": "git",
"url": "https://github.com/khoih-prog/AsyncHTTPRequest_Generic"
},
"license": "MIT",
"frameworks": "arduino",
"platforms": ["*"],
"dependencies": [
{
"name": "AsyncTCP",
"platforms": "espressif32"
},
{
"name": "ESP AsyncTCP",
"platforms": "espressif8266"
},
{
"name": "ESPAsync_WiFiManager",
"platforms": ["espressif8266", "espressif32"]
},
{
"name": "STM32duino LwIP",
"platforms": "ststm32"
},
{
"name": "STM32duino STM32Ethernet",
"platforms": "ststm32"
}
{
"name": "STM32 AsyncTCP",
"platforms": "ststm32"
}
]
}

12
library.properties Normal file
View File

@ -0,0 +1,12 @@
name=AsyncHTTPRequest_Generic
version=1.0.0
author=Bob Lemaire,Khoi Hoang
maintainer=Khoi Hoang <khoih.prog@gmail.com>
license=MIT
sentence=Simple Async HTTP Request library, supporting GET and POST, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32, ESP8266 and currently STM32 with built-in LAN8742A Ethernet.
paragraph=This AsyncHTTPRequest_Generic Library, supporting GET and POST, for ESP32, ESP8266 and STM32 with built-in LAN8742A Ethernet, such as Nucleo-144 F767ZI, etc.
category=Communication,AsyncTCP,AsyncHTTP
url=https://github.com/khoih-prog/AsyncHTTPRequest_Generic
architectures=*
depends=AsyncTCP,ESP AsyncTCP,ESPAsync_WiFiManager,STM32duino LwIP,STM32duino STM32Ethernet,STM32 AsyncTCP
includes=AsyncHTTPRequest_Generic.h

340
platformio/platformio.ini Normal file
View File

@ -0,0 +1,340 @@
;PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
; ============================================================
; chose environment:
; ESP8266
; ESP32
; SAMD
; NRF52
; STM32
; ============================================================
;default_envs = ESP8266
default_envs = ESP32
;default_envs = SAMD
;default_envs = NRF52
;default_envs = STM32
[env]
; ============================================================
; Serial configuration
; choose upload speed, serial-monitor speed
; ============================================================
upload_speed = 921600
;upload_port = COM11
;monitor_speed = 9600
;monitor_port = COM11
lib_deps =
AsyncTCP@~1.1.1
ESP AsyncTCP@~1.2.2
STM32 AsyncTCP@~1.0.0
STM32duino LwIP@~2.1.2
STM32duino STM32Ethernet@~1.2.0
ESPAsync_WiFiManager@~1.1.1
build_flags =
; set your debug output (default=Serial)
; -D DEBUG_ESP_PORT=Serial
; comment the folowing line to enable WiFi debugging
; -D NDEBUG
[env:ESP8266]
platform = espressif8266
framework = arduino
; ============================================================
; Board configuration
; choose your board by uncommenting one of the following lines
; ============================================================
;board = gen4iod
;board = huzzah
;board = oak
;board = esp_wroom_02
;board = espduino
;board = espectro
;board = espino
;board = espresso_lite_v1
;board = espresso_lite_v2
;board = esp12e
;board = esp01_1m
;board = esp01
;board = esp07
;board = esp8285
;board = heltec_wifi_kit_8
;board = inventone
;board = nodemcu
board = nodemcuv2
;board = modwifi
;board = phoenix_v1
;board = phoenix_v2
;board = sparkfunBlynk
;board = thing
;board = thingdev
;board = esp210
;board = espinotee
;board = d1
;board = d1_mini
;board = d1_mini_lite
;board = d1_mini_pro
;board = wifi_slot
;board = wifiduino
;board = wifinfo
;board = wio_link
;board = wio_node
;board = xinabox_cw01
;board = esp32doit-devkit-v1
[env:ESP32]
platform = espressif32
framework = arduino, espidf
; ============================================================
; Board configuration
; choose your board by uncommenting one of the following lines
; ============================================================
;board = esp32cam
;board = alksesp32
;board = featheresp32
;board = espea32
;board = bpi-bit
;board = d-duino-32
board = esp32doit-devkit-v1
;board = pocket_32
;board = fm-devkit
;board = pico32
;board = esp32-evb
;board = esp32-gateway
;board = esp32-pro
;board = esp32-poe
;board = oroca_edubot
;board = onehorse32dev
;board = lopy
;board = lopy4
;board = wesp32
;board = esp32thing
;board = sparkfun_lora_gateway_1-channel
;board = ttgo-lora32-v1
;board = ttgo-t-beam
;board = turta_iot_node
;board = lolin_d32
;board = lolin_d32_pro
;board = lolin32
;board = wemosbat
;board = widora-air
;board = xinabox_cw02
;board = iotbusio
;board = iotbusproteus
;board = nina_w10
[env:SAMD]
platform = atmelsam
framework = arduino
; ============================================================
; Choose your board by uncommenting one of the following lines
; ============================================================
; ============================================================
; Board configuration Adafruit SAMD
; ============================================================
;board = adafruit_feather_m0
;board = adafruit_feather_m0_express
;board = adafruit_metro_m0
;board = adafruit_circuitplayground_m0
;board = adafruit_gemma_m0
;board = adafruit_trinket_m0
;board = adafruit_itsybitsy_m0
;board = adafruit_pirkey
;board = adafruit_hallowing
;board = adafruit_crickit_m0
;board = adafruit_metro_m4
;board = adafruit_grandcentral_m4
board = adafruit_itsybitsy_m4
;board = adafruit_feather_m4
;board = adafruit_trellis_m4
;board = adafruit_pyportal_m4
;board = adafruit_pyportal_m4_titano
;board = adafruit_pybadge_m4
;board = adafruit_metro_m4_airliftlite
;board = adafruit_pygamer_m4
;board = adafruit_pygamer_advance_m4
;board = adafruit_pybadge_airlift_m4
;board = adafruit_monster_m4sk
;board = adafruit_hallowing_m4
; ============================================================
; Board configuration Arduino SAMD and SAM
; ============================================================
;board = arduino_zero_edbg
;board = arduino_zero_native
;board = mkr1000
;board = mkrzero
;board = mkrwifi1010
;board = nano_33_iot
;board = mkrfox1200
;board = mkrwan1300
;board = mkrwan1310
;board = mkrgsm1400
;board = mkrnb1500
;board = mkrvidor4000
;board = adafruit_circuitplayground_m0
;board = mzero_pro_bl_dbg
;board = mzero_pro_bl
;board = mzero_bl
;board = tian
;board = tian_cons
;board = arduino_due_x_dbg
;board = arduino_due_x
; ============================================================
; Board configuration Seeeduino SAMD
; ============================================================
;board = seeed_wio_terminal
;board = Seeed_femto_m0
;board = seeed_XIAO_m0
;board = Wio_Lite_MG126
;board = WioGPS
;board = zero
;board = rolawan
;board = seeed_grove_ui_wireless
[env:NRF52]
platform = nordicnrf52
framework = arduino
; ============================================================
; Board configuration Adafruit nRF52
; choose your board by uncommenting one of the following lines
; ============================================================
;board = feather52832
board = feather52840
;board = feather52840sense
;board = itsybitsy52840
;board = cplaynrf52840
;board = cluenrf52840
;board = metro52840
;board = pca10056
;board = particle_xenon
;board = mdbt50qrx
;board = ninab302
;board = ninab112
[env:STM32]
platform = ststm32
framework = arduino
; ============================================================
; Choose your board by uncommenting one of the following lines
; ============================================================
; ============================================================
; Board configuration Nucleo-144
; ============================================================
;board = nucleo_f207zg
;board = nucleo_f429zi
;board = nucleo_f746zg
;board = nucleo_f756zg
;board = nucleo_f767zi
;board = nucleo_h743zi
;board = nucleo_l496zg
;board = nucleo_l496zg-p
;board = nucleo_l4r5zi
;board = nucleo_l4r5zi-p
; ============================================================
; Board configuration Nucleo-64
; ============================================================
;board = nucleo_f030r8
;board = nucleo_f072rb
;board = nucleo_f091rc
;board = nucleo_f103rb
;board = nucleo_f302r8
;board = nucleo_f303re
;board = nucleo_f401re
;board = nucleo_f411re
;board = nucleo_f446re
;board = nucleo_g071rb
;board = nucleo_g431rb
;board = nucleo_g474re
;board = nucleo_l053r8
;board = nucleo_l073rz
;board = nucleo_l152re
;board = nucleo_l433rc_p
;board = nucleo_l452re
;board = nucleo_l452re-p
;board = nucleo_l476rg
;board = pnucleo_wb55rg
; ============================================================
; Board configuration Nucleo-32
; ============================================================
;board = nucleo_f031k6
;board = nucleo_l031k6
;board = nucleo_l412kb
;board = nucleo_l432lc
;board = nucleo_f303k8
;board = nucleo_g431kb
; ============================================================
; Board configuration Discovery Boards
; ============================================================
;board = disco_f030r8
;board = disco_f072rb
;board = disco_f030r8
;board = disco_f100rb
;board = disco_f407vg
;board = disco_f413zh
;board = disco_f746ng
;board = disco_g0316
;board = disco_l475vg_iot
;board = disco_f072cz-lrwan1
; ============================================================
; Board configuration STM32MP1 Boards
; ============================================================
;board = stm32mp157a-dk1
;board = stm32mp157c-dk2
; ============================================================
; Board configuration Generic Boards
; ============================================================
;board = bluepill_f103c6
;board = bluepill_f103c8
;board = blackpill_f103c8
;board = stm32f103cx
;board = stm32f103rx
;board = stm32f103tx
;board = stm32f103vx
;board = stm32f103zx
;board = stm32f103zet6
;board = maplemini_f103cb
;board = blackpill_f303cc
;board = black_f407ve
;board = black_f407vg
;board = black_f407ze
;board = black_f407zg
;board = blue_f407ve_mini
;board = blackpill_f401cc
;board = blackpill_f411ce
;board = coreboard_f401rc
;board = feather_f405
; ============================================================
; Board configuration Many more Boards to be filled
; ============================================================

View File

@ -0,0 +1,71 @@
/****************************************************************************************************************************
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.0.0
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).
*****************************************************************************************************************************/
#ifndef AsyncHTTPRequest_Debug_STM32_H
#define AsyncHTTPRequest_Debug_STM32_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
#define AHTTP_LOGERROR(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
#define AHTTP_LOGERROR0(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print(x); }
#define AHTTP_LOGERROR1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
#define AHTTP_LOGERROR2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
#define AHTTP_LOGERROR3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
#define AHTTP_LOGWARN(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
#define AHTTP_LOGWARN0(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print(x); }
#define AHTTP_LOGWARN1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
#define AHTTP_LOGWARN2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
#define AHTTP_LOGWARN3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
#define AHTTP_LOGINFO(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
#define AHTTP_LOGINFO0(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print(x); }
#define AHTTP_LOGINFO1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
#define AHTTP_LOGINFO2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
#define AHTTP_LOGINFO3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
#define AHTTP_LOGDEBUG(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
#define AHTTP_LOGDEBUG0(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print(x); }
#define AHTTP_LOGDEBUG1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
#endif // AsyncHTTPRequest_Debug_STM32_H

View File

@ -0,0 +1,269 @@
/****************************************************************************************************************************
AsyncHTTPRequest_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.0.0
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).
*****************************************************************************************************************************/
#ifndef AsyncHTTPRequest_Generic_h
#define AsyncHTTPRequest_Generic_h
#define AsyncHTTPRequest_Generic_version "1.0.0"
#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
#if ESP32
#include <AsyncTCP.h>
#define _lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
#define _unlock xSemaphoreGiveRecursive(threadLock)
#elif ESP8266
#include <ESPAsyncTCP.h>
#define _lock
#define _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 _lock
#define _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()
{
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()
{
delete[] scheme;
delete[] user;
delete[] pwd;
delete[] host;
delete[] path;
delete[] query;
delete[] 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)
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:
enum {HTTPmethodGET, HTTPmethodPOST} _HTTPmethod;
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_Impl_Generic.h"
#endif // AsyncHTTPRequest_Generic_h

File diff suppressed because it is too large Load Diff

153
src/utility/xbuf.h Normal file
View File

@ -0,0 +1,153 @@
/****************************************************************************************************************************
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.0.0
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).
*****************************************************************************************************************************/
/********************************************************************************************
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

395
src/utility/xbuf_Impl.h Normal file
View File

@ -0,0 +1,395 @@
/****************************************************************************************************************************
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.0.0
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).
*****************************************************************************************************************************/
#ifndef xbuf_Impl_h
#define xbuf_Impl_h
//#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];
_tail = _tail->next;
}
else
{
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
}
_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