Loading...
Searching...
No Matches
m6e_nano.h File Reference
#include <zephyr/kernel.h>
#include <zephyr/device.h>

Go to the source code of this file.

Classes

struct  m6e_nano_api
 
struct  m6e_nano_buf
 
struct  m6e_nano_data
 
struct  m6e_nano_config
 

Macros

#define M6E_NANO_BUF_SIZE   255
 
#define M6E_NANO_MAX_TAGS   150
 
#define TMR_START_HEADER   0xFF
 
#define TMR_SR_OPCODE_VERSION   0x03
 
#define TMR_SR_OPCODE_VERSION_STARTUP   0x04
 
#define TMR_SR_OPCODE_SET_BAUD_RATE   0x06
 
#define TMR_SR_OPCODE_READ_TAG_ID_SINGLE   0x21
 
#define TMR_SR_OPCODE_READ_TAG_ID_MULTIPLE   0x22
 
#define TMR_SR_OPCODE_WRITE_TAG_ID   0x23
 
#define TMR_SR_OPCODE_WRITE_TAG_DATA   0x24
 
#define TMR_SR_OPCODE_KILL_TAG   0x26
 
#define TMR_SR_OPCODE_READ_TAG_DATA   0x28
 
#define TMR_SR_OPCODE_CLEAR_TAG_ID_BUFFER   0x2A
 
#define TMR_SR_OPCODE_MULTI_PROTOCOL_TAG_OP   0x2F
 
#define TMR_SR_OPCODE_GET_READ_TX_POWER   0x62
 
#define TMR_SR_OPCODE_GET_WRITE_TX_POWER   0x64
 
#define TMR_SR_OPCODE_GET_USER_GPIO_INPUTS   0x66
 
#define TMR_SR_OPCODE_GET_POWER_MODE   0x68
 
#define TMR_SR_OPCODE_GET_READER_OPTIONAL_PARAMS   0x6A
 
#define TMR_SR_OPCODE_GET_PROTOCOL_PARAM   0x6B
 
#define TMR_SR_OPCODE_SET_ANTENNA_PORT   0x91
 
#define TMR_SR_OPCODE_SET_TAG_PROTOCOL   0x93
 
#define TMR_SR_OPCODE_SET_READ_TX_POWER   0x92
 
#define TMR_SR_OPCODE_SET_WRITE_TX_POWER   0x94
 
#define TMR_SR_OPCODE_SET_USER_GPIO_OUTPUTS   0x96
 
#define TMR_SR_OPCODE_SET_REGION   0x97
 
#define TMR_SR_OPCODE_SET_POWER_MODE   0x98
 
#define TMR_SR_OPCODE_SET_READER_OPTIONAL_PARAMS   0x9A
 
#define TMR_SR_OPCODE_SET_PROTOCOL_PARAM   0x9B
 
#define TMR_SR_POWER_MODE_FULL   0x00
 
#define TMR_SR_POWER_MODE_MIN_SAVE   0x01
 
#define TMR_SR_POWER_MODE_MED_SAVE   0x02
 
#define TMR_SR_POWER_MODE_MAX_SAVE   0x03
 
#define COMMAND_TIME_OUT   2000
 
#define RESPONSE_PENDING   0
 
#define ERROR_COMMAND_RESPONSE_TIMEOUT   1
 
#define ERROR_CORRUPT_RESPONSE   2
 
#define ERROR_WRONG_OPCODE_RESPONSE   3
 
#define ERROR_UNKNOWN_OPCODE   4
 
#define RESPONSE_IS_TEMPERATURE   5
 
#define RESPONSE_IS_KEEPALIVE   6
 
#define RESPONSE_IS_TEMPTHROTTLE   7
 
#define RESPONSE_IS_TAGFOUND   8
 
#define RESPONSE_IS_NOTAGFOUND   9
 
#define RESPONSE_IS_UNKNOWN   10
 
#define RESPONSE_SUCCESS   11
 
