acc_hal_integration_espidf_xe121.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "acc_definitions_common.h"
#include "acc_hal_definitions_a121.h"
#include "acc_hal_integration_a121.h"
#include "acc_integration.h"
#include "acc_integration_log.h"
#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "esp_sleep.h"
#include "gpio.h"
#include "FreeRTOS.h"
#include "semphr.h"

Go to the source code of this file.

Macros

#define SENSOR_COUNT   1
 The number of sensors available on the board. More...
 
#define GPIO_SEL0   18
 
#define GPIO_SEL1   5
 
#define GPIO_SEL2   17
 
#define GPIO_ENABLE   23
 
#define GPIO_INTERRUPT   4
 
#define GPIO_SCLK   2
 
#define GPIO_MOSI   3
 
#define GPIO_MISO   21
 
#define GPIO_CS   19
 
#define SPI_MAX_TRANSFER_SIZE   64
 Size of SPI transfer buffer. More...
 
#define SPI_TRANSFER_SPEED   1*1000*1000
 Transfer speed in Hz. More...
 

Functions

static void acc_hal_integration_sensor_transfer (acc_sensor_id_t sensor_id, uint8_t *buffer, size_t buffer_size)
 
static void isr_handler (void *args)
 
bool acc_hal_integration_wait_for_sensor_interrupt (acc_sensor_id_t sensor_id, uint32_t timeout_ms)
 Wait for a sensor interrupt. More...
 
const acc_hal_a121_tacc_hal_rss_integration_get_implementation (void)
 Get hal implementation reference. More...
 
void acc_hal_integration_sensor_supply_on (acc_sensor_id_t sensor_id)
 Power on sensor supply. More...
 
void acc_hal_integration_sensor_supply_off (acc_sensor_id_t sensor_id)
 Power off sensor supply. More...
 
void acc_hal_integration_sensor_enable (acc_sensor_id_t sensor_id)
 Enable sensor. More...
 
void acc_hal_integration_sensor_disable (acc_sensor_id_t sensor_id)
 Disable sensor. More...
 
uint16_t acc_hal_integration_sensor_count (void)
 Get the max number of sensors the integration supports. More...
 

Variables

static spi_device_handle_t spi = NULL
 
static StaticSemaphore_t xSemaphoreBuffer
 
static SemaphoreHandle_t isr_sem = NULL
 
static const acc_hal_a121_t hal
 

Macro Definition Documentation

◆ GPIO_CS

#define GPIO_CS   19

Definition at line 42 of file acc_hal_integration_espidf_xe121.c.

◆ GPIO_ENABLE

#define GPIO_ENABLE   23

Definition at line 35 of file acc_hal_integration_espidf_xe121.c.

◆ GPIO_INTERRUPT

#define GPIO_INTERRUPT   4

Definition at line 37 of file acc_hal_integration_espidf_xe121.c.

◆ GPIO_MISO

#define GPIO_MISO   21

Definition at line 41 of file acc_hal_integration_espidf_xe121.c.

◆ GPIO_MOSI

#define GPIO_MOSI   3

Definition at line 40 of file acc_hal_integration_espidf_xe121.c.

◆ GPIO_SCLK

#define GPIO_SCLK   2

Definition at line 39 of file acc_hal_integration_espidf_xe121.c.

◆ GPIO_SEL0

#define GPIO_SEL0   18

Definition at line 31 of file acc_hal_integration_espidf_xe121.c.

◆ GPIO_SEL1

#define GPIO_SEL1   5

Definition at line 32 of file acc_hal_integration_espidf_xe121.c.

◆ GPIO_SEL2

#define GPIO_SEL2   17

Definition at line 33 of file acc_hal_integration_espidf_xe121.c.

◆ SENSOR_COUNT

#define SENSOR_COUNT   1

The number of sensors available on the board.

Definition at line 29 of file acc_hal_integration_espidf_xe121.c.

◆ SPI_MAX_TRANSFER_SIZE

#define SPI_MAX_TRANSFER_SIZE   64

Size of SPI transfer buffer.

