Commit bf19627f authored by julien.delange's avatar julien.delange

* po-hi-c/include/drivers/po_hi_driver_serial_common.h

   po-hi-c/src/drivers/po_hi_driver_serial_common.c
   - Add generic function to handle serial configuration

 * po-hi-c/include/drivers/Makefile.am
   po-hi-c/src/drivers/Makefile.am
   - Include po_hi_driver_serial_common.[h|c] in pohic release

 * po-hi-c/src/drivers/po_hi_driver_rasta_serial.c
   po-hi-c/src/drivers/po_hi_driver_leon_serial.c
   po-hi-c/src/drivers/po_hi_driver_linux_serial.c
   - Adapt to use the new generic configuration mechanism

 * po-hi-c/share/config/leon-rtems/po_hi_rtemsconfig.h
   - Also take in account serial leon driver

 * po-hi-c/share/make/Makefile.common
   - Add po_hi_driver_serial_common to be compiled



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@2014 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 35e0fc44
AUTOMAKE_OPTIONS = no-dependencies
EXTRA_DIST = $(srcdir)/po_hi_driver_linux_serial.h \
$(srcdir)/po_hi_driver_leon_serial.h \
$(srcdir)/po_hi_driver_leon_serial.h \
$(srcdir)/po_hi_driver_serial_common.h \
$(srcdir)/po_hi_driver_exarm.h \
$(srcdir)/po_hi_driver_exarm_ni_6071e_analog.h \
$(srcdir)/po_hi_driver_exarm_ni_6071e_digital.h \
......
/*
* 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.
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2011, European Space Agency (ESA).
*/
#include <deployment.h>
#ifndef __PO_HI_DRIVER_SERIAL_COMMON_H__
#if defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_SENDER) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_RASTA) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_SENDER) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)
#include <po_hi_debug.h>
#define __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200 2
#define __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400 6
#define __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600 8
#define __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200 10
#define __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON 0
#define __PO_HI_DRIVER_SERIAL_COMMON_SPEED_DEFAULT __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400
int __po_hi_c_driver_serial_common_get_dev (const __po_hi_device_id id, char* dev);
/*
* __po_hi_c_driver_serial_common_get_dev finds the name associated
* with the device. In the config filed, this is the identifier of the
* dev argument.
* Configuration should be like that : dev=/dev/ttyS0 speed=115200
*
* The first parameter is the device id while the second is the memory
* chunk where the device name will be copied.
*
* Returns 1 when retrieved successfully the device name, 0 otherwise.
*/
int __po_hi_c_driver_serial_common_get_speed (const __po_hi_device_id id);
/*
* __po_hi_c_driver_serial_common_get_speed provides the speed
* of the serial line associated with a serial driver.
* Returns the speed of the port using a macro which
* has the form __PO_HI_DRIVER_SERIAL_COMMON_SPEED_XXXXX (XXXX being the
* potential speeds. If the parameter is not set on the device, it returns
* __PO_HI_DRIVER_SERIAL_COMMON_SPEED_DEFAULT. If the configuration is not
* valid, it returns __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON
*/
#endif
#endif
......@@ -16,6 +16,9 @@
#if (defined (__PO_HI_NEED_DRIVER_SPACEWIRE_RASTA)) || \
(defined (__PO_HI_NEED_DRIVER_SERIAL_RASTA)) || \
(defined (__PO_HI_USE_GPROF)) || \
(defined (__PO_HI_NEED_DRIVER_SERIAL_LEON)) || \
(defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_SENDER)) || \
(defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)) || \
(defined (__PO_HI_NEED_DRIVER_1553_RASTA))
#define CONFIGURE_MAXIMUM_DRIVERS 16
#endif
......
......@@ -94,6 +94,7 @@ ifeq ($(NEED_TRANSPORT), yes)
drivers/po_hi_driver_exarm_ni_6071e_digital.o \
drivers/po_hi_driver_linux_serial.o \
drivers/po_hi_driver_leon_serial.o \
drivers/po_hi_driver_serial_common.o \
drivers/po_hi_driver_sockets.o \
drivers/po_hi_driver_sockets_common.o \
drivers/po_hi_driver_sockets_asn1.o \
......
......@@ -9,6 +9,7 @@ C_FILES = $(srcdir)/po_hi_driver_linux_serial.c \
$(srcdir)/po_hi_driver_rasta_spacewire.c \
$(srcdir)/po_hi_driver_rasta_common.c \
$(srcdir)/po_hi_driver_exarm.c \
$(srcdir)/po_hi_driver_serial_common.c \
$(srcdir)/po_hi_driver_keyboard.c \
$(srcdir)/po_hi_driver_exarm_ni_6071e_analog.c \
$(srcdir)/po_hi_driver_exarm_ni_6071e_digital.c \
......
......@@ -14,13 +14,12 @@
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_SENDER) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)
#define __PO_HI_DRIVER_SERIAL_LEON_BAUDRATE B19200
#include <po_hi_debug.h>
#include <po_hi_utils.h>
#include <po_hi_messages.h>
#include <po_hi_transport.h>
#include <po_hi_gqueue.h>
#include <drivers/po_hi_driver_serial_common.h>
/* po-hi-c related files */
#include <activity.h>
......@@ -126,15 +125,30 @@ void __po_hi_c_driver_serial_leon_poller (void)
void __po_hi_c_driver_serial_leon_init_sender (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Init sender\n");
po_hi_c_driver_leon_serial_fd_write = open( __po_hi_get_device_naming (id), O_RDWR | O_NOCTTY | O_NONBLOCK);
memset (devname, '\0', 16);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Cannot get the name of the device !\n");
return;
}
if (__po_hi_c_driver_serial_common_get_speed (id) != __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400)
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] This driver handles only a speed of 38400, exiting initialization !\n");
return;
}
po_hi_c_driver_leon_serial_fd_write = open (devname, O_WRONLY );
if (po_hi_c_driver_leon_serial_fd_write < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", __po_hi_get_device_naming (id));
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", devname);
}
else
{
......@@ -153,26 +167,29 @@ void __po_hi_c_driver_serial_leon_init_sender (__po_hi_device_id id)
* CREAD : enable receiving characters
*/
newtio.c_cflag = __PO_HI_DRIVER_SERIAL_LEON_BAUDRATE;
/*| CRTSCTS | CS8 | CLOCAL;
newtio.c_cflag = CRTSCTS | CS8 | CLOCAL;
/*
* IGNPAR : ignore bytes with parity errors
* ICRNL : map CR to NL (otherwise a CR input on the other computer
* will not terminate input) otherwise make device raw
* (no other input processing)
newtio.c_iflag = IGNPAR | ICRNL;
*/
newtio.c_iflag = IGNPAR | ICRNL;
/*
* Raw output.
*/
newtio.c_oflag = 1;
newtio.c_oflag = OCRNL;
/*
* ICANON : enable canonical input
* disable all echo functionality, and don't send signals to calling program
newtio.c_lflag = ICANON;
*/
newtio.c_lflag = ~( ICANON | ECHO | ECHONL | ECHOK | ECHOE | ECHOPRT | ECHOCTL );
newtio.c_cc[VMIN] = 5;
newtio.c_cc[VTIME] = 20;
if (tcsetattr (po_hi_c_driver_leon_serial_fd_write, TCSANOW, &newtio) == -1)
{
......@@ -197,15 +214,32 @@ void __po_hi_c_driver_serial_leon_init_sender (__po_hi_device_id id)
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)
void __po_hi_c_driver_serial_leon_init_receiver (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Init receiver\n");
memset (devname, '\0', 16);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Cannot get the name of the device !\n");
return;
}
if (__po_hi_c_driver_serial_common_get_speed (id) != __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400)
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] This driver handles only a speed of 38400, exiting initialization !\n");
return;
}
po_hi_c_driver_leon_serial_fd_read = open( __po_hi_get_device_naming (id), O_RDONLY | O_NOCTTY);
if (po_hi_c_driver_leon_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", __po_hi_get_device_naming (id));
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", devname);
}
else
{
......@@ -224,7 +258,7 @@ void __po_hi_c_driver_serial_leon_init_receiver (__po_hi_device_id id)
* CREAD : enable receiving characters
*/
newtio.c_cflag = __PO_HI_DRIVER_SERIAL_LEON_BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD;
/*
* IGNPAR : ignore bytes with parity errors
......@@ -273,15 +307,30 @@ void __po_hi_c_driver_serial_leon_init_receiver (__po_hi_device_id id)
void __po_hi_c_driver_serial_leon_init (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Init both sender and receiver\n");
memset (devname, '\0', 16);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Cannot get the name of the device !\n");
return;
}
if (__po_hi_c_driver_serial_common_get_speed (id) != __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400)
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] This driver handles only a speed of 38400, exiting initialization !\n");
return;
}
po_hi_c_driver_leon_serial_fd_read = po_hi_c_driver_leon_serial_fd_write = open( __po_hi_get_device_naming (id), O_RDWR | O_NOCTTY | O_NONBLOCK);
if (po_hi_c_driver_leon_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", __po_hi_get_device_naming (id));
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", devname);
}
else
{
......@@ -300,7 +349,7 @@ void __po_hi_c_driver_serial_leon_init (__po_hi_device_id id)
* CREAD : enable receiving characters
*/
newtio.c_cflag = __PO_HI_DRIVER_SERIAL_LEON_BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD;
/*
* IGNPAR : ignore bytes with parity errors
......
......@@ -14,13 +14,12 @@
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_SENDER) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER)
#define __PO_HI_DRIVER_SERIAL_LINUX_BAUDRATE B19200
#include <po_hi_debug.h>
#include <po_hi_utils.h>
#include <po_hi_messages.h>
#include <po_hi_transport.h>
#include <po_hi_gqueue.h>
#include <drivers/po_hi_driver_serial_common.h>
/* po-hi-c related files */
#include <activity.h>
......@@ -123,15 +122,24 @@ void __po_hi_c_driver_serial_linux_poller (void)
void __po_hi_c_driver_serial_linux_init_sender (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Init sender\n");
po_hi_c_driver_serial_fd_write = open( __po_hi_get_device_naming (id), O_RDWR | O_NOCTTY | O_NONBLOCK);
memset (devname, '\0', 16);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
{
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Cannot get the name of the device !\n");
return;
}
po_hi_c_driver_serial_fd_write = open (devname, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (po_hi_c_driver_serial_fd_write < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", __po_hi_get_device_naming (id));
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", devname);
}
else
{
......@@ -150,7 +158,31 @@ void __po_hi_c_driver_serial_linux_init_sender (__po_hi_device_id id)
* CREAD : enable receiving characters
*/
newtio.c_cflag = __PO_HI_DRIVER_SERIAL_LINUX_BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD;
switch (__po_hi_c_driver_serial_common_get_speed (id))
{
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200:
newtio.c_cflag |= B19200;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400:
newtio.c_cflag |= B38400;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600:
newtio.c_cflag |= B57600;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200:
newtio.c_cflag |= B115200;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON:
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Unknwon speed for the serial line\n");
break;
}
/*
* IGNPAR : ignore bytes with parity errors
......@@ -216,15 +248,24 @@ void __po_hi_c_driver_serial_linux_init_sender (__po_hi_device_id id)
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER)
void __po_hi_c_driver_serial_linux_init_receiver (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Init receiver\n");
po_hi_c_driver_serial_fd_read = open( __po_hi_get_device_naming (id), O_RDONLY | O_NOCTTY);
memset (devname, '\0', 16);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
{
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Cannot get the name of the device !\n");
return;
}
po_hi_c_driver_serial_fd_read = open (devname, O_RDONLY | O_NOCTTY);
if (po_hi_c_driver_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", __po_hi_get_device_naming (id));
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", devname);
}
else
{
......@@ -243,7 +284,31 @@ void __po_hi_c_driver_serial_linux_init_receiver (__po_hi_device_id id)
* CREAD : enable receiving characters
*/
newtio.c_cflag = __PO_HI_DRIVER_SERIAL_LINUX_BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD;
switch (__po_hi_c_driver_serial_common_get_speed (id))
{
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200:
newtio.c_cflag |= B19200;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400:
newtio.c_cflag |= B38400;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600:
newtio.c_cflag |= B57600;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200:
newtio.c_cflag |= B115200;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON:
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Unknwon speed for the serial line\n");
break;
}
/*
* IGNPAR : ignore bytes with parity errors
......@@ -292,15 +357,24 @@ void __po_hi_c_driver_serial_linux_init_receiver (__po_hi_device_id id)
void __po_hi_c_driver_serial_linux_init (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
memset (devname, '\0', 16);
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Init both sender and receiver\n");
po_hi_c_driver_serial_fd_read = po_hi_c_driver_serial_fd_write = open( __po_hi_get_device_naming (id), O_RDWR | O_NOCTTY | O_NONBLOCK);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
{
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Cannot get the name of the device !\n");
return;
}
po_hi_c_driver_serial_fd_read = po_hi_c_driver_serial_fd_write = open(devname, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (po_hi_c_driver_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", __po_hi_get_device_naming (id));
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", devname);
}
else
{
......@@ -319,7 +393,30 @@ void __po_hi_c_driver_serial_linux_init (__po_hi_device_id id)
* CREAD : enable receiving characters
*/
newtio.c_cflag = __PO_HI_DRIVER_SERIAL_LINUX_BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_cflag = __PO_HI_DRIVER_SERIAL_COMMON_CONVERT_SPEED_TO_POSIX | CRTSCTS | CS8 | CLOCAL | CREAD;
switch (__po_hi_c_driver_serial_common_get_speed (id))
{
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200:
newtio.c_cflag |= B19200;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400:
newtio.c_cflag |= B38400;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600:
newtio.c_cflag |= B57600;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200:
newtio.c_cflag |= B115200;
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON:
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Unknwon speed for the serial line\n");
break;
}
/*
* IGNPAR : ignore bytes with parity errors
......
......@@ -23,6 +23,8 @@
#include <drivers/po_hi_driver_rasta_serial.h>
#include <drivers/po_hi_driver_rasta_common.h>
#include <drivers/po_hi_driver_serial_common.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
......@@ -93,29 +95,55 @@ void __po_hi_rasta_interrrupt_register(void *handler, int irqno, void *arg);
void __po_hi_c_driver_serial_rasta_init (__po_hi_device_id id)
{
char devname[16];
__po_hi_c_driver_rasta_common_init ();
memset (devname, '\0', 16);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
{
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Cannot get the name of the device !\n");
return;
}
/* provide the spacewire driver with AMBA Plug&Play
* info so that it can find the GRSPW cores.
*/
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Initialization starts !\n");
/*
if ( apbuart_rasta_register (__po_hi_driver_rasta_common_get_bus ()) )
{
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Failed to register RASTA APBUART driver\n\r");
}
*/
po_hi_c_driver_rasta_serial_fd = open (__po_hi_get_device_naming (id), O_RDWR);
po_hi_c_driver_rasta_serial_fd = open (devname, O_RDWR);
if (po_hi_c_driver_rasta_serial_fd < 0)
{
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Error while opening device %s\n", __po_hi_get_device_naming (id));
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Error while opening device %s\n", devname);
}
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Device open, fd=%d\n", po_hi_c_driver_rasta_serial_fd);
__PO_HI_DRIVERS_RTEMS_UTILS_IOCTL(po_hi_c_driver_rasta_serial_fd, APBUART_SET_BAUDRATE, __PO_HI_DRIVER_SERIAL_RASTA_BAUDRATE); /* stream mode */
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);
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);
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);
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);
break;
case __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON:
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Unknwon speed for the serial line\n");
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 */
......
/*
* 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.
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2011, European Space Agency (ESA).
*/
#include <deployment.h>
#include <drivers/po_hi_driver_serial_common.h>
#if defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_SENDER) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_RASTA) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_SENDER) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)
#include <po_hi_transport.h>
#include <po_hi_debug.h>
int __po_hi_c_driver_serial_common_get_dev (const __po_hi_device_id id, char* dev)
{
char* conf;
int tmp;
int n;
conf = __po_hi_get_device_naming (id);
n = sscanf (conf, "dev=%s speed=%d", dev, &tmp);
if (n >= 1)
{
__PO_HI_DEBUG_INFO ("Driver %d has device %s associated\n", id, dev);
return 1;
}
return 0;
}
int __po_hi_c_driver_serial_common_get_speed (const __po_hi_device_id id)
{
char* conf;
int n;
int speed;
char tmp[10];
conf = __po_hi_get_device_naming (id);
n = sscanf (conf, "dev=%s speed=%d", tmp, &speed);
if (n != 2)
{
__PO_HI_DEBUG_INFO ("Default speed for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_DEFAULT;
}
switch (speed)
{
case 115200:
__PO_HI_DEBUG_INFO ("Get speed 115200 for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200;
break;
case 57600:
__PO_HI_DEBUG_INFO ("Get speed 57600 for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600;
break;
case 38400:
__PO_HI_DEBUG_INFO ("Get speed 38400 for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400;
break;
case 19200:
__PO_HI_DEBUG_INFO ("Get speed 19200 for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200;
break;
default:
__PO_HI_DEBUG_INFO ("Unknown speed for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON;
break;
}
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_DEFAULT;
}
#endif
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