Microchip ATA8520E transceiver

Device driver for Microchip ATA8520E transceiver (Sigfox) More...

Detailed Description

Device driver for Microchip ATA8520E transceiver (Sigfox)

For more information, please refer to the datasheet http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-9409-Smart-RF-ATA8520E_Datasheet.pdf

Files

file  ata8520e_internals.h
 Internal addresses, registers, constants for the ATA8520E device.
 
file  ata8520e_params.h
 Default initialization parameters for the ATA8520E device.
 
file  ata8520e.h
 Device driver for Microchip ATA8520E transceiver (Sigfox)
 

Data Structures

struct  ata8520e_params_t
 Initialization parameters. More...
 
struct  ata8520e_t
 device descriptor More...
 

Enumerations

enum  {
  ATA8520E_OK = 0, ATA8520E_ERR_SPI, ATA8520E_ERR_GPIO_INT, ATA8520E_ERR_GPIO_RESET,
  ATA8520E_ERR_GPIO_POWER, ATA8520E_ERR_EVENT_TIMEOUT
}
 return codes More...
 
enum  { ATA8520E_STATE_IDLE, ATA8520E_STATE_INIT, ATA8520E_STATE_TX, ATA8520E_STATE_RX }
 device internal states More...
 
enum  ata8520e_status_type_t { ATA8520E_SSM, ATA8520E_ATMEL, ATA8520E_SIGFOX }
 device module status More...
 
enum  ata8520e_atmel_status_t {
  ATA8520E_ATMEL_OK, ATA8520E_ATMEL_COMMAND_ERROR, ATA8520E_ATMEL_GENERIC_ERROR, ATA8520E_ATMEL_FREQUENCY_ERROR,
  ATA8520E_ATMEL_USAGE_ERROR, ATA8520E_ATMEL_OPENING_ERROR, ATA8520E_ATMEL_CLOSING_ERROR, ATA8520E_ATMEL_SEND_ERROR
}
 Sigfox statuses. More...
 
enum  ata8520e_sigfox_status_t {
  ATA8520E_SIGFOX_OK, ATA8520E_SIGFOX_MANUFACTURER_ERROR, ATA8520E_SIGFOX_ID_OR_KEY_ERROR, ATA8520E_SIGFOX_STATE_MACHINE_ERROR,
  ATA8520E_SIGFOX_FRAME_SIZE_ERROR, ATA8520E_SIGFOX_MANUFACTURER_SEND_ERROR, ATA8520E_SIGFOX_GET_VOLTAGE_TEMP_ERROR, ATA8520E_SIGFOX_CLOSE_ERROR,
  ATA8520E_SIGFOX_API_ERROR, ATA8520E_SIGFOX_GET_PN9_ERROR, ATA8520E_SIGFOX_GET_FREQUENCY_ERROR, ATA8520E_SIGFOX_BUILDING_FRAME_ERROR,
  ATA8520E_SIGFOX_DELAY_ROUTINE_ERROR, ATA8520E_SIGFOX_CALLBACK_ERROR, ATA8520E_SIGFOX_TIMING_ERROR, ATA8520E_SIGFOX_FREQUENCY_ERROR
}
 Sigfox statuses. More...
 

Functions

int ata8520e_init (ata8520e_t *dev, const ata8520e_params_t *params)
 Initialize the device. More...
 
void ata8520e_system_reset (const ata8520e_t *dev)
 Perform a complete reset of the device. More...
 
void ata8520e_read_atmel_version (const ata8520e_t *dev, uint8_t *version)
 Return the Atmel version of the device. More...
 
void ata8520e_read_sigfox_version (const ata8520e_t *dev, char *version)
 Return the Atmel version of the device. More...
 
void ata8520e_read_pac (const ata8520e_t *dev, char *pac)
 Return the porting authorization code (PAC) available in the device. More...
 
void ata8520e_read_id (const ata8520e_t *dev, char *id)
 Return the ID of the device. More...
 
