|
upm
1.5.0
Sensor/Actuator repository for libmraa (v1.8.0)
|

Go to the source code of this file.
Data Structures | |
| struct | _lsm303d_context |
Functions | |
| lsm303d_context | lsm303d_init (int bus, int addr) |
| void | lsm303d_close (lsm303d_context dev) |
| upm_result_t | lsm303d_update (const lsm303d_context dev) |
| void | lsm303d_get_magnetometer (const lsm303d_context dev, float *x, float *y, float *z) |
| void | lsm303d_get_accelerometer (const lsm303d_context dev, float *x, float *y, float *z) |
| float | lsm303d_get_temperature (const lsm303d_context dev) |
| upm_result_t | lsm303d_set_acc_full_scale (const lsm303d_context dev, LSM303D_AFS_T fs) |
| upm_result_t | lsm303d_set_mag_full_scale (const lsm303d_context dev, LSM303D_MFS_T fs) |
| upm_result_t | lsm303d_devinit (const lsm303d_context dev, LSM303D_M_RES_T res) |
| upm_result_t | lsm303d_set_acc_odr (const lsm303d_context dev, LSM303D_AODR_T odr) |
| upm_result_t | lsm303d_set_mag_odr (const lsm303d_context dev, LSM303D_MODR_T odr) |
| uint8_t | lsm303d_read_reg (const lsm303d_context dev, uint8_t reg) |
| int | lsm303d_read_regs (const lsm303d_context dev, uint8_t reg, uint8_t *buffer, int len) |
| upm_result_t | lsm303d_write_reg (const lsm303d_context dev, uint8_t reg, uint8_t val) |
Typedefs | |
| typedef struct _lsm303d_context * | lsm303d_context |
| lsm303d_context lsm303d_init | ( | int | bus, |
| int | addr | ||
| ) |
LSM303D initialization
This driver only supports I2C.
Due to the fact that this chip is currently obsolete, we only support minimum functionality.
| bus | I2C bus to use |
| addr | The I2C address of the device |

| void lsm303d_close | ( | lsm303d_context | dev | ) |
LSM303D Destructor
| dev | The device context |

| upm_result_t lsm303d_update | ( | const lsm303d_context | dev | ) |
Update the internal stored values from sensor data
| dev | The device context |


| void lsm303d_get_magnetometer | ( | const lsm303d_context | dev, |
| float * | x, | ||
| float * | y, | ||
| float * | z | ||
| ) |
Return magnetometer data in micro-Teslas (uT). update() must have been called prior to calling this function.
| 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 |

| void lsm303d_get_accelerometer | ( | const lsm303d_context | dev, |
| float * | x, | ||
| float * | y, | ||
| float * | z | ||
| ) |
Return accelerometer data in gravities. update() must have been called prior to calling this function.
| 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 lsm303d_get_temperature | ( | const lsm303d_context | dev | ) |
Return temperature data in degrees Celsius.. update() must have been called prior to calling this function.
| dev | The device context |

| upm_result_t lsm303d_set_acc_full_scale | ( | const lsm303d_context | dev, |
| LSM303D_AFS_T | fs | ||
| ) |
Set the full scale (sensitivity) value for the accelerometer. This device supports 2G, 4G, 6G, 8G, and 16G full scale modes.
| dev | The device context |
| fs | One of the LSM303D_AFS_T values |


| upm_result_t lsm303d_set_mag_full_scale | ( | const lsm303d_context | dev, |
| LSM303D_MFS_T | fs | ||
| ) |
Set the full scale (sensitivity) value for the magnetometer. This device supports 2, 4, 8, and 16 Gauss.
| dev | The device context |
| fs | One of the LSM303D_MFS_T values |


| upm_result_t lsm303d_devinit | ( | const lsm303d_context | dev, |
| LSM303D_M_RES_T | res | ||
| ) |
Initialize the device and start operation. This function is called from the constructor so it will not typically need to be called by a user unless the device is reset. It will initialize the accelerometer and magnetometer (if enabled) to certain default running modes.
| dev | The device context |
| res | One of the LSM303D_M_RES_T values. This value sets the resolution of the magnetometer. At init time, this value is set to LSM303D_M_RES_HIGH. |


| upm_result_t lsm303d_set_acc_odr | ( | const lsm303d_context | dev, |
| LSM303D_AODR_T | odr | ||
| ) |
Set the accelerometer (acc) output data rate (odr)
| dev | The device context |
| odr | One of the LSM303D_AODR_T values. The default set at initialization time is LSM303D_AODR_100HZ. |


| upm_result_t lsm303d_set_mag_odr | ( | const lsm303d_context | dev, |
| LSM303D_MODR_T | odr | ||
| ) |
Set the magnetometer (mag) output data rate (odr)
| dev | The device context |
| odr | One of the LSM303D_MODR_T values. The default set at initialization time is LSM303D_MODR_12_5HZ. |


| uint8_t lsm303d_read_reg | ( | const lsm303d_context | dev, |
| uint8_t | reg | ||
| ) |
Read a register.
| dev | The device context |
| reg | The register to read |

| int lsm303d_read_regs | ( | const lsm303d_context | dev, |
| uint8_t | reg, | ||
| uint8_t * | buffer, | ||
| int | len | ||
| ) |
Read contiguous registers into a buffer
| dev | The device context |
| buffer | The buffer to store the results |
| len | The number of registers to read |

| upm_result_t lsm303d_write_reg | ( | const lsm303d_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 _lsm303d_context * lsm303d_context |
Device context
1.8.11