SELKIELogger
1.0.0
|
Classes | |
struct | i2c_msg_map |
Map device functions to message IDs. More... | |
struct | i2c_params |
I2C Source device specific parameters. More... | |
Functions | |
void * | i2c_setup (void *ptargs) |
I2C Connection setup. More... | |
void * | i2c_logging (void *ptargs) |
I2C main logging loop. More... | |
void * | i2c_shutdown (void *ptargs) |
I2C shutdown. More... | |
void * | i2c_channels (void *ptargs) |
Generate I2C channel map. More... | |
device_callbacks | i2c_getCallbacks (void) |
Fill out device callback functions for logging. More... | |
i2c_params | i2c_getParams (void) |
Fill out default I2C parameters. More... | |
bool | i2c_validate_chanmap (i2c_params *ip) |
Check channel mapping is valid. More... | |
bool | i2c_chanmap_add_ina219 (i2c_params *ip, const uint8_t devAddr, const uint8_t baseID) |
Add INA219 voltage and current readings to channel map. More... | |
bool | i2c_chanmap_add_ads1015 (i2c_params *ip, const uint8_t devAddr, const uint8_t baseID, const float scale, const float offset, const float minV, const float maxV) |
Add ADS1015 single ended voltage measurements to channel map. More... | |
bool | i2c_parseConfig (log_thread_args_t *lta, config_section *s) |
Take a configuration section, parse parameters and register devices. More... | |
Adds support for reading messages from an I2C bus directly connected to the logging machine.
General support functions are detailed in SELKIELoggerI2C.h. As the I2C bus must be polled rather than streaming data to the logger, each sensor and value that needs to be logged must be registered into the channel map in i2c_params before i2c_logging is called.
bool i2c_chanmap_add_ads1015 | ( | i2c_params * | ip, |
const uint8_t | devAddr, | ||
const uint8_t | baseID, | ||
const float | scale, | ||
const float | offset, | ||
const float | minV, | ||
const float | maxV | ||
) |
Add ADS1015 single ended voltage measurements to channel map.
Adds four entries to the channel map for a specified ADS1015 device, representing the four single ended measurement channels
baseID
: A0 [V]baseID+1
: A1 [V]baseID+2
: A2 [V]baseID+3
: A3 [V][in] | ip | i2c_params structure to modify |
[in] | devAddr | ADS1015 Device Address |
[in] | baseID | Message ID for first channel (A0) |
[in] | scale | Multiply received values by this quantity |
[in] | offset | Add this amount to received values |
[in] | minV | Minimum valid value |
[in] | maxV | Maximum valid value |
Definition at line 333 of file LoggerI2C.c.
bool i2c_chanmap_add_ina219 | ( | i2c_params * | ip, |
const uint8_t | devAddr, | ||
const uint8_t | baseID | ||
) |
Add INA219 voltage and current readings to channel map.
Adds three entries to the channel map for a specified INA219 device
baseID
: Shunt Voltage [mV]baseID+1
: Bus Voltage [V]baseID+2
: Bus Current [A][in] | ip | i2c_params structure to modify |
[in] | devAddr | INA219 Device Address |
[in] | baseID | Message ID for first message type (Shunt Voltage) |
Definition at line 275 of file LoggerI2C.c.
void* i2c_channels | ( | void * | ptargs | ) |
Generate I2C channel map.
Populate list of channels and push to queue as a map message
Terminates thread on error
[in] | ptargs | Pointer to log_thread_args_t |
Definition at line 163 of file LoggerI2C.c.
device_callbacks i2c_getCallbacks | ( | void | ) |
Fill out device callback functions for logging.
Definition at line 212 of file LoggerI2C.c.
i2c_params i2c_getParams | ( | void | ) |
Fill out default I2C parameters.
Definition at line 223 of file LoggerI2C.c.
void* i2c_logging | ( | void * | ptargs | ) |
I2C main logging loop.
Iterates over all registered channels, calling the appropriate read function against the registered I2C device ID.
After each conversion function has been called, this thread will sleep in an attempt to keep the poll frequency at the rate requested. This is a best effort attempt.
Thread will exit on error
[in] | ptargs | Pointer to log_thread_args_t |
Definition at line 68 of file LoggerI2C.c.
bool i2c_parseConfig | ( | log_thread_args_t * | lta, |
config_section * | s | ||
) |
Take a configuration section, parse parameters and register devices.
[in] | lta | Pointer to log_thread_args_t |
[in] | s | Pointer to config_section to be parsed |
Definition at line 405 of file LoggerI2C.c.
void* i2c_setup | ( | void * | ptargs | ) |
I2C Connection setup.
Connects to specified I2C bus after validating the configured channel map.
Device specific parameters need to be specified in an i2c_params structure
[in] | ptargs | Pointer to log_thread_args_t |
Definition at line 34 of file LoggerI2C.c.
void* i2c_shutdown | ( | void * | ptargs | ) |
I2C shutdown.
Simple wrapper around i2c_closeConnection(), which will do any cleanup required.
[in] | ptargs | Pointer to log_thread_args_t |
Definition at line 131 of file LoggerI2C.c.
bool i2c_validate_chanmap | ( | i2c_params * | ip | ) |
Check channel mapping is valid.
Ensures that the only one message is set for each channel, that no reserved channels are used and that device addresses and read functions are set.
[in] | ip | Pointer to i2c_params structure |
Definition at line 241 of file LoggerI2C.c.