int ata8520e_send_frame (ata8520e_t *dev, uint8_t *payload, uint8_t payload_len)
 Send a frame. More...
 
int ata8520e_send_receive_frame (ata8520e_t *dev, uint8_t *payload, uint8_t payload_len, uint8_t *rx_payload)
 Send a frame and wait for a RX packet. More...
 
int ata8520e_send_bit (ata8520e_t *dev, bool bit)
 Send a bit. More...
 

SIGFOX constants

#define SIGFOX_PAC_LENGTH   (16U)
 Length of Sigfox PAC.
 
#define SIGFOX_ID_LENGTH   (8U)
 Length of Sigfox ID.
 
#define SIGFOX_MAX_TX_LENGTH   (12U)
 Maximum length of a TX payload.
 
#define SIGFOX_RX_LENGTH   (8U)
 RX payload length is always 8.
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

return codes

Enumerator
ATA8520E_OK 

Everything is fine.

ATA8520E_ERR_SPI 

An error occurred with SPI.

ATA8520E_ERR_GPIO_INT 

An error occurred with interrupt pin.

ATA8520E_ERR_GPIO_RESET 

An error occurred with reset pin.

ATA8520E_ERR_GPIO_POWER 

An error occurred with power pin.

ATA8520E_ERR_EVENT_TIMEOUT 

An expected event never happened.

Definition at line 51 of file ata8520e.h.

◆ anonymous enum

anonymous enum

device internal states

Enumerator
ATA8520E_STATE_IDLE 

Device is in idle state.

ATA8520E_STATE_INIT 

Device is in initialization phase.

ATA8520E_STATE_TX 

Device is in TX mode.

ATA8520E_STATE_RX 

Device is in RX mode, just after TX.

Definition at line 63 of file ata8520e.h.

◆ ata8520e_atmel_status_t

Sigfox statuses.

See ATA8520E datasheet, section 2.1.2.10, page 12

Enumerator
ATA8520E_ATMEL_OK 

No error.

ATA8520E_ATMEL_COMMAND_ERROR 

Command error / not supported.

ATA8520E_ATMEL_GENERIC_ERROR 

Generic error.

ATA8520E_ATMEL_FREQUENCY_ERROR 

Frequency error.

ATA8520E_ATMEL_USAGE_ERROR 

Usage error.

ATA8520E_ATMEL_OPENING_ERROR 

Opening error.

ATA8520E_ATMEL_CLOSING_ERROR 

Closing error.

ATA8520E_ATMEL_SEND_ERROR 

Send error.

Definition at line 84 of file ata8520e.h.

◆ ata8520e_sigfox_status_t

Sigfox statuses.

See ATA8520E datasheet, section 2.1.2.10, page 12

Enumerator
ATA8520E_SIGFOX_OK 

No error.

ATA8520E_SIGFOX_MANUFACTURER_ERROR 

Manufacturer error.

ATA8520E_SIGFOX_ID_OR_KEY_ERROR 

ID or key error.

ATA8520E_SIGFOX_STATE_MACHINE_ERROR 

State machine error.

ATA8520E_SIGFOX_FRAME_SIZE_ERROR 

Frame size error.

ATA8520E_SIGFOX_MANUFACTURER_SEND_ERROR 

Manufacturer send error.

ATA8520E_SIGFOX_GET_VOLTAGE_TEMP_ERROR 

Get voltage/temperature error.

ATA8520E_SIGFOX_CLOSE_ERROR 

Close issues encountered.

ATA8520E_SIGFOX_API_ERROR 

API error indication.

ATA8520E_SIGFOX_GET_PN9_ERROR 

Error getting PN9.

ATA8520E_SIGFOX_GET_FREQUENCY_ERROR 

Error getting frequency.

ATA8520E_SIGFOX_BUILDING_FRAME_ERROR 

Error building frame.

ATA8520E_SIGFOX_DELAY_ROUTINE_ERROR 

