public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "liang rainti" <rainti_1212@hotmail.com>
To: ecos-discuss@sources.redhat.com
Cc: bartv@ecoscentric.com
Subject: [ECOS] bugs on spi API
Date: Tue, 26 Jul 2005 10:26:00 -0000	[thread overview]
Message-ID: <BAY13-F299C27DC9052461241565C99CD0@phx.gbl> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312; format=flowed, Size: 2149 bytes --]

hi,all,
  i am writing a qspi drivers on mcf5272 for eCos, the qspi has a 
character:read and write in a transfer at one time. Referering generic SPI 
API, cyg_spi_transfer( ) function can read  spi device a transfer at one 
time or write that. But read operation and write operation can not be 
finished at the same time in the transfer( ) function.

eg.
A typical transaction might involve the following. First a command
should be sent to the device, consisting of four bytes. The device
will then respond with a single status byte, zero for failure,
non-zero for success. If successful then the device can accept another
n bytes of data, and will generate a 2-byte response including a
checksum. The device's chip select should remain asserted throughout.
The code for this would look something like:

#include &lt;cyg/io/spi.h&gt;
#include &lt;cyg/hal/hal_io.h&gt;    // Defines the SPI devices

    cyg_spi_transaction_begin(hal_spi_eprom);
    // Interrupt-driven transfer, four bytes of command
   !!! cyg_spi_transaction_transfer(hal_spi_eprom, 0, 4, command, NULL, 0);
    // Read back the status
   !!! cyg_spi_transaction_transfer(hal_spi_eprom, 0, 1, NULL, status, 0);
    
Why not be 
cyg_spi_transaction_transfer(hal_spi_eprom,0,4,command,status,0)???  This 
will be OK??? I am wondering.
   if (!status[0]) {
        // Command failed, generate some extra ticks to drop the chip 
select
        cyg_spi_transaction_tick(hal_spi_eprom, 0, 1);
    } else {
        // Transfer the data, then read back the final status. The
        // chip select should be dropped at the end of this.
        cyg_spi_transaction_transfer(hal_spi_eprom, 0, n, data, NULL, 0);
        cyg_spi_transaction_transfer(hal_spi_eprom, 0, 2, NULL, status, 1);
        // Code for checking the final status should go here 
    }

_________________________________________________________________
ÓëÊÀ½ç¸÷µØµÄÅóÓѽøÐн»Á÷£¬Ãâ·ÑÏÂÔØ MSN Messenger:  
http://messenger.msn.com/cn 


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

             reply	other threads:[~2005-07-26 10:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-26 10:26 liang rainti [this message]
2005-07-26 18:52 ` Bart Veer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY13-F299C27DC9052461241565C99CD0@phx.gbl \
    --to=rainti_1212@hotmail.com \
    --cc=bartv@ecoscentric.com \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).