The ADL User Guide v6.31 still documents adl_busWrite() purely as an output function: there is no mention of data being clocked-in on MISO while the data from adl_busWrite() is clocked-out on MOSI - let alone any description of how one would access any such received data!
I was wondering if open-at can do full duplex now. I am currently using the ADC122S101 and from looking at the timing diagram, it seems the device only works in full duplex mode not half duplex.
As stated in the PTS of the Q26 device, the SPI peripheral on the device is configurable as half duplex, not full duplex.
The APIs also indicate that reads and writes take place independantly from each other.
I’m also trying to implement the SPI bus on the Q2686 and Q2687RD. I installed the latest firmware 7.45.
But still without result. It’s not possible to send and receive at the same time on the MISO and MOSI pins.
Is there anyone who has already achieved an SPI in full duplex?
It’s like everybody said pretty standard to work with the MISO and MOSI pin on the SPI bus.
static s32 hspi;
static adl_busSPISettings_t spichip =
{
127, //Master max freqclock = 13000/(1+127)~= 102 kHz
ADL_BUS_SPI_CLK_MODE_0, //rest state 0, data valid on rising edge.
ADL_BUS_SPI_ADDR_CS_GPIO, //CS_HARD does not work!
//use the reserved hardware chip select pin.
ADL_BUS_SPI_CS_POL_LOW, //Chip select signal is low level.
ADL_BUS_SPI_MSB_FIRST, //Send msb bit first.
ADL_IO_GPIO | 31, //We use a gpio for chip select
ADL_BUS_SPI_LOAD_UNUSED, //The load signal is unused.
ADL_BUS_SPI_DATA_UNIDIR, //3 wire mode miso, mosi and clk.
ADL_BUS_SPI_MASTER_MODE, //bus is used in master mode.
ADL_BUS_SPI_BUSY_UNUSED //The busy signal is not used.
};
void Init()
{
hspi = adl_busSubscribe(ADL_BUS_ID_SPI,1,&spichip); //select spi port 1
u32 addsize =8;
adl_busIOCtl(hspi, ADL_BUS_CMD_SET_ADD_SIZE,&addsize);
}
void ReadSpi()
{
u8 i, data = 0;
adl_busAccess_t address = {0,0};
for(i=0;i<=8;i++)
{
address.Address = ((u32)i)<<24;
adl_busRead(hspi,&address,1,&data);
WriteDebugMsg("Read data on addres 0x%02x, data 0x%02x.\r\n",i,data);
}
}
I first set the SPI settings. Selecting the CS_HARD (chip select hardwarepin) parameter does not work so I use a the same pin but in gpio mode.
The spi clock speed is set to the lowest value but this can be modified of course.
The register size of my device is 8-bit (cs is selecting the device). To access this one I’m setting the address length to 8-bit. Don’t forget to shift the address, it’s using 32 bits. See the ADL_user_guide for more details.
In this example I only read one byte at a time for the first 9 register.
Setting the bus SPI settings in full duplex is done with ‘ADL_BUS_SPI_DATA_UNIDIR’.
In this case your using a 3 wire interface. CLK,MISO,MOSI
Setting the SPI parameter to ‘ADL_BUS_SPI_DATA_BIDIR’ will set the SPI in half duplex mode.
Now you will use only 2 wires CLK and I/O SPI. One wire to send and receive the data from the slave (=half duplex).
Don’t make a mistake! ‘ADL_BUS_SPI_DATA_UNIDIR’ & ‘ADL_BUS_SPI_DATA_BIDIR’ already exist since 6.xx FW.
They only set the configuration of data lines.
To have a Full-Duplex communication we would need an adl_busWrite function which receives data during its write, which (as far as i know) is not available.