This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Semantics of cyg_spi_transaction_tick?


>>>>> "Stanislav" == Stanislav Meduna <stano@meduna.org> writes:

    Stanislav> Hi,
    Stanislav> the docs state that

    Stanislav>   If the device requires additional clock ticks in the
    Stanislav>   middle of a transaction without being selected,
    Stanislav>   cyg_spi_transaction_tick can be used. This will drop
    Stanislav>   the device's chip select if necessary, then generate
    Stanislav>   the appropriate number of ticks. The arguments are
    Stanislav>   the same as for cyg_spi_tick.

    Stanislav> This does not correspond to what the present SPI
    Stanislav> drivers do; they state that they do not touch the chip
    Stanislav> select.

I am not sure which existing SPI drivers you are referring to. The
documentation is correct: a tick means clock signals with no device
selected. If a device is currently selected as part of a transaction,
the chip select should be deasserted first. The tick functionality was
incorporated into the API because of MMC cards, where the protocol
requires clock ticks on the SPI bus with no data being transferred.

    Stanislav> My problem is that the protocol of the dataflash device
    Stanislav> I am using returns a byte specifying the number of
    Stanislav> following data, that can be either zero, or can fit in
    Stanislav> the specified buffer, or the user supplied a buffer of
    Stanislav> insufficient length.

    Stanislav> So I read the number of the present data with
    Stanislav>   cyg_spi_transaction_transfer(..., false);
    Stanislav> and now I can have three cases

    Stanislav> - no further data. I am done and need to simply
    Stanislav> deassert the CS.

    Stanislav> - additional data and I have place for them - I just read
    Stanislav>   them using
    Stanislav>     cyg_spi_transaction_transfer(..., true);

    Stanislav> - insufficient buffer - I should tick the device to
    Stanislav>   throw the data away, deselect and return error to the
    Stanislav>   caller.

    Stanislav> From what I read in the code I can throw the unused
    Stanislav> data using cyg_spi_transaction_tick (which does not
    Stanislav> touch the CS) and rely on cyg_spi_transaction_end to
    Stanislav> deassert the CS; however, this does not correspond with
    Stanislav> the documentation. Can I rely on what the code does, or
    Stanislav> is it possible that another SPI driver implements it
    Stanislav> another way?

In theory the correct way to handle this is to use
cyg_spi_transaction_transfer() with NULL arguments for both RX and TX
buffers. In other words you transfer data to/from the current data
device, but you do not care what data gets sent to the device and any
data coming from the device should be discarded. I do not know if all
current drivers handle this correctly.
    
Bart    

-- 
Bart Veer                                   eCos Configuration Architect
eCosCentric Limited    The eCos experts      http://www.ecoscentric.com/
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]