mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-08-19 13:23:37 +08:00
[BSP][NS800RT7P65] Add ADC driver support
ToolsCI / Tools (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
ToolsCI / Tools (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
This commit is contained in:
@@ -19,6 +19,9 @@ if GetDepend('BSP_USING_CAN'):
|
||||
if GetDepend('BSP_USING_ECAP'):
|
||||
src += ['drv_ecap.c']
|
||||
|
||||
if GetDepend('BSP_USING_ADC'):
|
||||
src += ['drv_adc.c']
|
||||
|
||||
if GetDepend('BSP_USING_TIM'):
|
||||
src += ['drv_timer.c']
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2026, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2026-05-30 NinoC137 add NS800 ADC driver
|
||||
*/
|
||||
|
||||
#ifndef __DRV_ADC_H__
|
||||
#define __DRV_ADC_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <drv_common.h>
|
||||
|
||||
#ifdef __ADC_H__
|
||||
#undef __ADC_H__
|
||||
#endif
|
||||
#include "adc.h"
|
||||
#ifdef __ADC_H__
|
||||
#undef __ADC_H__
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
ADC外设相关配置
|
||||
该芯片单个ADC单元支持32个通道与SoC
|
||||
同时,共有4个Int模块与4个PPB模块
|
||||
*/
|
||||
#define NS800_ADC_CHANNEL_MAX 32U
|
||||
#define NS800_ADC_SOC_MAX 32U
|
||||
#define NS800_ADC_INT_MAX 4U
|
||||
#define NS800_ADC_PPB_MAX 4U
|
||||
|
||||
/*
|
||||
ADC Int模块的序列号掩码
|
||||
*/
|
||||
#define NS800_ADC_INT1 0U
|
||||
#define NS800_ADC_INT2 1U
|
||||
#define NS800_ADC_INT3 2U
|
||||
#define NS800_ADC_INT4 3U
|
||||
|
||||
/*
|
||||
ADC PPB模块的序列号掩码
|
||||
*/
|
||||
#define NS800_ADC_PPB1 0U
|
||||
#define NS800_ADC_PPB2 1U
|
||||
#define NS800_ADC_PPB3 2U
|
||||
#define NS800_ADC_PPB4 3U
|
||||
|
||||
/*
|
||||
ADC PPB模块的功能配置
|
||||
PPB模块支持:
|
||||
1. 超上限检测
|
||||
2. 超下限检测
|
||||
3. 过零检测
|
||||
4. oversampling
|
||||
*/
|
||||
#define NS800_ADC_PPB_EVT_TRIPHI 0x0001U
|
||||
#define NS800_ADC_PPB_EVT_TRIPLO 0x0002U
|
||||
#define NS800_ADC_PPB_EVT_ZERO 0x0004U
|
||||
#define NS800_ADC_PPB_EVT_ALL (NS800_ADC_PPB_EVT_TRIPHI | NS800_ADC_PPB_EVT_TRIPLO | NS800_ADC_PPB_EVT_ZERO)
|
||||
|
||||
/*
|
||||
ADC的控制指令
|
||||
*/
|
||||
#define NS800_ADC_CMD_DISABLE_EXT (RT_DEVICE_CTRL_BASE(ADC) + 0x10)
|
||||
#define NS800_ADC_CMD_ENABLE_PPB (RT_DEVICE_CTRL_BASE(ADC) + 0x11)
|
||||
#define NS800_ADC_CMD_ENABLE_IRQ (RT_DEVICE_CTRL_BASE(ADC) + 0x12)
|
||||
#define NS800_ADC_CMD_SET_CALLBACK (RT_DEVICE_CTRL_BASE(ADC) + 0x13)
|
||||
|
||||
/* 注意:务必确保在调用adc中断之前已正确初始化全局中断向量表 */
|
||||
typedef void (*ns800_adc_irq_callback_t)(void *user_data);
|
||||
|
||||
struct ns800_adc_callback
|
||||
{
|
||||
ns800_adc_irq_callback_t callback;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
int rt_hw_adc_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DRV_ADC_H__ */
|
||||
@@ -7,4 +7,8 @@ devices.ecap:
|
||||
- CONFIG_BSP_USING_ECAP=y
|
||||
- CONFIG_BSP_USING_ECAP1=y
|
||||
- CONFIG_BSP_USING_SPI=y
|
||||
- CONFIG_BSP_USING_SPI1=y
|
||||
- CONFIG_BSP_USING_SPI1=y
|
||||
devices.adc:
|
||||
<<: *scons
|
||||
kconfig:
|
||||
- CONFIG_BSP_USING_ADC=y
|
||||
@@ -24,6 +24,7 @@
|
||||
| **片上外设** | **支持情况** | **备注** |
|
||||
| GPIO | 支持 | |
|
||||
| UART | 支持 | UART1 |
|
||||
| ADC | 支持 | ADC0 |
|
||||
|
||||
## 使用说明
|
||||
|
||||
|
||||
@@ -148,6 +148,11 @@ menu "On-chip Peripheral Drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_ADC
|
||||
bool "Enable ADC"
|
||||
select RT_USING_ADC
|
||||
default n
|
||||
|
||||
menuconfig BSP_USING_CAN
|
||||
bool "Enable CAN"
|
||||
select RT_USING_CAN
|
||||
|
||||
Reference in New Issue
Block a user