sys/auto_init: update lsm303dlhc with new API
This commit is contained in:
parent
d81cf561b0
commit
dd055f3b32
@ -29,7 +29,7 @@
|
|||||||
/**
|
/**
|
||||||
* @brief Define the number of configured sensors
|
* @brief Define the number of configured sensors
|
||||||
*/
|
*/
|
||||||
#define LSM303DLHC_NUM (sizeof(lsm303dlhc_params)/sizeof(lsm303dlhc_params[0]))
|
#define LSM303DLHC_NUM (sizeof(lsm303dlhc_params) / sizeof(lsm303dlhc_params[0]))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocate memory for the device descriptors
|
* @brief Allocate memory for the device descriptors
|
||||||
@ -42,7 +42,12 @@ static lsm303dlhc_t lsm303dlhc_devs[LSM303DLHC_NUM];
|
|||||||
static saul_reg_t saul_entries[LSM303DLHC_NUM * 2];
|
static saul_reg_t saul_entries[LSM303DLHC_NUM * 2];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reference the driver structs
|
* @brief Define the number of saul info
|
||||||
|
*/
|
||||||
|
#define LSM303DLHC_INFO_NUM (sizeof(lsm303dlhc_saul_info) / sizeof(lsm303dlhc_saul_info[0]))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name Reference the driver structs
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
extern saul_driver_t lsm303dlhc_saul_acc_driver;
|
extern saul_driver_t lsm303dlhc_saul_acc_driver;
|
||||||
@ -51,16 +56,12 @@ extern saul_driver_t lsm303dlhc_saul_mag_driver;
|
|||||||
|
|
||||||
void auto_init_lsm303dlhc(void)
|
void auto_init_lsm303dlhc(void)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < LSM303DLHC_NUM; i++) {
|
assert(LSM303DLHC_NUM == LSM303DLHC_INFO_NUM);
|
||||||
const lsm303dlhc_params_t *p = &lsm303dlhc_params[i];
|
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < LSM303DLHC_NUM; i++) {
|
||||||
LOG_DEBUG("[auto_init_saul] initializing lsm303dlhc #%u\n", i);
|
LOG_DEBUG("[auto_init_saul] initializing lsm303dlhc #%u\n", i);
|
||||||
|
|
||||||
int res = lsm303dlhc_init(&lsm303dlhc_devs[i], p->i2c,
|
if (lsm303dlhc_init(&lsm303dlhc_devs[i], &lsm303dlhc_params[i]) < 0) {
|
||||||
p->acc_pin, p->mag_pin,
|
|
||||||
p->acc_addr, p->acc_rate, p->acc_scale,
|
|
||||||
p->mag_addr, p->mag_rate, p->mag_gain);
|
|
||||||
if (res < 0) {
|
|
||||||
LOG_ERROR("[auto_init_saul] error initializing lsm303dlhc #%u\n", i);
|
LOG_ERROR("[auto_init_saul] error initializing lsm303dlhc #%u\n", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user