Skip to content

Commit 015da41

Browse files
committed
Add support for the SAMD family!
1 parent 4a7f01e commit 015da41

File tree

6 files changed

+18
-6
lines changed

6 files changed

+18
-6
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ A simple library to interface with RDM6300 RFID reader.
66
* Using a single configurable GPIO pin.
77
* Can tell if the tag is still near the antenna.
88
* Both hardware and software uart (serial) support on esp8266.
9+
* SAMD hardware uart (serial) support.
910
* Both SoftwareSerial and [AltSoftSerial](https://github.com/PaulStoffregen/AltSoftSerial) support.
1011

1112
## Getting Started

examples/read_to_serial/read_to_serial.ino

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Connect the rdm6300 to VCC=5V, GND=GND, TX=any GPIO (this case GPIO-04)
55
* Note that the rdm6300's TX line is 3.3V level,
66
* so it's safe to use with both AVR* and ESP* microcontrollers.
7+
* Note that on SAMD the RX_PIN is ignored, the default is Serial1 (pin0),
8+
* but if specify rdm6300.begin(RDM6300_RX_PIN, 2); then Serial2 (pin30) is used.
79
*
810
* This example uses SoftwareSerial, please read its limitations here:
911
* https://www.arduino.cc/en/Reference/softwareSerial

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rdm6300",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"keywords": "rdm6300, rfid",
55
"description": "A simple library to interface with rdm6300 rfid reader.",
66
"repository":

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Rdm6300
2-
version=1.2.0
2+
version=1.3.0
33
author=Arad Eizen
44
maintainer=Arad Eizen <https://github.com/arduino12>
55
sentence=A simple library to interface with rdm6300 rfid reader.

src/rdm6300.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ void Rdm6300::begin(int rx_pin, uint8_t uart_nr)
2929
if (uart_nr)
3030
_hardware_serial->swap();
3131
}
32+
#elif defined(ARDUINO_ARCH_SAMD)
33+
_stream = _hardware_serial = (uart_nr == 2 ? &Serial2 : &Serial1);
34+
_hardware_serial->begin(RDM6300_BAUDRATE, SERIAL_8N1);
3235
#endif
3336
#ifdef RDM6300_SOFTWARE_SERIAL
3437
if (!_stream) {

src/rdm6300.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@
77
#ifndef _RDM6300_h_
88
#define _RDM6300_h_
99

10-
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
10+
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_SAMD)
1111
#define RDM6300_HARDWARE_SERIAL
1212
#endif
1313

14-
#if !defined(ARDUINO_ARCH_ESP32)
14+
#if !(defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_SAMD))
1515
#define RDM6300_SOFTWARE_SERIAL
1616
#endif
1717

1818
#ifdef RDM6300_HARDWARE_SERIAL
19-
#include <HardwareSerial.h>
19+
#ifdef ARDUINO_ARCH_SAMD
20+
#include <Uart.h>
21+
#define HardwareSerial_t Uart
22+
#else
23+
#include <HardwareSerial.h>
24+
#define HardwareSerial_t HardwareSerial
25+
#endif
2026
#endif
2127
#ifdef RDM6300_SOFTWARE_SERIAL
2228
#include <SoftwareSerial.h>
@@ -46,7 +52,7 @@ class Rdm6300
4652
#endif
4753
private:
4854
#ifdef RDM6300_HARDWARE_SERIAL
49-
HardwareSerial *_hardware_serial = NULL;
55+
HardwareSerial_t *_hardware_serial = NULL;
5056
#endif
5157
#ifdef RDM6300_SOFTWARE_SERIAL
5258
SoftwareSerial *_software_serial = NULL;

0 commit comments

Comments
 (0)