From a94b6658b51cd36dead34401009f32bfac63b575 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Wed, 23 Nov 2022 17:04:14 -0500 Subject: [PATCH] Update `Packages' Patches` --- .../nrf52/0.23.0/cores/nRF5/Print.cpp | 164 ++++++---- .../hardware/nrf52/0.23.0/cores/nRF5/Print.h | 42 ++- .../hardware/nrf52/0.23.0/cores/nRF5/Udp.h | 160 +++++----- .../variants/NINA_B112_ublox/variant.cpp | 11 +- .../0.23.0/variants/NINA_B112_ublox/variant.h | 28 +- .../variants/NINA_B302_ublox/variant.cpp | 16 +- .../0.23.0/variants/NINA_B302_ublox/variant.h | 34 +- .../nrf52/0.24.0/cores/nRF5/Print.cpp | 164 ++++++---- .../hardware/nrf52/0.24.0/cores/nRF5/Print.h | 42 ++- .../hardware/nrf52/0.24.0/cores/nRF5/Udp.h | 160 +++++----- .../variants/NINA_B112_ublox/variant.cpp | 11 +- .../0.24.0/variants/NINA_B112_ublox/variant.h | 28 +- .../variants/NINA_B302_ublox/variant.cpp | 16 +- .../0.24.0/variants/NINA_B302_ublox/variant.h | 34 +- .../hardware/nrf52/1.0.0/cores/nRF5/Print.cpp | 164 ++++++---- .../hardware/nrf52/1.0.0/cores/nRF5/Print.h | 42 ++- .../hardware/nrf52/1.0.0/cores/nRF5/Udp.h | 160 +++++----- .../variants/NINA_B112_ublox/variant.cpp | 11 +- .../1.0.0/variants/NINA_B112_ublox/variant.h | 28 +- .../variants/NINA_B302_ublox/variant.cpp | 16 +- .../1.0.0/variants/NINA_B302_ublox/variant.h | 34 +- .../sparkfun_nrf52840_mini/variant.cpp | 98 +++--- .../variants/sparkfun_nrf52840_mini/variant.h | 302 +++++++++--------- .../hardware/nrf52/1.1.0/cores/nRF5/Print.cpp | 164 ++++++---- .../hardware/nrf52/1.1.0/cores/nRF5/Print.h | 42 ++- .../hardware/nrf52/1.1.0/cores/nRF5/Udp.h | 160 +++++----- .../variants/NINA_B112_ublox/variant.cpp | 11 +- .../1.1.0/variants/NINA_B112_ublox/variant.h | 28 +- .../variants/NINA_B302_ublox/variant.cpp | 16 +- .../1.1.0/variants/NINA_B302_ublox/variant.h | 34 +- .../sparkfun_nrf52840_mini/variant.cpp | 98 +++--- .../variants/sparkfun_nrf52840_mini/variant.h | 302 +++++++++--------- .../hardware/nrf52/1.2.0/cores/nRF5/Print.cpp | 164 ++++++---- .../hardware/nrf52/1.2.0/cores/nRF5/Print.h | 42 ++- .../hardware/nrf52/1.2.0/cores/nRF5/Udp.h | 160 +++++----- .../variants/NINA_B112_ublox/variant.cpp | 11 +- .../1.2.0/variants/NINA_B112_ublox/variant.h | 28 +- .../variants/NINA_B302_ublox/variant.cpp | 16 +- .../1.2.0/variants/NINA_B302_ublox/variant.h | 34 +- .../sparkfun_nrf52840_mini/variant.cpp | 98 +++--- .../variants/sparkfun_nrf52840_mini/variant.h | 302 +++++++++--------- .../hardware/nrf52/1.3.0/cores/nRF5/Print.cpp | 164 ++++++---- .../hardware/nrf52/1.3.0/cores/nRF5/Print.h | 42 ++- .../hardware/nrf52/1.3.0/cores/nRF5/Udp.h | 160 +++++----- .../variants/NINA_B112_ublox/variant.cpp | 11 +- .../1.3.0/variants/NINA_B112_ublox/variant.h | 28 +- .../variants/NINA_B302_ublox/variant.cpp | 16 +- .../1.3.0/variants/NINA_B302_ublox/variant.h | 34 +- .../sparkfun_nrf52840_mini/variant.cpp | 98 +++--- .../variants/sparkfun_nrf52840_mini/variant.h | 302 +++++++++--------- 50 files changed, 2378 insertions(+), 1952 deletions(-) diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.cpp b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.cpp index 09d5864..d2db957 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.cpp @@ -36,10 +36,15 @@ size_t Print::write(const uint8_t *buffer, size_t size) { size_t n = 0; - while (size--) { - if (write(*buffer++)) n++; - else break; + + while (size--) + { + if (write(*buffer++)) + n++; + else + break; } + return n; } @@ -80,46 +85,64 @@ size_t Print::print(unsigned int n, int base) size_t Print::print(long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printNumber(n, 10) + t; } + return printNumber(n, 10); - } else { + } + else + { return printNumber(n, base); } } size_t Print::print(unsigned long n, int base) { - if (base == 0) return write(n); - else return printNumber(n, base); + if (base == 0) + return write(n); + else + return printNumber(n, base); } size_t Print::print(long long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printULLNumber(n, 10) + t; } + return printULLNumber(n, 10); - } else { + } + else + { return printULLNumber(n, base); } } size_t Print::print(unsigned long long n, int base) { - if (base == 0) return write(n); - else return printULLNumber(n, base); + if (base == 0) + return write(n); + else + return printULLNumber(n, base); } size_t Print::print(double n, int digits) @@ -253,14 +276,16 @@ size_t Print::printNumber(unsigned long n, uint8_t base) *str = '\0'; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; - do { + do + { char c = n % base; n /= base; *--str = c < 10 ? c + '0' : c + 'A' - 10; - } while(n); + } while (n); return write(str); } @@ -268,23 +293,23 @@ size_t Print::printNumber(unsigned long n, uint8_t base) // REFERENCE IMPLEMENTATION FOR ULL // size_t Print::printULLNumber(unsigned long long n, uint8_t base) // { - // // if limited to base 10 and 16 the bufsize can be smaller - // char buf[65]; - // char *str = &buf[64]; +// // if limited to base 10 and 16 the bufsize can be smaller +// char buf[65]; +// char *str = &buf[64]; - // *str = '\0'; +// *str = '\0'; - // // prevent crash if called with base == 1 - // if (base < 2) base = 10; +// // prevent crash if called with base == 1 +// if (base < 2) base = 10; - // do { - // unsigned long long t = n / base; - // char c = n - t * base; // faster than c = n%base; - // n = t; - // *--str = c < 10 ? c + '0' : c + 'A' - 10; - // } while(n); +// do { +// unsigned long long t = n / base; +// char c = n - t * base; // faster than c = n%base; +// n = t; +// *--str = c < 10 ? c + '0' : c + 'A' - 10; +// } while(n); - // return write(str); +// return write(str); // } // FAST IMPLEMENTATION FOR ULL @@ -296,11 +321,13 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) uint8_t innerLoops = 0; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; // process chunks that fit in "16 bit math". uint16_t top = 0xFFFF / base; uint16_t th16 = 1; + while (th16 < top) { th16 *= base; @@ -311,31 +338,33 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) { // 64 bit math part uint64_t q = n64 / th16; - uint16_t r = n64 - q*th16; + uint16_t r = n64 - q * th16; n64 = q; // 16 bit math loop to do remainder. (note buffer is filled reverse) - for (uint8_t j=0; j < innerLoops; j++) + for (uint8_t j = 0; j < innerLoops; j++) { - uint16_t qq = r/base; - buf[i++] = r - qq*base; + uint16_t qq = r / base; + buf[i++] = r - qq * base; r = qq; } } uint16_t n16 = n64; + while (n16 > 0) { - uint16_t qq = n16/base; - buf[i++] = n16 - qq*base; + uint16_t qq = n16 / base; + buf[i++] = n16 - qq * base; n16 = qq; } size_t bytes = i; + for (; i > 0; i--) write((char) (buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10)); + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); return bytes; } @@ -347,21 +376,29 @@ size_t Print::printFloat(double number, int digits) size_t n = 0; - if (isnan(number)) return print("nan"); - if (isinf(number)) return print("inf"); - if (number > 4294967040.0) return print ("ovf"); // constant determined empirically - if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + if (isnan(number)) + return print("nan"); + + if (isinf(number)) + return print("inf"); + + if (number > 4294967040.0) + return print ("ovf"); // constant determined empirically + + if (number < -4294967040.0) + return print ("ovf"); // constant determined empirically // Handle negative numbers if (number < 0.0) { - n += print('-'); - number = -number; + n += print('-'); + number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; - for (uint8_t i=0; i 0) { + if (digits > 0) + { n += print("."); } @@ -390,31 +428,39 @@ size_t Print::printFloat(double number, int digits) size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[i]); } - return (len*3 - 1); + return (len * 3 - 1); } size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[len-1-i]); + if ( byteline && (i % byteline == 0) ) + println(); + + this->printf("%02X", buffer[len - 1 - i]); } - return (len*3 - 1); + return (len * 3 - 1); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.h b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.h index 793a686..d03d1cc 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.h +++ b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Print.h @@ -37,26 +37,42 @@ class Print size_t printULLNumber(unsigned long long, uint8_t); size_t printFloat(double, int); protected: - void setWriteError(int err = 1) { write_error = err; } + void setWriteError(int err = 1) + { + write_error = err; + } public: Print() : write_error(0) {} - int getWriteError() { return write_error; } - void clearWriteError() { setWriteError(0); } + int getWriteError() + { + return write_error; + } + void clearWriteError() + { + setWriteError(0); + } virtual size_t write(uint8_t) = 0; - size_t write(const char *str) { - if (str == NULL) return 0; + size_t write(const char *str) + { + if (str == NULL) + return 0; + return write((const uint8_t *)str, strlen(str)); } virtual size_t write(const uint8_t *buffer, size_t size); - size_t write(const char *buffer, size_t size) { + size_t write(const char *buffer, size_t size) + { return write((const uint8_t *)buffer, size); } // default to zero, meaning "a single write may block" // should be overridden by subclasses with buffering - virtual int availableForWrite() { return 0; } + virtual int availableForWrite() + { + return 0; + } size_t print(const __FlashStringHelper *); size_t print(const String &); @@ -86,17 +102,17 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); - + size_t printf(const char * format, ...); - - size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + + size_t printBuffer(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBuffer((uint8_t const*) buffer, size, delim, byteline); } - size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + size_t printBufferReverse(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Udp.h b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Udp.h index cc814d3..c2d5824 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Udp.h +++ b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/cores/nRF5/Udp.h @@ -1,36 +1,36 @@ /* - * 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 - */ + 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 @@ -38,55 +38,63 @@ #include #include -class UDP : public Stream { +class UDP : public Stream +{ -public: - virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use - - // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) - virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure - - virtual void stop() =0; // Finish with the UDP socket + 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 - // Sending UDP packets + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) + { + return 0; // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + } - // 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; + virtual void stop() = 0; // Finish with the UDP socket - // 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 + // Sending UDP packets - // 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(); }; + // 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 diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.cpp index f43f3a4..63d3f4d 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.cpp @@ -27,12 +27,13 @@ //https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf //https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf -const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 5, // D0 is P0.05 (UART RX) - 6, // D1 is P0.06 (UART TX) - 7, // D2 is P0.07 - 31, // D3 is P0.31 + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 18, // D4 is P0.18 (LED Blue) 99, // D5 (NC) 9, // D6 is P0.09 NFC1 diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.h index 833cbf6..caa0b61 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B112_ublox/variant.h @@ -34,8 +34,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -66,12 +66,12 @@ extern "C" #define SW2 (19) // NFC -#define PIN_NFC_1 (6) // P0.9 -#define PIN_NFC_2 (7) // P0.10 +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (16) // P0.03 #define PIN_A1 (17) // P0.02 #define PIN_A2 (18) // P0.04 @@ -125,8 +125,8 @@ static const uint8_t D15 = PIN_D15 ; //#define PIN_VBAT PIN_A7 /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL_RX (0) // P0.05 #define PIN_SERIAL_TX (1) // P0.06 #define PIN_SERIAL_CTS (2) // P0.07 @@ -135,8 +135,8 @@ static const uint8_t D15 = PIN_D15 ; #define PIN_SERIAL_DSR (29) // P0.29 /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (12) // P0.12 @@ -149,8 +149,8 @@ static const uint8_t MISO = PIN_SPI_MISO ; static const uint8_t SCK = PIN_SPI_SCK ; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (14) // P0.02 @@ -165,8 +165,8 @@ static const uint8_t SCL = PIN_WIRE_SCL; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.cpp index 8b4df2e..7f317d6 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.cpp @@ -17,7 +17,7 @@ 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). +// 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" @@ -27,16 +27,16 @@ const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 + // D0 .. D13 29, // D0 is P0.29 (UART RX) - 45, // D1 is P1.13 (UART TX) + 45, // D1 is P1.13 (UART TX) 44, // D2 is P1.12 (NFC2) 31, // D3 is P0.31 (LED1) 13, // D4 is P0.13 (LED2) 11, // D5 is P0.11 9, // D6 is P0.09 10, // D7 is P0.10 (Button) - 41, // D8 is P1.09 + 41, // D8 is P1.09 12, // D9 is P0.12 14, // D10 is P0.14 15, // D11 is P0.15 @@ -54,7 +54,7 @@ const uint32_t g_ADigitalPinMap[] = // D20 .. D21 (aka I2C pins) 16, // D20 is P0.16 (SDA) 24, // D21 is P0.24 (SCL) - + // QSPI pins (not exposed via any header / test point) 19, // D22 is P0.19 (QSPI CLK) 17, // D23 is P0.17 (QSPI CS) @@ -62,7 +62,7 @@ const uint32_t g_ADigitalPinMap[] = 21, // D25 is P0.21 (QSPI Data 1) 22, // D26 is P0.22 (QSPI Data 2) 26, // D27 is P0.23 (QSPI Data 3) - + 40, // D28 is P1.08 - IO34 41, // D29 is P1.01 - IO35 44, // D30 is P1.02 - IO36 @@ -70,10 +70,10 @@ const uint32_t g_ADigitalPinMap[] = 42, // D32 is P1.10 - IO38 43, // D33 is P1.11 - IO39 47, // D34 is P1.15 - IO40 - 46, // D35 is P1.14 - IO41 + 46, // D35 is P1.14 - IO41 26, // D36 is P0.26 - IO42 6, // D37 is P0.6 - IO43 - 27, // D38 is P0.27 - IO44 + 27, // D38 is P0.27 - IO44 }; void initVariant() diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.h index a69575f..d588790 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/0.23.0/variants/NINA_B302_ublox/variant.h @@ -1,4 +1,4 @@ - /* +/* Copyright (c) 2014-2015 Arduino LLC. All right reserved. Copyright (c) 2016 Sandeep Mistry All right reserved. Copyright (c) 2018, Adafruit Industries (adafruit.com) @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// 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_ @@ -29,8 +29,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -41,7 +41,7 @@ extern "C" // Number of pins defined in PinDescription array #define PINS_COUNT (40) #define NUM_DIGITAL_PINS (34) -#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_INPUTS (6) #define NUM_ANALOG_OUTPUTS (0) // LEDs @@ -57,13 +57,13 @@ extern "C" #define LED_STATE_ON 1 // State when LED is litted /* - * Buttons - */ + Buttons +*/ #define PIN_BUTTON1 (7) /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (14) #define PIN_A1 (15) #define PIN_A2 (16) @@ -99,14 +99,14 @@ static const uint8_t A5 = PIN_A5 ; #define PIN_NFC2 (2) /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL1_RX (0) #define PIN_SERIAL1_TX (1) /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (22) //24 original @@ -119,8 +119,8 @@ static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (20) @@ -143,7 +143,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.cpp b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.cpp index 09d5864..d2db957 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.cpp @@ -36,10 +36,15 @@ size_t Print::write(const uint8_t *buffer, size_t size) { size_t n = 0; - while (size--) { - if (write(*buffer++)) n++; - else break; + + while (size--) + { + if (write(*buffer++)) + n++; + else + break; } + return n; } @@ -80,46 +85,64 @@ size_t Print::print(unsigned int n, int base) size_t Print::print(long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printNumber(n, 10) + t; } + return printNumber(n, 10); - } else { + } + else + { return printNumber(n, base); } } size_t Print::print(unsigned long n, int base) { - if (base == 0) return write(n); - else return printNumber(n, base); + if (base == 0) + return write(n); + else + return printNumber(n, base); } size_t Print::print(long long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printULLNumber(n, 10) + t; } + return printULLNumber(n, 10); - } else { + } + else + { return printULLNumber(n, base); } } size_t Print::print(unsigned long long n, int base) { - if (base == 0) return write(n); - else return printULLNumber(n, base); + if (base == 0) + return write(n); + else + return printULLNumber(n, base); } size_t Print::print(double n, int digits) @@ -253,14 +276,16 @@ size_t Print::printNumber(unsigned long n, uint8_t base) *str = '\0'; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; - do { + do + { char c = n % base; n /= base; *--str = c < 10 ? c + '0' : c + 'A' - 10; - } while(n); + } while (n); return write(str); } @@ -268,23 +293,23 @@ size_t Print::printNumber(unsigned long n, uint8_t base) // REFERENCE IMPLEMENTATION FOR ULL // size_t Print::printULLNumber(unsigned long long n, uint8_t base) // { - // // if limited to base 10 and 16 the bufsize can be smaller - // char buf[65]; - // char *str = &buf[64]; +// // if limited to base 10 and 16 the bufsize can be smaller +// char buf[65]; +// char *str = &buf[64]; - // *str = '\0'; +// *str = '\0'; - // // prevent crash if called with base == 1 - // if (base < 2) base = 10; +// // prevent crash if called with base == 1 +// if (base < 2) base = 10; - // do { - // unsigned long long t = n / base; - // char c = n - t * base; // faster than c = n%base; - // n = t; - // *--str = c < 10 ? c + '0' : c + 'A' - 10; - // } while(n); +// do { +// unsigned long long t = n / base; +// char c = n - t * base; // faster than c = n%base; +// n = t; +// *--str = c < 10 ? c + '0' : c + 'A' - 10; +// } while(n); - // return write(str); +// return write(str); // } // FAST IMPLEMENTATION FOR ULL @@ -296,11 +321,13 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) uint8_t innerLoops = 0; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; // process chunks that fit in "16 bit math". uint16_t top = 0xFFFF / base; uint16_t th16 = 1; + while (th16 < top) { th16 *= base; @@ -311,31 +338,33 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) { // 64 bit math part uint64_t q = n64 / th16; - uint16_t r = n64 - q*th16; + uint16_t r = n64 - q * th16; n64 = q; // 16 bit math loop to do remainder. (note buffer is filled reverse) - for (uint8_t j=0; j < innerLoops; j++) + for (uint8_t j = 0; j < innerLoops; j++) { - uint16_t qq = r/base; - buf[i++] = r - qq*base; + uint16_t qq = r / base; + buf[i++] = r - qq * base; r = qq; } } uint16_t n16 = n64; + while (n16 > 0) { - uint16_t qq = n16/base; - buf[i++] = n16 - qq*base; + uint16_t qq = n16 / base; + buf[i++] = n16 - qq * base; n16 = qq; } size_t bytes = i; + for (; i > 0; i--) write((char) (buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10)); + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); return bytes; } @@ -347,21 +376,29 @@ size_t Print::printFloat(double number, int digits) size_t n = 0; - if (isnan(number)) return print("nan"); - if (isinf(number)) return print("inf"); - if (number > 4294967040.0) return print ("ovf"); // constant determined empirically - if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + if (isnan(number)) + return print("nan"); + + if (isinf(number)) + return print("inf"); + + if (number > 4294967040.0) + return print ("ovf"); // constant determined empirically + + if (number < -4294967040.0) + return print ("ovf"); // constant determined empirically // Handle negative numbers if (number < 0.0) { - n += print('-'); - number = -number; + n += print('-'); + number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; - for (uint8_t i=0; i 0) { + if (digits > 0) + { n += print("."); } @@ -390,31 +428,39 @@ size_t Print::printFloat(double number, int digits) size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[i]); } - return (len*3 - 1); + return (len * 3 - 1); } size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[len-1-i]); + if ( byteline && (i % byteline == 0) ) + println(); + + this->printf("%02X", buffer[len - 1 - i]); } - return (len*3 - 1); + return (len * 3 - 1); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.h b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.h index 793a686..d03d1cc 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.h +++ b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Print.h @@ -37,26 +37,42 @@ class Print size_t printULLNumber(unsigned long long, uint8_t); size_t printFloat(double, int); protected: - void setWriteError(int err = 1) { write_error = err; } + void setWriteError(int err = 1) + { + write_error = err; + } public: Print() : write_error(0) {} - int getWriteError() { return write_error; } - void clearWriteError() { setWriteError(0); } + int getWriteError() + { + return write_error; + } + void clearWriteError() + { + setWriteError(0); + } virtual size_t write(uint8_t) = 0; - size_t write(const char *str) { - if (str == NULL) return 0; + size_t write(const char *str) + { + if (str == NULL) + return 0; + return write((const uint8_t *)str, strlen(str)); } virtual size_t write(const uint8_t *buffer, size_t size); - size_t write(const char *buffer, size_t size) { + size_t write(const char *buffer, size_t size) + { return write((const uint8_t *)buffer, size); } // default to zero, meaning "a single write may block" // should be overridden by subclasses with buffering - virtual int availableForWrite() { return 0; } + virtual int availableForWrite() + { + return 0; + } size_t print(const __FlashStringHelper *); size_t print(const String &); @@ -86,17 +102,17 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); - + size_t printf(const char * format, ...); - - size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + + size_t printBuffer(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBuffer((uint8_t const*) buffer, size, delim, byteline); } - size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + size_t printBufferReverse(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Udp.h b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Udp.h index cc814d3..c2d5824 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Udp.h +++ b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/cores/nRF5/Udp.h @@ -1,36 +1,36 @@ /* - * 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 - */ + 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 @@ -38,55 +38,63 @@ #include #include -class UDP : public Stream { +class UDP : public Stream +{ -public: - virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use - - // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) - virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure - - virtual void stop() =0; // Finish with the UDP socket + 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 - // Sending UDP packets + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) + { + return 0; // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + } - // 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; + virtual void stop() = 0; // Finish with the UDP socket - // 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 + // Sending UDP packets - // 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(); }; + // 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 diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.cpp index f43f3a4..63d3f4d 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.cpp @@ -27,12 +27,13 @@ //https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf //https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf -const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 5, // D0 is P0.05 (UART RX) - 6, // D1 is P0.06 (UART TX) - 7, // D2 is P0.07 - 31, // D3 is P0.31 + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 18, // D4 is P0.18 (LED Blue) 99, // D5 (NC) 9, // D6 is P0.09 NFC1 diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.h index 833cbf6..caa0b61 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B112_ublox/variant.h @@ -34,8 +34,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -66,12 +66,12 @@ extern "C" #define SW2 (19) // NFC -#define PIN_NFC_1 (6) // P0.9 -#define PIN_NFC_2 (7) // P0.10 +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (16) // P0.03 #define PIN_A1 (17) // P0.02 #define PIN_A2 (18) // P0.04 @@ -125,8 +125,8 @@ static const uint8_t D15 = PIN_D15 ; //#define PIN_VBAT PIN_A7 /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL_RX (0) // P0.05 #define PIN_SERIAL_TX (1) // P0.06 #define PIN_SERIAL_CTS (2) // P0.07 @@ -135,8 +135,8 @@ static const uint8_t D15 = PIN_D15 ; #define PIN_SERIAL_DSR (29) // P0.29 /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (12) // P0.12 @@ -149,8 +149,8 @@ static const uint8_t MISO = PIN_SPI_MISO ; static const uint8_t SCK = PIN_SPI_SCK ; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (14) // P0.02 @@ -165,8 +165,8 @@ static const uint8_t SCL = PIN_WIRE_SCL; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.cpp index 8b4df2e..7f317d6 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.cpp @@ -17,7 +17,7 @@ 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). +// 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" @@ -27,16 +27,16 @@ const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 + // D0 .. D13 29, // D0 is P0.29 (UART RX) - 45, // D1 is P1.13 (UART TX) + 45, // D1 is P1.13 (UART TX) 44, // D2 is P1.12 (NFC2) 31, // D3 is P0.31 (LED1) 13, // D4 is P0.13 (LED2) 11, // D5 is P0.11 9, // D6 is P0.09 10, // D7 is P0.10 (Button) - 41, // D8 is P1.09 + 41, // D8 is P1.09 12, // D9 is P0.12 14, // D10 is P0.14 15, // D11 is P0.15 @@ -54,7 +54,7 @@ const uint32_t g_ADigitalPinMap[] = // D20 .. D21 (aka I2C pins) 16, // D20 is P0.16 (SDA) 24, // D21 is P0.24 (SCL) - + // QSPI pins (not exposed via any header / test point) 19, // D22 is P0.19 (QSPI CLK) 17, // D23 is P0.17 (QSPI CS) @@ -62,7 +62,7 @@ const uint32_t g_ADigitalPinMap[] = 21, // D25 is P0.21 (QSPI Data 1) 22, // D26 is P0.22 (QSPI Data 2) 26, // D27 is P0.23 (QSPI Data 3) - + 40, // D28 is P1.08 - IO34 41, // D29 is P1.01 - IO35 44, // D30 is P1.02 - IO36 @@ -70,10 +70,10 @@ const uint32_t g_ADigitalPinMap[] = 42, // D32 is P1.10 - IO38 43, // D33 is P1.11 - IO39 47, // D34 is P1.15 - IO40 - 46, // D35 is P1.14 - IO41 + 46, // D35 is P1.14 - IO41 26, // D36 is P0.26 - IO42 6, // D37 is P0.6 - IO43 - 27, // D38 is P0.27 - IO44 + 27, // D38 is P0.27 - IO44 }; void initVariant() diff --git a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.h index a69575f..d588790 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/0.24.0/variants/NINA_B302_ublox/variant.h @@ -1,4 +1,4 @@ - /* +/* Copyright (c) 2014-2015 Arduino LLC. All right reserved. Copyright (c) 2016 Sandeep Mistry All right reserved. Copyright (c) 2018, Adafruit Industries (adafruit.com) @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// 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_ @@ -29,8 +29,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -41,7 +41,7 @@ extern "C" // Number of pins defined in PinDescription array #define PINS_COUNT (40) #define NUM_DIGITAL_PINS (34) -#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_INPUTS (6) #define NUM_ANALOG_OUTPUTS (0) // LEDs @@ -57,13 +57,13 @@ extern "C" #define LED_STATE_ON 1 // State when LED is litted /* - * Buttons - */ + Buttons +*/ #define PIN_BUTTON1 (7) /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (14) #define PIN_A1 (15) #define PIN_A2 (16) @@ -99,14 +99,14 @@ static const uint8_t A5 = PIN_A5 ; #define PIN_NFC2 (2) /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL1_RX (0) #define PIN_SERIAL1_TX (1) /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (22) //24 original @@ -119,8 +119,8 @@ static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (20) @@ -143,7 +143,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp index 09d5864..d2db957 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp @@ -36,10 +36,15 @@ size_t Print::write(const uint8_t *buffer, size_t size) { size_t n = 0; - while (size--) { - if (write(*buffer++)) n++; - else break; + + while (size--) + { + if (write(*buffer++)) + n++; + else + break; } + return n; } @@ -80,46 +85,64 @@ size_t Print::print(unsigned int n, int base) size_t Print::print(long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printNumber(n, 10) + t; } + return printNumber(n, 10); - } else { + } + else + { return printNumber(n, base); } } size_t Print::print(unsigned long n, int base) { - if (base == 0) return write(n); - else return printNumber(n, base); + if (base == 0) + return write(n); + else + return printNumber(n, base); } size_t Print::print(long long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printULLNumber(n, 10) + t; } + return printULLNumber(n, 10); - } else { + } + else + { return printULLNumber(n, base); } } size_t Print::print(unsigned long long n, int base) { - if (base == 0) return write(n); - else return printULLNumber(n, base); + if (base == 0) + return write(n); + else + return printULLNumber(n, base); } size_t Print::print(double n, int digits) @@ -253,14 +276,16 @@ size_t Print::printNumber(unsigned long n, uint8_t base) *str = '\0'; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; - do { + do + { char c = n % base; n /= base; *--str = c < 10 ? c + '0' : c + 'A' - 10; - } while(n); + } while (n); return write(str); } @@ -268,23 +293,23 @@ size_t Print::printNumber(unsigned long n, uint8_t base) // REFERENCE IMPLEMENTATION FOR ULL // size_t Print::printULLNumber(unsigned long long n, uint8_t base) // { - // // if limited to base 10 and 16 the bufsize can be smaller - // char buf[65]; - // char *str = &buf[64]; +// // if limited to base 10 and 16 the bufsize can be smaller +// char buf[65]; +// char *str = &buf[64]; - // *str = '\0'; +// *str = '\0'; - // // prevent crash if called with base == 1 - // if (base < 2) base = 10; +// // prevent crash if called with base == 1 +// if (base < 2) base = 10; - // do { - // unsigned long long t = n / base; - // char c = n - t * base; // faster than c = n%base; - // n = t; - // *--str = c < 10 ? c + '0' : c + 'A' - 10; - // } while(n); +// do { +// unsigned long long t = n / base; +// char c = n - t * base; // faster than c = n%base; +// n = t; +// *--str = c < 10 ? c + '0' : c + 'A' - 10; +// } while(n); - // return write(str); +// return write(str); // } // FAST IMPLEMENTATION FOR ULL @@ -296,11 +321,13 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) uint8_t innerLoops = 0; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; // process chunks that fit in "16 bit math". uint16_t top = 0xFFFF / base; uint16_t th16 = 1; + while (th16 < top) { th16 *= base; @@ -311,31 +338,33 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) { // 64 bit math part uint64_t q = n64 / th16; - uint16_t r = n64 - q*th16; + uint16_t r = n64 - q * th16; n64 = q; // 16 bit math loop to do remainder. (note buffer is filled reverse) - for (uint8_t j=0; j < innerLoops; j++) + for (uint8_t j = 0; j < innerLoops; j++) { - uint16_t qq = r/base; - buf[i++] = r - qq*base; + uint16_t qq = r / base; + buf[i++] = r - qq * base; r = qq; } } uint16_t n16 = n64; + while (n16 > 0) { - uint16_t qq = n16/base; - buf[i++] = n16 - qq*base; + uint16_t qq = n16 / base; + buf[i++] = n16 - qq * base; n16 = qq; } size_t bytes = i; + for (; i > 0; i--) write((char) (buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10)); + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); return bytes; } @@ -347,21 +376,29 @@ size_t Print::printFloat(double number, int digits) size_t n = 0; - if (isnan(number)) return print("nan"); - if (isinf(number)) return print("inf"); - if (number > 4294967040.0) return print ("ovf"); // constant determined empirically - if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + if (isnan(number)) + return print("nan"); + + if (isinf(number)) + return print("inf"); + + if (number > 4294967040.0) + return print ("ovf"); // constant determined empirically + + if (number < -4294967040.0) + return print ("ovf"); // constant determined empirically // Handle negative numbers if (number < 0.0) { - n += print('-'); - number = -number; + n += print('-'); + number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; - for (uint8_t i=0; i 0) { + if (digits > 0) + { n += print("."); } @@ -390,31 +428,39 @@ size_t Print::printFloat(double number, int digits) size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[i]); } - return (len*3 - 1); + return (len * 3 - 1); } size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[len-1-i]); + if ( byteline && (i % byteline == 0) ) + println(); + + this->printf("%02X", buffer[len - 1 - i]); } - return (len*3 - 1); + return (len * 3 - 1); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.h b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.h index 793a686..d03d1cc 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Print.h @@ -37,26 +37,42 @@ class Print size_t printULLNumber(unsigned long long, uint8_t); size_t printFloat(double, int); protected: - void setWriteError(int err = 1) { write_error = err; } + void setWriteError(int err = 1) + { + write_error = err; + } public: Print() : write_error(0) {} - int getWriteError() { return write_error; } - void clearWriteError() { setWriteError(0); } + int getWriteError() + { + return write_error; + } + void clearWriteError() + { + setWriteError(0); + } virtual size_t write(uint8_t) = 0; - size_t write(const char *str) { - if (str == NULL) return 0; + size_t write(const char *str) + { + if (str == NULL) + return 0; + return write((const uint8_t *)str, strlen(str)); } virtual size_t write(const uint8_t *buffer, size_t size); - size_t write(const char *buffer, size_t size) { + size_t write(const char *buffer, size_t size) + { return write((const uint8_t *)buffer, size); } // default to zero, meaning "a single write may block" // should be overridden by subclasses with buffering - virtual int availableForWrite() { return 0; } + virtual int availableForWrite() + { + return 0; + } size_t print(const __FlashStringHelper *); size_t print(const String &); @@ -86,17 +102,17 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); - + size_t printf(const char * format, ...); - - size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + + size_t printBuffer(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBuffer((uint8_t const*) buffer, size, delim, byteline); } - size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + size_t printBufferReverse(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Udp.h b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Udp.h index cc814d3..c2d5824 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Udp.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Udp.h @@ -1,36 +1,36 @@ /* - * 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 - */ + 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 @@ -38,55 +38,63 @@ #include #include -class UDP : public Stream { +class UDP : public Stream +{ -public: - virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use - - // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) - virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure - - virtual void stop() =0; // Finish with the UDP socket + 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 - // Sending UDP packets + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) + { + return 0; // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + } - // 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; + virtual void stop() = 0; // Finish with the UDP socket - // 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 + // Sending UDP packets - // 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(); }; + // 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 diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.cpp index f43f3a4..63d3f4d 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.cpp @@ -27,12 +27,13 @@ //https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf //https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf -const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 5, // D0 is P0.05 (UART RX) - 6, // D1 is P0.06 (UART TX) - 7, // D2 is P0.07 - 31, // D3 is P0.31 + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 18, // D4 is P0.18 (LED Blue) 99, // D5 (NC) 9, // D6 is P0.09 NFC1 diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.h index 833cbf6..caa0b61 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.h @@ -34,8 +34,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -66,12 +66,12 @@ extern "C" #define SW2 (19) // NFC -#define PIN_NFC_1 (6) // P0.9 -#define PIN_NFC_2 (7) // P0.10 +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (16) // P0.03 #define PIN_A1 (17) // P0.02 #define PIN_A2 (18) // P0.04 @@ -125,8 +125,8 @@ static const uint8_t D15 = PIN_D15 ; //#define PIN_VBAT PIN_A7 /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL_RX (0) // P0.05 #define PIN_SERIAL_TX (1) // P0.06 #define PIN_SERIAL_CTS (2) // P0.07 @@ -135,8 +135,8 @@ static const uint8_t D15 = PIN_D15 ; #define PIN_SERIAL_DSR (29) // P0.29 /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (12) // P0.12 @@ -149,8 +149,8 @@ static const uint8_t MISO = PIN_SPI_MISO ; static const uint8_t SCK = PIN_SPI_SCK ; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (14) // P0.02 @@ -165,8 +165,8 @@ static const uint8_t SCL = PIN_WIRE_SCL; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.cpp index 8b4df2e..7f317d6 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.cpp @@ -17,7 +17,7 @@ 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). +// 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" @@ -27,16 +27,16 @@ const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 + // D0 .. D13 29, // D0 is P0.29 (UART RX) - 45, // D1 is P1.13 (UART TX) + 45, // D1 is P1.13 (UART TX) 44, // D2 is P1.12 (NFC2) 31, // D3 is P0.31 (LED1) 13, // D4 is P0.13 (LED2) 11, // D5 is P0.11 9, // D6 is P0.09 10, // D7 is P0.10 (Button) - 41, // D8 is P1.09 + 41, // D8 is P1.09 12, // D9 is P0.12 14, // D10 is P0.14 15, // D11 is P0.15 @@ -54,7 +54,7 @@ const uint32_t g_ADigitalPinMap[] = // D20 .. D21 (aka I2C pins) 16, // D20 is P0.16 (SDA) 24, // D21 is P0.24 (SCL) - + // QSPI pins (not exposed via any header / test point) 19, // D22 is P0.19 (QSPI CLK) 17, // D23 is P0.17 (QSPI CS) @@ -62,7 +62,7 @@ const uint32_t g_ADigitalPinMap[] = 21, // D25 is P0.21 (QSPI Data 1) 22, // D26 is P0.22 (QSPI Data 2) 26, // D27 is P0.23 (QSPI Data 3) - + 40, // D28 is P1.08 - IO34 41, // D29 is P1.01 - IO35 44, // D30 is P1.02 - IO36 @@ -70,10 +70,10 @@ const uint32_t g_ADigitalPinMap[] = 42, // D32 is P1.10 - IO38 43, // D33 is P1.11 - IO39 47, // D34 is P1.15 - IO40 - 46, // D35 is P1.14 - IO41 + 46, // D35 is P1.14 - IO41 26, // D36 is P0.26 - IO42 6, // D37 is P0.6 - IO43 - 27, // D38 is P0.27 - IO44 + 27, // D38 is P0.27 - IO44 }; void initVariant() diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.h index a69575f..d588790 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.h @@ -1,4 +1,4 @@ - /* +/* Copyright (c) 2014-2015 Arduino LLC. All right reserved. Copyright (c) 2016 Sandeep Mistry All right reserved. Copyright (c) 2018, Adafruit Industries (adafruit.com) @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// 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_ @@ -29,8 +29,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -41,7 +41,7 @@ extern "C" // Number of pins defined in PinDescription array #define PINS_COUNT (40) #define NUM_DIGITAL_PINS (34) -#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_INPUTS (6) #define NUM_ANALOG_OUTPUTS (0) // LEDs @@ -57,13 +57,13 @@ extern "C" #define LED_STATE_ON 1 // State when LED is litted /* - * Buttons - */ + Buttons +*/ #define PIN_BUTTON1 (7) /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (14) #define PIN_A1 (15) #define PIN_A2 (16) @@ -99,14 +99,14 @@ static const uint8_t A5 = PIN_A5 ; #define PIN_NFC2 (2) /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL1_RX (0) #define PIN_SERIAL1_TX (1) /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (22) //24 original @@ -119,8 +119,8 @@ static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (20) @@ -143,7 +143,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.cpp index b01c147..534abf3 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.cpp @@ -1,49 +1,49 @@ -/* - Copyright (c) 2014-2015 Arduino LLC. All right reserved. - Copyright (c) 2016 Sandeep Mistry All right reserved. - Copyright (c) 2018, Adafruit Industries (adafruit.com) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "variant.h" -#include "wiring_constants.h" -#include "wiring_digital.h" -#include "nrf.h" - -const uint32_t g_ADigitalPinMap[] = -{ - // P0 - 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, - - // P1 - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63 -}; -void initVariant() -{ - // LED1 & LED2 - pinMode(PIN_LED1, OUTPUT); - ledOff(PIN_LED1); - - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); -} - +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 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, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 +}; +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} + diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.h index c534ceb..f98c8e0 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.0.0/variants/sparkfun_nrf52840_mini/variant.h @@ -1,152 +1,152 @@ - /* - 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_SPARKFUN52840MINI_ -#define _VARIANT_SPARKFUN52840MINI_ - -/** 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 (64) -#define NUM_DIGITAL_PINS (64) -#define NUM_ANALOG_INPUTS (8) -#define NUM_ANALOG_OUTPUTS (0) - -// LEDs -#define PIN_LED1 (7) -#define PIN_LED2 (14) - -#define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 - -#define LED_BLUE PIN_LED1 -#define LED_RED PIN_LED2 - -#define LED_STATE_ON 1 // State when LED is litted - -// Buttons -/* -#define PIN_BUTTON1 (2) -#define PIN_BUTTON2 (3) -#define PIN_BUTTON3 (4) -#define PIN_BUTTON4 (5) -*/ - -/* - * Analog pins - */ -#define PIN_A0 (2) -#define PIN_A1 (3) -#define PIN_A2 (4) -#define PIN_A3 (5) -#define PIN_A4 (28) -#define PIN_A5 (29) -#define PIN_A6 (30) -#define PIN_A7 (31) - -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 (2) -#define PIN_DFU (13) -#define PIN_NFC1 (9) -#define PIN_NFC2 (10) - -static const uint8_t AREF = PIN_AREF; - -/* - * Serial interfaces - */ -// Serial -//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 -//Feel free to comment out these two lines below if there are conflicts with latest release -#define PIN_SERIAL_RX (15) -#define PIN_SERIAL_TX (17) - -//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above -#define PIN_SERIAL1_RX (15) -#define PIN_SERIAL1_TX (17) - -/* - * SPI Interfaces - */ -#define SPI_INTERFACES_COUNT 1 - -#define PIN_SPI_MISO (31) -#define PIN_SPI_MOSI (3) -#define PIN_SPI_SCK (30) - -static const uint8_t SS = 2 ; -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 (8) -#define PIN_WIRE_SCL (11) - -/* - * QSPI interface for external flash - */ -#define PIN_QSPI_SCK 32 -#define PIN_QSPI_CS 33 -#define PIN_QSPI_DATA0 34 -#define PIN_QSPI_DATA1 35 -#define PIN_QSPI_DATA2 36 -#define PIN_QSPI_DATA3 37 - -// On-board QSPI Flash -// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used -#define EXTERNAL_FLASH_DEVICES GD25Q16C - -#ifdef __cplusplus -} -#endif - -/*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ - +/* + 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_SPARKFUN52840MINI_ +#define _VARIANT_SPARKFUN52840MINI_ + +/** 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 (64) +#define NUM_DIGITAL_PINS (64) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (7) +#define PIN_LED2 (14) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_BLUE PIN_LED1 +#define LED_RED PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons +/* + #define PIN_BUTTON1 (2) + #define PIN_BUTTON2 (3) + #define PIN_BUTTON3 (4) + #define PIN_BUTTON4 (5) +*/ + +/* + Analog pins +*/ +#define PIN_A0 (2) +#define PIN_A1 (3) +#define PIN_A2 (4) +#define PIN_A3 (5) +#define PIN_A4 (28) +#define PIN_A5 (29) +#define PIN_A6 (30) +#define PIN_A7 (31) + +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 (2) +#define PIN_DFU (13) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + Serial interfaces +*/ +// Serial +//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 +//Feel free to comment out these two lines below if there are conflicts with latest release +#define PIN_SERIAL_RX (15) +#define PIN_SERIAL_TX (17) + +//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (17) + +/* + SPI Interfaces +*/ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (31) +#define PIN_SPI_MOSI (3) +#define PIN_SPI_SCK (30) + +static const uint8_t SS = 2 ; +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 (8) +#define PIN_WIRE_SCL (11) + +/* + QSPI interface for external flash +*/ +#define PIN_QSPI_SCK 32 +#define PIN_QSPI_CS 33 +#define PIN_QSPI_DATA0 34 +#define PIN_QSPI_DATA1 35 +#define PIN_QSPI_DATA2 36 +#define PIN_QSPI_DATA3 37 + +// On-board QSPI Flash +// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ + #endif \ No newline at end of file diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.cpp index 09d5864..d2db957 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.cpp @@ -36,10 +36,15 @@ size_t Print::write(const uint8_t *buffer, size_t size) { size_t n = 0; - while (size--) { - if (write(*buffer++)) n++; - else break; + + while (size--) + { + if (write(*buffer++)) + n++; + else + break; } + return n; } @@ -80,46 +85,64 @@ size_t Print::print(unsigned int n, int base) size_t Print::print(long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printNumber(n, 10) + t; } + return printNumber(n, 10); - } else { + } + else + { return printNumber(n, base); } } size_t Print::print(unsigned long n, int base) { - if (base == 0) return write(n); - else return printNumber(n, base); + if (base == 0) + return write(n); + else + return printNumber(n, base); } size_t Print::print(long long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printULLNumber(n, 10) + t; } + return printULLNumber(n, 10); - } else { + } + else + { return printULLNumber(n, base); } } size_t Print::print(unsigned long long n, int base) { - if (base == 0) return write(n); - else return printULLNumber(n, base); + if (base == 0) + return write(n); + else + return printULLNumber(n, base); } size_t Print::print(double n, int digits) @@ -253,14 +276,16 @@ size_t Print::printNumber(unsigned long n, uint8_t base) *str = '\0'; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; - do { + do + { char c = n % base; n /= base; *--str = c < 10 ? c + '0' : c + 'A' - 10; - } while(n); + } while (n); return write(str); } @@ -268,23 +293,23 @@ size_t Print::printNumber(unsigned long n, uint8_t base) // REFERENCE IMPLEMENTATION FOR ULL // size_t Print::printULLNumber(unsigned long long n, uint8_t base) // { - // // if limited to base 10 and 16 the bufsize can be smaller - // char buf[65]; - // char *str = &buf[64]; +// // if limited to base 10 and 16 the bufsize can be smaller +// char buf[65]; +// char *str = &buf[64]; - // *str = '\0'; +// *str = '\0'; - // // prevent crash if called with base == 1 - // if (base < 2) base = 10; +// // prevent crash if called with base == 1 +// if (base < 2) base = 10; - // do { - // unsigned long long t = n / base; - // char c = n - t * base; // faster than c = n%base; - // n = t; - // *--str = c < 10 ? c + '0' : c + 'A' - 10; - // } while(n); +// do { +// unsigned long long t = n / base; +// char c = n - t * base; // faster than c = n%base; +// n = t; +// *--str = c < 10 ? c + '0' : c + 'A' - 10; +// } while(n); - // return write(str); +// return write(str); // } // FAST IMPLEMENTATION FOR ULL @@ -296,11 +321,13 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) uint8_t innerLoops = 0; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; // process chunks that fit in "16 bit math". uint16_t top = 0xFFFF / base; uint16_t th16 = 1; + while (th16 < top) { th16 *= base; @@ -311,31 +338,33 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) { // 64 bit math part uint64_t q = n64 / th16; - uint16_t r = n64 - q*th16; + uint16_t r = n64 - q * th16; n64 = q; // 16 bit math loop to do remainder. (note buffer is filled reverse) - for (uint8_t j=0; j < innerLoops; j++) + for (uint8_t j = 0; j < innerLoops; j++) { - uint16_t qq = r/base; - buf[i++] = r - qq*base; + uint16_t qq = r / base; + buf[i++] = r - qq * base; r = qq; } } uint16_t n16 = n64; + while (n16 > 0) { - uint16_t qq = n16/base; - buf[i++] = n16 - qq*base; + uint16_t qq = n16 / base; + buf[i++] = n16 - qq * base; n16 = qq; } size_t bytes = i; + for (; i > 0; i--) write((char) (buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10)); + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); return bytes; } @@ -347,21 +376,29 @@ size_t Print::printFloat(double number, int digits) size_t n = 0; - if (isnan(number)) return print("nan"); - if (isinf(number)) return print("inf"); - if (number > 4294967040.0) return print ("ovf"); // constant determined empirically - if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + if (isnan(number)) + return print("nan"); + + if (isinf(number)) + return print("inf"); + + if (number > 4294967040.0) + return print ("ovf"); // constant determined empirically + + if (number < -4294967040.0) + return print ("ovf"); // constant determined empirically // Handle negative numbers if (number < 0.0) { - n += print('-'); - number = -number; + n += print('-'); + number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; - for (uint8_t i=0; i 0) { + if (digits > 0) + { n += print("."); } @@ -390,31 +428,39 @@ size_t Print::printFloat(double number, int digits) size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[i]); } - return (len*3 - 1); + return (len * 3 - 1); } size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[len-1-i]); + if ( byteline && (i % byteline == 0) ) + println(); + + this->printf("%02X", buffer[len - 1 - i]); } - return (len*3 - 1); + return (len * 3 - 1); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.h b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.h index 793a686..d03d1cc 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.h @@ -37,26 +37,42 @@ class Print size_t printULLNumber(unsigned long long, uint8_t); size_t printFloat(double, int); protected: - void setWriteError(int err = 1) { write_error = err; } + void setWriteError(int err = 1) + { + write_error = err; + } public: Print() : write_error(0) {} - int getWriteError() { return write_error; } - void clearWriteError() { setWriteError(0); } + int getWriteError() + { + return write_error; + } + void clearWriteError() + { + setWriteError(0); + } virtual size_t write(uint8_t) = 0; - size_t write(const char *str) { - if (str == NULL) return 0; + size_t write(const char *str) + { + if (str == NULL) + return 0; + return write((const uint8_t *)str, strlen(str)); } virtual size_t write(const uint8_t *buffer, size_t size); - size_t write(const char *buffer, size_t size) { + size_t write(const char *buffer, size_t size) + { return write((const uint8_t *)buffer, size); } // default to zero, meaning "a single write may block" // should be overridden by subclasses with buffering - virtual int availableForWrite() { return 0; } + virtual int availableForWrite() + { + return 0; + } size_t print(const __FlashStringHelper *); size_t print(const String &); @@ -86,17 +102,17 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); - + size_t printf(const char * format, ...); - - size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + + size_t printBuffer(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBuffer((uint8_t const*) buffer, size, delim, byteline); } - size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + size_t printBufferReverse(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h index cc814d3..c2d5824 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h @@ -1,36 +1,36 @@ /* - * 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 - */ + 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 @@ -38,55 +38,63 @@ #include #include -class UDP : public Stream { +class UDP : public Stream +{ -public: - virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use - - // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) - virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure - - virtual void stop() =0; // Finish with the UDP socket + 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 - // Sending UDP packets + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) + { + return 0; // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + } - // 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; + virtual void stop() = 0; // Finish with the UDP socket - // 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 + // Sending UDP packets - // 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(); }; + // 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 diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.cpp index f43f3a4..63d3f4d 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.cpp @@ -27,12 +27,13 @@ //https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf //https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf -const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 5, // D0 is P0.05 (UART RX) - 6, // D1 is P0.06 (UART TX) - 7, // D2 is P0.07 - 31, // D3 is P0.31 + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 18, // D4 is P0.18 (LED Blue) 99, // D5 (NC) 9, // D6 is P0.09 NFC1 diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.h index 833cbf6..caa0b61 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.h @@ -34,8 +34,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -66,12 +66,12 @@ extern "C" #define SW2 (19) // NFC -#define PIN_NFC_1 (6) // P0.9 -#define PIN_NFC_2 (7) // P0.10 +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (16) // P0.03 #define PIN_A1 (17) // P0.02 #define PIN_A2 (18) // P0.04 @@ -125,8 +125,8 @@ static const uint8_t D15 = PIN_D15 ; //#define PIN_VBAT PIN_A7 /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL_RX (0) // P0.05 #define PIN_SERIAL_TX (1) // P0.06 #define PIN_SERIAL_CTS (2) // P0.07 @@ -135,8 +135,8 @@ static const uint8_t D15 = PIN_D15 ; #define PIN_SERIAL_DSR (29) // P0.29 /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (12) // P0.12 @@ -149,8 +149,8 @@ static const uint8_t MISO = PIN_SPI_MISO ; static const uint8_t SCK = PIN_SPI_SCK ; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (14) // P0.02 @@ -165,8 +165,8 @@ static const uint8_t SCL = PIN_WIRE_SCL; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.cpp index 8b4df2e..7f317d6 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.cpp @@ -17,7 +17,7 @@ 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). +// 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" @@ -27,16 +27,16 @@ const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 + // D0 .. D13 29, // D0 is P0.29 (UART RX) - 45, // D1 is P1.13 (UART TX) + 45, // D1 is P1.13 (UART TX) 44, // D2 is P1.12 (NFC2) 31, // D3 is P0.31 (LED1) 13, // D4 is P0.13 (LED2) 11, // D5 is P0.11 9, // D6 is P0.09 10, // D7 is P0.10 (Button) - 41, // D8 is P1.09 + 41, // D8 is P1.09 12, // D9 is P0.12 14, // D10 is P0.14 15, // D11 is P0.15 @@ -54,7 +54,7 @@ const uint32_t g_ADigitalPinMap[] = // D20 .. D21 (aka I2C pins) 16, // D20 is P0.16 (SDA) 24, // D21 is P0.24 (SCL) - + // QSPI pins (not exposed via any header / test point) 19, // D22 is P0.19 (QSPI CLK) 17, // D23 is P0.17 (QSPI CS) @@ -62,7 +62,7 @@ const uint32_t g_ADigitalPinMap[] = 21, // D25 is P0.21 (QSPI Data 1) 22, // D26 is P0.22 (QSPI Data 2) 26, // D27 is P0.23 (QSPI Data 3) - + 40, // D28 is P1.08 - IO34 41, // D29 is P1.01 - IO35 44, // D30 is P1.02 - IO36 @@ -70,10 +70,10 @@ const uint32_t g_ADigitalPinMap[] = 42, // D32 is P1.10 - IO38 43, // D33 is P1.11 - IO39 47, // D34 is P1.15 - IO40 - 46, // D35 is P1.14 - IO41 + 46, // D35 is P1.14 - IO41 26, // D36 is P0.26 - IO42 6, // D37 is P0.6 - IO43 - 27, // D38 is P0.27 - IO44 + 27, // D38 is P0.27 - IO44 }; void initVariant() diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.h index a69575f..d588790 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.h @@ -1,4 +1,4 @@ - /* +/* Copyright (c) 2014-2015 Arduino LLC. All right reserved. Copyright (c) 2016 Sandeep Mistry All right reserved. Copyright (c) 2018, Adafruit Industries (adafruit.com) @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// 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_ @@ -29,8 +29,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -41,7 +41,7 @@ extern "C" // Number of pins defined in PinDescription array #define PINS_COUNT (40) #define NUM_DIGITAL_PINS (34) -#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_INPUTS (6) #define NUM_ANALOG_OUTPUTS (0) // LEDs @@ -57,13 +57,13 @@ extern "C" #define LED_STATE_ON 1 // State when LED is litted /* - * Buttons - */ + Buttons +*/ #define PIN_BUTTON1 (7) /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (14) #define PIN_A1 (15) #define PIN_A2 (16) @@ -99,14 +99,14 @@ static const uint8_t A5 = PIN_A5 ; #define PIN_NFC2 (2) /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL1_RX (0) #define PIN_SERIAL1_TX (1) /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (22) //24 original @@ -119,8 +119,8 @@ static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (20) @@ -143,7 +143,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.cpp index b01c147..534abf3 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.cpp @@ -1,49 +1,49 @@ -/* - Copyright (c) 2014-2015 Arduino LLC. All right reserved. - Copyright (c) 2016 Sandeep Mistry All right reserved. - Copyright (c) 2018, Adafruit Industries (adafruit.com) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "variant.h" -#include "wiring_constants.h" -#include "wiring_digital.h" -#include "nrf.h" - -const uint32_t g_ADigitalPinMap[] = -{ - // P0 - 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, - - // P1 - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63 -}; -void initVariant() -{ - // LED1 & LED2 - pinMode(PIN_LED1, OUTPUT); - ledOff(PIN_LED1); - - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); -} - +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 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, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 +}; +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} + diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.h index c534ceb..f98c8e0 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.1.0/variants/sparkfun_nrf52840_mini/variant.h @@ -1,152 +1,152 @@ - /* - 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_SPARKFUN52840MINI_ -#define _VARIANT_SPARKFUN52840MINI_ - -/** 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 (64) -#define NUM_DIGITAL_PINS (64) -#define NUM_ANALOG_INPUTS (8) -#define NUM_ANALOG_OUTPUTS (0) - -// LEDs -#define PIN_LED1 (7) -#define PIN_LED2 (14) - -#define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 - -#define LED_BLUE PIN_LED1 -#define LED_RED PIN_LED2 - -#define LED_STATE_ON 1 // State when LED is litted - -// Buttons -/* -#define PIN_BUTTON1 (2) -#define PIN_BUTTON2 (3) -#define PIN_BUTTON3 (4) -#define PIN_BUTTON4 (5) -*/ - -/* - * Analog pins - */ -#define PIN_A0 (2) -#define PIN_A1 (3) -#define PIN_A2 (4) -#define PIN_A3 (5) -#define PIN_A4 (28) -#define PIN_A5 (29) -#define PIN_A6 (30) -#define PIN_A7 (31) - -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 (2) -#define PIN_DFU (13) -#define PIN_NFC1 (9) -#define PIN_NFC2 (10) - -static const uint8_t AREF = PIN_AREF; - -/* - * Serial interfaces - */ -// Serial -//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 -//Feel free to comment out these two lines below if there are conflicts with latest release -#define PIN_SERIAL_RX (15) -#define PIN_SERIAL_TX (17) - -//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above -#define PIN_SERIAL1_RX (15) -#define PIN_SERIAL1_TX (17) - -/* - * SPI Interfaces - */ -#define SPI_INTERFACES_COUNT 1 - -#define PIN_SPI_MISO (31) -#define PIN_SPI_MOSI (3) -#define PIN_SPI_SCK (30) - -static const uint8_t SS = 2 ; -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 (8) -#define PIN_WIRE_SCL (11) - -/* - * QSPI interface for external flash - */ -#define PIN_QSPI_SCK 32 -#define PIN_QSPI_CS 33 -#define PIN_QSPI_DATA0 34 -#define PIN_QSPI_DATA1 35 -#define PIN_QSPI_DATA2 36 -#define PIN_QSPI_DATA3 37 - -// On-board QSPI Flash -// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used -#define EXTERNAL_FLASH_DEVICES GD25Q16C - -#ifdef __cplusplus -} -#endif - -/*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ - +/* + 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_SPARKFUN52840MINI_ +#define _VARIANT_SPARKFUN52840MINI_ + +/** 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 (64) +#define NUM_DIGITAL_PINS (64) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (7) +#define PIN_LED2 (14) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_BLUE PIN_LED1 +#define LED_RED PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons +/* + #define PIN_BUTTON1 (2) + #define PIN_BUTTON2 (3) + #define PIN_BUTTON3 (4) + #define PIN_BUTTON4 (5) +*/ + +/* + Analog pins +*/ +#define PIN_A0 (2) +#define PIN_A1 (3) +#define PIN_A2 (4) +#define PIN_A3 (5) +#define PIN_A4 (28) +#define PIN_A5 (29) +#define PIN_A6 (30) +#define PIN_A7 (31) + +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 (2) +#define PIN_DFU (13) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + Serial interfaces +*/ +// Serial +//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 +//Feel free to comment out these two lines below if there are conflicts with latest release +#define PIN_SERIAL_RX (15) +#define PIN_SERIAL_TX (17) + +//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (17) + +/* + SPI Interfaces +*/ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (31) +#define PIN_SPI_MOSI (3) +#define PIN_SPI_SCK (30) + +static const uint8_t SS = 2 ; +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 (8) +#define PIN_WIRE_SCL (11) + +/* + QSPI interface for external flash +*/ +#define PIN_QSPI_SCK 32 +#define PIN_QSPI_CS 33 +#define PIN_QSPI_DATA0 34 +#define PIN_QSPI_DATA1 35 +#define PIN_QSPI_DATA2 36 +#define PIN_QSPI_DATA3 37 + +// On-board QSPI Flash +// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ + #endif \ No newline at end of file diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.cpp index 09d5864..d2db957 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.cpp @@ -36,10 +36,15 @@ size_t Print::write(const uint8_t *buffer, size_t size) { size_t n = 0; - while (size--) { - if (write(*buffer++)) n++; - else break; + + while (size--) + { + if (write(*buffer++)) + n++; + else + break; } + return n; } @@ -80,46 +85,64 @@ size_t Print::print(unsigned int n, int base) size_t Print::print(long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printNumber(n, 10) + t; } + return printNumber(n, 10); - } else { + } + else + { return printNumber(n, base); } } size_t Print::print(unsigned long n, int base) { - if (base == 0) return write(n); - else return printNumber(n, base); + if (base == 0) + return write(n); + else + return printNumber(n, base); } size_t Print::print(long long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printULLNumber(n, 10) + t; } + return printULLNumber(n, 10); - } else { + } + else + { return printULLNumber(n, base); } } size_t Print::print(unsigned long long n, int base) { - if (base == 0) return write(n); - else return printULLNumber(n, base); + if (base == 0) + return write(n); + else + return printULLNumber(n, base); } size_t Print::print(double n, int digits) @@ -253,14 +276,16 @@ size_t Print::printNumber(unsigned long n, uint8_t base) *str = '\0'; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; - do { + do + { char c = n % base; n /= base; *--str = c < 10 ? c + '0' : c + 'A' - 10; - } while(n); + } while (n); return write(str); } @@ -268,23 +293,23 @@ size_t Print::printNumber(unsigned long n, uint8_t base) // REFERENCE IMPLEMENTATION FOR ULL // size_t Print::printULLNumber(unsigned long long n, uint8_t base) // { - // // if limited to base 10 and 16 the bufsize can be smaller - // char buf[65]; - // char *str = &buf[64]; +// // if limited to base 10 and 16 the bufsize can be smaller +// char buf[65]; +// char *str = &buf[64]; - // *str = '\0'; +// *str = '\0'; - // // prevent crash if called with base == 1 - // if (base < 2) base = 10; +// // prevent crash if called with base == 1 +// if (base < 2) base = 10; - // do { - // unsigned long long t = n / base; - // char c = n - t * base; // faster than c = n%base; - // n = t; - // *--str = c < 10 ? c + '0' : c + 'A' - 10; - // } while(n); +// do { +// unsigned long long t = n / base; +// char c = n - t * base; // faster than c = n%base; +// n = t; +// *--str = c < 10 ? c + '0' : c + 'A' - 10; +// } while(n); - // return write(str); +// return write(str); // } // FAST IMPLEMENTATION FOR ULL @@ -296,11 +321,13 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) uint8_t innerLoops = 0; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; // process chunks that fit in "16 bit math". uint16_t top = 0xFFFF / base; uint16_t th16 = 1; + while (th16 < top) { th16 *= base; @@ -311,31 +338,33 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) { // 64 bit math part uint64_t q = n64 / th16; - uint16_t r = n64 - q*th16; + uint16_t r = n64 - q * th16; n64 = q; // 16 bit math loop to do remainder. (note buffer is filled reverse) - for (uint8_t j=0; j < innerLoops; j++) + for (uint8_t j = 0; j < innerLoops; j++) { - uint16_t qq = r/base; - buf[i++] = r - qq*base; + uint16_t qq = r / base; + buf[i++] = r - qq * base; r = qq; } } uint16_t n16 = n64; + while (n16 > 0) { - uint16_t qq = n16/base; - buf[i++] = n16 - qq*base; + uint16_t qq = n16 / base; + buf[i++] = n16 - qq * base; n16 = qq; } size_t bytes = i; + for (; i > 0; i--) write((char) (buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10)); + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); return bytes; } @@ -347,21 +376,29 @@ size_t Print::printFloat(double number, int digits) size_t n = 0; - if (isnan(number)) return print("nan"); - if (isinf(number)) return print("inf"); - if (number > 4294967040.0) return print ("ovf"); // constant determined empirically - if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + if (isnan(number)) + return print("nan"); + + if (isinf(number)) + return print("inf"); + + if (number > 4294967040.0) + return print ("ovf"); // constant determined empirically + + if (number < -4294967040.0) + return print ("ovf"); // constant determined empirically // Handle negative numbers if (number < 0.0) { - n += print('-'); - number = -number; + n += print('-'); + number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; - for (uint8_t i=0; i 0) { + if (digits > 0) + { n += print("."); } @@ -390,31 +428,39 @@ size_t Print::printFloat(double number, int digits) size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[i]); } - return (len*3 - 1); + return (len * 3 - 1); } size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[len-1-i]); + if ( byteline && (i % byteline == 0) ) + println(); + + this->printf("%02X", buffer[len - 1 - i]); } - return (len*3 - 1); + return (len * 3 - 1); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.h b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.h index 793a686..d03d1cc 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Print.h @@ -37,26 +37,42 @@ class Print size_t printULLNumber(unsigned long long, uint8_t); size_t printFloat(double, int); protected: - void setWriteError(int err = 1) { write_error = err; } + void setWriteError(int err = 1) + { + write_error = err; + } public: Print() : write_error(0) {} - int getWriteError() { return write_error; } - void clearWriteError() { setWriteError(0); } + int getWriteError() + { + return write_error; + } + void clearWriteError() + { + setWriteError(0); + } virtual size_t write(uint8_t) = 0; - size_t write(const char *str) { - if (str == NULL) return 0; + size_t write(const char *str) + { + if (str == NULL) + return 0; + return write((const uint8_t *)str, strlen(str)); } virtual size_t write(const uint8_t *buffer, size_t size); - size_t write(const char *buffer, size_t size) { + size_t write(const char *buffer, size_t size) + { return write((const uint8_t *)buffer, size); } // default to zero, meaning "a single write may block" // should be overridden by subclasses with buffering - virtual int availableForWrite() { return 0; } + virtual int availableForWrite() + { + return 0; + } size_t print(const __FlashStringHelper *); size_t print(const String &); @@ -86,17 +102,17 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); - + size_t printf(const char * format, ...); - - size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + + size_t printBuffer(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBuffer((uint8_t const*) buffer, size, delim, byteline); } - size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + size_t printBufferReverse(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Udp.h b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Udp.h index cc814d3..c2d5824 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Udp.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/cores/nRF5/Udp.h @@ -1,36 +1,36 @@ /* - * 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 - */ + 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 @@ -38,55 +38,63 @@ #include #include -class UDP : public Stream { +class UDP : public Stream +{ -public: - virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use - - // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) - virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure - - virtual void stop() =0; // Finish with the UDP socket + 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 - // Sending UDP packets + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) + { + return 0; // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + } - // 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; + virtual void stop() = 0; // Finish with the UDP socket - // 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 + // Sending UDP packets - // 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(); }; + // 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 diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.cpp index f43f3a4..63d3f4d 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.cpp @@ -27,12 +27,13 @@ //https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf //https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf -const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 5, // D0 is P0.05 (UART RX) - 6, // D1 is P0.06 (UART TX) - 7, // D2 is P0.07 - 31, // D3 is P0.31 + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 18, // D4 is P0.18 (LED Blue) 99, // D5 (NC) 9, // D6 is P0.09 NFC1 diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.h index 833cbf6..caa0b61 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B112_ublox/variant.h @@ -34,8 +34,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -66,12 +66,12 @@ extern "C" #define SW2 (19) // NFC -#define PIN_NFC_1 (6) // P0.9 -#define PIN_NFC_2 (7) // P0.10 +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (16) // P0.03 #define PIN_A1 (17) // P0.02 #define PIN_A2 (18) // P0.04 @@ -125,8 +125,8 @@ static const uint8_t D15 = PIN_D15 ; //#define PIN_VBAT PIN_A7 /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL_RX (0) // P0.05 #define PIN_SERIAL_TX (1) // P0.06 #define PIN_SERIAL_CTS (2) // P0.07 @@ -135,8 +135,8 @@ static const uint8_t D15 = PIN_D15 ; #define PIN_SERIAL_DSR (29) // P0.29 /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (12) // P0.12 @@ -149,8 +149,8 @@ static const uint8_t MISO = PIN_SPI_MISO ; static const uint8_t SCK = PIN_SPI_SCK ; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (14) // P0.02 @@ -165,8 +165,8 @@ static const uint8_t SCL = PIN_WIRE_SCL; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.cpp index 8b4df2e..7f317d6 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.cpp @@ -17,7 +17,7 @@ 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). +// 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" @@ -27,16 +27,16 @@ const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 + // D0 .. D13 29, // D0 is P0.29 (UART RX) - 45, // D1 is P1.13 (UART TX) + 45, // D1 is P1.13 (UART TX) 44, // D2 is P1.12 (NFC2) 31, // D3 is P0.31 (LED1) 13, // D4 is P0.13 (LED2) 11, // D5 is P0.11 9, // D6 is P0.09 10, // D7 is P0.10 (Button) - 41, // D8 is P1.09 + 41, // D8 is P1.09 12, // D9 is P0.12 14, // D10 is P0.14 15, // D11 is P0.15 @@ -54,7 +54,7 @@ const uint32_t g_ADigitalPinMap[] = // D20 .. D21 (aka I2C pins) 16, // D20 is P0.16 (SDA) 24, // D21 is P0.24 (SCL) - + // QSPI pins (not exposed via any header / test point) 19, // D22 is P0.19 (QSPI CLK) 17, // D23 is P0.17 (QSPI CS) @@ -62,7 +62,7 @@ const uint32_t g_ADigitalPinMap[] = 21, // D25 is P0.21 (QSPI Data 1) 22, // D26 is P0.22 (QSPI Data 2) 26, // D27 is P0.23 (QSPI Data 3) - + 40, // D28 is P1.08 - IO34 41, // D29 is P1.01 - IO35 44, // D30 is P1.02 - IO36 @@ -70,10 +70,10 @@ const uint32_t g_ADigitalPinMap[] = 42, // D32 is P1.10 - IO38 43, // D33 is P1.11 - IO39 47, // D34 is P1.15 - IO40 - 46, // D35 is P1.14 - IO41 + 46, // D35 is P1.14 - IO41 26, // D36 is P0.26 - IO42 6, // D37 is P0.6 - IO43 - 27, // D38 is P0.27 - IO44 + 27, // D38 is P0.27 - IO44 }; void initVariant() diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.h index a69575f..d588790 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/NINA_B302_ublox/variant.h @@ -1,4 +1,4 @@ - /* +/* Copyright (c) 2014-2015 Arduino LLC. All right reserved. Copyright (c) 2016 Sandeep Mistry All right reserved. Copyright (c) 2018, Adafruit Industries (adafruit.com) @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// 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_ @@ -29,8 +29,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -41,7 +41,7 @@ extern "C" // Number of pins defined in PinDescription array #define PINS_COUNT (40) #define NUM_DIGITAL_PINS (34) -#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_INPUTS (6) #define NUM_ANALOG_OUTPUTS (0) // LEDs @@ -57,13 +57,13 @@ extern "C" #define LED_STATE_ON 1 // State when LED is litted /* - * Buttons - */ + Buttons +*/ #define PIN_BUTTON1 (7) /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (14) #define PIN_A1 (15) #define PIN_A2 (16) @@ -99,14 +99,14 @@ static const uint8_t A5 = PIN_A5 ; #define PIN_NFC2 (2) /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL1_RX (0) #define PIN_SERIAL1_TX (1) /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (22) //24 original @@ -119,8 +119,8 @@ static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (20) @@ -143,7 +143,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.cpp index b01c147..534abf3 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.cpp @@ -1,49 +1,49 @@ -/* - Copyright (c) 2014-2015 Arduino LLC. All right reserved. - Copyright (c) 2016 Sandeep Mistry All right reserved. - Copyright (c) 2018, Adafruit Industries (adafruit.com) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "variant.h" -#include "wiring_constants.h" -#include "wiring_digital.h" -#include "nrf.h" - -const uint32_t g_ADigitalPinMap[] = -{ - // P0 - 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, - - // P1 - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63 -}; -void initVariant() -{ - // LED1 & LED2 - pinMode(PIN_LED1, OUTPUT); - ledOff(PIN_LED1); - - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); -} - +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 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, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 +}; +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} + diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.h index c534ceb..f98c8e0 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.2.0/variants/sparkfun_nrf52840_mini/variant.h @@ -1,152 +1,152 @@ - /* - 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_SPARKFUN52840MINI_ -#define _VARIANT_SPARKFUN52840MINI_ - -/** 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 (64) -#define NUM_DIGITAL_PINS (64) -#define NUM_ANALOG_INPUTS (8) -#define NUM_ANALOG_OUTPUTS (0) - -// LEDs -#define PIN_LED1 (7) -#define PIN_LED2 (14) - -#define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 - -#define LED_BLUE PIN_LED1 -#define LED_RED PIN_LED2 - -#define LED_STATE_ON 1 // State when LED is litted - -// Buttons -/* -#define PIN_BUTTON1 (2) -#define PIN_BUTTON2 (3) -#define PIN_BUTTON3 (4) -#define PIN_BUTTON4 (5) -*/ - -/* - * Analog pins - */ -#define PIN_A0 (2) -#define PIN_A1 (3) -#define PIN_A2 (4) -#define PIN_A3 (5) -#define PIN_A4 (28) -#define PIN_A5 (29) -#define PIN_A6 (30) -#define PIN_A7 (31) - -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 (2) -#define PIN_DFU (13) -#define PIN_NFC1 (9) -#define PIN_NFC2 (10) - -static const uint8_t AREF = PIN_AREF; - -/* - * Serial interfaces - */ -// Serial -//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 -//Feel free to comment out these two lines below if there are conflicts with latest release -#define PIN_SERIAL_RX (15) -#define PIN_SERIAL_TX (17) - -//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above -#define PIN_SERIAL1_RX (15) -#define PIN_SERIAL1_TX (17) - -/* - * SPI Interfaces - */ -#define SPI_INTERFACES_COUNT 1 - -#define PIN_SPI_MISO (31) -#define PIN_SPI_MOSI (3) -#define PIN_SPI_SCK (30) - -static const uint8_t SS = 2 ; -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 (8) -#define PIN_WIRE_SCL (11) - -/* - * QSPI interface for external flash - */ -#define PIN_QSPI_SCK 32 -#define PIN_QSPI_CS 33 -#define PIN_QSPI_DATA0 34 -#define PIN_QSPI_DATA1 35 -#define PIN_QSPI_DATA2 36 -#define PIN_QSPI_DATA3 37 - -// On-board QSPI Flash -// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used -#define EXTERNAL_FLASH_DEVICES GD25Q16C - -#ifdef __cplusplus -} -#endif - -/*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ - +/* + 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_SPARKFUN52840MINI_ +#define _VARIANT_SPARKFUN52840MINI_ + +/** 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 (64) +#define NUM_DIGITAL_PINS (64) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (7) +#define PIN_LED2 (14) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_BLUE PIN_LED1 +#define LED_RED PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons +/* + #define PIN_BUTTON1 (2) + #define PIN_BUTTON2 (3) + #define PIN_BUTTON3 (4) + #define PIN_BUTTON4 (5) +*/ + +/* + Analog pins +*/ +#define PIN_A0 (2) +#define PIN_A1 (3) +#define PIN_A2 (4) +#define PIN_A3 (5) +#define PIN_A4 (28) +#define PIN_A5 (29) +#define PIN_A6 (30) +#define PIN_A7 (31) + +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 (2) +#define PIN_DFU (13) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + Serial interfaces +*/ +// Serial +//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 +//Feel free to comment out these two lines below if there are conflicts with latest release +#define PIN_SERIAL_RX (15) +#define PIN_SERIAL_TX (17) + +//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (17) + +/* + SPI Interfaces +*/ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (31) +#define PIN_SPI_MOSI (3) +#define PIN_SPI_SCK (30) + +static const uint8_t SS = 2 ; +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 (8) +#define PIN_WIRE_SCL (11) + +/* + QSPI interface for external flash +*/ +#define PIN_QSPI_SCK 32 +#define PIN_QSPI_CS 33 +#define PIN_QSPI_DATA0 34 +#define PIN_QSPI_DATA1 35 +#define PIN_QSPI_DATA2 36 +#define PIN_QSPI_DATA3 37 + +// On-board QSPI Flash +// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ + #endif \ No newline at end of file diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp index 09d5864..d2db957 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp @@ -36,10 +36,15 @@ size_t Print::write(const uint8_t *buffer, size_t size) { size_t n = 0; - while (size--) { - if (write(*buffer++)) n++; - else break; + + while (size--) + { + if (write(*buffer++)) + n++; + else + break; } + return n; } @@ -80,46 +85,64 @@ size_t Print::print(unsigned int n, int base) size_t Print::print(long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printNumber(n, 10) + t; } + return printNumber(n, 10); - } else { + } + else + { return printNumber(n, base); } } size_t Print::print(unsigned long n, int base) { - if (base == 0) return write(n); - else return printNumber(n, base); + if (base == 0) + return write(n); + else + return printNumber(n, base); } size_t Print::print(long long n, int base) { - if (base == 0) { + if (base == 0) + { return write(n); - } else if (base == 10) { - if (n < 0) { + } + else if (base == 10) + { + if (n < 0) + { int t = print('-'); n = -n; return printULLNumber(n, 10) + t; } + return printULLNumber(n, 10); - } else { + } + else + { return printULLNumber(n, base); } } size_t Print::print(unsigned long long n, int base) { - if (base == 0) return write(n); - else return printULLNumber(n, base); + if (base == 0) + return write(n); + else + return printULLNumber(n, base); } size_t Print::print(double n, int digits) @@ -253,14 +276,16 @@ size_t Print::printNumber(unsigned long n, uint8_t base) *str = '\0'; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; - do { + do + { char c = n % base; n /= base; *--str = c < 10 ? c + '0' : c + 'A' - 10; - } while(n); + } while (n); return write(str); } @@ -268,23 +293,23 @@ size_t Print::printNumber(unsigned long n, uint8_t base) // REFERENCE IMPLEMENTATION FOR ULL // size_t Print::printULLNumber(unsigned long long n, uint8_t base) // { - // // if limited to base 10 and 16 the bufsize can be smaller - // char buf[65]; - // char *str = &buf[64]; +// // if limited to base 10 and 16 the bufsize can be smaller +// char buf[65]; +// char *str = &buf[64]; - // *str = '\0'; +// *str = '\0'; - // // prevent crash if called with base == 1 - // if (base < 2) base = 10; +// // prevent crash if called with base == 1 +// if (base < 2) base = 10; - // do { - // unsigned long long t = n / base; - // char c = n - t * base; // faster than c = n%base; - // n = t; - // *--str = c < 10 ? c + '0' : c + 'A' - 10; - // } while(n); +// do { +// unsigned long long t = n / base; +// char c = n - t * base; // faster than c = n%base; +// n = t; +// *--str = c < 10 ? c + '0' : c + 'A' - 10; +// } while(n); - // return write(str); +// return write(str); // } // FAST IMPLEMENTATION FOR ULL @@ -296,11 +321,13 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) uint8_t innerLoops = 0; // prevent crash if called with base == 1 - if (base < 2) base = 10; + if (base < 2) + base = 10; // process chunks that fit in "16 bit math". uint16_t top = 0xFFFF / base; uint16_t th16 = 1; + while (th16 < top) { th16 *= base; @@ -311,31 +338,33 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base) { // 64 bit math part uint64_t q = n64 / th16; - uint16_t r = n64 - q*th16; + uint16_t r = n64 - q * th16; n64 = q; // 16 bit math loop to do remainder. (note buffer is filled reverse) - for (uint8_t j=0; j < innerLoops; j++) + for (uint8_t j = 0; j < innerLoops; j++) { - uint16_t qq = r/base; - buf[i++] = r - qq*base; + uint16_t qq = r / base; + buf[i++] = r - qq * base; r = qq; } } uint16_t n16 = n64; + while (n16 > 0) { - uint16_t qq = n16/base; - buf[i++] = n16 - qq*base; + uint16_t qq = n16 / base; + buf[i++] = n16 - qq * base; n16 = qq; } size_t bytes = i; + for (; i > 0; i--) write((char) (buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10)); + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); return bytes; } @@ -347,21 +376,29 @@ size_t Print::printFloat(double number, int digits) size_t n = 0; - if (isnan(number)) return print("nan"); - if (isinf(number)) return print("inf"); - if (number > 4294967040.0) return print ("ovf"); // constant determined empirically - if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + if (isnan(number)) + return print("nan"); + + if (isinf(number)) + return print("inf"); + + if (number > 4294967040.0) + return print ("ovf"); // constant determined empirically + + if (number < -4294967040.0) + return print ("ovf"); // constant determined empirically // Handle negative numbers if (number < 0.0) { - n += print('-'); - number = -number; + n += print('-'); + number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; - for (uint8_t i=0; i 0) { + if (digits > 0) + { n += print("."); } @@ -390,31 +428,39 @@ size_t Print::printFloat(double number, int digits) size_t Print::printBuffer(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[i]); } - return (len*3 - 1); + return (len * 3 - 1); } size_t Print::printBufferReverse(uint8_t const buffer[], int len, char delim, int byteline) { - if (buffer == NULL || len == 0) return 0; + if (buffer == NULL || len == 0) + return 0; - for(int i=0; iprintf("%02X", buffer[len-1-i]); + if ( byteline && (i % byteline == 0) ) + println(); + + this->printf("%02X", buffer[len - 1 - i]); } - return (len*3 - 1); + return (len * 3 - 1); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h index 793a686..d03d1cc 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h @@ -37,26 +37,42 @@ class Print size_t printULLNumber(unsigned long long, uint8_t); size_t printFloat(double, int); protected: - void setWriteError(int err = 1) { write_error = err; } + void setWriteError(int err = 1) + { + write_error = err; + } public: Print() : write_error(0) {} - int getWriteError() { return write_error; } - void clearWriteError() { setWriteError(0); } + int getWriteError() + { + return write_error; + } + void clearWriteError() + { + setWriteError(0); + } virtual size_t write(uint8_t) = 0; - size_t write(const char *str) { - if (str == NULL) return 0; + size_t write(const char *str) + { + if (str == NULL) + return 0; + return write((const uint8_t *)str, strlen(str)); } virtual size_t write(const uint8_t *buffer, size_t size); - size_t write(const char *buffer, size_t size) { + size_t write(const char *buffer, size_t size) + { return write((const uint8_t *)buffer, size); } // default to zero, meaning "a single write may block" // should be overridden by subclasses with buffering - virtual int availableForWrite() { return 0; } + virtual int availableForWrite() + { + return 0; + } size_t print(const __FlashStringHelper *); size_t print(const String &); @@ -86,17 +102,17 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); - + size_t printf(const char * format, ...); - - size_t printBuffer(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBuffer(char const buffer[], int size, char delim=' ', int byteline = 0) + + size_t printBuffer(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBuffer(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBuffer((uint8_t const*) buffer, size, delim, byteline); } - size_t printBufferReverse(uint8_t const buffer[], int len, char delim=' ', int byteline = 0); - size_t printBufferReverse(char const buffer[], int size, char delim=' ', int byteline = 0) + size_t printBufferReverse(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); + size_t printBufferReverse(char const buffer[], int size, char delim = ' ', int byteline = 0) { return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); } diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h index cc814d3..c2d5824 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h @@ -1,36 +1,36 @@ /* - * 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 - */ + 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 @@ -38,55 +38,63 @@ #include #include -class UDP : public Stream { +class UDP : public Stream +{ -public: - virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use - - // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) - virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure - - virtual void stop() =0; // Finish with the UDP socket + 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 - // Sending UDP packets + // KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) + virtual uint8_t beginMulticast(IPAddress, uint16_t) + { + return 0; // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + } - // 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; + virtual void stop() = 0; // Finish with the UDP socket - // 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 + // Sending UDP packets - // 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(); }; + // 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 diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp index f43f3a4..63d3f4d 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp @@ -27,12 +27,13 @@ //https://www.u-blox.com/sites/default/files/NINA-B1_DataSheet_UBX-15019243.pdf //https://www.u-blox.com/sites/default/files/EVK-NINA-B1_UserGuide_%28UBX-15028120%29_C1-Public.pdf -const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 5, // D0 is P0.05 (UART RX) - 6, // D1 is P0.06 (UART TX) - 7, // D2 is P0.07 - 31, // D3 is P0.31 + 6, // D1 is P0.06 (UART TX) + 7, // D2 is P0.07 + 31, // D3 is P0.31 18, // D4 is P0.18 (LED Blue) 99, // D5 (NC) 9, // D6 is P0.09 NFC1 diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h index 833cbf6..caa0b61 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h @@ -34,8 +34,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -66,12 +66,12 @@ extern "C" #define SW2 (19) // NFC -#define PIN_NFC_1 (6) // P0.9 -#define PIN_NFC_2 (7) // P0.10 +#define PIN_NFC_1 (6) // P0.9 +#define PIN_NFC_2 (7) // P0.10 /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (16) // P0.03 #define PIN_A1 (17) // P0.02 #define PIN_A2 (18) // P0.04 @@ -125,8 +125,8 @@ static const uint8_t D15 = PIN_D15 ; //#define PIN_VBAT PIN_A7 /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL_RX (0) // P0.05 #define PIN_SERIAL_TX (1) // P0.06 #define PIN_SERIAL_CTS (2) // P0.07 @@ -135,8 +135,8 @@ static const uint8_t D15 = PIN_D15 ; #define PIN_SERIAL_DSR (29) // P0.29 /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (12) // P0.12 @@ -149,8 +149,8 @@ static const uint8_t MISO = PIN_SPI_MISO ; static const uint8_t SCK = PIN_SPI_SCK ; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (14) // P0.02 @@ -165,8 +165,8 @@ static const uint8_t SCL = PIN_WIRE_SCL; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B112_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp index 8b4df2e..7f317d6 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp @@ -17,7 +17,7 @@ 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). +// 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" @@ -27,16 +27,16 @@ const uint32_t g_ADigitalPinMap[] = { - // D0 .. D13 + // D0 .. D13 29, // D0 is P0.29 (UART RX) - 45, // D1 is P1.13 (UART TX) + 45, // D1 is P1.13 (UART TX) 44, // D2 is P1.12 (NFC2) 31, // D3 is P0.31 (LED1) 13, // D4 is P0.13 (LED2) 11, // D5 is P0.11 9, // D6 is P0.09 10, // D7 is P0.10 (Button) - 41, // D8 is P1.09 + 41, // D8 is P1.09 12, // D9 is P0.12 14, // D10 is P0.14 15, // D11 is P0.15 @@ -54,7 +54,7 @@ const uint32_t g_ADigitalPinMap[] = // D20 .. D21 (aka I2C pins) 16, // D20 is P0.16 (SDA) 24, // D21 is P0.24 (SCL) - + // QSPI pins (not exposed via any header / test point) 19, // D22 is P0.19 (QSPI CLK) 17, // D23 is P0.17 (QSPI CS) @@ -62,7 +62,7 @@ const uint32_t g_ADigitalPinMap[] = 21, // D25 is P0.21 (QSPI Data 1) 22, // D26 is P0.22 (QSPI Data 2) 26, // D27 is P0.23 (QSPI Data 3) - + 40, // D28 is P1.08 - IO34 41, // D29 is P1.01 - IO35 44, // D30 is P1.02 - IO36 @@ -70,10 +70,10 @@ const uint32_t g_ADigitalPinMap[] = 42, // D32 is P1.10 - IO38 43, // D33 is P1.11 - IO39 47, // D34 is P1.15 - IO40 - 46, // D35 is P1.14 - IO41 + 46, // D35 is P1.14 - IO41 26, // D36 is P0.26 - IO42 6, // D37 is P0.6 - IO43 - 27, // D38 is P0.27 - IO44 + 27, // D38 is P0.27 - IO44 }; void initVariant() diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h index a69575f..d588790 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h @@ -1,4 +1,4 @@ - /* +/* Copyright (c) 2014-2015 Arduino LLC. All right reserved. Copyright (c) 2016 Sandeep Mistry All right reserved. Copyright (c) 2018, Adafruit Industries (adafruit.com) @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip). +// 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_ @@ -29,8 +29,8 @@ // define USE_LFRC // Board uses RC for LF /*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ + Headers + ----------------------------------------------------------------------------*/ #include "WVariant.h" @@ -41,7 +41,7 @@ extern "C" // Number of pins defined in PinDescription array #define PINS_COUNT (40) #define NUM_DIGITAL_PINS (34) -#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_INPUTS (6) #define NUM_ANALOG_OUTPUTS (0) // LEDs @@ -57,13 +57,13 @@ extern "C" #define LED_STATE_ON 1 // State when LED is litted /* - * Buttons - */ + Buttons +*/ #define PIN_BUTTON1 (7) /* - * Analog pins - */ + Analog pins +*/ #define PIN_A0 (14) #define PIN_A1 (15) #define PIN_A2 (16) @@ -99,14 +99,14 @@ static const uint8_t A5 = PIN_A5 ; #define PIN_NFC2 (2) /* - * Serial interfaces - */ + Serial interfaces +*/ #define PIN_SERIAL1_RX (0) #define PIN_SERIAL1_TX (1) /* - * SPI Interfaces - */ + SPI Interfaces +*/ #define SPI_INTERFACES_COUNT 1 #define PIN_SPI_MISO (22) //24 original @@ -119,8 +119,8 @@ static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; /* - * Wire Interfaces - */ + Wire Interfaces +*/ #define WIRE_INTERFACES_COUNT 1 #define PIN_WIRE_SDA (20) @@ -143,7 +143,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #endif /*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ #endif //_VARIANT_NINA_B302_UBLOX_ diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.cpp b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.cpp index b01c147..534abf3 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.cpp +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.cpp @@ -1,49 +1,49 @@ -/* - Copyright (c) 2014-2015 Arduino LLC. All right reserved. - Copyright (c) 2016 Sandeep Mistry All right reserved. - Copyright (c) 2018, Adafruit Industries (adafruit.com) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "variant.h" -#include "wiring_constants.h" -#include "wiring_digital.h" -#include "nrf.h" - -const uint32_t g_ADigitalPinMap[] = -{ - // P0 - 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, - - // P1 - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63 -}; -void initVariant() -{ - // LED1 & LED2 - pinMode(PIN_LED1, OUTPUT); - ledOff(PIN_LED1); - - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); -} - +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 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, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 +}; +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} + diff --git a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.h b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.h index c534ceb..f98c8e0 100644 --- a/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.h +++ b/Packages_Patches/adafruit/hardware/nrf52/1.3.0/variants/sparkfun_nrf52840_mini/variant.h @@ -1,152 +1,152 @@ - /* - 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_SPARKFUN52840MINI_ -#define _VARIANT_SPARKFUN52840MINI_ - -/** 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 (64) -#define NUM_DIGITAL_PINS (64) -#define NUM_ANALOG_INPUTS (8) -#define NUM_ANALOG_OUTPUTS (0) - -// LEDs -#define PIN_LED1 (7) -#define PIN_LED2 (14) - -#define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 - -#define LED_BLUE PIN_LED1 -#define LED_RED PIN_LED2 - -#define LED_STATE_ON 1 // State when LED is litted - -// Buttons -/* -#define PIN_BUTTON1 (2) -#define PIN_BUTTON2 (3) -#define PIN_BUTTON3 (4) -#define PIN_BUTTON4 (5) -*/ - -/* - * Analog pins - */ -#define PIN_A0 (2) -#define PIN_A1 (3) -#define PIN_A2 (4) -#define PIN_A3 (5) -#define PIN_A4 (28) -#define PIN_A5 (29) -#define PIN_A6 (30) -#define PIN_A7 (31) - -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 (2) -#define PIN_DFU (13) -#define PIN_NFC1 (9) -#define PIN_NFC2 (10) - -static const uint8_t AREF = PIN_AREF; - -/* - * Serial interfaces - */ -// Serial -//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 -//Feel free to comment out these two lines below if there are conflicts with latest release -#define PIN_SERIAL_RX (15) -#define PIN_SERIAL_TX (17) - -//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above -#define PIN_SERIAL1_RX (15) -#define PIN_SERIAL1_TX (17) - -/* - * SPI Interfaces - */ -#define SPI_INTERFACES_COUNT 1 - -#define PIN_SPI_MISO (31) -#define PIN_SPI_MOSI (3) -#define PIN_SPI_SCK (30) - -static const uint8_t SS = 2 ; -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 (8) -#define PIN_WIRE_SCL (11) - -/* - * QSPI interface for external flash - */ -#define PIN_QSPI_SCK 32 -#define PIN_QSPI_CS 33 -#define PIN_QSPI_DATA0 34 -#define PIN_QSPI_DATA1 35 -#define PIN_QSPI_DATA2 36 -#define PIN_QSPI_DATA3 37 - -// On-board QSPI Flash -// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used -#define EXTERNAL_FLASH_DEVICES GD25Q16C - -#ifdef __cplusplus -} -#endif - -/*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ - +/* + 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_SPARKFUN52840MINI_ +#define _VARIANT_SPARKFUN52840MINI_ + +/** 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 (64) +#define NUM_DIGITAL_PINS (64) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (7) +#define PIN_LED2 (14) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_BLUE PIN_LED1 +#define LED_RED PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons +/* + #define PIN_BUTTON1 (2) + #define PIN_BUTTON2 (3) + #define PIN_BUTTON3 (4) + #define PIN_BUTTON4 (5) +*/ + +/* + Analog pins +*/ +#define PIN_A0 (2) +#define PIN_A1 (3) +#define PIN_A2 (4) +#define PIN_A3 (5) +#define PIN_A4 (28) +#define PIN_A5 (29) +#define PIN_A6 (30) +#define PIN_A7 (31) + +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 (2) +#define PIN_DFU (13) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + Serial interfaces +*/ +// Serial +//Previous Hardware UART definition for nRF52 Arduino Core, below 0.16.0 +//Feel free to comment out these two lines below if there are conflicts with latest release +#define PIN_SERIAL_RX (15) +#define PIN_SERIAL_TX (17) + +//Hardware UART definition for nRF52 Arduino Core, 0.17.0 and above +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (17) + +/* + SPI Interfaces +*/ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (31) +#define PIN_SPI_MOSI (3) +#define PIN_SPI_SCK (30) + +static const uint8_t SS = 2 ; +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 (8) +#define PIN_WIRE_SCL (11) + +/* + QSPI interface for external flash +*/ +#define PIN_QSPI_SCK 32 +#define PIN_QSPI_CS 33 +#define PIN_QSPI_DATA0 34 +#define PIN_QSPI_DATA1 35 +#define PIN_QSPI_DATA2 36 +#define PIN_QSPI_DATA3 37 + +// On-board QSPI Flash +// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + Arduino objects - C++ only + ----------------------------------------------------------------------------*/ + #endif \ No newline at end of file