RetargetIoKit Drivers

Detailed Description

Standard I/O retargeting driver.

This module provide low-level retargeting of stdio for all supported toolchains.


Retarget TextDisplay Module

The source code of the RETARGETTEXTDISPLAY module is implemented in kits/common/drivers/retargettextdisplay.c and retargettextdisplay.h.


Introduction

The RETARGETTEXTDISPLAY Library implements a stdout interface to a textdisplay device (TextDisplay Library) in order for the user to print text by calling standard C language functions that prints text to stdout.


Retarget TextDisplay Configuration.

This section contains a description of the configuration parameters of the RETARGETTEXTDISPLAY Library.

#define RETARGETTEXTDISPLAY_SCROLL_MODE
       Set to 'true' to enable scroll mode on the text display device where
       stdout is retargeted. Set to 'false' to disable scroll mode.
#define RETARGETTEXTDISPLAY_LINE_FEED_MODE
       Set to 'true' to enable adding Carriage Return (CR) to Line Feed (LF)
       characters on the text display device where stdout is retargeted.
       Set to 'false' to disable line feed mode.
#define RETARGETTEXTDISPLAY_DISPLAY_NO
       Select which TEXTDISPLAY device number to retarget stdout to. Normally
       there is only one display device present in the system therefore this
       parameter should be zero. However if there are more than one display
       device the user may want to select a different display device.

Macros

#define RXBUFSIZE   8
 
#define setupSWOForPrint   RETARGET_SwoInit
 

Functions

int _close (int file)
 Close a file.
 
void _exit (int status)
 Exit the program.
 
int _fstat (int file, struct stat *st)
 Status of an open file.
 
int _getpid (void)
 Get process ID.
 
int _isatty (int file)
 Query whether output stream is a terminal.
 
int _kill (int pid, int sig)
 Send signal to process.
 
int _lseek (int file, int ptr, int dir)
 Set position in a file.
 
int _read (int file, char *ptr, int len)
 Read from a file.
 
caddr_t _sbrk (int incr)
 Increase heap.
 
int _write (int file, const char *ptr, int len)
 Write to a file.
 
static void disableRxInterrupt ()
 Disable RX interrupt.
 
static void enableRxInterrupt ()
 Enable RX interrupt.
 
void RETARGET_IRQ_NAME (void)
 UART/LEUART IRQ Handler.
 
int RETARGET_ReadChar (void)
 Receive a byte from USART/LEUART and put into global buffer.
 
void RETARGET_SerialCrLf (int on)
 UART/LEUART toggle LF to CRLF conversion.
 
bool RETARGET_SerialEnableFlowControl (void)
 Enable hardware flow control. (RTS + CTS)
 
void RETARGET_SerialFlush (void)
 Flush UART/LEUART.
 
void RETARGET_SerialInit (void)
 Intializes UART/LEUART.
 
void RETARGET_SwoInit (void)
 Setup SWO for output.
 
EMSTATUS RETARGET_TextDisplayInit (void)
 Initialize/retarget a TEXTDISPLAY device to receivie stdout(put).
 
void RETARGET_TftCrLf (int on)
 Toggle LF to CRLF conversion.
 
void RETARGET_TftInit (void)
 Intializes TFT text display.
 
void RETARGET_TFTTX (int c)
 Transmit/display a character.
 
void RETARGET_TFTUpdate (bool fullFrame)
 Display framebuffer.
 
int RETARGET_WriteChar (char c)
 Transmit single byte to USART/LEUART.
 
EMSTATUS RETARGET_WriteString (char *str)
 Write a string of characters to the RETARGET text display device.
 

Variables

char _end
 
static bool initialized = false
 
static uint8_t LFtoCRLF = 0
 
static volatile uint8_t rxBuffer [RXBUFSIZE]
 
static volatile int rxCount = 0
 
static volatile int rxReadIndex = 0
 
static volatile int rxWriteIndex = 0
 

Macro Definition Documentation

#define RXBUFSIZE   8

Buffer size for RX

Definition at line 51 of file retargetserial.c.

Referenced by RETARGET_IRQ_NAME(), and RETARGET_ReadChar().

#define setupSWOForPrint   RETARGET_SwoInit
Deprecated:
Use RETARGET_SwoInit instead

Definition at line 42 of file retargetswo.h.

Function Documentation

int _close ( int  file)

Close a file.

Parameters
[in]fileFile you want to close.
Returns
Returns 0 when the file is closed.

Definition at line 63 of file retargetio.c.

void _exit ( int  status)

Exit the program.

Parameters
[in]statusThe value to return to the parent process as the exit status (not used).

Definition at line 74 of file retargetio.c.

int _fstat ( int  file,
struct stat *  st 
)

Status of an open file.

Parameters
[in]fileCheck status for this file.
[in]stStatus information.
Returns
Returns 0 when st_mode is set to character special.

Definition at line 94 of file retargetio.c.

int _isatty ( int  file)

Query whether output stream is a terminal.

Parameters
[in]fileDescriptor for the file.
Returns
Returns 1 when query is done.

Definition at line 119 of file retargetio.c.

int _kill ( int  pid,
int  sig 
)

Send signal to process.

Parameters
[in]pidProcess id (not used).
[in]sigSignal to send (not used).

Definition at line 130 of file retargetio.c.

int _lseek ( int  file,
int  ptr,
int  dir 
)

Set position in a file.

Parameters
[in]fileDescriptor for the file.
[in]ptrPoiter to the argument offset.
[in]dirDirectory whence.
Returns
Returns 0 when position is set.

Definition at line 153 of file retargetio.c.

int _read ( int  file,
char *  ptr,
int  len 
)

