[ECOS] SPI problem on AT91EB55
Julien Stéphane
Stephane.Julien@he-arc.ch
Tue Feb 27 09:25:00 GMT 2007
Hy everybody,
I have problems for programming SPI on AT91EB55. I have plugged an oscilloscope to the corresponding pins of I/O extension connector and nothing come to the pins. Does it come from a driver problem or an error in code? I have checked the connections. Here is part of my code :
------------------------------------------------------------------------------------------------------------
#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 4 //default 0
#define CL_POL 1 //default 1 / mode3=1
#define CL_PHA 1 //default 0 / mode3=1
#define CL_BRATE 3000000 //default 8192000, 2000000?, 3000000?
#define CS_UP_UDLY 1 //default 1
#define CS_DW_UDLY 1 //default 1
#define TR_BT_UDLY 1 //default 1
static cyg_spi_at91_device_t spi_eb55_device CYG_SPI_DEVICE_ON_BUS(DEV_NUM) = //CYG_SPI_DEVICE_ON_BUS(0)
{
.spi_device.spi_bus = &cyg_spi_at91_bus.spi_bus,
.dev_num = DEV_NUM, // Device number
.cl_pol = CL_POL, // Clock polarity (0 or 1)
.cl_pha = CL_PHA, // Clock phase (0 or 1)
.cl_brate = CL_BRATE, // Clock baud rate
.cs_up_udly = CS_UP_UDLY, // Delay in usec between CS up and transfer start
.cs_dw_udly = CS_DW_UDLY, // Delay in usec between transfer end and CS down
.tr_bt_udly = TR_BT_UDLY // Delay in usec between two transfers
};
cyg_spi_device *cyg_spi_eb55_device = &spi_eb55_device.spi_device;
int main(void)
{
cyg_uint8 tx_data0, tx_data1, tx_data2, tx_data3;
cyg_uint8 rx_data;
printf("Entering application !\n");
hal_diag_led(0x0);
tx_data0=0x0;
tx_data1=0x1;
tx_data2=0x90;
tx_data3=0x15;
printf("Sending data...\n");
cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data0, &rx_data);
printf("Datas deceived : %i\n",rx_data);
cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data1, &rx_data);
printf("Datas deceived : %i\n",rx_data);
cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data2, &rx_data);
printf("Datas deceived : %i\n",rx_data);
cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data3, &rx_data);
printf("Datas deceived : %i\n",rx_data);
cyg_spi_tick(cyg_spi_eb55_device, 0, 1000);
printf("End of main !\n");
//cyg_thread_exit();
}
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list