SPI
#define SLAVE_ENABLE2 (1) // Using DIO19 and DIO0
#define CS_DIO19 (0x01) // Use the one connected to SPISEL0:DIO19
#define CS_DIO0 (0x02) // SPISEL1: Use the one connected to DIO0
...
// SPI の初期化
vAHI_SpiConfigure(SLAVE_ENABLE2, // Use two SPISEL0,1
E_AHI_SPIM_MSB_FIRST,
TRUE,
TRUE,
1,
E_AHI_SPIM_INT_DISABLE,
E_AHI_SPIM_AUTOSLAVE_DSABL);
...
// Transfer 1(8bit write out)
vAHI_SpiSelect(CS_DIO0); // Enable SPISEL1
vAHI_SpiStartTransfer(
7, // 7+1=8 bit transfer
0x00000012L ); // sends 0x12
while(bAHI_SpiPollBusy()); // Waiting for read/write by polling
//uint8 u8val = u8AHI_SpiReadTransfer8();
// SPIMISO input data can be read.
// In this example, u8val is not used.
// Give it some time if necessary.
vWait(100);
// Transfer 2 (16-bit read)
vAHI_SpiStartTransfer(
15, // transfer 15+1=16 bit
0x00000000L ); // dummy send data
while(bAHI_SpiPollBusy()); // Waiting for read/write by polling
uint16 u16val = u16AHI_SpiReadTransfer16();
// The read 16bit data is stored to u16val.
// release the SPISEL
vAHI_SpiStop();
...
// disable the SPI device.
vAHI_SpiDisable();functions
vAHI_SpiConfigure()
Name
Remark
Relationship between SPI Mode and bPolarity, bPhase.
vAHI_SpiSelect()
Name
Remark
vAHI_SpiStartTransfer()
Name
Remark
bAHI_SpiPollBusy()
u32AHI_SpiReadTransfer32()
最終更新