pellepl / spiflash_driver

Hardware agnostic generic spi flash driver
MIT License
73 stars 27 forks source link

Question: what is the purpose of `spi->could_be_busy`? #8

Closed g-berthiaume closed 3 months ago

g-berthiaume commented 3 months ago

I'm trying to understand in what situation the spi->busy_pre_check routine would be executed.` This flag seems to be set in only one condition:

  if (spi->could_be_busy) {
    spi->busy_pre_check = 1;
  }

The spi->could_be_busy flag does not seems to get set anywhere. In what case would the busy_pre_check would be triggered?

Am I missing something? Thanks for this great library.

pellepl commented 3 months ago

Hi, it was some time since I wrote this, but I have a vague recollection of that the user can set could_be_busy if there are other drivers acting on the spi flash also. If not, and this driver is the lone and only actor, it is always false and we do not need to waste time checking the busy flag.

I'll add a comment in near future. Thanks for pointing this out, and thanks for the kind words. 🙏

g-berthiaume commented 3 months ago

Thanks for your answer. I did not understand this use case.

It was a pleasure to read your code. I like the way you decoupled the sync and async.