Loading...
Searching...
No Matches
ata8520e.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Inria
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License v2.1. See the file LICENSE in the top level directory for more
6 * details.
7 */
8
25#ifndef ATA8520E_H
26#define ATA8520E_H
27
28#include <stdint.h>
29#include <inttypes.h>
30#include "mutex.h"
31#include "periph/gpio.h"
32#include "periph/spi.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
42#define SIGFOX_PAC_LENGTH (16U)
43#define SIGFOX_ID_LENGTH (8U)
44#define SIGFOX_MAX_TX_LENGTH (12U)
45#define SIGFOX_RX_LENGTH (8U)
51enum {
58};
59
63enum {
68};
69
78
94
118
122typedef struct {
123 spi_t spi;
125 gpio_t cs_pin;
126 gpio_t int_pin;
127 gpio_t power_pin;
128 gpio_t reset_pin;
130
140
157
164
172void ata8520e_read_atmel_version(const ata8520e_t *dev, uint8_t *version);
173
181void ata8520e_read_sigfox_version(const ata8520e_t *dev, char *version);
182
190void ata8520e_read_pac(const ata8520e_t *dev, char *pac);
191
199void ata8520e_read_id(const ata8520e_t *dev, char *id);
200
211int ata8520e_send_frame(ata8520e_t *dev, uint8_t *payload, uint8_t payload_len);
212
224int ata8520e_send_receive_frame(ata8520e_t *dev, uint8_t *payload,
225 uint8_t payload_len, uint8_t *rx_payload);
226
236int ata8520e_send_bit(ata8520e_t *dev, bool bit);
237
238#ifdef __cplusplus
239}
240#endif
241
242#endif /* ATA8520E_H */
spi_clk_t
Definition periph_cpu.h:352
Low-level GPIO peripheral driver interface definitions.
void ata8520e_read_atmel_version(const ata8520e_t *dev, uint8_t *version)
Return the Atmel version of the device.
int ata8520e_send_frame(ata8520e_t *dev, uint8_t *payload, uint8_t payload_len)
Send a frame.
int ata8520e_init(ata8520e_t *dev, const ata8520e_params_t *params)
Initialize the device.
void ata8520e_read_id(const ata8520e_t *dev, char *id)
Return the ID of the device.
int ata8520e_send_bit(ata8520e_t *dev, bool bit)
Send a bit.
ata8520e_status_type_t
device module status
Definition ata8520e.h:73
ata8520e_atmel_status_t
Sigfox statuses.
Definition ata8520e.h:84
void ata8520e_read_pac(const ata8520e_t *dev, char *pac)
Return the porting authorization code (PAC) available in the device.
void ata8520e_read_sigfox_version(const ata8520e_t *dev, char *version)
Return the Atmel version of the device.
void ata8520e_system_reset(const ata8520e_t *dev)
Perform a complete reset of the device.
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.
ata8520e_sigfox_status_t
Sigfox statuses.
Definition ata8520e.h:100
@ ATA8520E_STATE_RX
Device is in RX mode, just after TX.
Definition ata8520e.h:67
@ ATA8520E_STATE_TX
Device is in TX mode.
Definition ata8520e.h:66
@ ATA8520E_STATE_IDLE
Device is in idle state.
Definition ata8520e.h:64
@ ATA8520E_STATE_INIT
Device is in initialization phase.
Definition ata8520e.h:65
@ ATA8520E_SIGFOX
Sigfox status.
Definition ata8520e.h:76
@ ATA8520E_SSM
SoC System Management status.
Definition ata8520e.h:74
@ ATA8520E_ATMEL
Atmel status.
Definition ata8520e.h:75
@ ATA8520E_ATMEL_OPENING_ERROR
Opening error.
Definition ata8520e.h:90
@ ATA8520E_ATMEL_FREQUENCY_ERROR
Frequency error.
Definition ata8520e.h:88
@ ATA8520E_ATMEL_COMMAND_ERROR
Command error / not supported.
Definition ata8520e.h:86
@ ATA8520E_ATMEL_OK
No error.
Definition ata8520e.h:85
@ ATA8520E_ATMEL_GENERIC_ERROR
Generic error.
Definition ata8520e.h:87
@ ATA8520E_ATMEL_CLOSING_ERROR
Closing error.
Definition ata8520e.h:91
@ ATA8520E_ATMEL_USAGE_ERROR
Usage error.
Definition ata8520e.h:89
@ ATA8520E_ATMEL_SEND_ERROR
Send error.
Definition ata8520e.h:92
@ ATA8520E_OK
Everything is fine.
Definition ata8520e.h:52
@ ATA8520E_ERR_EVENT_TIMEOUT
An expected event never happened.
Definition ata8520e.h:57
@ ATA8520E_ERR_GPIO_POWER
An error occurred with power pin.
Definition ata8520e.h:56
@ ATA8520E_ERR_GPIO_INT
An error occurred with interrupt pin.
Definition ata8520e.h:54
@ ATA8520E_ERR_GPIO_RESET
An error occurred with reset pin.
Definition ata8520e.h:55
@ ATA8520E_ERR_SPI
An error occurred with SPI.
Definition ata8520e.h:53
@ ATA8520E_SIGFOX_MANUFACTURER_SEND_ERROR
Manufacturer send error.
Definition ata8520e.h:106
@ ATA8520E_SIGFOX_OK
No error.
Definition ata8520e.h:101
@ ATA8520E_SIGFOX_GET_FREQUENCY_ERROR
Error getting frequency.
Definition ata8520e.h:111
@ ATA8520E_SIGFOX_ID_OR_KEY_ERROR
ID or key error.
Definition ata8520e.h:103
@ ATA8520E_SIGFOX_FREQUENCY_ERROR
Frequency error.
Definition ata8520e.h:116
@ ATA8520E_SIGFOX_CALLBACK_ERROR
Callback causes error.
Definition ata8520e.h:114
@ ATA8520E_SIGFOX_GET_PN9_ERROR
Error getting PN9.
Definition ata8520e.h:110
@ ATA8520E_SIGFOX_CLOSE_ERROR
Close issues encountered.
Definition ata8520e.h:108
@ ATA8520E_SIGFOX_DELAY_ROUTINE_ERROR
Error in delay routine.
Definition ata8520e.h:113
@ ATA8520E_SIGFOX_TIMING_ERROR
Timing error.
Definition ata8520e.h:115
@ ATA8520E_SIGFOX_BUILDING_FRAME_ERROR
Error building frame.
Definition ata8520e.h:112
@ ATA8520E_SIGFOX_MANUFACTURER_ERROR
Manufacturer error.
Definition ata8520e.h:102
@ ATA8520E_SIGFOX_GET_VOLTAGE_TEMP_ERROR
Get voltage/temperature error.
Definition ata8520e.h:107
@ ATA8520E_SIGFOX_FRAME_SIZE_ERROR
Frame size error.
Definition ata8520e.h:105
@ ATA8520E_SIGFOX_API_ERROR
API error indication.
Definition ata8520e.h:109
@ ATA8520E_SIGFOX_STATE_MACHINE_ERROR
State machine error.
Definition ata8520e.h:104
Adds include for missing inttype definitions.
Mutex for thread synchronization.
Low-level SPI peripheral driver interface definition.
Initialization parameters.
Definition ata8520e.h:122
spi_clk_t spi_clk
SPI clock speed.
Definition ata8520e.h:124
gpio_t reset_pin
Reset pin.
Definition ata8520e.h:128
gpio_t power_pin
Power pin.
Definition ata8520e.h:127
spi_t spi
SPI device.
Definition ata8520e.h:123
gpio_t cs_pin
Chip select pin.
Definition ata8520e.h:125
gpio_t int_pin
IRQ pin.
Definition ata8520e.h:126
device descriptor
Definition ata8520e.h:134
mutex_t event_lock
mutex for waiting for event
Definition ata8520e.h:138
uint8_t internal_state
current state of the device
Definition ata8520e.h:136
uint8_t event_received
check if an event was received
Definition ata8520e.h:137
ata8520e_params_t params
Device parameters.
Definition ata8520e.h:135
Mutex structure.
Definition mutex.h:146