Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page
41
of
106
5.6.3. Usage description
The following #define needs to be set by the user application to be able to use the UART32:
CONFIGURE_APPLICATION_NEEDS_UART32_DRIVER
5.6.3.1. RTEMS application example
In order to use the UART32 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/uart32_rtems.h>
is required for accessing the UART32.
5.6.4. Limitations
The driver has limited UART functionality and can only receive data.
Data length is always 8 bits, no parity check and only 1 stop bit is used.
The receive buffer must be aligned to
CPU_STRUCTURE_ALIGNMENT
and the size must be a
multiple of
CPU_STRUCTURE_ALIGNMENT
#include <bsp.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <bsp/uart32_rtems.h>
#define CONFIGURE_APPLICATION_NEEDS_UART32_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) {
int read_fd;
uint32_t buffer[4];
ssize_t size;
read_fd = open(UART32_DEVICE_NAME, O_RDONLY);
size = read(read_fd, &buffer, 4);
status = close(read_fd);
}