Document number
205065
Version
Rev. N
Issue date
2019-02-04
Sirius OBC and TCM User Manual
Page
62
of
174
Figure 5
–
RTEMS driver usage description
Note!
All calls to RTEMS driver are blocking calls.
In order to support different chip types with different size characteristics, two separate
modes of usage are available for determining the page size:
5.6.4.4. Same-size usage mode
This usage mode is backwards-compatible, and exposes 16GB of available space
regardless of the chip type, it defines MASSMEM_PAGE_BYTES and
MASSMEM_SPARE_AREA_BYTES for use by the application at compile-time.
This usage mode is only available if the RTEMS BSP is compiled
without
the
BSP_AAC_MASSMEM_ENABLE_32GB define set.
In order to use the mass memory flash driver in RTEMS environment with the same-size
usage mode, the following code structure is suggested to be used:
#include <bsp.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <bsp/massmem_flash_rtems.h>
#define CONFIGURE_APPLICATION_NEEDS_MASSMEM_FLASH_DRIVER
.
.
#define CONFIGURE_INIT
rtems_task Init (rtems_task_argument argument);
#include <bsp/bsp_confdefs.h>
#include <rtems/confdefs.h>
static uint8_t buf[MASSMEM_PAGE_BYTES];
rtems_task Init (rtems_task_argument ignored)
{
.
fd = open(MASSMEM_DEVICE_NAME, O_RDWR);
.
off = lseek(fd, page_number, SEEK_SET);
.
sz = write(fd, buf, MASSMEM_PAGE_BYTES);
.
off = lseek(fd, page_number, SEEK_SET)
.
sz = read(fd, buf, MASSMEM_PAGE_BYTES);
.
}