Display.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
188 #ifndef ti_display_Display__include
189 #define ti_display_Display__include
190 
191 #ifdef __cplusplus
192 extern "C" {
193 #endif
194 
195 #include <stdint.h>
196 #include <stdarg.h>
197 
198 /* -----------------------------------------------------------------------------
199  * Constants
200  * ------------------------------------------------------------------------------
201  */
210 #define Display_Type_ANY 0xFFFFFFFF
211 #define Display_Type_INVALID 0x00000000
212 #define Display_Type_LCD 0x80000000
213 #define Display_Type_UART 0x40000000
214 #define Display_Type_LOG 0x20000000
215 #define Display_Type_ITM 0x10000000
216 #define Display_Type_HOST 0x08000000
217 #define Display_Type_ANSI 0x04000000
218 #define Display_Type_GRLIB 0x00100000
222 #define Display_MAXINDEX 15
223 
241 #define DISPLAY_CMD_RESERVED 32
242 
255 #define DISPLAY_STATUS_RESERVED -32
256 
270 #define DISPLAY_STATUS_SUCCESS 0
271 
278 #define DISPLAY_STATUS_ERROR -1
279 
287 #define DISPLAY_STATUS_UNDEFINEDCMD -2
288 
308 #define DISPLAY_CMD_TRANSPORT_CLOSE 0
309 
318 #define DISPLAY_CMD_TRANSPORT_OPEN 1
319 
323 /* -----------------------------------------------------------------------------
324  * Macros
325  * ------------------------------------------------------------------------------
326  */
327 #define Display_clearLine(handle, n) Display_clearLines(handle, n, 0)
328 #define Display_isIndex(i) (i <= Display_MAXINDEX)
329 #define Display_isMetaType(i) (i > Display_MAXINDEX)
330 
331 #if !defined(Display_DISABLE_ALL) || (!Display_DISABLE_ALL)
332 
334 # define Display_init() \
335  Display_doInit()
336 
338 # define Display_open(id, params) \
339  Display_doOpen(id, params)
340 
342 # define Display_Params_init(params) \
343  Display_doParamsInit(params)
344 
346 # define Display_clear(handle) \
347  Display_doClear(handle)
348 
350 # define Display_clearLines(handle, fromLine, toLine) \
351  Display_doClearLines(handle, fromLine, toLine)
352 
354 # define Display_printf Display_doPrintf
355 
357 # define Display_print0(handle, line, col, fmt) \
358  Display_printf(handle, line, col, fmt)
359 
361 # define Display_print1(handle, line, col, fmt, a0) \
362  Display_printf(handle, line, col, fmt, a0)
363 
365 # define Display_print2(handle, line, col, fmt, a0, a1) \
366  Display_printf(handle, line, col, fmt, a0, a1)
367 
369 # define Display_print3(handle, line, col, fmt, a0, a1, a2) \
370  Display_printf(handle, line, col, fmt, a0, a1, a2)
371 
373 # define Display_print4(handle, line, col, fmt, a0, a1, a2, a3) \
374  Display_printf(handle, line, col, fmt, a0, a1, a2, a3)
375 
377 # define Display_print5(handle, line, col, fmt, a0, a1, a2, a3, a4) \
378  Display_printf(handle, line, col, fmt, a0, a1, a2, a3, a4)
379 
381 # define Display_getType(handle) \
382  Display_doGetType(handle)
383 
385 # define Display_control(handle, cmd, arg) \
386  Display_doControl(handle, cmd, arg)
387 
389 # define Display_close(handle) \
390  Display_doClose(handle)
391 #else
392 # define Display_init()
393 # define Display_open(id, params) NULL
394 # define Display_Params_init(params)
395 # define Display_clear(handle)
396 # define Display_clearLines(handle, fromLine, toLine)
397 # define Display_printf(handle, line, col, fmt, ...)
398 # define Display_print0(handle, line, col, fmt)
399 # define Display_print1(handle, line, col, fmt, a0)
400 # define Display_print2(handle, line, col, fmt, a0, a1)
401 # define Display_print3(handle, line, col, fmt, a0, a1, a2)
402 # define Display_print4(handle, line, col, fmt, a0, a1, a2, a3)
403 # define Display_print5(handle, line, col, fmt, a0, a1, a2, a3, a4)
404 # define Display_getType(handle) Display_Type_INVALID
405 # define Display_control(handle, cmd, arg) NULL
406 # define Display_close(handle)
407 #endif
408 
409 /* -----------------------------------------------------------------------------
410  * Typedefs
411  * ------------------------------------------------------------------------------
412  */
417 
422 typedef void (*Display_initFxn)(Display_Handle handle);
423 
428 {
434 
443 typedef struct Display_Params
444 {
445  Display_LineClearMode lineClearMode; /* Default clear entire line */
447 
452 typedef Display_Handle (*Display_openFxn)(Display_Handle handle,
453  Display_Params *params);
458 typedef void (*Display_clearFxn)(Display_Handle handle);
459 
464 typedef void (*Display_clearLinesFxn)(Display_Handle handle,
465  uint8_t fromLine,
466  uint8_t toLine);
467 
472 typedef void (*Display_vprintfFxn)(Display_Handle handle,
473  uint8_t line,
474  uint8_t column,
475  char *fmt,
476  va_list va);
477 
483 
488 typedef int (*Display_controlFxn)(Display_Handle handle,
489  unsigned int cmd,
490  void *arg);
495 typedef unsigned int (*Display_getTypeFxn)(void);
496 
502 typedef struct Display_FxnTable
503 {
513 
525 typedef struct Display_Config
526 {
529 
531  void *object;
532 
534  void const *hwAttrs;
536 
537 
538 /* -----------------------------------------------------------------------------
539  * Functions
540  * ------------------------------------------------------------------------------
541  */
572 Display_Handle Display_doOpen(uint32_t id, Display_Params *params);
573 
582 
590 void Display_doClear(Display_Handle handle);
591 
601 void Display_doClearLines(Display_Handle handle, uint8_t fromLine, uint8_t toLine);
602 
614 void Display_doPrintf(Display_Handle handle, uint8_t line, uint8_t column,
615  char *fmt, ...);
616 
622 void Display_doClose(Display_Handle handle);
623 
630 uint32_t Display_doGetType(Display_Handle handle);
631 
667 void Display_doControl(Display_Handle handle, unsigned int cmd, void *arg);
668 
676 void Display_doInit(void);
677 
678 #ifdef __cplusplus
679 }
680 #endif
681 
682 #endif //ti_display_Display__include
void Display_doClose(Display_Handle handle)
Closes selected Display implementations.
Display_vprintfFxn vprintfFxn
Definition: Display.h:508
struct Display_Config * Display_Handle
A handle for specific Display implementations.
Definition: Display.h:416
struct Display_Config Display_Config
Display Global configuration.
void(* Display_clearLinesFxn)(Display_Handle handle, uint8_t fromLine, uint8_t toLine)
A function pointer to a specific implementation of Display_clearLines().
Definition: Display.h:464
void Display_doParamsInit(Display_Params *params)
Initializes parameter structure with default parameters.
void * object
Definition: Display.h:531
void Display_doInit(void)
Function to initializes the Display driver.
Display_Handle(* Display_openFxn)(Display_Handle handle, Display_Params *params)
A function pointer to a specific implementation of Display_open().
Definition: Display.h:452
unsigned int(* Display_getTypeFxn)(void)
A function pointer to a specific implementation of Display_getType().
Definition: Display.h:495
void Display_doClear(Display_Handle handle)
Calls the clear fxn of all opened Display implementations.
Display Parameters.
Definition: Display.h:443
void const * hwAttrs
Definition: Display.h:534
uint32_t Display_doGetType(Display_Handle handle)
Gets the type of display for the handle.
Definition: Display.h:429
void Display_doControl(Display_Handle handle, unsigned int cmd, void *arg)
Function performs implementation specific features on a given Display_Handle.
Display_clearFxn clearFxn
Definition: Display.h:506
Display_controlFxn controlFxn
Definition: Display.h:510
void(* Display_vprintfFxn)(Display_Handle handle, uint8_t line, uint8_t column, char *fmt, va_list va)
A function pointer to a specific implementation of Display_vprintf().
Definition: Display.h:472
void Display_doPrintf(Display_Handle handle, uint8_t line, uint8_t column, char *fmt,...)
Calls the output function of all opened Display implementations.
void(* Display_clearFxn)(Display_Handle handle)
A function pointer to a specific implementation of Display_clear().
Definition: Display.h:458
Display_initFxn initFxn
Definition: Display.h:504
Definition: Display.h:431
The definition of a Display function table that contains the required set of functions to control a s...
Definition: Display.h:502
Display_openFxn openFxn
Definition: Display.h:505
void(* Display_initFxn)(Display_Handle handle)
A function pointer to a specific implementation of Display_initFxn().
Definition: Display.h:422
Definition: Display.h:430
Display_getTypeFxn getTypeFxn
Definition: Display.h:511
void Display_doClearLines(Display_Handle handle, uint8_t fromLine, uint8_t toLine)
Calls the clearLines fxn of all opened Display implementations.
struct Display_FxnTable Display_FxnTable
The definition of a Display function table that contains the required set of functions to control a s...
Display_LineClearMode lineClearMode
Definition: Display.h:445
Display_Handle Display_doOpen(uint32_t id, Display_Params *params)
Initialize all the selected Display implementations.
Display Global configuration.
Definition: Display.h:525
struct Display_Params Display_Params
Display Parameters.
Display_FxnTable const * fxnTablePtr
Definition: Display.h:528
int(* Display_controlFxn)(Display_Handle handle, unsigned int cmd, void *arg)
A function pointer to a driver specific implementation of Display_control().
Definition: Display.h:488
Display_closeFxn closeFxn
Definition: Display.h:509
Display_LineClearMode
How to treat existing elements on a line when writing text.
Definition: Display.h:427
Definition: Display.h:432
Display_clearLinesFxn clearLinesFxn
Definition: Display.h:507
void(* Display_closeFxn)(Display_Handle)
A function pointer to a specific implementation of Display_close().
Definition: Display.h:482
Copyright 2017, Texas Instruments Incorporated