您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > DAC8552驱动程序
//首先是.h文件#ifndef__DAC8552_H#define__DAC8552_H#includeconfig.h#defineSYNC_0P1OUT&=~BIT0#defineSYNC_1P1OUT|=BIT0#defineSCLK_0P1OUT&=~BIT1#defineSCLK_1P1OUT|=BIT1#defineDIN_0P1OUT&=~BIT2#defineDIN_1P1OUT|=BIT2voidport_init();voidwrite_8552(ulongdata);voidDAC_A(ulongdata);//启用A通道voidDAC_B(ulongdata);//启用B通道voidDAC_AB(ulongdata_A,ulongdata_B);//启用A、B通道,且同时触发#endif//下面为.c文件#includeDAC8552.hvoidport_init(){P1SEL=0X00;P1DIR=0XFF;}voidwrite_8552(ulongdata){uchari;SYNC_1;delay_us(1);SCLK_0;SYNC_0;for(i=0;i24;i++){if(0x800000&data)DIN_1;elseDIN_0;SCLK_1;delay_us(1);SCLK_0;data=data1;}delay_us(1);SYNC_1;}voidDAC_A(ulongdata){ulongctr=0x10;data=data|(ctr16);write_8552(data);}voidDAC_B(ulongdata){ulongctr=0x24;data=data|(ctr16);write_8552(data);}voidDAC_AB(ulongdata_A,ulongdata_B){ulongctr=0x00;data_A=data_A|(ctr16);write_8552(data_A);ctr=0x34;data_B=data_B|(ctr16);write_8552(data_B);}
本文标题:DAC8552驱动程序
链接地址:https://www.777doc.com/doc-1201253 .html