adc: Implement ADC driver interface for MCP3008 over SPI. Includes documentation page for the driver, and inclusion of driver registration code for RP2040-based boards.

This commit is contained in:
Matteo Golin
2024-10-22 13:56:23 +08:00
committed by Xiang Xiao
parent 9b0fc1277b
commit bbc95d70db
9 changed files with 648 additions and 0 deletions
+5
View File
@@ -111,6 +111,11 @@
#define AN_SAMV7_AFEC_FIRST (AN_MCP48XX_FIRST + AN_MCP48XX_NCMDS)
#define AN_SAMV7_AFEC_NCMDS 1
/* See include/nuttx/analog/mcp3008.h */
#define AN_MCP3008_FIRST (AN_SAMV7_AFEC_FIRST + AN_SAMV7_AFEC_NCMDS)
#define AN_MCP3008_NCMDS 1
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
+52
View File
@@ -0,0 +1,52 @@
/****************************************************************************
* include/nuttx/analog/mcp3008.h
*
* Contributed by Matteo Golin
*
* SPDX-License-Identifier: Apache-2.0
*
* 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_ANALOG_MCP3008_H
#define __INCLUDE_NUTTX_ANALOG_MCP3008_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/analog/ioctl.h>
#include <nuttx/config.h>
#include <nuttx/spi/spi.h>
/****************************************************************************
* Preprocessor definitions
****************************************************************************/
/* IOCTL Commands
* Cmd: ANIOC_MCP3008_DIFF Arg: 1 for differential, 0 for single-ended
*/
#define ANIOC_MCP3008_DIFF _ANIOC(AN_MCP3008_FIRST + 0)
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
FAR struct adc_dev_s *mcp3008_initialize(FAR struct spi_dev_s *spi);
#endif /* __INCLUDE_NUTTX_ANALOG_MCP3008_H */