Hi,
 
I still have problems to make SPI work on my AT91 evaluation board. I hava 
nothing to the SPI output of my AT91EB55 board (sniffing with scope). I've 
studied the datasheet of my processor and have seen the block diagram attached 
to this mail. Apparently, there are switches default openned to activate SPI 
signals. I didn't found in code where these switches are closed, so I have 
tried to write directly to the memory with HAL_WRITE_UINT32 to close them but 
no chages appears. Furthermore, I've studied the at91 SPI driver code and I 
have readed this comment in the function spi_at91_transaction_begin() : 
 
    /* As we are using this driver only in master mode with NPCS0 
       configured as GPIO instead of a peripheral pin, it is neccessary 
       for the Mode Failure detection to be switched off as this will
       cause havoc with the driver */ 
 
My question is the next one : Does the driver support sending datas through SPI 
to external devices or not? If the answer is "yes", can I get help please? I 
think I initialize the SPI bus and device correctly and I'm sure that I call 
the correct functions because I print debug messages in the driver. If it can 
help, I attached my source code.
 
Thanks for the help and excuse me for the number of messages sent!
 
 

<<attachment: SPI_Block_Diagram.JPG>>

#include <stdio.h>
#include <cyg/hal/hal_diag.h>
#include <cyg/io/spi.h>
#include <cyg/io/spi_at91.h>
#include <cyg/io/spi_eb55.h>

#define DEV_NUM 5 //default 0
#define CL_POL 1 //default 1 //mode3=1
#define CL_PHA 1 //default 0 //mode3=1
#define CL_BRATE 10000 //default 8192000
#define CS_UP_UDLY 1 //default 1
#define CS_DW_UDLY 1 //default 1
#define TR_BT_UDLY 1 //default 1

cyg_spi_at91_device_t *spi_eb55_device;
cyg_spi_device *cyg_spi_eb55_device;

void echo_spi_at91_device(cyg_spi_at91_device_t dev);
cyg_spi_device *configure_spi_at91_device(cyg_spi_at91_device_t *dev);

int main()
{
    int i=0;
    cyg_uint8 tx_data_test;
    cyg_uint8 rx_data;
    
    printf("Entering application !\n");
    hal_diag_led(0x0);
    
    //HAL_WRITE_UINT32(0xFFFEC000, 0x01FC);
    
    cyg_spi_eb55_device = configure_spi_at91_device(spi_eb55_device);
    
    tx_data_test=0x55;
    
    printf("Sending data...\n");
    printf("1\n");
    cyg_spi_transaction_begin(cyg_spi_eb55_device);
    printf("2\n");
    while(1)
    {
        printf("%i\n",i++);
        printf("a\n");
        cyg_spi_transaction_transfer(cyg_spi_eb55_device, 0, 8, &tx_data_test, 
&rx_data, 0);
        cyg_spi_transaction_tick(cyg_spi_eb55_device, 0, 1);
        printf("b\n");
        //printf("Datas deceived : %i\n",rx_data);
    }
    
    /*cyg_spi_transaction_end(cyg_spi_eb55_device);*/
    
    printf("End of main !\n");
}

cyg_spi_device *configure_spi_at91_device(cyg_spi_at91_device_t *dev)
{
    echo_spi_at91_device(*dev);
    
    printf("Setting SPI AT91 device configuration...\n");
    dev->spi_device.spi_bus = &cyg_spi_at91_bus.spi_bus;
    dev->dev_num = DEV_NUM;
    dev->cl_pol = CL_POL;
    dev->cl_pha = CL_PHA;
    dev->cl_brate = CL_BRATE;
    dev->cs_up_udly = CS_UP_UDLY;
    dev->cs_dw_udly = CS_DW_UDLY;
    dev->tr_bt_udly = TR_BT_UDLY;
    printf("Configuration setted.\n");
    
    echo_spi_at91_device(*dev);
    
    return &dev->spi_device;
}

void echo_spi_at91_device(cyg_spi_at91_device_t dev)
{
    printf("Printing SPI AT91 device configuration :\n");
    printf("-  -------------\n");
    printf("-  dev_number  = %i\n",dev.dev_num);
    printf("-  cl_polarity = %i\n",dev.cl_pol);
    printf("-  cl_phase    = %i\n",dev.cl_pha);
    printf("-  cl_baudrate = %i\n",dev.cl_brate);
    printf("-  cs_up_udly  = %i\n",dev.cs_up_udly);
    printf("-  cs_dw_udly  = %i\n",dev.cs_dw_udly);
    printf("-  tr_br_udly  = %i\n",dev.tr_bt_udly);
    printf("-  -------------\n");
}
-- 
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 via email to