EFM32 Wonder Gecko Software Documentation  efm32wg-doc-5.1.2
retargettextdisplay.c
Go to the documentation of this file.
1 /***************************************************************************/
17 #include <stdio.h>
18 #include <stdint.h>
19 
20 #include "displayconfigall.h"
21 #include "display.h"
22 #include "textdisplay.h"
23 #include "retargettextdisplay.h"
24 
25 
28 /*******************************************************************************
29  ******************************** STATICS ************************************
30  ******************************************************************************/
31 
32 /* Handle which references the selected text display to print text on. */
33 TEXTDISPLAY_Handle_t textDisplayHandle = 0;
34 
38 /*******************************************************************************
39  ************************** GLOBAL FUNCTIONS **************************
40  ******************************************************************************/
41 
42 /**************************************************************************/
48 {
49  EMSTATUS status;
50  DISPLAY_Device_t displayDevice;
51  TEXTDISPLAY_Config_t textDisplayConfig;
52 
53  /* Query that the specified DISPLAY device is available. */
54  status = DISPLAY_DeviceGet(RETARGETTEXTDISPLAY_DISPLAY_NO, &displayDevice);
55 
56  if (DISPLAY_EMSTATUS_OK == status)
57  {
58  textDisplayConfig.displayDeviceNo = RETARGETTEXTDISPLAY_DISPLAY_NO;
59  textDisplayConfig.scrollEnable = RETARGETTEXTDISPLAY_SCROLL_MODE;
60  textDisplayConfig.lfToCrLf = RETARGETTEXTDISPLAY_LINE_FEED_MODE;
61 
62  status = TEXTDISPLAY_New(&textDisplayConfig, &textDisplayHandle);
63 
64 #if !defined(__CROSSWORKS_ARM) && defined(__GNUC__)
65  if (TEXTDISPLAY_EMSTATUS_OK == status)
66  {
67  /* Set unbuffered mode for stdout (newlib) */
68  setvbuf(stdout, NULL, _IONBF, 0);
69  }
70 #endif
71  }
72 
73  return status;
74 }
75 
76 
77 /**************************************************************************/
85 {
86  return -1;
87 }
88 
89 /**************************************************************************/
97 int RETARGET_WriteChar(char c)
98 {
99  if (textDisplayHandle)
100  {
101  TEXTDISPLAY_WriteChar(textDisplayHandle, c);
102  return c;
103  }
104  else
105  return -1;
106 }
107 
108 
109 /**************************************************************************/
116 EMSTATUS RETARGET_WriteString(char* str)
117 {
118  if (textDisplayHandle)
119  {
120  return TEXTDISPLAY_WriteString(textDisplayHandle, str);
121  }
122  else
124 }
125 
126 
127 /*************** THE REST OF THE FILE IS DOCUMENTATION ONLY ! ***************/
128 
129 /*******************************************************************************
130  ************************** DOCUMENTATION **************************
131  ******************************************************************************/
132 
133 /**************************************************************************/
int RETARGET_ReadChar(void)
Receive a byte No input method from the text display is possible, thus we always return -1...
Retarget stdout to text display module.
EMSTATUS RETARGET_TextDisplayInit(void)
Initialize/retarget a TEXTDISPLAY device to receivie stdout(put).
#define TEXTDISPLAY_EMSTATUS_OK
Definition: textdisplay.h:43
EMSTATUS TEXTDISPLAY_New(TEXTDISPLAY_Config_t *config, TEXTDISPLAY_Handle_t *handle)
Create a new text display device.
Definition: textdisplay.c:210
Text display interface.
EMSTATUS TEXTDISPLAY_WriteString(TEXTDISPLAY_Handle_t handle, const char *str)
Write a string of characters to a text display.
Definition: textdisplay.c:454
Display device interface.
int RETARGET_WriteChar(char c)
Write a single byte to the text display.
#define DISPLAY_EMSTATUS_OK
Definition: display.h:45
Main configuration file for the DISPLAY driver software stack.
#define TEXTDISPLAY_EMSTATUS_NOT_INITIALIZED
Definition: textdisplay.h:49
void * TEXTDISPLAY_Handle_t
Definition: textdisplay.h:68
EMSTATUS RETARGET_WriteString(char *str)
Write a string of characters to the RETARGET text display device.
EMSTATUS TEXTDISPLAY_WriteChar(TEXTDISPLAY_Handle_t handle, char c)
Write a single character to a text display.
Definition: textdisplay.c:381
EMSTATUS DISPLAY_DeviceGet(int displayDeviceNo, DISPLAY_Device_t *device)
Get the display device data structure corresponding to the device number.
Definition: display.c:139