SPI Hal - Waiting to MISO line to be released

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
akshaim
Posts: 20
Joined: Tue Sep 21, 2021 9:47 am
Has thanked: 9 times

SPI Hal - Waiting to MISO line to be released

Post by akshaim »

Hi Team,

I am trying to implement a driver using SPI for the ADBMS1818 chip which is used to measure the Cell voltages of battery cells. To start measuring the voltage using the ADC . I have to do a start poll operation (PLADC). After which I shall use another command to read the ADC values (say for eg : RDCVA).
When I ask the chip to start measuring ( PLADC) I have to wait for a specific amount of time depending on the number of cells being measured. The operation is shown in the image attached.

My doubt is with PLADC command. Is there a way to know when the request for conversion has been done based on the SDO line activity? I currently use spiStartExchange. Can `end_cb` in the SPI device descriptor be used for this purpose ?

Regards,

Akshai
Attachments
ADBMS1818.png
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SPI Hal - Waiting to MISO line to be released

Post by Giovanni »

Hi,

I think you could use GPIO (PAL driver) and poll for completion or to wait for a rising edge.

You could also keep doing spiReceive() until you get an 0xFF if the extra clocks are tolerated by the ADC.

Giovanni
akshaim
Posts: 20
Joined: Tue Sep 21, 2021 9:47 am
Has thanked: 9 times

Re: SPI Hal - Waiting to MISO line to be released

Post by akshaim »

Hi Giovanni,

Thank you for the reply. Unfortunately, I cannot wait as it will kill the timings. Is there a possibility for an asynchronous way to do it?

Regards,

Akshai
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SPI Hal - Waiting to MISO line to be released

Post by Giovanni »

Waiting for a rising edge is asynchronous, it triggers a callback. See PAL callbacks.

Giovanni
akshaim
Posts: 20
Joined: Tue Sep 21, 2021 9:47 am
Has thanked: 9 times

Re: SPI Hal - Waiting to MISO line to be released

Post by akshaim »

Thanks Giovanni. I shall explore that :)

Regards,

Akshai
akshaim
Posts: 20
Joined: Tue Sep 21, 2021 9:47 am
Has thanked: 9 times

Re: SPI Hal - Waiting to MISO line to be released

Post by akshaim »

Instead of polling via GPIO I ended up sending an empty requests using DMA and have callback check for `0xFF` in Rx buffer which shows the device is free :). This ended up being the easiest option
Post Reply