sys/auto_init: add driver for ITG320X 3-axis gyroscope
This commit is contained in:
parent
71772cc3b3
commit
79884687b2
@ -451,6 +451,10 @@ void auto_init(void)
|
||||
extern void auto_init_isl29020(void);
|
||||
auto_init_isl29020();
|
||||
#endif
|
||||
#ifdef MODULE_ITG320X
|
||||
extern void auto_init_itg320x(void);
|
||||
auto_init_itg320x();
|
||||
#endif
|
||||
#ifdef MODULE_JC42
|
||||
extern void auto_init_jc42(void);
|
||||
auto_init_jc42();
|
||||
|
||||
79
sys/auto_init/saul/auto_init_itg320x.c
Normal file
79
sys/auto_init/saul/auto_init_itg320x.c
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_itg320x
|
||||
* @ingroup sys_auto_init_saul
|
||||
* @brief Auto initialization of InvenSense ITG320X 3-axis gyroscope
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef MODULE_ITG320X
|
||||
|
||||
#include "assert.h"
|
||||
#include "log.h"
|
||||
#include "saul_reg.h"
|
||||
#include "itg320x.h"
|
||||
#include "itg320x_params.h"
|
||||
|
||||
/**
|
||||
* @brief Define the number of configured sensors
|
||||
*/
|
||||
#define ITG320X_NUM (ARRAY_SIZE(itg320x_params))
|
||||
|
||||
/**
|
||||
* @brief Allocate memory for the device descriptors
|
||||
*/
|
||||
static itg320x_t itg320x_devs[ITG320X_NUM];
|
||||
|
||||
/**
|
||||
* @brief Memory for the SAUL registry entries
|
||||
*/
|
||||
static saul_reg_t saul_entries[ITG320X_NUM * 2];
|
||||
|
||||
/**
|
||||
* @brief Define the number of saul info
|
||||
*/
|
||||
#define ITG320X_INFO_NUM (ARRAY_SIZE(itg320x_saul_info))
|
||||
|
||||
/**
|
||||
* @name Reference the driver structs
|
||||
* @{
|
||||
*/
|
||||
extern saul_driver_t itg320x_saul_gyro_driver;
|
||||
extern saul_driver_t itg320x_saul_temp_driver;
|
||||
/** @} */
|
||||
|
||||
void auto_init_itg320x(void)
|
||||
{
|
||||
assert(ITG320X_NUM == ITG320X_INFO_NUM);
|
||||
|
||||
for (unsigned int i = 0; i < ITG320X_NUM; i++) {
|
||||
LOG_DEBUG("[auto_init_saul] initializing itg320x #%u\n", i);
|
||||
|
||||
if (itg320x_init(&itg320x_devs[i], &itg320x_params[i]) < 0) {
|
||||
LOG_ERROR("[auto_init_saul] error initializing itg320x #%u\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
saul_entries[(i * 2)].dev = &(itg320x_devs[i]);
|
||||
saul_entries[(i * 2)].name = itg320x_saul_info[i].name;
|
||||
saul_entries[(i * 2)].driver = &itg320x_saul_gyro_driver;
|
||||
saul_entries[(i * 2) + 1].dev = &(itg320x_devs[i]);
|
||||
saul_entries[(i * 2) + 1].name = itg320x_saul_info[i].name;
|
||||
saul_entries[(i * 2) + 1].driver = &itg320x_saul_temp_driver;
|
||||
saul_reg_add(&(saul_entries[(i * 2)]));
|
||||
saul_reg_add(&(saul_entries[(i * 2) + 1]));
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
typedef int dont_be_pedantic;
|
||||
#endif /* MODULE_ITG320X */
|
||||
Loading…
x
Reference in New Issue
Block a user