SPI.begin()要做腳位宣告
hspi = new SPIClass(HSPI);
hspi->setBitOrder(MSBFIRST);
hspi->setDataMode(SPI_MODE1);
pinMode(ADS1220_CS_PIN, OUTPUT); //HSPI SS
pinMode(ADS1220_DRDY_PIN,INPUT);
hspi->begin(14,12,13,15);//HSPI_CLK HSPI_O HSPI ID HSPI_SS
//SCLK, MISO, MOSI, SS
不然真的會被搞很久
不要用範例裡面的SPI通訊方式
hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
digitalWrite(15, LOW);
hspi->transfer(stuff);
digitalWrite(15, HIGH);
hspi->endTransaction();
SPI.begin()內有設定腳位的話就當作SPI.transfer在用就好
像下面範例
digitalWrite(ADS1220_CS_PIN,LOW); //Take CS low
delayMicroseconds(100);
for (int i = 0; i < 3; i++)
{
SPI_Buff[i] = hspi->transfer(SPI_MASTER_DUMMY);
}
delayMicroseconds(100);
digitalWrite(ADS1220_CS_PIN,HIGH);
沒有留言:
發佈留言