#define RESPONSE_FAIL   12
 
#define RESPONSE_CLEAR   13
 
#define RESPONSE_STARTUP   14
 
#define REGION_INDIA   0x04
 
#define REGION_JAPAN   0x05
 
#define REGION_CHINA   0x06
 
#define REGION_EUROPE   0x08
 
#define REGION_KOREA   0x09
 
#define REGION_AUSTRALIA   0x0B
 
#define REGION_NEWZEALAND   0x0C
 
#define REGION_NORTHAMERICA   0x0D
 
#define REGION_OPEN   0xFF
 
#define TMR_TAG_PROTOCOL_NONE   0x00
 
#define TMR_TAG_PROTOCOL_ISO180006B   0x03
 
#define TMR_TAG_PROTOCOL_GEN2   0x05
 
#define TMR_TAG_PROTOCOL_ISO180006B_UCODE   0x06
 
#define TMR_TAG_PROTOCOL_IPX64   0x07
 
#define TMR_TAG_PROTOCOL_IPX256   0x08
 
#define TMR_TAG_PROTOCOL_ATA   0x1D
 
#define CFG_M6E_NANO_SERIAL_TIMEOUT   1000
 

Typedefs

typedef int(* m6e_nano_send_command_t) (const struct device *dev, uint8_t *command, const uint8_t length, bool timeout)
 
typedef void(* m6e_nano_callback_t) (const struct device *dev, void *user_data)
 
typedef void(* m6e_nano_set_callback_t) (const struct device *dev, m6e_nano_callback_t callback, void *user_data)
 

Functions

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.
 
uint8_t m6e_nano_get_tag_epc_bytes (const struct device *dev)
 Retrieve the number of bytes from EPC.
 
uint8_t m6e_nano_get_tag_rssi (const struct device *dev)
 Retrieve the RSSI of the tag.
 
uint16_t m6e_nano_get_tag_timestamp (const struct device *dev)
 Retrieve the timestamp of the tag.
 
uint32_t m6e_nano_get_tag_freq (const struct device *dev)
 Retrieve the frequency of the tag.
 
void m6e_nano_disable_read_filter (const struct device *dev)
 Disable the read filter.
 
void m6e_nano_stop_reading (const struct device *dev)
 Stop a continuous read operation.
 
void m6e_nano_set_power_mode (const struct device *dev, uint8_t mode)
 Set the power mode of the M6E Nano.
 
void m6e_nano_set_antenna_port (const struct device *dev)
 Set the antenna port 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.
 
void m6e_nano_start_reading (const struct device *dev)
 Start a continuous read operation.
 
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.
 
int m6e_nano_get_version (const struct device *dev)
 Retrieve the firmware version of the M6E Nano.
 
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_set_baud (const struct device *dev, long baud_rate)
 Set the baudrate of the M6E Nano.
 
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.
 
uint8_t m6e_nano_parse_response (const struct device *dev)
 Parse the tag response from the M6E Nano.
 

Macro Definition Documentation

◆ CFG_M6E_NANO_SERIAL_TIMEOUT

#define CFG_M6E_NANO_SERIAL_TIMEOUT   1000

◆ COMMAND_TIME_OUT

#define COMMAND_TIME_OUT   2000

◆ ERROR_COMMAND_RESPONSE_TIMEOUT

#define ERROR_COMMAND_RESPONSE_TIMEOUT   1

◆ ERROR_CORRUPT_RESPONSE

#define ERROR_CORRUPT_RESPONSE   2

◆ ERROR_UNKNOWN_OPCODE

#define ERROR_UNKNOWN_OPCODE   4

◆ ERROR_WRONG_OPCODE_RESPONSE

#define ERROR_WRONG_OPCODE_RESPONSE   3

◆ M6E_NANO_BUF_SIZE

#define M6E_NANO_BUF_SIZE   255

◆ M6E_NANO_MAX_TAGS

#define M6E_NANO_MAX_TAGS   150

