From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23680 invoked by alias); 26 Jul 2005 10:26:42 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 23603 invoked by uid 22791); 26 Jul 2005 10:26:31 -0000 Received: from bay13-f29.bay13.hotmail.com (HELO hotmail.com) (64.4.31.29) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 26 Jul 2005 10:26:31 +0000 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 26 Jul 2005 03:26:28 -0700 Message-ID: Received: from 63.236.40.165 by by13fd.bay13.hotmail.msn.com with HTTP; Tue, 26 Jul 2005 10:26:28 GMT X-Originating-Email: [rainti_1212@hotmail.com] X-Sender: rainti_1212@hotmail.com From: "liang rainti" To: ecos-discuss@sources.redhat.com Cc: bartv@ecoscentric.com Bcc: Date: Tue, 26 Jul 2005 10:26:00 -0000 Mime-Version: 1.0 Content-Type: text/plain; charset=gb2312; format=flowed Subject: [ECOS] bugs on spi API X-SW-Source: 2005-07/txt/msg00268.txt.bz2 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 <cyg/io/spi.h> #include <cyg/hal/hal_io.h> // 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