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: SPI usage


Hi, 

SPI devices should be defined in the file spi_eb55.c. You can specify the CS
in the field .dev_num.
 
// -------------------------------------------------------------------------
// AT91EB55 SPI exported devices 
 
// AT45DB321B DataFlash
static cyg_spi_at91_device_t spi_dataflash_dev0 CYG_SPI_DEVICE_ON_BUS(0) = 
{
    .spi_device.spi_bus = &cyg_spi_at91_bus.spi_bus,
    .dev_num     = 0,       // Device number = CHIP SELECT
    .cl_pol      = 1,       // Clock polarity (0 or 1)
    .cl_pha      = 0,       // Clock phase (0 or 1)
    .cl_brate    = 8192000, // Clock baud rate
    .cs_up_udly  = 1,       // Delay in usec between CS up and transfer
start
    .cs_dw_udly  = 1,       // Delay in usec between transfer end and CS
down
    .tr_bt_udly  = 1        // Delay in usec between two transfers
};
cyg_spi_device *cyg_spi_dataflash_dev0 = &spi_dataflash_dev0.spi_device;


If you prefer not modify in spi_eb55.c, you can put the device definition in
your drive file. This is an example for the ADC on the AT91EB55 board :

#define CHIP_SELECT 5       ///< Chip select pour selectionner l'ADC
/// Definition du device SPI associe au bus SPI defini dans le driver SPI
pour AT91
static cyg_spi_at91_device_t spi_adc_dev  CYG_SPI_DEVICE_ON_BUS(0) = {
    .spi_device.spi_bus = &cyg_spi_at91_bus.spi_bus,
    .dev_num = CHIP_SELECT,
    .cl_pol = 0,
    .cl_pha = 1, // Il est important de mettre la phase a 1 pour la lecture
des data sur le front montant de l'horloge.
    .cl_brate = 500000, // 500 KHz (Min 10 KHz, Max 1 MHz pour cet ADC en
2.7 Volts)
    .cs_up_udly = 0,
    .cs_dw_udly = 0,
    .tr_bt_udly = 0
};

For sending data, use 

-----Original Message-----
From: Julien Stéphane [mailto:Stephane.Julien@he-arc.ch] 
Sent: Monday, February 26, 2007 09:49
To: ecos-discuss@ecos.sourceware.org
Cc: Etique Philippe
Subject: SPI usage

Hy everybody,
 
I have problems developing an application using SPI on AT91EB55. When I send
a tick, then I connot send datas any more because the programm is blocking.
If I don't send ticks, it blocks on the next transfer.
 
I have checked the clock phase, clock polarity and chip select. Could it
come from an hardware problem or I'm wrong in my code?
 
Thank you very much for your help.... 
Stéphane



--
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]