◆ REGION_AUSTRALIA

#define REGION_AUSTRALIA   0x0B

◆ REGION_CHINA

#define REGION_CHINA   0x06

◆ REGION_EUROPE

#define REGION_EUROPE   0x08

◆ REGION_INDIA

#define REGION_INDIA   0x04

◆ REGION_JAPAN

#define REGION_JAPAN   0x05

◆ REGION_KOREA

#define REGION_KOREA   0x09

◆ REGION_NEWZEALAND

#define REGION_NEWZEALAND   0x0C

◆ REGION_NORTHAMERICA

#define REGION_NORTHAMERICA   0x0D

◆ REGION_OPEN

#define REGION_OPEN   0xFF

◆ RESPONSE_CLEAR

#define RESPONSE_CLEAR   13

◆ RESPONSE_FAIL

#define RESPONSE_FAIL   12

◆ RESPONSE_IS_KEEPALIVE

#define RESPONSE_IS_KEEPALIVE   6

◆ RESPONSE_IS_NOTAGFOUND

#define RESPONSE_IS_NOTAGFOUND   9

◆ RESPONSE_IS_TAGFOUND

#define RESPONSE_IS_TAGFOUND   8

◆ RESPONSE_IS_TEMPERATURE

#define RESPONSE_IS_TEMPERATURE   5

◆ RESPONSE_IS_TEMPTHROTTLE

#define RESPONSE_IS_TEMPTHROTTLE   7

◆ RESPONSE_IS_UNKNOWN

#define RESPONSE_IS_UNKNOWN   10

◆ RESPONSE_PENDING

#define RESPONSE_PENDING   0

◆ RESPONSE_STARTUP

#define RESPONSE_STARTUP   14

◆ RESPONSE_SUCCESS

#define RESPONSE_SUCCESS   11

◆ TMR_SR_OPCODE_CLEAR_TAG_ID_BUFFER

#define TMR_SR_OPCODE_CLEAR_TAG_ID_BUFFER   0x2A

◆ TMR_SR_OPCODE_GET_POWER_MODE

#define TMR_SR_OPCODE_GET_POWER_MODE   0x68

◆ TMR_SR_OPCODE_GET_PROTOCOL_PARAM

#define TMR_SR_OPCODE_GET_PROTOCOL_PARAM   0x6B

◆ TMR_SR_OPCODE_GET_READ_TX_POWER

#define TMR_SR_OPCODE_GET_READ_TX_POWER   0x62

◆ TMR_SR_OPCODE_GET_READER_OPTIONAL_PARAMS

#define TMR_SR_OPCODE_GET_READER_OPTIONAL_PARAMS   0x6A

◆ TMR_SR_OPCODE_GET_USER_GPIO_INPUTS

#define TMR_SR_OPCODE_GET_USER_GPIO_INPUTS   0x66

◆ TMR_SR_OPCODE_GET_WRITE_TX_POWER

#define TMR_SR_OPCODE_GET_WRITE_TX_POWER   0x64

◆ TMR_SR_OPCODE_KILL_TAG

#define TMR_SR_OPCODE_KILL_TAG   0x26

◆ TMR_SR_OPCODE_MULTI_PROTOCOL_TAG_OP

#define TMR_SR_OPCODE_MULTI_PROTOCOL_TAG_OP   0x2F

◆ TMR_SR_OPCODE_READ_TAG_DATA

#define TMR_SR_OPCODE_READ_TAG_DATA   0x28

◆ TMR_SR_OPCODE_READ_TAG_ID_MULTIPLE

#define TMR_SR_OPCODE_READ_TAG_ID_MULTIPLE   0x22

◆ TMR_SR_OPCODE_READ_TAG_ID_SINGLE

#define TMR_SR_OPCODE_READ_TAG_ID_SINGLE   0x21

◆ TMR_SR_OPCODE_SET_ANTENNA_PORT

#define TMR_SR_OPCODE_SET_ANTENNA_PORT   0x91

