加了个延时,好像行了。
#include "adg738.h"
void ADG738Delay(u16 time)
{
u16 i;
for(i = 0; i < time; time++);
}
//¸ÃоƬÊÇϽµÑزÉÑù£¬¹ÊÐèÒª¸ü¸Ä¿ÕÏеçƽ
void ADG738_Set(unsigned char value)
{
SPI_InitTypeDef SPI_InitStructure;
SPI_Cmd(SPI3, DISABLE);
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
// SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI3, &SPI_InitStructure);
SPI_Cmd(SPI3, ENABLE);
ADG738_CS(ON);
SPI3_ReadWriteByte(value);
ADG738_CS(OFF);
ADG738Delay(1);
SPI_Cmd(SPI3, DISABLE);
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_Init(SPI3, &SPI_InitStructure);
SPI_Cmd(SPI3, ENABLE);
}
|