Commit 753edbea authored by julien.delange's avatar julien.delange

* add initialization arguments

 * complete spacewire driver



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@585 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 9de4d672
......@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = no-dependencies
EXTRA_DIST = $(srcdir)/po_hi_driver_linux_serial.h \
$(srcdir)/po_hi_driver_rasta_spacewire.h \
$(srcdir)/po_hi_driver_sockets.h \
$(srcdir)/rtems_utils.h \
$(srcdir)/po_hi_rtems_utils.h \
$(srcdir)/po_hi_driver_rasta_serial.h
CLEANFILES = *~
......
......@@ -15,7 +15,7 @@
void __po_hi_c_driver_serial_linux_poller (void);
void __po_hi_c_driver_serial_linux_init (void);
void __po_hi_c_driver_serial_linux_init (char*, char*);
int __po_hi_c_driver_serial_linux_sender (__po_hi_task_id task, __po_hi_port_t port);
......
......@@ -15,7 +15,7 @@
void __po_hi_c_driver_serial_rasta_poller (void);
void __po_hi_c_driver_serial_rasta_init (void);
void __po_hi_c_driver_serial_rasta_init (char*, char*);
int __po_hi_c_driver_serial_rasta_sender (const __po_hi_task_id task_id, const __po_hi_port_t port);
......
......@@ -13,9 +13,21 @@
#ifdef __PO_HI_NEED_DRIVER_SPACEWIRE_RASTA
#define __PO_HI_DRIVER_RASTA_SPACEWIRE_RXPKT_BUF 5
#define __PO_HI_DRIVER_RASTA_SPACEWIRE_PKTSIZE 1000
typedef struct {
unsigned char addr;
unsigned char protid;
unsigned char dummy;
unsigned char channel;
unsigned char data[__PO_HI_DRIVER_RASTA_SPACEWIRE_PKTSIZE];
}__po_hi_c_driver_spacewire_pkt_hdr_t;
void __po_hi_c_driver_spacewire_rasta_poller (void);
void __po_hi_c_driver_spacewire_rasta_init (void);
void __po_hi_c_driver_spacewire_rasta_init (char*, char*);
int __po_hi_c_driver_spacewire_rasta_sender (const __po_hi_task_id task_id, const __po_hi_port_t port);
......
/*
* This is a part of PolyORB-HI-C distribution, a minimal
* middleware written for generated code from AADL models.
* You should use it with the Ocarina toolsuite.
*
* Copyright (C) 2010, European Space Agency
*/
#include <deployment.h>
#ifndef __PO_HI_DRIVER_SOCKETS_H__
#define __PO_HI_DRIVER_SOCKETS_H__
#ifdef __PO_HI_NEED_DRIVER_SOCKETS
void __po_hi_driver_sockets_receiver (void);
void __po_hi_driver_sockets_init (void);
#include <po_hi_transport.h>
/* Files from PolyORB-HI-C */
extern __po_hi_node_t mynode;
extern __po_hi_inetport_t node_port[__PO_HI_NB_NODES];
extern __po_hi_inetaddr_t node_addr[__PO_HI_NB_NODES];
#define __PO_HI_TRANSPORT_SOCKET_NEED_RECEIVER_TASK() \
(node_port[mynode] != __PO_HI_NOPORT)
/*
* Maccro that declare if we need to activate another thread
* that receives data from a socket (receiver task)
*/
void __po_hi_sockets_initialize (char*, char*);
/*
* Initialize sockets, create the receiver tasks
* and sender file descriptors
*/
int __po_hi_driver_sockets_send (__po_hi_entity_t from, __po_hi_entity_t to, __po_hi_msg_t* msg);
/*
* Send data through the sending socket
*/
void* __po_hi_sockets_receiver_task (void);
/*
* Task that polls for incoming data
* and dispatch it in po-hi-c queues
*/
#endif
#endif
......@@ -76,7 +76,7 @@ void __po_hi_c_driver_serial_linux_poller (void)
}
void __po_hi_c_driver_serial_linux_init (void)
void __po_hi_c_driver_serial_linux_init (char* name, char* location)
{
struct termios oldtio,newtio;
......
......@@ -17,7 +17,7 @@
#include <po_hi_transport.h>
#include <po_hi_gqueue.h>
#include <po_hi_messages.h>
#include <drivers/rtems_utils.h>
#include <drivers/po_hi_rtems_utils.h>
#include <drivers/po_hi_driver_rasta_serial.h>
#include <sys/ioctl.h>
......@@ -50,7 +50,7 @@ void __po_hi_c_driver_serial_rasta_poller (void)
}
}
void __po_hi_c_driver_serial_rasta_init (void)
void __po_hi_c_driver_serial_rasta_init (char* name, char* location)
{
__DEBUGMSG ("[RASTA SERIAL] Init\n");
init_pci();
......
......@@ -17,9 +17,11 @@
#include <po_hi_transport.h>
#include <po_hi_gqueue.h>
#include <po_hi_messages.h>
#include <drivers/rtems_utils.h>
#include <po_hi_messages.h>
#include <drivers/po_hi_rtems_utils.h>
#include <drivers/po_hi_driver_rasta_spacewire.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
......@@ -34,29 +36,122 @@
#define __PO_HI_DRIVER_SPACEWIRE_RASTA_DEVICE "/dev/grspwrasta0"
static unsigned char po_hi_c_driver_spacewire_rxpkt[__PO_HI_DRIVER_RASTA_SPACEWIRE_PKTSIZE * __PO_HI_DRIVER_RASTA_SPACEWIRE_RXPKT_BUF];
static __po_hi_c_driver_spacewire_pkt_hdr_t po_hi_c_driver_spacewire_txpkts[1];
int po_hi_c_driver_rasta_spacewire_fd;
void po_hi_c_driver_rasta_spacewire_init_pkt(__po_hi_c_driver_spacewire_pkt_hdr_t *p)
{
p->addr = 10;
p->protid = 50;
p->dummy = 0x01;
p->channel = 0x01;
memset (p->data, '\0', __PO_HI_DRIVER_RASTA_SPACEWIRE_PKTSIZE);
}
void __po_hi_c_driver_spacewire_rasta_poller (void)
{
char buf[1024];
int len;
int j;
int n;
__DEBUGMSG ("[RASTA SPACEWIRE] Hello, i'm the 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);
if (len < 0)
{
__DEBUGMSG ("[RASTA SPACEWIRE] Error while reading\n");
}
/* skip first 2bytes (vchan and dummy) */
if ( (po_hi_c_driver_spacewire_rxpkt[0]==1) && (po_hi_c_driver_spacewire_rxpkt[1]==1) )
{
j=2; /* strip virtual channel protocol, non-ssspw device */
}
else
{
j=0; /* hardware uses virtual channel protocol, hw already stripped it */
}
n = 0;
memcpy (buf, po_hi_c_driver_spacewire_rxpkt, 6);
buf[6] = '\0';
}
void __po_hi_c_driver_spacewire_rasta_init (void)
void __po_hi_c_driver_spacewire_rasta_init (char* name, char* location)
{
unsigned int node_addr;
node_addr = atoi (location);
__DEBUGMSG ("[RASTA SPACEWIRE] Init\n");
init_pci();
__DEBUGMSG ("[RASTA SPACEWIRE] Initializing RASTA ...\n");
if ( rasta_register() ){
__DEBUGMSG(" ERROR !\n");
return;
}
__DEBUGMSG(" OK !\n");
__DEBUGMSG ("[RASTA SPACEWIRE] Initializing RASTA ...");
if (rasta_register ())
{
__DEBUGMSG(" ERROR !\n");
return;
}
__DEBUGMSG(" OK !\n");
__DEBUGMSG ("[RASTA SPACEWIRE] Open spacewire device ...");
po_hi_c_driver_rasta_spacewire_fd = open (__PO_HI_DRIVER_SPACEWIRE_RASTA_DEVICE, O_RDWR);
if (po_hi_c_driver_rasta_spacewire_fd < 0)
{
__DEBUGMSG(" ERROR !\n");
}
__DEBUGMSG(" OK !\n");
__DEBUGMSG ("[RASTA SPACEWIRE] Configure spacewire device node address = %d ...", node_addr);
__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_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);
/* remove protocol id */
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_spacewire_fd,SPACEWIRE_IOCTRL_START,2000);
}
int __po_hi_c_driver_spacewire_rasta_sender (const __po_hi_task_id task_id, const __po_hi_port_t port)
{
(void) task_id;
(void) port;
int len = -1;
int i;
__DEBUGMSG ("[RASTA SPACEWIRE] Send packet ...");
for(i=0; i<1; i++)
{
po_hi_c_driver_rasta_spacewire_init_pkt(&po_hi_c_driver_spacewire_txpkts[i]);
}
memcpy (po_hi_c_driver_spacewire_txpkts[0].data, "bonjour", 6);
len = write (po_hi_c_driver_rasta_spacewire_fd,po_hi_c_driver_spacewire_txpkts, __PO_HI_DRIVER_RASTA_SPACEWIRE_PKTSIZE + 4);
if (len < 0)
{
__DEBUGMSG (" failed !\n");
}
else
{
__DEBUGMSG (" OK !\n");
}
return 1;
}
......
......@@ -86,7 +86,7 @@ typedef struct
__po_hi_inetnode_t nodes[__PO_HI_NB_NODES];
__po_hi_inetnode_t rnodes[__PO_HI_NB_NODES];
void __po_hi_driver_sockets_init (void)
void __po_hi_driver_sockets_init (char* name, char* location)
{
int i;
int ret;
......
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