◆ TMR_SR_OPCODE_SET_BAUD_RATE

#define TMR_SR_OPCODE_SET_BAUD_RATE   0x06

◆ TMR_SR_OPCODE_SET_POWER_MODE

#define TMR_SR_OPCODE_SET_POWER_MODE   0x98

◆ TMR_SR_OPCODE_SET_PROTOCOL_PARAM

#define TMR_SR_OPCODE_SET_PROTOCOL_PARAM   0x9B

◆ TMR_SR_OPCODE_SET_READ_TX_POWER

#define TMR_SR_OPCODE_SET_READ_TX_POWER   0x92

◆ TMR_SR_OPCODE_SET_READER_OPTIONAL_PARAMS

#define TMR_SR_OPCODE_SET_READER_OPTIONAL_PARAMS   0x9A

◆ TMR_SR_OPCODE_SET_REGION

#define TMR_SR_OPCODE_SET_REGION   0x97

◆ TMR_SR_OPCODE_SET_TAG_PROTOCOL

#define TMR_SR_OPCODE_SET_TAG_PROTOCOL   0x93

◆ TMR_SR_OPCODE_SET_USER_GPIO_OUTPUTS

#define TMR_SR_OPCODE_SET_USER_GPIO_OUTPUTS   0x96

◆ TMR_SR_OPCODE_SET_WRITE_TX_POWER

#define TMR_SR_OPCODE_SET_WRITE_TX_POWER   0x94

◆ TMR_SR_OPCODE_VERSION

#define TMR_SR_OPCODE_VERSION   0x03

◆ TMR_SR_OPCODE_VERSION_STARTUP

#define TMR_SR_OPCODE_VERSION_STARTUP   0x04

◆ TMR_SR_OPCODE_WRITE_TAG_DATA

#define TMR_SR_OPCODE_WRITE_TAG_DATA   0x24

◆ TMR_SR_OPCODE_WRITE_TAG_ID

#define TMR_SR_OPCODE_WRITE_TAG_ID   0x23

◆ TMR_SR_POWER_MODE_FULL

#define TMR_SR_POWER_MODE_FULL   0x00

◆ TMR_SR_POWER_MODE_MAX_SAVE

#define TMR_SR_POWER_MODE_MAX_SAVE   0x03

◆ TMR_SR_POWER_MODE_MED_SAVE

#define TMR_SR_POWER_MODE_MED_SAVE   0x02

◆ TMR_SR_POWER_MODE_MIN_SAVE

#define TMR_SR_POWER_MODE_MIN_SAVE   0x01

◆ TMR_START_HEADER

#define TMR_START_HEADER   0xFF

◆ TMR_TAG_PROTOCOL_ATA

#define TMR_TAG_PROTOCOL_ATA   0x1D

◆ TMR_TAG_PROTOCOL_GEN2

#define TMR_TAG_PROTOCOL_GEN2   0x05

◆ TMR_TAG_PROTOCOL_IPX256

#define TMR_TAG_PROTOCOL_IPX256   0x08

◆ TMR_TAG_PROTOCOL_IPX64

#define TMR_TAG_PROTOCOL_IPX64   0x07

◆ TMR_TAG_PROTOCOL_ISO180006B

#define TMR_TAG_PROTOCOL_ISO180006B   0x03

◆ TMR_TAG_PROTOCOL_ISO180006B_UCODE

#define TMR_TAG_PROTOCOL_ISO180006B_UCODE   0x06

◆ TMR_TAG_PROTOCOL_NONE

#define TMR_TAG_PROTOCOL_NONE   0x00

Typedef Documentation

◆ m6e_nano_callback_t

typedef void(* m6e_nano_callback_t) (const struct device *dev, void *user_data)

◆ m6e_nano_send_command_t

typedef int(* m6e_nano_send_command_t) (const struct device *dev, uint8_t *command, const uint8_t length, bool timeout)

◆ m6e_nano_set_callback_t

typedef void(* m6e_nano_set_callback_t) (const struct device *dev, m6e_nano_callback_t callback, void *user_data)

Function Documentation

◆ m6e_nano_disable_read_filter()

void m6e_nano_disable_read_filter ( const struct device * dev)

Disable the read filter.

Parameters
devUART peripheral device.

◆ m6e_nano_get_tag_epc_bytes()

uint8_t m6e_nano_get_tag_epc_bytes ( const struct device * dev)

Retrieve the number of bytes from EPC.

Parameters
devUART peripheral device.
Returns
uint8_t Number of bytes from EPC.

◆ m6e_nano_get_tag_freq()

uint32_t m6e_nano_get_tag_freq ( const struct device * dev)

Retrieve the frequency of the tag.

Parameters
devUART peripheral device.
Returns
uint32_t Frequency of the tag.

◆ m6e_nano_get_tag_rssi()

uint8_t m6e_nano_get_tag_rssi ( const struct device * dev)

Retrieve the RSSI of the tag.

Parameters
devUART peripheral device.
Returns
uint8_t RSSI of the tag.

◆ m6e_nano_get_tag_timestamp()

uint16_t m6e_nano_get_tag_timestamp ( const struct device * dev)

Retrieve the timestamp of the tag.

Parameters
devUART peripheral device.
Returns
uint16_t Timestamp of the tag.

◆ m6e_nano_get_version()

int m6e_nano_get_version ( const struct device * dev)

Retrieve the firmware version of the M6E Nano.

Parameters
devUART peripheral device.

◆ m6e_nano_get_write_power()

void m6e_nano_get_write_power ( const struct device * dev)

Retrieve the write power of the M6E Nano.

Parameters
devUART peripheral device.

◆ m6e_nano_parse_response()

uint8_t m6e_nano_parse_response ( const struct device * dev)

Parse the tag response from the M6E Nano.

Parameters
devUART peripheral device.
Returns
uint8_t Status of the response.

◆ m6e_nano_send_generic_command()

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.

Parameters
devUART peripheral device.
commandCommand to be sent.
sizeSize of command.
opcodeOpcode to be packed.

◆ m6e_nano_set_antenna_port()

void m6e_nano_set_antenna_port ( const struct device * dev)

Set the antenna port of the M6E Nano.

Parameters
devUART peripheral device.

◆ m6e_nano_set_baud()

void m6e_nano_set_baud ( const struct device * dev,
long baud_rate )

Set the baudrate of the M6E Nano.

Parameters
devUART peripheral device.
baud_ratebaudrate to set.

◆ m6e_nano_set_power_mode()

void m6e_nano_set_power_mode ( const struct device * dev,
uint8_t mode )

Set the power mode of the M6E Nano.

Parameters
devUART peripheral device.
modePower mode to set. See docs for valid modes.

◆ m6e_nano_set_read_power()

void m6e_nano_set_read_power ( const struct device * dev,
uint16_t power )

Set the read power of the M6E Nano.

Parameters
devUART peripheral device.
powerPower to set. Between 0 and 27dBm.

◆ m6e_nano_set_region()

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.

Parameters
devUART peripheral device.
regionOperating region to set.

◆ m6e_nano_set_tag_protocol()

void m6e_nano_set_tag_protocol ( const struct device * dev,
uint8_t protocol )

Set the tag protocol of the M6E Nano.

Parameters
devUART peripheral device.
protocolTag protocol to set.

◆ m6e_nano_start_reading()

void m6e_nano_start_reading ( const struct device * dev)

Start a continuous read operation.

Parameters
devUART peripheral device.

◆ m6e_nano_stop_reading()

void m6e_nano_stop_reading ( const struct device * dev)

Stop a continuous read operation.

Parameters
devUART peripheral device.

◆ user_send_command()

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.

Parameters
devUART peripheral device.
commandCommand to be transmitted.
lengthLength of the command.
timeoutWhether to wait for a response from the module.
Returns
int Status of the command.