Error in delay routine.

ATA8520E_SIGFOX_CALLBACK_ERROR 

Callback causes error.

ATA8520E_SIGFOX_TIMING_ERROR 

Timing error.

ATA8520E_SIGFOX_FREQUENCY_ERROR 

Frequency error.

Definition at line 100 of file ata8520e.h.

◆ ata8520e_status_type_t

device module status

Enumerator
ATA8520E_SSM 

SoC System Management status.

ATA8520E_ATMEL 

Atmel status.

ATA8520E_SIGFOX 

Sigfox status.

Definition at line 73 of file ata8520e.h.

Function Documentation

◆ ata8520e_init()

int ata8520e_init ( ata8520e_t dev,
const ata8520e_params_t params 
)

Initialize the device.

This will also initialize the CS pin as a GPIO output, without pull resistors and the interrupt pin handler to manage events.

Parameters
[out]devPointer to device descriptor
[in]paramsPointer to SPI settings
Returns
ATA8520E_OK on success
-ATA8520E_ERR_SPI on SPI initialization error
-ATA8520E_ERR_GPIO_INT on interrupt pin initialization error
-ATA8520E_ERR_GPIO_RESET on reset pin initialization error
-ATA8520E_ERR_GPIO_POWER on power pin initialization error

◆ ata8520e_read_atmel_version()

void ata8520e_read_atmel_version ( const ata8520e_t dev,
uint8_t *  version 
)

Return the Atmel version of the device.

Parameters
[in]devPointer to device descriptor
[out]versionPointer to the string containing the version, must be able to hold 2 characters

◆ ata8520e_read_id()

void ata8520e_read_id ( const ata8520e_t dev,
char *  id 
)

Return the ID of the device.

Parameters
[in]devPointer to device descriptor
[out]idString containing the ID, must be able to hold 9 characters

◆ ata8520e_read_pac()

void ata8520e_read_pac ( const ata8520e_t dev,
char *  pac 
)

Return the porting authorization code (PAC) available in the device.

Parameters
[in]devPointer to device descriptor
[out]pacString containing the pac, must be able to hold 17 characters

◆ ata8520e_read_sigfox_version()

void ata8520e_read_sigfox_version ( const ata8520e_t dev,
char *  version 
)

Return the Atmel version of the device.

Parameters
[in]devPointer to device descriptor
[out]versionString containing the version, must be able to hold 11 characters

◆ ata8520e_send_bit()

int ata8520e_send_bit ( ata8520e_t dev,
bool  bit 
)

Send a bit.

Parameters
[in]devPointer to device descriptor
[in]bitThe bit to send
Returns
ATA8520E_OK if the send was successful
-ATA8520E_ERR_EVENT_TIMEOUT if the send failed

◆ ata8520e_send_frame()

int ata8520e_send_frame ( ata8520e_t dev,
uint8_t *  payload,
uint8_t  payload_len 
)

Send a frame.

Parameters
[in]devPointer to device descriptor
[in]payloadThe payload to send
[in]payload_lenThe length of the payload to send
Returns
ATA8520E_OK if the send was successful
-ATA8520E_ERR_EVENT_TIMEOUT if the send failed

◆ ata8520e_send_receive_frame()

int ata8520e_send_receive_frame ( ata8520e_t dev,
uint8_t *  payload,
uint8_t  payload_len,
uint8_t *  rx_payload 
)

Send a frame and wait for a RX packet.

Parameters
[in]devPointer to device descriptor
[in]payloadThe payload to send
[in]payload_lenThe length of the payload to send
[out]rx_payloadThe payload received
Returns
ATA8520E_OK if the send was successful
-ATA8520E_ERR_EVENT_TIMEOUT if the send failed

◆ ata8520e_system_reset()

void ata8520e_system_reset ( const ata8520e_t dev)

Perform a complete reset of the device.

Parameters
[in]devPointer to device descriptor