Document number
205065
Version
Rev. N
Issue date
2019-02-04
Sirius OBC and TCM User Manual
Page
98
of
174
EDAC error information is reported via errors in the read operation, which is the
recommended way to obtain this information.
The SPI_RAM_GET_EDAC_STATUS_IOCTL command is deprecated and may be
removed in future versions.
5.11.5.1. RTEMS application example
In order to use the SPI RAM driver on RTEMS environment, the following code structure is
suggested to be used:
Inclusion of
<fcntl.h>
and <unistd.h>
are required for using the POSIX functions:
open
,
close, ioctl
.
Inclusion of
<errno.h>
is required for retrieving error values on failures.
Inclusion of <
bsp/spi_ram_rtems.h>
is required for accessing the SPI_RAM.
#include <bsp.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <bsp/spi_ram_rtems.h>
#define CONFIGURE_APPLICATION_NEEDS_SPI_RAM_DRIVER
#include <bsp/bsp_confdefs.h>
#include <rtems/confdefs.h>
#define CONFIGURE_INIT
rtems_task Init (rtems_task_argument argument);
rtems_task Init (rtems_task_argument argument){
rtems_status_code status;
int dsc;
uint8_t buf[8];
ssize_t cnt;
off_t offset;
dsc = open(SPI_RAM_DEVICE_NAME, O_RDWR);
offset = lseek(dsc, 0x200, SEEK_SET);
cnt = write(dsc, &buf[0], sizeof(buf));
offset = lseek(dsc, 0x200, SEEK_SET);
cnt = read(dsc, &buf[0], sizeof(buf));
status = close(dsc);
}