00001 /***************************************************************************/ 00017 #include <stdio.h> 00018 #include <stdint.h> 00019 00020 #include "displayconfigall.h" 00021 #include "display.h" 00022 #include "textdisplay.h" 00023 #include "retargettextdisplay.h" 00024 00025 00028 /******************************************************************************* 00029 ******************************** STATICS ************************************ 00030 ******************************************************************************/ 00031 00032 /* Handle which references the selected text display to print text on. */ 00033 TEXTDISPLAY_Handle_t textDisplayHandle = 0; 00034 00038 /******************************************************************************* 00039 ************************** GLOBAL FUNCTIONS ************************** 00040 ******************************************************************************/ 00041 00042 /**************************************************************************/ 00047 EMSTATUS RETARGET_TextDisplayInit(void) 00048 { 00049 EMSTATUS status; 00050 DISPLAY_Device_t displayDevice; 00051 TEXTDISPLAY_Config_t textDisplayConfig; 00052 00053 /* Query that the specified DISPLAY device is available. */ 00054 status = DISPLAY_DeviceGet(RETARGETTEXTDISPLAY_DISPLAY_NO, &displayDevice); 00055 00056 if (DISPLAY_EMSTATUS_OK == status) 00057 { 00058 textDisplayConfig.displayDeviceNo = RETARGETTEXTDISPLAY_DISPLAY_NO; 00059 textDisplayConfig.scrollEnable = RETARGETTEXTDISPLAY_SCROLL_MODE; 00060 textDisplayConfig.lfToCrLf = RETARGETTEXTDISPLAY_LINE_FEED_MODE; 00061 00062 status = TEXTDISPLAY_New(&textDisplayConfig, &textDisplayHandle); 00063 00064 #if !defined(__CROSSWORKS_ARM) && defined(__GNUC__) 00065 if (TEXTDISPLAY_EMSTATUS_OK == status) 00066 { 00067 /* Set unbuffered mode for stdout (newlib) */ 00068 setvbuf(stdout, NULL, _IONBF, 0); 00069 } 00070 #endif 00071 } 00072 00073 return status; 00074 } 00075 00076 00077 /**************************************************************************/ 00084 int RETARGET_ReadChar(void) 00085 { 00086 return -1; 00087 } 00088 00089 /**************************************************************************/ 00097 int RETARGET_WriteChar(char c) 00098 { 00099 if (textDisplayHandle) 00100 { 00101 TEXTDISPLAY_WriteChar(textDisplayHandle, c); 00102 return c; 00103 } 00104 else 00105 return -1; 00106 } 00107 00108 00109 /**************************************************************************/ 00116 EMSTATUS RETARGET_WriteString(char* str) 00117 { 00118 if (textDisplayHandle) 00119 { 00120 return TEXTDISPLAY_WriteString(textDisplayHandle, str); 00121 } 00122 else 00123 return TEXTDISPLAY_EMSTATUS_NOT_INITIALIZED; 00124 } 00125 00126 00127 /*************** THE REST OF THE FILE IS DOCUMENTATION ONLY ! ***************/ 00128 00129 /******************************************************************************* 00130 ************************** DOCUMENTATION ************************** 00131 ******************************************************************************/ 00132 00133 /**************************************************************************/