Commit 12968e50 authored by jdelange's avatar jdelange

* Fix for serial drivers, Demo_RASTA_FPGA should work fine.



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@2558 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent de4b5e55
......@@ -6,7 +6,7 @@
#define __PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(fd,num,arg) \
{ int ioctl_ret ; \
if ( (ioctl_ret=ioctl(fd,num,arg)) != RTEMS_SUCCESSFUL ) { \
__DEBUGMSG("[RTEMS UTILS] IOCTL " #num " failed: ret: %d \n",ioctl_ret); \
__PO_HI_DEBUG_DEBUG("[RTEMS UTILS] IOCTL " #num " failed: ret: %d \n",ioctl_ret); \
} \
}
......
......@@ -87,11 +87,12 @@ void __po_hi_c_driver_serial_linux_poller (void)
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] read() returns %d\n", n);
msg.length = n;
swap_pointer = (unsigned long*) &msg.content[0];
swap_value = *swap_pointer;
*swap_pointer = __po_hi_swap_byte (swap_value);
msg.length = n;
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Message after swapped port: 0x");
for (ts = 0 ; ts < msg.length ; ts++)
{
......
......@@ -304,10 +304,11 @@ void __po_hi_c_driver_rasta_common_init ()
{
if (__po_hi_c_driver_rasta_common_is_init == 1)
{
__PO_HI_DEBUG_DEBUG ("[RASTA COMMON] RASTA already initialized, pass init\n");
return;
}
__PO_HI_DEBUG_INFO ("[RASTA COMMON] Init\n");
__PO_HI_DEBUG_DEBUG ("[RASTA COMMON] Init\n");
init_pci();
__PO_HI_DEBUG_DEBUG ("[RASTA COMMON] Initializing RASTA ...");
/*
......
......@@ -40,7 +40,8 @@
#include <drivers/configuration/serial.h>
int po_hi_c_driver_rasta_serial_fd;
int po_hi_c_driver_rasta_serial_fd_read;
int po_hi_c_driver_rasta_serial_fd_write;
__po_hi_msg_t __po_hi_c_driver_rasta_serial_msg;
__po_hi_request_t __po_hi_c_driver_rasta_serial_request;
......@@ -50,40 +51,38 @@ void __po_hi_c_driver_serial_rasta_poller (void)
int n;
int ts;
int tr;
uint8_t* ptr;
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Poller waits for incoming message !\n");
ts = __PO_HI_MESSAGES_MAX_SIZE;
tr = 0;
ptr = &(__po_hi_c_driver_rasta_serial_msg.content[0]);
__po_hi_msg_reallocate (&__po_hi_c_driver_rasta_serial_msg);
while (ts > 0)
{
n = read (po_hi_c_driver_rasta_serial_fd, ptr, ts);
ptr += n;
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Poller waits for incoming message (%d bytes are required)!\n", ts);
n = read (po_hi_c_driver_rasta_serial_fd_read, ptr, ts);
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] read() %d returns %d!\n", po_hi_c_driver_rasta_serial_fd_read, n);
if (n == -1)
{
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Cannot read on socket !\n");
return;
}
ts -= n;
tr += n;
else
{
ptr += n;
ts -= n;
}
}
#ifdef __PO_HI_DEBUG_INFO
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] read() returns total %d, max message size=%d\n", tr, __PO_HI_MESSAGES_MAX_SIZE);
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Message received by poller: 0x");
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Message received by poller: 0x");
for (ts = 0 ; ts < __PO_HI_MESSAGES_MAX_SIZE ; ts++)
{
__PO_HI_DEBUG_INFO ("%x", __po_hi_c_driver_rasta_serial_msg.content[ts]);
__PO_HI_DEBUG_DEBUG ("%x", __po_hi_c_driver_rasta_serial_msg.content[ts]);
}
__PO_HI_DEBUG_INFO ("\n");
#endif
__PO_HI_DEBUG_DEBUG ("\n");
return;
__po_hi_c_driver_rasta_serial_msg.length = tr;
__po_hi_c_driver_rasta_serial_msg.length = __PO_HI_MESSAGES_MAX_SIZE;
__po_hi_unmarshall_request (&__po_hi_c_driver_rasta_serial_request,
&__po_hi_c_driver_rasta_serial_msg);
......@@ -114,30 +113,44 @@ void __po_hi_c_driver_serial_rasta_init (__po_hi_device_id id)
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Initialization starts !\n");
po_hi_c_driver_rasta_serial_fd = open (serialconf->devname, O_RDWR);
po_hi_c_driver_rasta_serial_fd_write =
po_hi_c_driver_rasta_serial_fd_read = open (serialconf->devname, O_RDWR);
/*
po_hi_c_driver_rasta_serial_fd_write = open (serialconf->devname, O_WRONLY);
*/
if (po_hi_c_driver_rasta_serial_fd < 0)
if (po_hi_c_driver_rasta_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Error while opening device %s\n", serialconf->devname);
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Error while opening device %s for reading\n", serialconf->devname);
}
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Device open, fd=%d\n", po_hi_c_driver_rasta_serial_fd);
if (po_hi_c_driver_rasta_serial_fd_write < 0)
{
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Error while opening device %s for writing\n", serialconf->devname);
}
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Device opened for read (%s), fd=%d\n", serialconf->devname , po_hi_c_driver_rasta_serial_fd_read);
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Device opened for write (%s), fd=%d\n", serialconf->devname , po_hi_c_driver_rasta_serial_fd_write);
switch (__po_hi_c_driver_serial_common_get_speed (id))
{
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200:
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_BAUDRATE, 19200);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_SET_BAUDRATE, 19200);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_write, APBUART_SET_BAUDRATE, 19200);
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400:
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_BAUDRATE, 38400);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_SET_BAUDRATE, 38400);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_write, APBUART_SET_BAUDRATE, 38400);
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600:
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_BAUDRATE, 57600);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_SET_BAUDRATE, 57600);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_write, APBUART_SET_BAUDRATE, 57600);
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200:
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_BAUDRATE, 115200);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_SET_BAUDRATE, 115200);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_write, APBUART_SET_BAUDRATE, 115200);
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON:
......@@ -145,18 +158,29 @@ void __po_hi_c_driver_serial_rasta_init (__po_hi_device_id id)
break;
}
/*
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_BLOCKING, APBUART_BLK_RX | APBUART_BLK_TX | APBUART_BLK_FLUSH);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_TXFIFO_LEN, 64); /* Transmitt buffer 64 chars */
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_RXFIFO_LEN, 256); /* Receive buffer 256 chars */
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_ASCII_MODE, 0); /* Make \n go \n\r or \r\n */
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_CLR_STATS, 0);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_START, 0);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_BLOCKING, APBUART_BLK_FLUSH | APBUART_BLK_RX);
*/
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_SET_BLOCKING, APBUART_BLK_FLUSH | APBUART_BLK_TX );
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_SET_TXFIFO_LEN, 256); /* Transmitt buffer 64 chars */
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_SET_RXFIFO_LEN, 256); /* Receive buffer 256 chars */
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_SET_ASCII_MODE, 0); /* Make \n go \n\r or \r\n */
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_CLR_STATS, 0);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd_read, APBUART_START, 0);
if (tcflush (po_hi_c_driver_rasta_serial_fd, TCIOFLUSH) != 0)
if (tcflush (po_hi_c_driver_rasta_serial_fd_read, TCIOFLUSH) != 0)
{
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Error when trying to flush read part\n");
}
if (tcflush (po_hi_c_driver_rasta_serial_fd_write, TCIOFLUSH) != 0)
{
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Error when trying to flush\n");
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Error when trying to flush write part\n");
}
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Initialization complete !\n");
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Initialization complete !\n");
}
int __po_hi_c_driver_serial_rasta_sender (const __po_hi_task_id task_id, const __po_hi_port_t port)
......@@ -183,21 +207,19 @@ int __po_hi_c_driver_serial_rasta_sender (const __po_hi_task_id task_id, const _
__po_hi_msg_reallocate (&msg);
request->port = destination_port;
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Destination port= %d\n", destination_port);
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Destination port= %d\n", destination_port);
__po_hi_marshall_request (request, &msg);
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Message sent: 0x");
#ifdef __PO_HI_DEBUG_LEVEL_INFO
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Message sent: 0x");
for (ts = 0 ; ts < __PO_HI_MESSAGES_MAX_SIZE ; ts++)
{
__PO_HI_DEBUG_INFO ("%x", msg.content[ts]);
__PO_HI_DEBUG_DEBUG ("%x", msg.content[ts]);
}
#endif
__PO_HI_DEBUG_INFO ("\n");
__PO_HI_DEBUG_DEBUG ("\n");
n = write (po_hi_c_driver_rasta_serial_fd, &msg, __PO_HI_MESSAGES_MAX_SIZE);
n = write (po_hi_c_driver_rasta_serial_fd_write, &msg, __PO_HI_MESSAGES_MAX_SIZE);
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] write() returns %d\n", n);
......
......@@ -79,15 +79,16 @@ void __po_hi_c_driver_spacewire_rasta_poller (void)
__po_hi_msg_t msg;
__po_hi_request_t request;
__PO_HI_DEBUG_INFO ("[RASTA SPACEWIRE] Hello, i'm the spacewire poller !\n");
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Hello, i'm the spacewire poller !\n");
len = read (po_hi_c_driver_rasta_spacewire_fd,
&po_hi_c_driver_spacewire_rxpkt[0],
__PO_HI_DRIVER_RASTA_SPACEWIRE_PKTSIZE * __PO_HI_DRIVER_RASTA_SPACEWIRE_RXPKT_BUF);
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Poller reveived a message !\n");
if (len < 0)
{
__PO_HI_DEBUG_CRITICAL ("[RASTA SPACEWIRE] Error while reading\n");
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Error while reading\n");
}
else
{
......@@ -106,7 +107,7 @@ void __po_hi_c_driver_spacewire_rasta_poller (void)
__po_hi_unmarshall_request (&request, &msg);
__PO_HI_DEBUG_INFO ("[RASTA SPACEWIRE] Destination port: %d\n", request.port);
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Destination port: %d\n", request.port);
__po_hi_main_deliver (&request);
}
}
......@@ -161,7 +162,7 @@ void __po_hi_c_driver_spacewire_rasta_init (__po_hi_device_id id)
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_spacewire_fd,SPACEWIRE_IOCTRL_SET_COREFREQ,30000);
/* make driver calculate timings from 30MHz spacewire clock */
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_spacewire_fd,SPACEWIRE_IOCTRL_SET_NODEADDR, node_addr);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_spacewire_fd,SPACEWIRE_IOCTRL_SET_RXBLOCK,1);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_spacewire_fd,SPACEWIRE_IOCTRL_SET_RXBLOCK,0);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_spacewire_fd,SPACEWIRE_IOCTRL_SET_TXBLOCK,0);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_spacewire_fd,SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL,1);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_spacewire_fd,SPACEWIRE_IOCTRL_SET_RM_PROT_ID,1);
......@@ -196,13 +197,13 @@ int __po_hi_c_driver_spacewire_rasta_sender (const __po_hi_task_id task_id, cons
__po_hi_marshall_request (request, &msg);
__PO_HI_DEBUG_INFO ("[RASTA SPACEWIRE] Send packet destination port = %d ...", destination_port);
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Send packet destination port = %d ...", destination_port);
for(i=0; i<1; i++)
{
po_hi_c_driver_rasta_spacewire_init_pkt (&po_hi_c_driver_spacewire_txpkts[i], destination_port);
__PO_HI_DEBUG_INFO ("destination note = %d ...", po_hi_c_driver_spacewire_txpkts[i].addr);
__PO_HI_DEBUG_DEBUG ("destination node = %d ...", po_hi_c_driver_spacewire_txpkts[i].addr);
}
memcpy (po_hi_c_driver_spacewire_txpkts[0].data, &msg, __PO_HI_MESSAGES_MAX_SIZE);
......@@ -211,11 +212,11 @@ int __po_hi_c_driver_spacewire_rasta_sender (const __po_hi_task_id task_id, cons
if (len < 0)
{
__PO_HI_DEBUG_INFO (" failed !\n");
__PO_HI_DEBUG_DEBUG (" failed !\n");
}
else
{
__PO_HI_DEBUG_INFO (" OK !\n");
__PO_HI_DEBUG_DEBUG (" OK !\n");
}
request->port = __PO_HI_GQUEUE_INVALID_PORT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment