sensors: Move SCU-specific ak09912 sensor into spresense board

Move SCU-specific ak09912 sensor into spresense board layer.
Rename a function name to register SCU sensor driver
from ak09912_register to ak09912_scu_register.
This commit is contained in:
SPRESENSE 2023-08-24 16:02:05 +09:00 committed by Xiang Xiao
parent 606b6d9310
commit 795dcee521
4 changed files with 51 additions and 37 deletions

View file

@ -31,6 +31,7 @@
#include <nuttx/board.h>
#include <nuttx/sensors/ak09912.h>
#include <arch/board/cxd56_ak09912.h>
#include "cxd56_i2c.h"
#include <arch/chip/scu.h>
@ -79,7 +80,7 @@ int board_ak09912_initialize(const char *devpath, int bus)
{
/* register device at I2C bus */
ret = ak09912_register(devpath, i, i2c, bus);
ret = ak09912_scu_register(devpath, i, i2c, bus);
if (ret < 0)
{
snerr("Error registering AK09912.\n");

View file

@ -511,23 +511,25 @@ int ak09912_init(struct i2c_master_s *i2c, int port)
}
/****************************************************************************
* Name: ak09912_register
* Name: ak09912_scu_register
*
* Description:
* Register the AK09912 character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/mag"
* minor - The number of sequencer
* i2c - An instance of the I2C interface to use to communicate with
* AK09912
* port - I2C port number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int ak09912_register(const char *devpath, int minor,
struct i2c_master_s *i2c, int port)
int ak09912_scu_register(const char *devpath, int minor,
struct i2c_master_s *i2c, int port)
{
struct ak09912_dev_s *priv;
char path[16];

View file

@ -26,17 +26,9 @@
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Types
****************************************************************************/
#include <nuttx/i2c/i2c_master.h>
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
@ -62,6 +54,48 @@ extern "C"
int board_ak09912_initialize(const char *devpath, int bus);
#endif
#ifdef CONFIG_SENSORS_AK09912_SCU
/****************************************************************************
* Name: ak09912_init
*
* Description:
* Initialize AK09912 magnetometer device
*
* Input Parameters:
* i2c - An instance of the I2C interface to use to communicate with
* AK09912
* port - I2C port number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int ak09912_init(FAR struct i2c_master_s *i2c, int port);
/****************************************************************************
* Name: ak09912_scu_register
*
* Description:
* Register the AK09912 character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/mag0"
* minor - The number of sequencer
* i2c - An instance of the I2C interface to use to communicate with
* AK09912
* port - I2C port number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int ak09912_scu_register(const char *devpath, int minor,
struct i2c_master_s *i2c, int port);
#endif /* CONFIG_SENSORS_AK09912_SCU */
#undef EXTERN
#if defined(__cplusplus)
}

View file

@ -83,25 +83,6 @@ struct ak09912_sensadj_s
uint8_t z;
};
#ifdef CONFIG_SENSORS_AK09912_SCU
/****************************************************************************
* Name: ak09912_init
*
* Description:
* Initialize AK09912 magnetometer device
*
* Input Parameters:
* i2c - An instance of the I2C interface to use to communicate with
* AK09912
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int ak09912_init(FAR struct i2c_master_s *i2c, int port);
#endif
/****************************************************************************
* Name: ak09912_register
*
@ -117,12 +98,8 @@ int ak09912_init(FAR struct i2c_master_s *i2c, int port);
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_SENSORS_AK09912_SCU
int ak09912_register(FAR const char *devpath, int minor,
FAR struct i2c_master_s *i2c, int port);
#else
int ak09912_register(FAR const char *devpath, FAR struct i2c_master_s *i2c);
#endif
#undef EXTERN
#ifdef __cplusplus