no-OS
max11205.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef __MAX11205_H__
40 #define __MAX11205_H__
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include <stdbool.h>
47 #include "no_os_gpio.h"
48 #include "no_os_irq.h"
49 #include "no_os_spi.h"
50 #include "no_os_util.h"
51 
52 /******************************************************************************/
53 /********************** Macros and Constants Definitions **********************/
54 /******************************************************************************/
55 #define MAX11205_VREF_MAX_MV 3600
56 #define MAX11205_DATA_SIZE_BYTES 2
57 #define MAX11205_SCALE NO_OS_GENMASK(14,0)
58 
59 /******************************************************************************/
60 /*************************** Types Declarations *******************************/
61 /******************************************************************************/
62 struct max11205_dev {
72  uint32_t vref_mv;
74  int16_t adc_data_raw;
77 };
78 
87  uint32_t vref_mv;
88 };
89 
90 int max11205_init(struct max11205_dev **device,
92 int max11205_get_data_raw(struct max11205_dev *dev, bool *new_data_avail,
93  int16_t *data_raw);
94 int max11205_get_data_mv(struct max11205_dev *dev, int16_t raw_data,
95  int32_t *data_mv);
96 
97 int max11205_remove(struct max11205_dev *dev);
98 
99 #endif /* __MAX11205_H__ */
max11205_get_data_raw
int max11205_get_data_raw(struct max11205_dev *dev, bool *new_data_avail, int16_t *data_raw)
Get the converted data.
Definition: max11205.c:173
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
max11205_init_param
Definition: max11205.h:79
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:165
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:148
no_os_spi.h
Header file of SPI Interface.
no_os_irq.h
Header file of IRQ interface.
no_os_irq_register_callback
int32_t no_os_irq_register_callback(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, struct no_os_callback_desc *callback_desc)
Register a callback to handle the irq events.
Definition: no_os_irq.c:98
device
Definition: ad9361_util.h:75
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:60
no_os_gpio_direction_input
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:130
NO_OS_IRQ_EDGE_FALLING
@ NO_OS_IRQ_EDGE_FALLING
Definition: no_os_irq.h:85
max11205_dev::irq_cb
struct no_os_callback_desc irq_cb
Definition: max11205.h:70
max11205_init
int max11205_init(struct max11205_dev **device, struct max11205_init_param init_param)
Initializes the communication peripheral.
Definition: max11205.c:91
max11205_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: max11205.h:81
MAX11205_DATA_SIZE_BYTES
#define MAX11205_DATA_SIZE_BYTES
Definition: max11205.h:56
max11205_init_param::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: max11205.h:85
max11205_dev::data_updated
bool data_updated
Definition: max11205.h:76
no_os_irq_unregister_callback
int32_t no_os_irq_unregister_callback(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, struct no_os_callback_desc *callback_desc)
Unregisters a generic IRQ handling function.
Definition: no_os_irq.c:118
max11205_init_param::gpio_rdy
struct no_os_gpio_init_param * gpio_rdy
Definition: max11205.h:83
max11205_remove
int max11205_remove(struct max11205_dev *dev)
Free memory allocated by max11205_init().
Definition: max11205.c:209
max11205_init_param::vref_mv
uint32_t vref_mv
Definition: max11205.h:87
max11205_get_data_raw
int max11205_get_data_raw(struct max11205_dev *dev, bool *new_data_avail, int16_t *data_raw)
Get the converted data.
Definition: max11205.c:173
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:110
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:150
max11205_dev
Definition: max11205.h:62
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
max11205_dev::gpio_rdy
struct no_os_gpio_desc * gpio_rdy
Definition: max11205.h:66
max11205_get_data_mv
int max11205_get_data_mv(struct max11205_dev *dev, int16_t raw_data, int32_t *data_mv)
Get the converted data.
Definition: max11205.c:193
MAX11205_VREF_MAX_MV
#define MAX11205_VREF_MAX_MV
Definition: max11205.h:55
max11205_init
int max11205_init(struct max11205_dev **device, struct max11205_init_param init_param)
Initializes the communication peripheral.
Definition: max11205.c:91
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:75
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
NO_OS_EVT_GPIO
@ NO_OS_EVT_GPIO
Definition: no_os_irq.h:68
MAX11205_SCALE
#define MAX11205_SCALE
Definition: max11205.h:57
max11205_remove
int max11205_remove(struct max11205_dev *dev)
Free memory allocated by max11205_init().
Definition: max11205.c:209
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:122
max11205_dev::vref_mv
uint32_t vref_mv
Definition: max11205.h:72
max11205_get_data_mv
int max11205_get_data_mv(struct max11205_dev *dev, int16_t raw_data, int32_t *data_mv)
Get the converted data.
Definition: max11205.c:193
no_os_irq_enable
int32_t no_os_irq_enable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Enable specific interrupt.
Definition: no_os_irq.c:187
max11205.h
Implementation of max11205.h.
no_os_gpio.h
Header file of GPIO Interface.
max11205_dev::adc_data_raw
int16_t adc_data_raw
Definition: max11205.h:74
NO_OS_GPIO_IRQ
@ NO_OS_GPIO_IRQ
Definition: no_os_irq.h:91
max11205_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: max11205.h:64
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:58
no_os_get_unaligned_be16
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
no_os_util.h
Header file of utility functions.
no_os_irq_trigger_level_set
int32_t no_os_irq_trigger_level_set(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, enum no_os_irq_trig_level trig)
Set interrupt trigger level.
Definition: no_os_irq.c:168
no_os_irq_disable
int32_t no_os_irq_disable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Disable specific interrupt.
Definition: no_os_irq.c:204
max11205_dev::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: max11205.h:68
no_os_irq_ctrl_desc
Definition: no_os_irq.h:129
no_os_gpio_desc::number
int32_t number
Definition: no_os_gpio.h:106
errno.h
Error macro definition for ARM Compiler.
NO_OS_DIV_ROUND_CLOSEST
#define NO_OS_DIV_ROUND_CLOSEST(x, y)
Definition: no_os_util.h:58
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131
no_os_gpio_get_optional
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:81