资源简介
本示例基于stm32f103外设固件库开发的AD7091驱动程序,内涵初始化和AD获取操作代码。
在项目中亲测可以正常运行和使用,适合参考作为二次开发。
在项目中亲测可以正常运行和使用,适合参考作为二次开发。
代码片段和文件信息
#include “ad7091.h“
#include “delay.h“
/**
* @brief Select AD7091: Chip Select pin low
*/
#define AD7091_CS_LOW() GPIO_ResetBits(AD7091_CS_GPIO_PORT AD7091_CS_PIN)
/**
* @brief Deselect AD7091: Chip Select pin high
*/
#define AD7091_CS_HIGH() GPIO_SetBits(AD7091_CS_GPIO_PORT AD7091_CS_PIN)
/**
* @brief Select AD7091: Chip CONVST pin low
*/
#define AD7091_CONVST_LOW() GPIO_ResetBits(AD7091_CONVST_GPIO_PORT AD7091_CONVST_PIN)
/**
* @brief Deselect AD7091: Chip CONVST pin high
*/
#define AD7091_CONVST_HIGH() GPIO_SetBits(AD7091_CONVST_GPIO_PORT AD7091_CONVST_PIN)
#define AD7091_DUMMY_BYTE 0xffff
uint16_t AD7091_SendByte(uint16_t byte)
{
/*!< Loop while DR register in not emplty */
while (SPI_I2S_GetFlagStatus(AD7091_SPI SPI_I2S_FLAG_TXE) == RESET);
/*!< Send byte through the SPI1 peripheral */
SPI_I2S_SendData(AD7091_SPI byte);
/*!< Wait to receive a byte */
while (SPI_I2S_GetFlagStatus(AD7091_SPI SPI_I2S_FLAG_RXNE) == RESET);
/*!< Return the byte read from the SPI bus */
return SPI_I2S_ReceiveData(AD7091_SPI);
}
uint16_t AD7091_ReadByte(void)
{
return (AD7091_SendByte(AD7091_DUMMY_BYTE));
}
void AD7091_LowLevel_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/*!< AD7091_SPI_CS_GPIO AD7091_SPI_MOSI_GPIO AD7091_SPI_MISO_GPIO
and AD7091_SPI_SCK_GPIO Periph clock enable */
RCC_APB2PeriphClockCmd(AD7091_CS_GPIO_CLK | AD7091_SPI_MOSI_GPIO_CLK | AD7091_SPI_MISO_GPIO_CLK |
AD7091_SPI_SCK_GPIO_CLK | AD7091_CONVST_GPIO_CLK ENABLE);
/*!< AD7091_SPI Periph clock enable */
RCC_APB2PeriphClockCmd(AD7091_SPI_CLK ENABLE);
/*!< Configure AD7091_SPI pins: SCK */
GPIO_InitStructure.GPIO_Pin = AD7091_SPI_SCK_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(AD7091_SPI_SCK_GPIO_PORT &GPIO_InitStructure);
/*!< Configure AD7091_SPI pins: MOSI */
GPIO_InitStructure.GPIO_Pin = AD7091_SPI_MOSI_PIN;
GPIO_Init(AD7091_SPI_MOSI_GPIO_PORT &GPIO_InitStructure);
/*!< Configure AD7091_SPI pins: MISO */
GPIO_InitStructure.GPIO_Pin = AD7091_SPI_MISO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(AD7091_SPI_MISO_GPIO_PORT &GPIO_InitStructure);
/*!< Configure AD7091_CS_PIN pin: AD7091 Card CS pin */
GPIO_InitStructure.GPIO_Pin = AD7091_CS_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(AD7091_CS_GPIO_PORT &GPIO_InitStructure);
/*!< Configure AD7091_CONVST_PIN pin: AD7091 Card CONVST pin */
GPIO_InitStructure.GPIO_Pin = AD7091_CONVST_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(AD7091_CONVST_GPIO_PORT &GPIO_InitStructure);
}
uint16_t AD7091_GetSmpNormal(void)
{
#if 1
uint16_t adc_smp;
AD7091_CONVST_HIGH();
AD7091_CONVST_LOW();
AD7091_CONVST_HIGH();
//delay<=650ns
delay_us(1);
AD7091
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4409 2018-06-29 06:46 AD7091\ad7091.c
文件 1430 2018-05-06 21:55 AD7091\ad7091.h
目录 0 2018-06-29 06:46 AD7091
----------- --------- ---------- ----- ----
5839 3
- 上一篇:AVR 模拟IIC总线
- 下一篇:47个过程组强化记忆-详细
相关资源
- stm32f103系列spi连接rc522的rfid读卡程序
- STM32F103+GPRS原理图 PCB制作PM2.5检测仪和
- STM32F103下的编码器程序
-
STM32f103 jli
nk命令行 SWD方式烧写脚本 - AD7793 c程序
- STM32F103 ucLinux 开发BOOT源码
- CANOPEN在STM32F103ZET6单片机上的实现
- STM32F103ZET6原理图及pcb.rar
- STM32F103ZET6单片机CAN总线通信程序例程
- 基于STM32F103的4*5矩阵按键
- 基于Stm32f10x的循迹灭火小车
- STM32F103C8T6脚位分布图.pdf
- stm32f103x系列常用芯片引脚图
- STM32F103RCT6最小系统板——华北五省
- DHT22(AM2302)STM32f103程序
- STM32F103+ENC28J60+Webserver
- STM32F103RCT6使用I2C通讯PCF8591数模转换模
- stm32f103c8t6+ESP826 设置为AP模式
- STM32F103,4*4矩阵按键
- STM32F103C8T6核心板测试程序(RTC).ra
- FlashTool STM32F103ZET6通过USB串口烧写
- STM32F103通过模拟IIC读取LIS3DH 解析数据
- STM32F103RBT6+DM9000CEP+UIP Telnet功能实现工
- STM32F103VCT6+W5500 telnet功能实现
- Speex 库在 STM32F103xxxSTM32F101xxx 上使用的
- STM32F103四个通用定时器编码器模式配
- STM32F103ZET6原理图
- stm32f103c8t6 最小系统 开发板 AD电路图
- STM32F103 AM2302温湿度模块驱动例程
- STM32F103 NRF24L01无线通讯模块驱动例程
评论
共有 条评论