This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0.0 for hardware-PWM on nRF52 boards
### Initial Releases v1.0.0 1. Initial coding to support **nRF52-based boards, such as AdaFruit Itsy-Bitsy nRF52840, Feather nRF52840 Express, Seeed XIAO nRF52840, Seeed XIAO nRF52840 Sense**, etc. using [`Adafruit nRF52 core`](https://github.com/adafruit/Adafruit_nRF52_Arduino) or [`Seeeduino nRF52 core`](https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino)
- Loading branch information
1 parent
2017789
commit 2384153
Showing
55 changed files
with
10,023 additions
and
0 deletions.
There are no files selected for viewing
466 changes: 466 additions & 0 deletions
466
Packages_Patches/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
Packages_Patches/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
Copyright (c) 2016 Arduino LLC. All right reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <inttypes.h> | ||
#include <stdio.h> // for size_t | ||
|
||
#include "WString.h" | ||
#include "Printable.h" | ||
|
||
#define DEC 10 | ||
#define HEX 16 | ||
#define OCT 8 | ||
#define BIN 2 | ||
|
||
class Print | ||
{ | ||
private: | ||
int write_error; | ||
size_t printNumber(unsigned long, uint8_t); | ||
size_t printULLNumber(unsigned long long, uint8_t); | ||
size_t printFloat(double, int); | ||
protected: | ||
void setWriteError(int err = 1) | ||
{ | ||
write_error = err; | ||
} | ||
public: | ||
Print() : write_error(0) {} | ||
|
||
int getWriteError() | ||
{ | ||
return write_error; | ||
} | ||
void clearWriteError() | ||
{ | ||
setWriteError(0); | ||
} | ||
|
||
virtual size_t write(uint8_t) = 0; | ||
size_t write(const char *str) | ||
{ | ||
if (str == NULL) | ||
return 0; | ||
|
||
return write((const uint8_t *)str, strlen(str)); | ||
} | ||
virtual size_t write(const uint8_t *buffer, size_t size); | ||
size_t write(const char *buffer, size_t size) | ||
{ | ||
return write((const uint8_t *)buffer, size); | ||
} | ||
|
||
// default to zero, meaning "a single write may block" | ||
// should be overridden by subclasses with buffering | ||
virtual int availableForWrite() | ||
{ | ||
return 0; | ||
} | ||
|
||
size_t print(const __FlashStringHelper *); | ||
size_t print(const String &); | ||
size_t print(const char[]); | ||
size_t print(char); | ||
size_t print(unsigned char, int = DEC); | ||
size_t print(int, int = DEC); | ||
size_t print(unsigned int, int = DEC); | ||
size_t print(long, int = DEC); | ||
size_t print(unsigned long, int = DEC); | ||
size_t print(long long, int = DEC); | ||
size_t print(unsigned long long, int = DEC); | ||
size_t print(double, int = 2); | ||
size_t print(const Printable&); | ||
|
||
size_t println(const __FlashStringHelper *); | ||
size_t println(const String &s); | ||
size_t println(const char[]); | ||
size_t println(char); | ||
size_t println(unsigned char, int = DEC); | ||
size_t println(int, int = DEC); | ||
size_t println(unsigned int, int = DEC); | ||
size_t println(long, int = DEC); | ||
size_t println(unsigned long, int = DEC); | ||
size_t println(long long, int = DEC); | ||
size_t println(unsigned long long, int = DEC); | ||
size_t println(double, int = 2); | ||
size_t println(const Printable&); | ||
size_t println(void); | ||
|
||
size_t printf(const char * format, ...); | ||
|
||
size_t printBuffer(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); | ||
size_t printBuffer(char const buffer[], int size, char delim = ' ', int byteline = 0) | ||
{ | ||
return printBuffer((uint8_t const*) buffer, size, delim, byteline); | ||
} | ||
|
||
size_t printBufferReverse(uint8_t const buffer[], int len, char delim = ' ', int byteline = 0); | ||
size_t printBufferReverse(char const buffer[], int size, char delim = ' ', int byteline = 0) | ||
{ | ||
return printBufferReverse((uint8_t const*) buffer, size, delim, byteline); | ||
} | ||
|
||
virtual void flush() { /* Empty implementation for backward compatibility */ } | ||
}; | ||
|
||
|
100 changes: 100 additions & 0 deletions
100
Packages_Patches/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Udp.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
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. | ||
[email protected] 12/30/2008 | ||
*/ | ||
|
||
#ifndef udp_h | ||
#define udp_h | ||
|
||
#include <Stream.h> | ||
#include <IPAddress.h> | ||
|
||
class UDP : public Stream | ||
{ | ||
|
||
public: | ||
virtual uint8_t begin(uint16_t) = | ||
0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use | ||
|
||
// KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.) | ||
virtual uint8_t beginMulticast(IPAddress, uint16_t) | ||
{ | ||
return 0; // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure | ||
} | ||
|
||
virtual void stop() = 0; // Finish with the UDP socket | ||
|
||
// Sending UDP packets | ||
|
||
// Start building up a packet to send to the remote host specific in ip and port | ||
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port | ||
virtual int beginPacket(IPAddress ip, uint16_t port) = 0; | ||
// Start building up a packet to send to the remote host specific in host and port | ||
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port | ||
virtual int beginPacket(const char *host, uint16_t port) = 0; | ||
// Finish off this packet and send it | ||
// Returns 1 if the packet was sent successfully, 0 if there was an error | ||
virtual int endPacket() = 0; | ||
// Write a single byte into the packet | ||
virtual size_t write(uint8_t) = 0; | ||
// Write size bytes from buffer into the packet | ||
virtual size_t write(const uint8_t *buffer, size_t size) = 0; | ||
|
||
// Start processing the next available incoming packet | ||
// Returns the size of the packet in bytes, or 0 if no packets are available | ||
virtual int parsePacket() = 0; | ||
// Number of bytes remaining in the current packet | ||
virtual int available() = 0; | ||
// Read a single byte from the current packet | ||
virtual int read() = 0; | ||
// Read up to len bytes from the current packet and place them into buffer | ||
// Returns the number of bytes read, or 0 if none are available | ||
virtual int read(unsigned char* buffer, size_t len) = 0; | ||
// Read up to len characters from the current packet and place them into buffer | ||
// Returns the number of characters read, or 0 if none are available | ||
virtual int read(char* buffer, size_t len) = 0; | ||
// Return the next byte from the current packet without moving on to the next byte | ||
virtual int peek() = 0; | ||
virtual void flush() = 0; // Finish reading the current packet | ||
|
||
// Return the IP address of the host who sent the current incoming packet | ||
virtual IPAddress remoteIP() = 0; | ||
// Return the port of the host who sent the current incoming packet | ||
virtual uint16_t remotePort() = 0; | ||
protected: | ||
uint8_t* rawIPAddress(IPAddress& addr) | ||
{ | ||
return addr.raw_address(); | ||
}; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.