no-OS
ltc2358.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef LTC2358_H
41 #define LTC2358_H
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 
47 #include <stdint.h>
48 #include "no_os_spi.h"
49 #include "no_os_util.h"
50 
51 /******************************************************************************/
52 /********************** Macros and Constants Definitions **********************/
53 /******************************************************************************/
54 
55 #define LTC2358_BYTES_PER_CH 3
56 #define LTC2358_CHANNEL_MSK NO_OS_GENMASK(2, 0)
57 
58 /******************************************************************************/
59 /*************************** Types Declarations *******************************/
60 /******************************************************************************/
61 
67  /* SPI Initialization structure. */
69 };
70 
75 struct ltc2358_dev {
76  /* SPI handler */
78 };
79 
80 /******************************************************************************/
81 /************************ Functions Declarations ******************************/
82 /******************************************************************************/
83 
84 /* Creates 24-bit configuration word for the 8 channels. */
85 void ltc2358_create_config_word(uint8_t channel, uint8_t config_number,
86  uint32_t *config_word);
87 
88 /* Parse single channel data. */
89 int32_t ltc2358_channel_data(struct ltc2358_dev *dev, uint32_t config_word,
90  uint8_t data_array[24], uint8_t channel, uint32_t *readval);
91 
92 /* Initializes the LTC2358. */
93 int32_t ltc2358_init(struct ltc2358_dev **device,
95 
96 /* Free the resources allocated by ltc2358_init(). */
97 int32_t ltc2358_remove(struct ltc2358_dev *dev);
98 
99 #endif /* LTC2358_H */
ltc2358_create_config_word
void ltc2358_create_config_word(uint8_t channel, uint8_t config_number, uint32_t *config_word)
Create 24-bit configuration word for the 8 channels.
Definition: ltc2358.c:59
ltc2358_channel_data
int32_t ltc2358_channel_data(struct ltc2358_dev *dev, uint32_t config_word, uint8_t data_array[24], uint8_t channel, uint32_t *readval)
Read single channel data.
Definition: ltc2358.c:102
no_os_put_unaligned_be24
void no_os_put_unaligned_be24(uint32_t val, uint8_t *buf)
ltc2358_init
int32_t ltc2358_init(struct ltc2358_dev **device, struct ltc2358_init_param *init_param)
Initialize the device.
Definition: ltc2358.c:124
no_os_alloc.h
no_os_spi.h
Header file of SPI Interface.
no_os_spi_msg
Definition: no_os_spi.h:91
device
Definition: ad9361_util.h:75
ltc2358_channel_data
int32_t ltc2358_channel_data(struct ltc2358_dev *dev, uint32_t config_word, uint8_t data_array[24], uint8_t channel, uint32_t *readval)
Read single channel data.
Definition: ltc2358.c:102
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
LTC2358_CHANNEL_MSK
#define LTC2358_CHANNEL_MSK
Definition: ltc2358.h:56
no_os_spi_msg::tx_buff
uint8_t * tx_buff
Definition: no_os_spi.h:93
ltc2358_init_param
Structure holding the parameters for ltc2358 initialization.
Definition: ltc2358.h:66
no_os_get_unaligned_be24
uint32_t no_os_get_unaligned_be24(uint8_t *buf)
ltc2358.h
Implementation of LTC2358 Driver.
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
ltc2358_create_config_word
void ltc2358_create_config_word(uint8_t channel, uint8_t config_number, uint32_t *config_word)
Create 24-bit configuration word for the 8 channels.
Definition: ltc2358.c:59
ltc2358_remove
int32_t ltc2358_remove(struct ltc2358_dev *dev)
Free memory allocated by ltc2358_init().
Definition: ltc2358.c:152
no_os_spi_transfer
int32_t no_os_spi_transfer(struct no_os_spi_desc *desc, struct no_os_spi_msg *msgs, uint32_t len)
Iterate over head list and send all spi messages.
Definition: no_os_spi.c:191
ltc2358_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ltc2358.h:77
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
LTC2358_BYTES_PER_CH
#define LTC2358_BYTES_PER_CH
Definition: ltc2358.h:55
ltc2358_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: ltc2358.h:68
ltc2358_dev
Structure holding ltc2358 descriptor.
Definition: ltc2358.h:75
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
ltc2358_remove
int32_t ltc2358_remove(struct ltc2358_dev *dev)
Free memory allocated by ltc2358_init().
Definition: ltc2358.c:152
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_util.h
Header file of utility functions.
errno.h
Error macro definition for ARM Compiler.
ltc2358_init
int32_t ltc2358_init(struct ltc2358_dev **device, struct ltc2358_init_param *init_param)
Initialize the device.
Definition: ltc2358.c:124
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131