Definition at line 54 of file acc_hal_integration_espidf_xe121.c.

◆ SPI_TRANSFER_SPEED

#define SPI_TRANSFER_SPEED   1*1000*1000

Transfer speed in Hz.

Definition at line 60 of file acc_hal_integration_espidf_xe121.c.

Function Documentation

◆ acc_hal_integration_sensor_count()

uint16_t acc_hal_integration_sensor_count ( void  )

Get the max number of sensors the integration supports.

Returns
The max sensor count

Definition at line 224 of file acc_hal_integration_espidf_xe121.c.

◆ acc_hal_integration_sensor_disable()

void acc_hal_integration_sensor_disable ( acc_sensor_id_t  sensor_id)

Disable sensor.

Parameters
[in]sensor_idThe id of the sensor to disable

Definition at line 214 of file acc_hal_integration_espidf_xe121.c.

◆ acc_hal_integration_sensor_enable()

void acc_hal_integration_sensor_enable ( acc_sensor_id_t  sensor_id)

Enable sensor.

Any pending sensor interrupts should be cleared before returning from function. The sensor supply needs to be enabled by invoking acc_hal_integration_sensor_supply_on before calling this function.

Parameters
[in]sensor_idThe id of the sensor to enable

Definition at line 199 of file acc_hal_integration_espidf_xe121.c.

◆ acc_hal_integration_sensor_supply_off()

void acc_hal_integration_sensor_supply_off ( acc_sensor_id_t  sensor_id)

Power off sensor supply.

Parameters
[in]sensor_idThe id of the sensor to power off

Definition at line 192 of file acc_hal_integration_espidf_xe121.c.

◆ acc_hal_integration_sensor_supply_on()

void acc_hal_integration_sensor_supply_on ( acc_sensor_id_t  sensor_id)

Power on sensor supply.

Parameters
[in]sensor_idThe id of the sensor to power on

Definition at line 185 of file acc_hal_integration_espidf_xe121.c.

◆ acc_hal_integration_sensor_transfer()

static void acc_hal_integration_sensor_transfer ( acc_sensor_id_t  sensor_id,
uint8_t *  buffer,
size_t  buffer_size 
)
static

Definition at line 68 of file acc_hal_integration_espidf_xe121.c.

◆ acc_hal_integration_wait_for_sensor_interrupt()

bool acc_hal_integration_wait_for_sensor_interrupt ( acc_sensor_id_t  sensor_id,
uint32_t  timeout_ms 
)

Wait for a sensor interrupt.

Parameters
[in]sensor_idThe sensor to wait for the interrupt on
[in]timeout_msThe maximum time to wait in milliseconds
Returns
True if an interrupt has occurred within timeout, false if timeout occurred

Definition at line 100 of file acc_hal_integration_espidf_xe121.c.

◆ acc_hal_rss_integration_get_implementation()

const acc_hal_a121_t* acc_hal_rss_integration_get_implementation ( void  )

Get hal implementation reference.

Definition at line 135 of file acc_hal_integration_espidf_xe121.c.

◆ isr_handler()

static void isr_handler ( void *  args)
static

Definition at line 91 of file acc_hal_integration_espidf_xe121.c.

Variable Documentation

◆ hal

◆ isr_sem

SemaphoreHandle_t isr_sem = NULL
static

Definition at line 48 of file acc_hal_integration_espidf_xe121.c.

◆ spi

spi_device_handle_t spi = NULL
static

Definition at line 45 of file acc_hal_integration_espidf_xe121.c.

◆ xSemaphoreBuffer

StaticSemaphore_t xSemaphoreBuffer
static

Definition at line 47 of file acc_hal_integration_espidf_xe121.c.

acc_hal_integration_sensor_transfer
static void acc_hal_integration_sensor_transfer(acc_sensor_id_t sensor_id, uint8_t *buffer, size_t buffer_size)
Definition: acc_hal_integration_espidf_xe121.c:68
acc_integration_log
void acc_integration_log(acc_log_level_t level, const char *module, const char *format,...)
Log function.
Definition: acc_integration_log.c:21