no-OS
ltc3350.h
Go to the documentation of this file.
1 /***************************************************************************/
35 #ifndef __LTC3350_H__
36 #define __LTC3350_H__
37 
38 /******************************************************************************/
39 /***************************** Include Files **********************************/
40 /******************************************************************************/
41 
42 #include <stdint.h>
43 #include <string.h>
44 #include "no_os_util.h"
45 #include "no_os_i2c.h"
46 
47 /******************************************************************************/
48 /********************** Macros and Constants Definitions **********************/
49 /******************************************************************************/
50 
51 /* LTC3350 Register Map */
52 #define LTC3350_AD_CLR_ALARMS 0x00
53 #define LTC3350_AD_MSK_ALARMS 0x01
54 #define LTC3350_AD_MSK_MON_STATUS 0x02
55 #define LTC3350_AD_CAP_ESR_PER 0x04
56 #define LTC3350_AD_VCAPFB_DAC 0x05
57 #define LTC3350_AD_VSHUNT 0x06
58 #define LTC3350_AD_CAP_UV_LVL 0x07
59 #define LTC3350_AD_CAP_OV_LVL 0x08
60 #define LTC3350_AD_GPI_UV_LVL 0x09
61 #define LTC3350_AD_GPI_OV_LVL 0x0A
62 #define LTC3350_AD_VIN_UV_LVL 0x0B
63 #define LTC3350_AD_VIN_OV_LVL 0x0C
64 #define LTC3350_AD_VCAP_UV_LVL 0x0D
65 #define LTC3350_AD_VCAP_OV_LVL 0x0E
66 #define LTC3350_AD_VOUT_UV_LVL 0x0F
67 #define LTC3350_AD_VOUT_OV_LVL 0x10
68 #define LTC3350_AD_IIN_OC_LVL 0x11
69 #define LTC3350_AD_ICHG_UC_LVL 0x12
70 #define LTC3350_AD_DTEMP_COLD_LVL 0x13
71 #define LTC3350_AD_DTEMP_HOT_LVL 0x14
72 #define LTC3350_AD_ESR_HI_LVL 0x15
73 #define LTC3350_AD_CAP_LO_LVL 0x16
74 #define LTC3350_AD_CTL_REG 0x17
75 #define LTC3350_AD_NUM_CAPS 0x1A
76 #define LTC3350_AD_CHRG_STATUS 0x1B
77 #define LTC3350_AD_MON_STATUS 0x1C
78 #define LTC3350_AD_ALARM_REG 0x1D
79 #define LTC3350_AD_MEAS_CAP 0x1E
80 #define LTC3350_AD_MEAS_ESR 0x1F
81 #define LTC3350_AD_MEAS_VCAP1 0x20
82 #define LTC3350_AD_MEAS_VCAP2 0x21
83 #define LTC3350_AD_MEAS_VCAP3 0x22
84 #define LTC3350_AD_MEAS_VCAP4 0x23
85 #define LTC3350_AD_MEAS_GPI 0x24
86 #define LTC3350_AD_MEAS_VIN 0x25
87 #define LTC3350_AD_MEAS_VCAP 0x26
88 #define LTC3350_AD_MEAS_VOUT 0x27
89 #define LTC3350_AD_MEAS_IIN 0x28
90 #define LTC3350_AD_MEAS_ICHG 0x29
91 #define LTC3350_AD_MEAS_DTEMP 0x2A
92 
93 /******************************************************************************/
94 /******************* Driver pre-compile time settings *************************/
95 /******************************************************************************/
96 
102 #ifndef LTC3350_USE_MEASUREMENTS
103 #define LTC3350_USE_MEASUREMENTS 1
104 #endif
105 
111 #ifndef LTC3350_USE_ALARMS
112 #define LTC3350_USE_ALARMS 0
113 #endif
114 
115 /******************************************************************************/
116 /*************************** Types Declarations *******************************/
117 /******************************************************************************/
118 
119 /*LTC3350 alarms*/
137 };
138 
139 /*LTC3350 alarms_mask*/
157 };
158 
166 };
167 
172 struct ltc3350_dev {
175 };
176 
177 /******************************************************************************/
178 /************************ Functions Declarations ******************************/
179 /******************************************************************************/
180 
183 int ltc3350_init(struct ltc3350_dev **device,
186 int ltc3350_remove(struct ltc3350_dev *dev);
187 
190 int ltc3350_read_device_data(struct ltc3350_dev *dev, uint8_t base_address,
191  uint16_t *read_data);
193 int ltc3350_write_device_data(struct ltc3350_dev *dev, uint8_t base_address,
194  uint16_t write_data);
195 
198 /* LTC3350_USE_MEASUREMENTS == 1 */
199 
200 #if LTC3350_USE_MEASUREMENTS
201 
203 int ltc3350_get_num_caps(struct ltc3350_dev *dev, uint8_t *num_caps);
204 
206 int ltc3350_get_esr(struct ltc3350_dev *dev, uint16_t *value);
208 int ltc3350_get_vcap(struct ltc3350_dev *dev, uint8_t n_cap, uint16_t *value);
209 
210 #endif
211 
212 /* LTC3350_USE_ALARMS == 0 */
213 
214 #if LTC3350_USE_ALARMS
215 
217 int ltc3350_set_alarm(struct ltc3350_dev *dev, enum ltc3350_enum_alarms alarm,
218  uint16_t alarm_threshold);
220 int ltc3350_mute_alarm(struct ltc3350_dev *dev, enum ltc3350_enum_alarms alarm);
222 int ltc3350_get_alarm_status_mask(struct ltc3350_dev *dev,
223  uint16_t *alarm_mask);
225 int ltc3350_clear_alarm_status_mask(struct ltc3350_dev *dev);
226 
227 #endif
228 
229 #endif /* __LTC3350_H__ */
LTC3350_CAP_OV_LVL
@ LTC3350_CAP_OV_LVL
Definition: ltc3350.h:122
ltc3350_get_vcap
int ltc3350_get_vcap(struct ltc3350_dev *dev, uint8_t n_cap, uint16_t *value)
Reads the Vcap data for selected capacitor.
Definition: ltc3350.c:206
ltc3350_init
int ltc3350_init(struct ltc3350_dev **device, struct ltc3350_init_param *init_param)
Initializes the communication peripheral and checks if the LTC3350 part is present.
Definition: ltc3350.c:60
no_os_alloc.h
LTC3350_VOUT_OV_LVL
@ LTC3350_VOUT_OV_LVL
Definition: ltc3350.h:130
ltc3350.h
no_os_i2c_write
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
no_os_i2c_init
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
LTC3350_VOUT_OV_LVL_BIT
@ LTC3350_VOUT_OV_LVL_BIT
Definition: ltc3350.h:150
LTC3350_ICHG_UC_LVL
@ LTC3350_ICHG_UC_LVL
Definition: ltc3350.h:132
LTC3350_VCAP_UV_LVL
@ LTC3350_VCAP_UV_LVL
Definition: ltc3350.h:127
LTC3350_VOUT_UV_LVL_BIT
@ LTC3350_VOUT_UV_LVL_BIT
Definition: ltc3350.h:149
ltc3350_write_device_data
int ltc3350_write_device_data(struct ltc3350_dev *dev, uint8_t base_address, uint16_t write_data)
Writes data to the device (I2C)
Definition: ltc3350.c:138
no_os_i2c_remove
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
LTC3350_VCAP_OV_LVL_BIT
@ LTC3350_VCAP_OV_LVL_BIT
Definition: ltc3350.h:148
LTC3350_GPI_UV_LVL_BIT
@ LTC3350_GPI_UV_LVL_BIT
Definition: ltc3350.h:143
ltc3350_dev
LTC3350 Device structure.
Definition: ltc3350.h:172
no_os_delay.h
Header file of Delay functions.
device
Definition: ad9361_util.h:69
ltc3350_read_device_data
int ltc3350_read_device_data(struct ltc3350_dev *dev, uint8_t base_address, uint16_t *read_data)
Reads data from the device (I2C).
Definition: ltc3350.c:110
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
ltc3350_get_esr
int ltc3350_get_esr(struct ltc3350_dev *dev, uint16_t *value)
Reads the ESR data.
Definition: ltc3350.c:183
ltc3350_remove
int ltc3350_remove(struct ltc3350_dev *dev)
Free the resources allocated by ltc3350_init().
Definition: ltc3350.c:88
LTC3350_IIN_OC_LVL_BIT
@ LTC3350_IIN_OC_LVL_BIT
Definition: ltc3350.h:151
LTC3350_AD_CLR_ALARMS
#define LTC3350_AD_CLR_ALARMS
Definition: ltc3350.h:52
LTC3350_VCAP_OV_LVL
@ LTC3350_VCAP_OV_LVL
Definition: ltc3350.h:128
LTC3350_VIN_OV_LVL
@ LTC3350_VIN_OV_LVL
Definition: ltc3350.h:126
ltc3350_write_device_data
int ltc3350_write_device_data(struct ltc3350_dev *dev, uint8_t base_address, uint16_t write_data)
Writes data to the device (I2C)
Definition: ltc3350.c:138
LTC3350_CAP_UV_LVL_B_BIT
@ LTC3350_CAP_UV_LVL_B_BIT
Definition: ltc3350.h:141
LTC3350_DTEMP_COLD_LVL_BIT
@ LTC3350_DTEMP_COLD_LVL_BIT
Definition: ltc3350.h:153
LTC3350_ESR_HI_LVL_BIT
@ LTC3350_ESR_HI_LVL_BIT
Definition: ltc3350.h:155
ltc3350_get_vcap
int ltc3350_get_vcap(struct ltc3350_dev *dev, uint8_t n_cap, uint16_t *value)
Reads the Vcap data for selected capacitor.
Definition: ltc3350.c:206
ltc3350_init
int ltc3350_init(struct ltc3350_dev **device, struct ltc3350_init_param *init_param)
Initializes the communication peripheral and checks if the LTC3350 part is present.
Definition: ltc3350.c:60
LTC3350_VIN_UV_LVL
@ LTC3350_VIN_UV_LVL
Definition: ltc3350.h:125
ltc3350_read_device_data
int ltc3350_read_device_data(struct ltc3350_dev *dev, uint8_t base_address, uint16_t *read_data)
Reads data from the device (I2C).
Definition: ltc3350.c:110
LTC3350_AD_NUM_CAPS
#define LTC3350_AD_NUM_CAPS
Definition: ltc3350.h:75
LTC3350_DTEMP_COLD_LVL
@ LTC3350_DTEMP_COLD_LVL
Definition: ltc3350.h:133
LTC3350_VIN_OV_LVL_BIT
@ LTC3350_VIN_OV_LVL_BIT
Definition: ltc3350.h:146
LTC3350_GPI_OV_LVL
@ LTC3350_GPI_OV_LVL
Definition: ltc3350.h:124
ltc3350_init_param
Structure holding the parameters for LTC3350 device initialization.
Definition: ltc3350.h:163
ltc3350_enum_alarms
ltc3350_enum_alarms
Definition: ltc3350.h:120
ltc3350_get_num_caps
int ltc3350_get_num_caps(struct ltc3350_dev *dev, uint8_t *num_caps)
Gets number of capacitors configured based on PIN.
Definition: ltc3350.c:161
LTC3350_VCAP_UV_LVL_BIT
@ LTC3350_VCAP_UV_LVL_BIT
Definition: ltc3350.h:147
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
LTC3350_AD_MEAS_VCAP1
#define LTC3350_AD_MEAS_VCAP1
Definition: ltc3350.h:81
no_os_i2c_read
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
no_os_i2c.h
Header file of I2C Interface.
LTC3350_AD_MEAS_VCAP
#define LTC3350_AD_MEAS_VCAP
Definition: ltc3350.h:87
LTC3350_CAP_LO_LVL
@ LTC3350_CAP_LO_LVL
Definition: ltc3350.h:136
ltc3350_dev::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: ltc3350.h:174
LTC3350_ICHG_UC_LVL_BIT
@ LTC3350_ICHG_UC_LVL_BIT
Definition: ltc3350.h:152
LTC3350_VOUT_UV_LVL
@ LTC3350_VOUT_UV_LVL
Definition: ltc3350.h:129
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
ltc3350_get_esr
int ltc3350_get_esr(struct ltc3350_dev *dev, uint16_t *value)
Reads the ESR data.
Definition: ltc3350.c:183
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
LTC3350_DTEMP_HOT_LVL_BIT
@ LTC3350_DTEMP_HOT_LVL_BIT
Definition: ltc3350.h:154
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
LTC3350_ESR_HI_LVL
@ LTC3350_ESR_HI_LVL
Definition: ltc3350.h:135
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
LTC3350_CAP_OV_LVL_BIT
@ LTC3350_CAP_OV_LVL_BIT
Definition: ltc3350.h:142
LTC3350_GPI_UV_LVL
@ LTC3350_GPI_UV_LVL
Definition: ltc3350.h:123
ltc3350_enum_alarms_mask
ltc3350_enum_alarms_mask
Definition: ltc3350.h:140
LTC3350_AD_ALARM_REG
#define LTC3350_AD_ALARM_REG
Definition: ltc3350.h:78
LTC3350_IIN_OC_LVL
@ LTC3350_IIN_OC_LVL
Definition: ltc3350.h:131
LTC3350_DTEMP_HOT_LVL
@ LTC3350_DTEMP_HOT_LVL
Definition: ltc3350.h:134
LTC3350_AD_MEAS_ESR
#define LTC3350_AD_MEAS_ESR
Definition: ltc3350.h:80
LTC3350_VIN_UV_LVL_BIT
@ LTC3350_VIN_UV_LVL_BIT
Definition: ltc3350.h:145
ltc3350_get_num_caps
int ltc3350_get_num_caps(struct ltc3350_dev *dev, uint8_t *num_caps)
Gets number of capacitors configured based on PIN.
Definition: ltc3350.c:161
LTC3350_AD_MSK_ALARMS
#define LTC3350_AD_MSK_ALARMS
Definition: ltc3350.h:53
no_os_util.h
Header file of utility functions.
LTC3350_CAP_UV_LVL
@ LTC3350_CAP_UV_LVL
Definition: ltc3350.h:121
ltc3350_remove
int ltc3350_remove(struct ltc3350_dev *dev)
Free the resources allocated by ltc3350_init().
Definition: ltc3350.c:88
LTC3350_AD_CAP_UV_LVL
#define LTC3350_AD_CAP_UV_LVL
Definition: ltc3350.h:58
ltc3350_init_param::i2c_init
struct no_os_i2c_init_param i2c_init
Definition: ltc3350.h:165
LTC3350_GPI_OV_LVL_BIT
@ LTC3350_GPI_OV_LVL_BIT
Definition: ltc3350.h:144
errno.h
Error macro definition for ARM Compiler.
LTC3350_CAP_LO_LVL_BIT
@ LTC3350_CAP_LO_LVL_BIT
Definition: ltc3350.h:156