upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | _lis2ds12_context |
Functions | |
lis2ds12_context | lis2ds12_init (int bus, int addr, int cs) |
void | lis2ds12_close (lis2ds12_context dev) |
upm_result_t | lis2ds12_update (const lis2ds12_context dev) |
uint8_t | lis2ds12_get_chip_id (const lis2ds12_context dev) |
upm_result_t | lis2ds12_devinit (const lis2ds12_context dev, LIS2DS12_ODR_T odr, LIS2DS12_FS_T fs) |
upm_result_t | lis2ds12_set_odr (const lis2ds12_context dev, LIS2DS12_ODR_T odr) |
upm_result_t | lis2ds12_set_full_scale (const lis2ds12_context dev, LIS2DS12_FS_T fs) |
void | lis2ds12_get_accelerometer (const lis2ds12_context dev, float *x, float *y, float *z) |
float | lis2ds12_get_temperature (const lis2ds12_context dev) |
upm_result_t | lis2ds12_reset (const lis2ds12_context dev) |
upm_result_t | lis2ds12_enable_hp_filtering (const lis2ds12_context dev, bool filter) |
upm_result_t | lis2ds12_enable_interrupt_latching (const lis2ds12_context dev, bool latch) |
upm_result_t | lis2ds12_set_interrupt_active_high (const lis2ds12_context dev, bool high) |
upm_result_t | lis2ds12_set_interrupt_push_pull (const lis2ds12_context dev, bool pp) |
upm_result_t | lis2ds12_set_int1_config (const lis2ds12_context dev, uint8_t cfg) |
upm_result_t | lis2ds12_set_int2_config (const lis2ds12_context dev, uint8_t cfg) |
uint8_t | lis2ds12_get_status (const lis2ds12_context dev) |
upm_result_t | lis2ds12_install_isr (const lis2ds12_context dev, LIS2DS12_INTERRUPT_PINS_T intr, int gpio, mraa_gpio_edge_t level, void(*isr)(void *), void *arg) |
void | lis2ds12_uninstall_isr (const lis2ds12_context dev, LIS2DS12_INTERRUPT_PINS_T intr) |
uint8_t | lis2ds12_read_reg (const lis2ds12_context dev, uint8_t reg) |
int | lis2ds12_read_regs (const lis2ds12_context dev, uint8_t reg, uint8_t *buffer, int len) |
upm_result_t | lis2ds12_write_reg (const lis2ds12_context dev, uint8_t reg, uint8_t val) |
Typedefs | |
typedef struct _lis2ds12_context * | lis2ds12_context |
lis2ds12_context lis2ds12_init | ( | int | bus, |
int | addr, | ||
int | cs | ||
) |
LIS2DS12 initialization.
This device can support both I2C and SPI. For SPI, set the addr to -1, and specify a positive integer representing the Chip Select (CS) pin for the cs argument. If you are using a hardware CS pin (like Intel Edison with Arduino breakout), then you can connect the proper pin to the hardware CS pin on your MCU and supply -1 for cs.
bus | I2C or SPI bus to use |
addr | The address for this device, or -1 for SPI |
cs | The gpio pin to use for the SPI Chip Select. Use -1 for I2C or for SPI with a hardware controlled pin. |
void lis2ds12_close | ( | lis2ds12_context | dev | ) |
LIS2DS12 Destructor
dev | The device context |
upm_result_t lis2ds12_update | ( | const lis2ds12_context | dev | ) |
Update the internal stored values from sensor data
dev | The device context |
uint8_t lis2ds12_get_chip_id | ( | const lis2ds12_context | dev | ) |
Return the chip ID
dev | The device context |
upm_result_t lis2ds12_devinit | ( | const lis2ds12_context | dev, |
LIS2DS12_ODR_T | odr, | ||
LIS2DS12_FS_T | fs | ||
) |
Initialize the device and start operation. This function is called from lis2ds12_init(), so it will not need to be called by a user unless the device is reset.
dev | The device context |
odr | One of the LIS2DS12_ODR_T values |
fs | One of the LIS2DS12_FS_T values |
upm_result_t lis2ds12_set_odr | ( | const lis2ds12_context | dev, |
LIS2DS12_ODR_T | odr | ||
) |
Set the output data rate (ODR) of the device
dev | The device context |
odr | One of the LIS2DS12_ODR_T values |
upm_result_t lis2ds12_set_full_scale | ( | const lis2ds12_context | dev, |
LIS2DS12_FS_T | fs | ||
) |
Set the full scale (FS) of the device. This device supports a full scale of 2, 4, 8, and 16G.
dev | The device context |
fs | One of the LIS2DS12_FS_T values |
void lis2ds12_get_accelerometer | ( | const lis2ds12_context | dev, |
float * | x, | ||
float * | y, | ||
float * | z | ||
) |
Return accelerometer data gravities (g). lis2ds12_update() must have been called prior to calling this method.
dev | The device context |
x | Pointer to a floating point value that will have the current x component placed into it |
y | Pointer to a floating point value that will have the current y component placed into it |
z | Pointer to a floating point value that will have the current z component placed into it |
float lis2ds12_get_temperature | ( | const lis2ds12_context | dev | ) |
Return the current measured temperature. Note, this is not ambient temperature. lis2ds12_update() must have been called prior to calling this method.
dev | The device context |
upm_result_t lis2ds12_reset | ( | const lis2ds12_context | dev | ) |
Reset the device as if during a power on reset. All configured values are lost when this happens. You should call lis2ds12_devinit() afterwards, or at least perform the same initialization lis2ds12_devinit() does before continuing.
dev | The device context |
upm_result_t lis2ds12_enable_hp_filtering | ( | const lis2ds12_context | dev, |
bool | filter | ||
) |
Enable high pass filtering of the accelerometer axis data. lis2ds12_devinit() disables this by default. See the datasheet for details.
dev | The device context |
filter | true to enable filtering, false to disable |
upm_result_t lis2ds12_enable_interrupt_latching | ( | const lis2ds12_context | dev, |
bool | latch | ||
) |
Enable or disable interrupt latching. If latching is disabled, pulsed is enabled. See the datasheet for details.
dev | The device context |
latch | true to enable latching, false to disable |
upm_result_t lis2ds12_set_interrupt_active_high | ( | const lis2ds12_context | dev, |
bool | high | ||
) |
Indicate whether the interrupt should be active high (default) or active low. See the datasheet for details.
dev | The device context |
high | true for active high, false for active low |
upm_result_t lis2ds12_set_interrupt_push_pull | ( | const lis2ds12_context | dev, |
bool | pp | ||
) |
Indicate whether interrupts are push-pull (default) or open drain. See the datasheet for details.
dev | The device context |
pp | true for push-pull, false for open-drain |
upm_result_t lis2ds12_set_int1_config | ( | const lis2ds12_context | dev, |
uint8_t | cfg | ||
) |
Set interrupt 1 configuration. See the datasheet for details.
dev | The device context |
cfg | A bitmask of values from LIS2DS12_CTRL4_BITS_T |
upm_result_t lis2ds12_set_int2_config | ( | const lis2ds12_context | dev, |
uint8_t | cfg | ||
) |
Set interrupt 2 configuration. See the datasheet for details.
dev | The device context |
cfg | A bitmask of values from LIS2DS12_CTRL5_BITS_T |
uint8_t lis2ds12_get_status | ( | const lis2ds12_context | dev | ) |
Return the contents of the status register
dev | The device context |
upm_result_t lis2ds12_install_isr | ( | const lis2ds12_context | dev, |
LIS2DS12_INTERRUPT_PINS_T | intr, | ||
int | gpio, | ||
mraa_gpio_edge_t | level, | ||
void(*)(void *) | isr, | ||
void * | arg | ||
) |
Install an interrupt handler
dev | The device context |
intr | One of the LIS2DS12_INTERRUPT_PINS_T values specifying which interrupt pin you are installing |
gpio | GPIO pin to use as interrupt pin |
level | The interrupt trigger level (one of mraa_gpio_edge_t values). Make sure that you have configured the interrupt pin properly for whatever level you choose. |
isr | The interrupt handler, accepting a void * argument |
arg | The argument to pass the the interrupt handler |
void lis2ds12_uninstall_isr | ( | const lis2ds12_context | dev, |
LIS2DS12_INTERRUPT_PINS_T | intr | ||
) |
Uninstall a previously installed interrupt handler
dev | The device context |
intr | One of the LIS2DS12_INTERRUPT_PINS_T values specifying which interrupt pin you are removing |
uint8_t lis2ds12_read_reg | ( | const lis2ds12_context | dev, |
uint8_t | reg | ||
) |
Read a register
dev | The device context |
reg | The register to read |
int lis2ds12_read_regs | ( | const lis2ds12_context | dev, |
uint8_t | reg, | ||
uint8_t * | buffer, | ||
int | len | ||
) |
Read contiguous registers into a buffer
dev | The device context |
reg | The register to start the read from |
buffer | The buffer to store the results |
len | The number of registers to read |
upm_result_t lis2ds12_write_reg | ( | const lis2ds12_context | dev, |
uint8_t | reg, | ||
uint8_t | val | ||
) |
Write to a register
dev | The device context |
reg | The register to write to |
val | The value to write |
typedef struct _lis2ds12_context * lis2ds12_context |
Device context