2019-08-14 14:38发布
Acuity 发表于 2017-8-16 11:20 1、AD7940,就一个spi,spi代码不上了,封装好后就没配置也不需要配置了(spi 8位传输模式,全双工,高位在 ...
最多设置5个标签!
int spi_send_recv(struct st_spi_device *spi_bus,const void *send_buff,void *recv_buff,unsigned short data_size);//发送完同时接收
u16 ad7940_read(void)
{
u8 send_buff[2] = {0},recv_buff[2] = {0};
spi_send_recv(spi1,send_buff,recv_buff,2);
return(recv_buff[0]<<8 | recv_buff[1])&0x3fff; //14位,最高2位无效
}
AD5300能帮忙写一下吗,8位的DAC,电压输出型的,谢啦!
int spi_send(struct st_spi_device *spi_bus,const void *send_buff,unsigned short send_size); //只发送
/*
mode范围0—3
*/
void ad5300_set(u8 mode,u8 out)
{
u16 send_data;
u8 send_buff[2];
send_data = ((mode << 8) | out)<<4; //这个逻辑手册,如下图
send_buff[0] = (send_data >> 8)&0xff; //高位在前
send_buff[1] = send_data & 0xff;
spi_send(spi1,send_buff,2);
}
一周热门 更多>