ESOS32
ESOSOn32-bitProcessors
esos_lcd44780wo.h
Go to the documentation of this file.
1 /*
2  * "Copyright (c) 2019 J. W. Bruce ("AUTHOR(S)")"
3  * All rights reserved.
4  * (J. W. Bruce, jwbruce_AT_tntech.edu, Tennessee Tech University)
5  *
6  * Permission to use, copy, modify, and distribute this software and its
7  * documentation for any purpose, without fee, and without written agreement is
8  * hereby granted, provided that the above copyright notice, the following
9  * two paragraphs and the authors appear in all copies of this software.
10  *
11  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
12  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
13  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
14  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15  *
16  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
17  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
19  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
20  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
21  *
22  * Please maintain this header in its entirety when copying/modifying
23  * these files.
24  *
25  *
26  */
27 
39 #ifndef ESOS_LCDWO_H
40 #define ESOS_LCDWO_H
41 
42 /* I N C L U D E S **********************************************************/
43 #include <esos.h>
44 
45 /* D E F I N E S ************************************************************/
46 #define ESOS_LCD44780_CMD_CLEAR_DISPLAY 0b00000001
47 #define ESOS_LCD44780_CMD_RETURN_HOME 0b00000010
48 #define ESOS_LCD44780_CMD_ENTRY_MODE_SET 0b00000100
49 #define ESOS_LCD44780_CMD_ENTRY_MODE_SET_INC 0b00000010
50 #define ESOS_LCD44780_CMD_ENTRY_MODE_SET_SHIFT 0b00000001
51 #define ESOS_LCD44780_CMD_DISPLAY_ON_OFF 0b00001000
52 #define ESOS_LCD44780_CMD_DISPLAY_ON_OFF_DISPLAYON 0b00000100
53 #define ESOS_LCD44780_CMD_DISPLAY_ON_OFF_CURSORON 0b00000010
54 #define ESOS_LCD44780_CMD_DISPLAY_ON_OFF_BLINKCURSOR 0b00000001
55 #define ESOS_LCD44780_CMD_CUR_DISP_CURSOR_SHIFT_L 0b00010000
56 #define ESOS_LCD44780_CMD_CUR_DISP_CURSOR_SHIFT_R 0b00010100
57 #define ESOS_LCD44780_CMD_CUR_DISP_DISPLAY_SHIFT_L 0b00011000
58 #define ESOS_LCD44780_CMD_CUR_DISP_DISPLAY_SHIFT_R 0b00011100
59 #define ESOS_LCD44780_CMD_FUNCTION_SET 0b00100000
60 #define ESOS_LCD44780_CMD_FUNCTION_SET_8BIT_MODE 0b00010000
61 #define ESOS_LCD44780_CMD_FUNCTION_SET_4BIT_MODE 0b00000000
62 #define ESOS_LCD44780_CMD_FUNCTION_SET_1LINE_MODE 0b00000000
63 #define ESOS_LCD44780_CMD_FUNCTION_SET_2LINE_MODE 0b00001000
64 #define ESOS_LCD44780_CMD_FUNCTION_SET_LOWFONT_MODE 0b00000000
65 #define ESOS_LCD44780_CMD_FUNCTION_SET_HIFONT_MODE 0b00000100
66 #define ESOS_LCD44780_CMD_SET_CGRAM_ADDR 0b01000000
67 #define ESOS_LCD44780_CMD_SET_DDRAM_ADDR 0b10000000
68 // HD44780 chipsets implement 40 characters in the IC because 40 wide
69 // displays are available. The physically connected LCD may be (much)
70 // smaller in width, but the memory is still there. Some applications
71 // exploit this fact for "off-screen" rendering or buffering.
72 // Furthermore, the display "shift" commands facilitate this behavior.
73 // The ESOS LCD character service will implement LCD memory as 40
74 // characters wide to allow apps to work this way.
75 #define ESOS_LCD44780_MEM_WIDTH 40
76 #define ESOS_LCD44780_MEM_HEIGHT 2
77 #define ESOS_LCD44780_NUM_CUSTOM_CHARS 8
78 
79 #define LCD44780_READ 1
80 #define LCD44780_WRITE 0
81 #define LCD44780_DATA TRUE
82 #define LCD44780_COMMANDS FALSE
83 
84 
85 #define ESOS_TASK_WAIT_ON_LCD44780_REFRESH() ESOS_TASK_WAIT_UNTIL(esos_lcd44780_isCurrent())
86 
87 #define ESOS_TASK_WAIT_LCD44780_WRITE_COMMAND(u8_cmd) do { \
88  ESOS_TASK_SPAWN_AND_WAIT( (ESOS_TASK_HANDLE) &__stLCDChildTask, __esos_lcd44780_hw_write_u8, u8_cmd, LCD44780_COMMANDS ); \
89 } while(0)
90 
91 #define ESOS_TASK_WAIT_LCD44780_WRITE_COMMAND_NOWAIT(u8_cmd) do { \
92  ESOS_TASK_SPAWN_AND_WAIT( (ESOS_TASK_HANDLE) &__stLCDChildTask, __esos_lcd44780_hw_write_u8, u8_cmd, LCD44780_COMMANDS ); \
93 } while(0)
94 
95 #define ESOS_TASK_WAIT_LCD44780_SET_CG_ADDRESS(u8_addr) \
96  ESOS_TASK_WAIT_LCD44780_WRITE_COMMAND( u8_addr | ESOS_LCD44780_CMD_SET_CGRAM_ADDR )
97 
98 #define ESOS_TASK_WAIT_LCD44780_SET_DATA_ADDRESS(u8_addr) \
99  ESOS_TASK_WAIT_LCD44780_WRITE_COMMAND( u8_addr | ESOS_LCD44780_CMD_SET_DDRAM_ADDR )
100 
101 #define ESOS_TASK_WAIT_LCD44780_WRITE_DATA(u8_data) do { \
102  ESOS_TASK_SPAWN_AND_WAIT( (ESOS_TASK_HANDLE) &__stLCDChildTask, __esos_lcd44780_hw_write_u8, u8_data, LCD44780_DATA ); \
103 } while(0)
104 
105 
106 /* S T R U C T U R E S ******************************************************/
107 typedef struct {
108  uint8_t au8_data[8];
110 
111 /* P U B L I C P R O T O T Y P E S *****************************************/
112 void esos_lcd44780_configDisplay( void );
113 void __esos_lcd44780_init( void );
114 void esos_lcd44780_clearScreen( void );
115 void esos_lcd44780_setCursorHome( void );
116 void esos_lcd44780_setCursor( uint8_t u8_row, uint8_t u8_column );
117 void esos_lcd44780_writeChar( uint8_t u8_row, uint8_t u8_column, uint8_t u8_data );
118 uint8_t esos_lcd44780_getChar( uint8_t u8_row, uint8_t u8_column );
119 void esos_lcd44780_writeBuffer( uint8_t u8_row, uint8_t u8_column, uint8_t *pu8_data, uint8_t u8_bufflen );
120 void esos_lcd44780_getBuffer( uint8_t u8_row, uint8_t u8_column, uint8_t *pu8_data, uint8_t u8_bufflen );
121 void esos_lcd44780_writeString( uint8_t u8_row, uint8_t u8_column, char *psz_data );
122 void esos_lcd44780_setCursorDisplay( BOOL u8_state );
123 BOOL esos_lcd44780_getCursorDisplay( void );
124 void esos_lcd44780_setCursorBlink( BOOL u8_state );
125 BOOL esos_lcd44780_getCursorBlink( void );
126 void esos_lcd44780_setDisplayVisible( BOOL u8_state );
127 BOOL esos_lcd44780_getDisplayVisible( void );
128 void esos_lcd44780_setCustomChar( uint8_t u8_charSlot, uint8_t *pu8_charData );
129 void esos_lcd44780_getCustomChar( uint8_t u8_charSlot, uint8_t *pu8_charData );
130 BOOL esos_lcd44780_isCurrent( void );
131 
132 ESOS_USER_TASK( __esos_lcd44780_service );
133 
134 /* P R O T O T Y P E S HARDWARE-SPECIFIC ********************************/
135 extern ESOS_CHILD_TASK( __esos_lcd44780_hw_write_u8, uint8_t u8_data, BOOL b_isData);
136 extern void __esos_lcd44780_hw_config(void);
137 
138 #ifdef ESOS_USE_LCD_4BIT
139 extern void __esos_unsafe_lcd44780_hw_write_u4(uint8_t u8_u4data, BOOL b_isEnable, BOOL b_isData);
140 #endif
141 
142 #endif // ESOS_LCDWO_H
esos_lcd44780_char_t
Definition: esos_lcd44780wo.h:107
esos.h
ESOS_CHILD_TASK
#define ESOS_CHILD_TASK(taskname,...)
Definition: esos_task.h:246
BOOL
enum _BOOL BOOL
ESOS_USER_TASK
#define ESOS_USER_TASK(taskname)
Definition: esos_task.h:227