feature(nuttx sensor driver): add ak09919c mag sensor dirver.

Add ak09919c mag sensor dirver.

Change-Id: Ie90149689a50dc4f68aa1802d00bb818092ed795
Signed-off-by: xiatian6 <xiatian6@xiaomi.com>
This commit is contained in:
xiatian6
2021-06-16 15:25:15 +08:00
parent 8cea82708a
commit cf9baa0178
4 changed files with 981 additions and 0 deletions
+15
View File
@@ -62,6 +62,21 @@ config SENSORS_AK09912
---help---
Enable driver for AK09911/AK09912 Compass sensor.
config SENSORS_AK09919C
bool "Asahi AK09919C Compass Sensor"
default n
select I2C
---help---
Enable driver for AK09919C Compass sensor.
config SENSORS_AK09919C_BUFFER_NUMBER
int "The nunmber of circular buffer for sensor AK09919C"
default 1
depends on SENSORS_AK09919C
---help---
The number of the circular buffer used. If the value equal to zero,
indicates that the circular buffer is disabled.
config SENSORS_AS5048B
bool "AMS AS5048B Magnetic Rotary Encoder support"
default n
+4
View File
@@ -60,6 +60,10 @@ ifeq ($(CONFIG_SENSORS_AK09912),y)
CSRCS += ak09912.c
endif
ifeq ($(CONFIG_SENSORS_AK09919C),y)
CSRCS += ak09919c.c
endif
ifeq ($(CONFIG_SENSORS_AS5048B),y)
CSRCS += as5048b.c
endif
File diff suppressed because it is too large Load Diff
+85
View File
@@ -0,0 +1,85 @@
/****************************************************************************
* include/nuttx/sensors/ak09919c.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_SENSORS_AK09919C_H
#define __INCLUDE_NUTTX_SENSORS_AK09919C_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_AK09919C)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
struct ak09919c_config_s
{
uint8_t addr; /* I2C address */
int freq; /* I2C frequency */
FAR struct i2c_master_s *i2c; /* I2C interface */
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: ak09919c_register
*
* Description:
* Register the AK09919C character device as 'devpath'.
*
* Input Parameters:
* devno - The device number, used to build the device path
* as /dev/sensor/magN
* i2c - An I2C driver instance.
* config - configuration for the AK09919C driver. For details see
* description above.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int ak09919c_register(int devno, FAR struct ak09919c_config_s *config);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_I2C && CONFIG_AK09919C */
#endif /* __INCLUDE_NUTTX_SENSORS_AK09919C_H */