no-OS
max11205.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __MAX11205_H__
34 #define __MAX11205_H__
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdint.h>
40 #include <stdbool.h>
41 #include "no_os_gpio.h"
42 #include "no_os_irq.h"
43 #include "no_os_spi.h"
44 #include "no_os_util.h"
45 
46 /******************************************************************************/
47 /********************** Macros and Constants Definitions **********************/
48 /******************************************************************************/
49 #define MAX11205_VREF_MAX_MV 3600
50 #define MAX11205_DATA_SIZE_BYTES 2
51 #define MAX11205_SCALE NO_OS_GENMASK(14,0)
52 
53 /******************************************************************************/
54 /*************************** Types Declarations *******************************/
55 /******************************************************************************/
56 struct max11205_dev {
66  uint32_t vref_mv;
68  int16_t adc_data_raw;
71 };
72 
81  uint32_t vref_mv;
82 };
83 
84 int max11205_init(struct max11205_dev **device,
86 int max11205_get_data_raw(struct max11205_dev *dev, bool *new_data_avail,
87  int16_t *data_raw);
88 int max11205_get_data_mv(struct max11205_dev *dev, int16_t raw_data,
89  int32_t *data_mv);
90 
91 int max11205_remove(struct max11205_dev *dev);
92 
93 #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:167
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
max11205_init_param
Definition: max11205.h:73
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:159
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:142
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:92
device
Definition: ad9361_util.h:69
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:54
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:124
NO_OS_IRQ_EDGE_FALLING
@ NO_OS_IRQ_EDGE_FALLING
Definition: no_os_irq.h:79
max11205_dev::irq_cb
struct no_os_callback_desc irq_cb
Definition: max11205.h:64
max11205_init
int max11205_init(struct max11205_dev **device, struct max11205_init_param init_param)
Initializes the communication peripheral.
Definition: max11205.c:85
max11205_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: max11205.h:75
MAX11205_DATA_SIZE_BYTES
#define MAX11205_DATA_SIZE_BYTES
Definition: max11205.h:50
max11205_init_param::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: max11205.h:79
max11205_dev::data_updated
bool data_updated
Definition: max11205.h:70
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:112
max11205_init_param::gpio_rdy
struct no_os_gpio_init_param * gpio_rdy
Definition: max11205.h:77
max11205_remove
int max11205_remove(struct max11205_dev *dev)
Free memory allocated by max11205_init().
Definition: max11205.c:203
max11205_init_param::vref_mv
uint32_t vref_mv
Definition: max11205.h:81
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:167
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:104
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:144
max11205_dev
Definition: max11205.h:56
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
max11205_dev::gpio_rdy
struct no_os_gpio_desc * gpio_rdy
Definition: max11205.h:60
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:187
MAX11205_VREF_MAX_MV
#define MAX11205_VREF_MAX_MV
Definition: max11205.h:49
max11205_init
int max11205_init(struct max11205_dev **device, struct max11205_init_param init_param)
Initializes the communication peripheral.
Definition: max11205.c:85
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:69
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
NO_OS_EVT_GPIO
@ NO_OS_EVT_GPIO
Definition: no_os_irq.h:62
MAX11205_SCALE
#define MAX11205_SCALE
Definition: max11205.h:51
max11205_remove
int max11205_remove(struct max11205_dev *dev)
Free memory allocated by max11205_init().
Definition: max11205.c:203
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:116
max11205_dev::vref_mv
uint32_t vref_mv
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:187
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:181
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:68
NO_OS_GPIO_IRQ
@ NO_OS_GPIO_IRQ
Definition: no_os_irq.h:85
max11205_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: max11205.h:58
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:52
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:162
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:198
max11205_dev::irq_ctrl
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: max11205.h:62
no_os_irq_ctrl_desc
Definition: no_os_irq.h:123
no_os_gpio_desc::number
int32_t number
Definition: no_os_gpio.h:100
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:54
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
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:75