acc_hal_definitions_a121.h
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2021-2023
2 // All rights reserved
3 
4 #ifndef ACC_HAL_DEFINITIONS_A121_H_
5 #define ACC_HAL_DEFINITIONS_A121_H_
6 
7 #include <inttypes.h>
8 #include <stdbool.h>
9 #include <stdint.h>
10 #include <stdlib.h>
11 
12 #include "acc_definitions_common.h"
13 
14 
15 /**
16  * @brief Specifies the minimal size in bytes that SPI transfers must be able to handle
17  */
18 #define ACC_HAL_SPI_TRANSFER_SIZE_REQUIRED 16U
19 
20 /**
21  * @brief Definition of a memory allocation function
22  *
23  * Allocated memory should be suitably aligned for any built-in type. Returning NULL is seen as failure.
24  */
25 typedef void *(*acc_hal_mem_alloc_function_t)(size_t);
26 
27 
28 /**
29  * @brief Definition of a memory free function
30  *
31  * Free memory which is previously allocated.
32  */
33 typedef void (*acc_hal_mem_free_function_t)(void *);
34 
35 
36 /**
37  * @brief Definition of a sensor transfer function
38  *
39  * This function shall transfer data to and from the sensor over spi. It's beneficial from a performance perspective
40  * to use dma if available.
41  * The buffer is naturally aligned to a maximum of 4 bytes.
42  *
43  */
44 typedef void (*acc_hal_sensor_transfer8_function_t)(acc_sensor_id_t sensor_id, uint8_t *buffer, size_t buffer_size);
45 
46 
47 /**
48  * @brief Definition of an optimized 16-bit sensor transfer function
49  *
50  * This function shall transfer data to and from the sensor over spi with 16 bits data size.
51  * It's beneficial from a performance perspective to use dma if available.
52  * The buffer is naturally aligned to a minimum of 4 bytes.
53  *
54  * If defined it will supersede the normal 8-bit function @ref acc_hal_sensor_transfer8_function_t
55  *
56  */
57 typedef void (*acc_hal_sensor_transfer16_function_t)(acc_sensor_id_t sensor_id, uint16_t *buffer, size_t buffer_length);
58 
59 
60 /**
61  * @brief This struct contains function pointers that are optional to support different optimizations
62  *
63  * Optional
64  *
65  * This struct contains function pointers to support different optimizations.
66  * These optimizations can be utilized for some integrations.
67  * If they are defined, they will override the corresponding non-optimized function.
68  *
69  * For example, if the transfer16 function is implemented, it will be used instead of the transfer function.
70  */
71 typedef struct
72 {
75 
76 
77 /**
78  * @brief Definition of a log function
79  */
80 typedef void (*acc_hal_log_function_t)(acc_log_level_t level, const char *module, const char *format, ...);
81 
82 typedef struct
83 {
85 
92 
93 #endif
acc_hal_sensor_transfer16_function_t
void(* acc_hal_sensor_transfer16_function_t)(acc_sensor_id_t sensor_id, uint16_t *buffer, size_t buffer_length)
Definition of an optimized 16-bit sensor transfer function.
Definition: acc_hal_definitions_a121.h:57
acc_hal_optimization_t
This struct contains function pointers that are optional to support different optimizations.
Definition: acc_hal_definitions_a121.h:71
acc_hal_a121_t::transfer
acc_hal_sensor_transfer8_function_t transfer
Definition: acc_hal_definitions_a121.h:88
acc_hal_log_function_t
void(* acc_hal_log_function_t)(acc_log_level_t level, const char *module, const char *format,...)
Definition of a log function.
Definition: acc_hal_definitions_a121.h:80
acc_hal_a121_t::log
acc_hal_log_function_t log
Definition: acc_hal_definitions_a121.h:89
acc_hal_mem_alloc_function_t
void *(* acc_hal_mem_alloc_function_t)(size_t)
Definition of a memory allocation function.
Definition: acc_hal_definitions_a121.h:25
acc_hal_sensor_transfer8_function_t
void(* acc_hal_sensor_transfer8_function_t)(acc_sensor_id_t sensor_id, uint8_t *buffer, size_t buffer_size)
Definition of a sensor transfer function.
Definition: acc_hal_definitions_a121.h:44
acc_hal_a121_t
Definition: acc_hal_definitions_a121.h:82
acc_log_level_t
acc_log_level_t
This enum represents the different log levels for RSS.
Definition: acc_definitions_common.h:25
acc_hal_a121_t::optimization
acc_hal_optimization_t optimization
Definition: acc_hal_definitions_a121.h:90
acc_hal_mem_free_function_t
void(* acc_hal_mem_free_function_t)(void *)
Definition of a memory free function.
Definition: acc_hal_definitions_a121.h:33
acc_hal_optimization_t::transfer16
acc_hal_sensor_transfer16_function_t transfer16
Definition: acc_hal_definitions_a121.h:73
acc_sensor_id_t
uint32_t acc_sensor_id_t
Type representing a sensor ID.
Definition: acc_definitions_common.h:14
acc_hal_a121_t::max_spi_transfer_size
uint16_t max_spi_transfer_size
Definition: acc_hal_definitions_a121.h:84
acc_hal_a121_t::mem_free
acc_hal_mem_free_function_t mem_free
Definition: acc_hal_definitions_a121.h:87
acc_definitions_common.h
acc_hal_a121_t::mem_alloc
acc_hal_mem_alloc_function_t mem_alloc
Definition: acc_hal_definitions_a121.h:86