1#include <zephyr/kernel.h>
2#include <zephyr/device.h>
7#define M6E_NANO_BUF_SIZE 255
8#define M6E_NANO_MAX_TAGS 150
11#define TMR_START_HEADER 0xFF
14#define TMR_SR_OPCODE_VERSION 0x03
15#define TMR_SR_OPCODE_VERSION_STARTUP 0x04
16#define TMR_SR_OPCODE_SET_BAUD_RATE 0x06
17#define TMR_SR_OPCODE_READ_TAG_ID_SINGLE 0x21
18#define TMR_SR_OPCODE_READ_TAG_ID_MULTIPLE 0x22
19#define TMR_SR_OPCODE_WRITE_TAG_ID 0x23
20#define TMR_SR_OPCODE_WRITE_TAG_DATA 0x24
21#define TMR_SR_OPCODE_KILL_TAG 0x26
22#define TMR_SR_OPCODE_READ_TAG_DATA 0x28
23#define TMR_SR_OPCODE_CLEAR_TAG_ID_BUFFER 0x2A
24#define TMR_SR_OPCODE_MULTI_PROTOCOL_TAG_OP 0x2F
25#define TMR_SR_OPCODE_GET_READ_TX_POWER 0x62
26#define TMR_SR_OPCODE_GET_WRITE_TX_POWER 0x64
27#define TMR_SR_OPCODE_GET_USER_GPIO_INPUTS 0x66
28#define TMR_SR_OPCODE_GET_POWER_MODE 0x68
29#define TMR_SR_OPCODE_GET_READER_OPTIONAL_PARAMS 0x6A
30#define TMR_SR_OPCODE_GET_PROTOCOL_PARAM 0x6B
31#define TMR_SR_OPCODE_SET_ANTENNA_PORT 0x91
32#define TMR_SR_OPCODE_SET_TAG_PROTOCOL 0x93
33#define TMR_SR_OPCODE_SET_READ_TX_POWER 0x92
34#define TMR_SR_OPCODE_SET_WRITE_TX_POWER 0x94
35#define TMR_SR_OPCODE_SET_USER_GPIO_OUTPUTS 0x96
36#define TMR_SR_OPCODE_SET_REGION 0x97
37#define TMR_SR_OPCODE_SET_POWER_MODE 0x98
38#define TMR_SR_OPCODE_SET_READER_OPTIONAL_PARAMS 0x9A
39#define TMR_SR_OPCODE_SET_PROTOCOL_PARAM 0x9B
42#define TMR_SR_POWER_MODE_FULL 0x00
43#define TMR_SR_POWER_MODE_MIN_SAVE 0x01
44#define TMR_SR_POWER_MODE_MED_SAVE 0x02
45#define TMR_SR_POWER_MODE_MAX_SAVE 0x03
48#define COMMAND_TIME_OUT 2000
51#define RESPONSE_PENDING 0
52#define ERROR_COMMAND_RESPONSE_TIMEOUT 1
53#define ERROR_CORRUPT_RESPONSE 2
54#define ERROR_WRONG_OPCODE_RESPONSE 3
55#define ERROR_UNKNOWN_OPCODE 4
56#define RESPONSE_IS_TEMPERATURE 5
57#define RESPONSE_IS_KEEPALIVE 6
58#define RESPONSE_IS_TEMPTHROTTLE 7
59#define RESPONSE_IS_TAGFOUND 8
60#define RESPONSE_IS_NOTAGFOUND 9
61#define RESPONSE_IS_UNKNOWN 10
62#define RESPONSE_SUCCESS 11
63#define RESPONSE_FAIL 12
64#define RESPONSE_CLEAR 13
65#define RESPONSE_STARTUP 14
68#define REGION_INDIA 0x04
69#define REGION_JAPAN 0x05
70#define REGION_CHINA 0x06
71#define REGION_EUROPE 0x08
72#define REGION_KOREA 0x09
73#define REGION_AUSTRALIA 0x0B
74#define REGION_NEWZEALAND 0x0C
75#define REGION_NORTHAMERICA 0x0D
76#define REGION_OPEN 0xFF
79#define TMR_TAG_PROTOCOL_NONE 0x00
80#define TMR_TAG_PROTOCOL_ISO180006B 0x03
81#define TMR_TAG_PROTOCOL_GEN2 0x05
82#define TMR_TAG_PROTOCOL_ISO180006B_UCODE 0x06
83#define TMR_TAG_PROTOCOL_IPX64 0x07
84#define TMR_TAG_PROTOCOL_IPX256 0x08
85#define TMR_TAG_PROTOCOL_ATA 0x1D
88#define CFG_M6E_NANO_SERIAL_TIMEOUT 1000
92 const uint8_t length,
bool timeout);
127static inline void m6e_nano_set_callback(
const struct device *dev,
m6e_nano_callback_t callback,
165int user_send_command(
const struct device *dev, uint8_t *command,
const uint8_t length,
const bool timeout);
void m6e_nano_send_generic_command(const struct device *dev, uint8_t *command, uint8_t size, uint8_t opcode)
Send a generic command to the M6E Nano.
void m6e_nano_stop_reading(const struct device *dev)
Stop a continuous read operation.
int user_send_command(const struct device *dev, uint8_t *command, const uint8_t length, const bool timeout)
Set the command to be transmitted by the UART peripheral.
void m6e_nano_set_region(const struct device *dev, uint8_t region)
Set the operating region of the M6E Nano. This controls the transmission frequency of the RFID reader...
uint32_t m6e_nano_get_tag_freq(const struct device *dev)
Retrieve the frequency of the tag.
uint16_t m6e_nano_get_tag_timestamp(const struct device *dev)
Retrieve the timestamp of the tag.
#define M6E_NANO_BUF_SIZE
Definition m6e_nano.h:7
void m6e_nano_disable_read_filter(const struct device *dev)
Disable the read filter.
uint8_t m6e_nano_parse_response(const struct device *dev)
Parse the tag response from the M6E Nano.
void m6e_nano_set_power_mode(const struct device *dev, uint8_t mode)
Set the power mode of the M6E Nano.
int(* m6e_nano_send_command_t)(const struct device *dev, uint8_t *command, const uint8_t length, bool timeout)
Definition m6e_nano.h:91
void(* m6e_nano_set_callback_t)(const struct device *dev, m6e_nano_callback_t callback, void *user_data)
Definition m6e_nano.h:98
void m6e_nano_set_tag_protocol(const struct device *dev, uint8_t protocol)
Set the tag protocol of the M6E Nano.
void m6e_nano_get_write_power(const struct device *dev)
Retrieve the write power of the M6E Nano.
void(* m6e_nano_callback_t)(const struct device *dev, void *user_data)
Definition m6e_nano.h:95
uint8_t m6e_nano_get_tag_rssi(const struct device *dev)
Retrieve the RSSI of the tag.
void m6e_nano_set_antenna_port(const struct device *dev)
Set the antenna port of the M6E Nano.
void m6e_nano_start_reading(const struct device *dev)
Start a continuous read operation.
int m6e_nano_get_version(const struct device *dev)
Retrieve the firmware version of the M6E Nano.
void m6e_nano_set_read_power(const struct device *dev, uint16_t power)
Set the read power of the M6E Nano.
uint8_t m6e_nano_get_tag_epc_bytes(const struct device *dev)
Retrieve the number of bytes from EPC.
void m6e_nano_set_baud(const struct device *dev, long baud_rate)
Set the baudrate of the M6E Nano.
Definition m6e_nano.h:101
m6e_nano_set_callback_t set_callback
Definition m6e_nano.h:103
Definition m6e_nano.h:134
size_t len
Definition m6e_nano.h:136
uint8_t data[M6E_NANO_BUF_SIZE]
Definition m6e_nano.h:135
size_t msg_len
Definition m6e_nano.h:137
Definition m6e_nano.h:151
const struct device * uart_dev
Definition m6e_nano.h:153
struct m6e_nano_data * data
Definition m6e_nano.h:152
Definition m6e_nano.h:140
m6e_nano_callback_t callback
Definition m6e_nano.h:147
bool debug
Definition m6e_nano.h:141
uint8_t status
Definition m6e_nano.h:142
struct m6e_nano_buf response
Definition m6e_nano.h:144
bool has_response
Definition m6e_nano.h:145
struct m6e_nano_buf command
Definition m6e_nano.h:143
void * user_data
Definition m6e_nano.h:148