Read from a file.

Parameters
[in]fileDescriptor for the file you want to read from.
[in]ptrPointer to the chacaters that are beeing read.
[in]lenNumber of characters to be read.
Returns
Number of characters that have been read.

Definition at line 177 of file retargetio.c.

References RETARGET_ReadChar(), and rxCount.

caddr_t _sbrk ( int  incr)

Increase heap.

Parameters
[in]incrNumber of bytes you want increment the program's data space.
Returns
Rsturns a pointer to the start of the new area.

Definition at line 209 of file retargetio.c.

References _end.

int _write ( int  file,
const char *  ptr,
int  len 
)

Write to a file.

Parameters
[in]fileDescriptor for the file you want to write to.
[in]ptrPointer to the text you want to write
[in]lenNumber of characters to be written.
Returns
Number of characters that have been written.

Definition at line 240 of file retargetio.c.

References RETARGET_WriteChar().

int RETARGET_ReadChar ( void  )

Receive a byte from USART/LEUART and put into global buffer.

Returns
-1 on failure, or positive character integer on sucesss

Definition at line 258 of file retargetserial.c.

References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, enableRxInterrupt(), initialized, RETARGET_SerialInit(), rxBuffer, RXBUFSIZE, rxCount, and rxReadIndex.

Referenced by _read().

void RETARGET_SerialCrLf ( int  on)

UART/LEUART toggle LF to CRLF conversion.

Parameters
onIf non-zero, automatic LF to CRLF conversion will be enabled

Definition at line 117 of file retargetserial.c.

References LFtoCRLF.

bool RETARGET_SerialEnableFlowControl ( void  )

Enable hardware flow control. (RTS + CTS)

Returns
true if hardware flow control was enabled and false otherwise.

Definition at line 310 of file retargetserial.c.

References _USART_ROUTELOC1_CTSLOC_SHIFT, _USART_ROUTELOC1_RTSLOC_SHIFT, GPIO_PinModeSet(), gpioModeInputPull, gpioModePushPull, USART_CTRLX_CTSEN, USART_ROUTEPEN_CTSPEN, and USART_ROUTEPEN_RTSPEN.

EMSTATUS RETARGET_TextDisplayInit ( void  )

Initialize/retarget a TEXTDISPLAY device to receivie stdout(put).

Returns
EMSTATUS code of the operation.

Definition at line 46 of file retargettextdisplay.c.

References DISPLAY_DeviceGet(), DISPLAY_EMSTATUS_OK, TEXTDISPLAY_Config_t::displayDeviceNo, TEXTDISPLAY_Config_t::lfToCrLf, TEXTDISPLAY_Config_t::scrollEnable, TEXTDISPLAY_EMSTATUS_OK, and TEXTDISPLAY_New().

void RETARGET_TftCrLf ( int  on)

Toggle LF to CRLF conversion.

Parameters
onIf non-zero, automatic LF to CRLF conversion will be enabled

Definition at line 67 of file retargettft.c.

References LFtoCRLF.

void RETARGET_TFTTX ( int  c)

Transmit/display a character.

Parameters
[in]cASCII character to output
Returns
-1 on failure, or positive character integer on sucesss

Definition at line 172 of file retargettft.c.

References charBuffer, CHARS, LINES, rgbColor, tftTextScrollUp(), xpos, and ypos.

Referenced by RETARGET_WriteChar().

void RETARGET_TFTUpdate ( bool  fullFrame)

Display framebuffer.

Parameters
[in]fullFrameIf true, draw entire screen, if false, draw incremental update (faster)

Definition at line 223 of file retargettft.c.

References charBuffer, CHARS, fontBits, LINES, rgbColor, xpos, and ypos.

Referenced by RETARGET_WriteChar().

int RETARGET_WriteChar ( char  c)

Transmit single byte to USART/LEUART.

Parameters
cCharacter to transmit
Returns
Transmitted character

Definition at line 291 of file retargetserial.c.

References initialized, LFtoCRLF, and RETARGET_SerialInit().

Referenced by _write().

EMSTATUS RETARGET_WriteString ( char *  str)

Write a string of characters to the RETARGET text display device.

Parameters
[in]strString to write.
Returns
EMSTATUS code of the operation.

Definition at line 110 of file retargettextdisplay.c.

References TEXTDISPLAY_EMSTATUS_NOT_INITIALIZED, and TEXTDISPLAY_WriteString().

Variable Documentation

char _end

Defined by the linker

Referenced by _sbrk().

uint8_t LFtoCRLF = 0
static

LF to CRLF conversion disabled

Definition at line 57 of file retargetserial.c.

Referenced by RETARGET_SerialCrLf(), and RETARGET_WriteChar().

volatile uint8_t rxBuffer[RXBUFSIZE]
static

Buffer to store data

Definition at line 56 of file retargetserial.c.

Referenced by KSZ8851SNL_SPI_ReadRegister(), RETARGET_IRQ_NAME(), RETARGET_ReadChar(), SPIDRV_MTransferSingleItemB(), UARTDRV_Abort(), and UARTDRV_GetReceiveStatus().

volatile int rxCount = 0
static

Keeps track of how much data which are stored in the buffer

Definition at line 55 of file retargetserial.c.

Referenced by _read(), RETARGET_IRQ_NAME(), and RETARGET_ReadChar().

volatile int rxReadIndex = 0
static

Index in buffer to be read

Definition at line 53 of file retargetserial.c.

Referenced by RETARGET_ReadChar().

volatile int rxWriteIndex = 0
static

Index in buffer to be written to

Definition at line 54 of file retargetserial.c.

Referenced by RETARGET_IRQ_NAME().