no-OS
ltc2358.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef LTC2358_H
35 #define LTC2358_H
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 
41 #include <stdint.h>
42 #include "no_os_spi.h"
43 #include "no_os_util.h"
44 
45 /******************************************************************************/
46 /********************** Macros and Constants Definitions **********************/
47 /******************************************************************************/
48 
49 #define LTC2358_BYTES_PER_CH 3
50 #define LTC2358_CHANNEL_MSK NO_OS_GENMASK(2, 0)
51 
52 /******************************************************************************/
53 /*************************** Types Declarations *******************************/
54 /******************************************************************************/
55 
61  /* SPI Initialization structure. */
63 };
64 
69 struct ltc2358_dev {
70  /* SPI handler */
72 };
73 
74 /******************************************************************************/
75 /************************ Functions Declarations ******************************/
76 /******************************************************************************/
77 
78 /* Creates 24-bit configuration word for the 8 channels. */
79 void ltc2358_create_config_word(uint8_t channel, uint8_t config_number,
80  uint32_t *config_word);
81 
82 /* Parse single channel data. */
83 int32_t ltc2358_channel_data(struct ltc2358_dev *dev, uint32_t config_word,
84  uint8_t data_array[24], uint8_t channel, uint32_t *readval);
85 
86 /* Initializes the LTC2358. */
87 int32_t ltc2358_init(struct ltc2358_dev **device,
89 
90 /* Free the resources allocated by ltc2358_init(). */
91 int32_t ltc2358_remove(struct ltc2358_dev *dev);
92 
93 #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:53
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:96
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:118
no_os_alloc.h
no_os_spi.h
Header file of SPI Interface.
no_os_spi_msg
Definition: no_os_spi.h:100
device
Definition: ad9361_util.h:69
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:96
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
LTC2358_CHANNEL_MSK
#define LTC2358_CHANNEL_MSK
Definition: ltc2358.h:50
no_os_spi_msg::tx_buff
uint8_t * tx_buff
Definition: no_os_spi.h:102
ltc2358_init_param
Structure holding the parameters for ltc2358 initialization.
Definition: ltc2358.h:60
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:192
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:53
ltc2358_remove
int32_t ltc2358_remove(struct ltc2358_dev *dev)
Free memory allocated by ltc2358_init().
Definition: ltc2358.c:146
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:185
ltc2358_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ltc2358.h:71
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
LTC2358_BYTES_PER_CH
#define LTC2358_BYTES_PER_CH
Definition: ltc2358.h:49
ltc2358_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: ltc2358.h:62
ltc2358_dev
Structure holding ltc2358 descriptor.
Definition: ltc2358.h:69
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
ltc2358_remove
int32_t ltc2358_remove(struct ltc2358_dev *dev)
Free memory allocated by ltc2358_init().
Definition: ltc2358.c:146
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_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:118
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140