This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
at91 SPI driver, use of cyg_drv_dsr_lock()
Hello all,
I cannot for the life of me get my head around this code in spi_at91.c (in
packages\devs\spi\arm\at91\current\src), function spi_at91_transfer:
// Unmask the SPI int
cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_SPI);
// Wait for its completition
cyg_drv_dsr_lock();
{
while (!spi_bus->transfer_end)
cyg_drv_cond_wait(&spi_bus->transfer_cond);
}
cyg_drv_dsr_unlock();
Now, the condition variable spi_bus->transfer_cond is signalled from the
DSR:
// Transfer ended
spi_bus->transfer_end = true;
cyg_drv_cond_signal(&spi_bus->transfer_cond);
However, if I understand correctly, cyg_drv_dsr_lock() will prevent the
(any) DSR from being run, so...while holding the DSR lock the code waits for
a condition variable that must be signalled from the DSR that we have just
prevented from running in the first place??
Either I completely misunderstand the way cyg_drv_dsr_lock() works (very
possible), or this code is broken...anyone care to comment?
Regards
Peter
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss