资源简介
基于STM32的DAC8552的驱动程序,DAC8554和这个一样,已经调试了

代码片段和文件信息
/**
******************************************************************************
* @file bsp_dac8552.c
* @author 张超凡
* @version V1.0
* @date
* @brief DAC8552驱动程序
*
*/
/*******************************调试信息*************************************************
* 模拟了三个spi通信。一红有6个通道,编号从 0-5 。
* 为保证输出的精度,有两种办法:1、用最小二乘法拟合直线。2、用分段线性插值。
*
*
* 增加了延时
*
*
*
*******************************************************************************/
#include “stm32f4xx.h“
#include “bsp_dac8552.h“
#include “stm32f4xx_conf.h“
#include “delay.h“
static void DAC8552_0_SPI_Write( unsigned int code);
static void DAC8552_1_SPI_Write( unsigned int code);
static void DAC8552_2_SPI_Write( unsigned int code);
static void DAC8552_delay(void);
void DAC8552_Init()
{
unsigned char i = 0;
GPIO_InitTypeDef GPIO_InitStructure;
DAC8552_RCC_GPIOClockCmd(); //使能端口引脚端口时钟
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = DAC8552_0_SYNC_Pin ; // 端口配置
GPIO_Init(DAC8552_0_SYNC_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = DAC8552_0_SCLK_Pin;
GPIO_Init(DAC8552_0_SCLK_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = DAC8552_0_DIN_Pin;
GPIO_Init(DAC8552_0_DIN_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = DAC8552_1_SYNC_Pin ; // 端口配置
GPIO_Init(DAC8552_1_SYNC_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = DAC8552_1_SCLK_Pin;
GPIO_Init(DAC8552_1_SCLK_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = DAC8552_1_DIN_Pin;
GPIO_Init(DAC8552_1_DIN_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = DAC8552_2_SYNC_Pin ; // 端口配置
GPIO_Init(DAC8552_2_SYNC_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = DAC8552_2_SCLK_Pin;
GPIO_Init(DAC8552_2_SCLK_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = DAC8552_2_DIN_Pin;
GPIO_Init(DAC8552_2_DIN_Port &GPIO_InitStructure);
for(i = 0;i <5;i ++)
{
DAC8552_SetVoltage(i0);
}
}
static void DAC8552_delay(void)
{
int x = 10;
while(--x);
}
void DAC8552_SetVoltage( unsigned char channelunsigned int code) //通道一共6个(0-5),一个芯片有两个通道 data是一个24位的数据STM32中int型是32位的数据
{
unsigned int data = 0;
unsigned char chip;
if( code > 65535 | channel > 5)
return ;
chip = channel >> 1;
(channel%2 == 0) ? (data = 0x100000 | code) : (data = 0x240000 | code) ; //通道有 chip0 : 0 1 chip1 : 2 3 chip2 : 4 5 偶数通道0 奇数通道一
switch( chip)
{
case 0 :
{
DAC8552_0_SPI_Write(data);
break;
}
case 1 :
{
DAC8552_1_SPI_Write(data);
break;
}
case 2 :
{
DAC8552_2_SPI_Write(data);
break;
}
}
}
static void DAC8552_1_SPI_Write( unsigned int code)
{
char i=0;
unsigned int data = code;
DAC8552_1_SYNC = 1;
DAC8
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-05-24 15:40 dac8552\
文件 4436 2017-05-24 15:40 dac8552\bsp_dac8552.c
文件 1694 2017-05-24 15:40 dac8552\bsp_dac8552.h
- 上一篇:AD5761R驱动程序,支持STM32
- 下一篇:Excel2LaTex.xla
相关资源
- stm32f407上的两个can发送和接收例程
- STM32 led 时钟
- STM32 2.4G通信例程
- 直流无刷电机方波驱动 stm32 例程代码
- STM32中文资料
- STM32蓝牙和串口程序
- STM32f103超声波模块例程
- stm32f103c8t6 4 oled.rar
- stm32f030 IAP Demo(原创)
- STM32基于rt_thread操作系统的SDHC卡文件
- NRF24L01实现51与STM32双向通讯
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- stm32官方例程
- STM32F103定时器中断程序
- [免费]基于stm32f103ze 的OLED驱动代码
- STM32F103RBT6驱动UC1698控制芯片的160160黑
- STM32F103 DS18B20 V3.5.0固件库驱动程序工
- STM32定时器使用入门。看了这个程序会
- SIM908 SDIO FSMC STM32 FIFO
- STM32F103 CC2500完整驱动(模拟SPI)
- AD7606采集程序
- stm32 用SPI 方式读写 SDHC
- stm32通过DMA方式采集ADC数据
- 意法半导体STM全系列微控制器STM32ST
- 基于STM32芯片的SX1278 驱动 LORA.rar
- STM32的PCB封装库,以及原理图库,48
- SX1280.rar
- STM32 DS3231驱动.zip
- STM32F103C8T6+NRF24l01无线通信
评论
共有 条评论