Document number
205065
Version
Rev. N
Issue date
2019-02-04
Sirius OBC and TCM User Manual
Page
72
of
174
Note!
The data rate depends on the packet size and the transmission rate of the SpaceWire
IP core. The larger the packet size, the higher the data rate.
5.7.3.4. RTEMS application example
In order to use the driver in RTEMS environment, the following code structure is suggested
to be used:
The above code registers the application for using the unique device name with the logical
address 42 (
SPWN_DEVICE_0_NAME_PREFIX”42”)
for data transaction.
The reception buffer
buf_rx,
is aligned to a 4-byte boundary in order to correctly handle
the DMA access when receiving SpaceWire packets.
Inclusion of
<fcntl.h>
and <unistd.h>
are required for using the POSIX functions
open
,
close
,
read
and
write
and
ioctl
functions for accessing the driver.
Inclusion of
<errno.h>
is required for retrieving error values on failures.
Inclusion of <
bsp/spacewire_node_rtems.h>
is required for driver related definitions
.
Inclusion of <
bsp/bsp_confdefs.h>
is required to initialise the driver at boot up.
CONFIGURE_APPLICATION_NEEDS_SPACEWIRE_DRIVER
must be defined for using the
driver. This will automatically initialise the driver at boot up.
#include <bsp.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <bsp/spacewire_node_rtems.h>
.
.
#define CONFIGURE_APPLICATION_NEEDS_SPACEWIRE_DRIVER
.
.
#define CONFIGURE_INIT
#include <bsp/bsp_confdefs.h>
#include <rtems/confdefs.h>
uint8_t __attribute__ ((aligned (4))) buf_rx[SPWN_MAX_PACKET_SIZE];
uint8_t buf_tx[SPWN_MAX_PACKET_SIZE];
rtems_task Init (rtems_task_argument ignored)
{
.
fd = open(
SPWN_DEVICE_0_NAME_PREFIX”42”,
O_RDWR);
.
}