📄 hal_lcd.lst
字号:
137 else \
138 P2INP &= ~(1<<(port+5)); \
139 }
140
141 /**************************************************************************************************
142 * TYPEDEFS
143 **************************************************************************************************/
144
145
146 /**************************************************************************************************
147 * GLOBAL VARIABLES
148 **************************************************************************************************/
149 #ifdef LCD_HW
150 static uint8 *Lcd_Line1;
151 #endif
152
153 /**************************************************************************************************
154 * FUNCTIONS - API
155 **************************************************************************************************/
156 #if (defined LCD_HW) && (HAL_LCD == TRUE)
157 static void initLcd( void );
158 static void initSmb( void );
159 static void lcdUpdateLine( uint8 line, uint8 *pLine );
160 static byte lcdConvertChar( byte aChar );
161 static void smbSend( uint8 *buffer, uint8 len );
162 static bool smbSendByte( uint8 dByte );
163 static void smbWrite( bool dBit );
164 static void smbClock( bool dir );
165 static void smbStart( void );
166 static void smbStop( void );
167 static void smbWait( void );
168 #endif
169
170 /**************************************************************************************************
171 * @fn HalLcdInit
172 *
173 * @brief Initilize LCD Service
174 *
175 * @param init - pointer to void that contains the initialized value
176 *
177 * @return None
178 **************************************************************************************************/
\ In segment BANKED_CODE, align 1, keep-with-next
179 void HalLcdInit(void)
\ HalLcdInit:
180 {
\ 000000 ; Saved register size: 0
\ 000000 ; Auto size: 0
181 #if (HAL_LCD == TRUE)
182
183 #ifdef LCD_HW
184 Lcd_Line1 = NULL;
185 initLcd();
186 #endif
187
188 #endif /* HAL_LCD */
189
190 }
\ 000000 02.... LJMP ?BRET
191
192 /*************************************************************************************************
193 * LCD EMULATION FUNCTIONS
194 *
195 * Some evaluation boards are equipped with Liquid Crystal Displays
196 * (LCD) which may be used to display diagnostic information. These
197 * functions provide LCD emulation, sending the diagnostic strings
198 * to Z-Tool via the RS232 serial port. These functions are enabled
199 * when the "LCD_SUPPORTED" compiler flag is placed in the makefile.
200 *
201 * Most applications update both lines (1 and 2) of the LCD whenever
202 * text is posted to the device. This emulator assumes that line 1 is
203 * updated first (saved locally) and the formatting and send operation
204 * is triggered by receipt of line 2. Nothing will be transmitted if
205 * only line 1 is updated.
206 *
207 *************************************************************************************************/
208
209
210 /**************************************************************************************************
211 * @fn HalLcdWriteString
212 *
213 * @brief Write a string to the LCD
214 *
215 * @param str - pointer to the string that will be displayed
216 * option - display options
217 *
218 * @return None
219 **************************************************************************************************/
\ In segment BANKED_CODE, align 1, keep-with-next
220 void HalLcdWriteString ( char *str, uint8 option)
\ HalLcdWriteString:
221 {
\ 000000 ; Saved register size: 0
\ 000000 ; Auto size: 0
222 #if (HAL_LCD == TRUE)
223
224 #ifdef LCD_SD
225 byte x;
226 byte bln;
227 byte sln;
228 char *buf;
229
230 if ( Lcd_Line1 == NULL )
231 {
232 // Set up system start-up message
233 Lcd_Line1 = osal_mem_alloc( MAX_LCD_CHARS+1 );
234 HalLcdWriteString( "Figure8 Wireless", HAL_LCD_LINE_1 );
235 }
236
237 sln = (byte)osal_strlen( str );
238
239 // Check boundries
240 if ( sln > MAX_LCD_CHARS )
241 sln = MAX_LCD_CHARS;
242
243 if ( option == HAL_LCD_LINE_1 ) {
244 // Line 1 gets saved for later
245 osal_memcpy( Lcd_Line1, str, sln );
246 Lcd_Line1[sln] = '\0';
247 }
248 else {
249 // Line 2 triggers action
250 x = (byte)osal_strlen( (char*)Lcd_Line1 );
251 bln = x + 1 + sln + 1;
252 buf = osal_mem_alloc( bln );
253 if ( buf != NULL ) {
254 // Concatenate strings
255 osal_memcpy( buf, Lcd_Line1, x );
256 buf[x++] = ' ';
257 osal_memcpy( &buf[x], str, sln );
258 buf[x+sln] = '\0';
259 // Send it out
260 #ifdef ZTOOL_PORT
261 debug_str( (byte*)buf );
262 #endif
263 osal_mem_free( buf );
264 }
265 }
266 #endif // LCD_SD
267
268 #ifdef LCD_HW
269 lcdUpdateLine( option, (byte*)str );
270 #endif
271
272 #endif /* HAL_LCD */
273
274 }
\ 000000 02.... LJMP ?BRET
275
276 /**************************************************************************************************
277 * @fn HalLcdWriteValue
278 *
279 * @brief Write a value to the LCD
280 *
281 * @param value - value that will be displayed
282 * radix - 8, 10, 16
283 * option - display options
284 *
285 * @return None
286 **************************************************************************************************/
\ In segment BANKED_CODE, align 1, keep-with-next
287 void HalLcdWriteValue ( uint32 value, const uint8 radix, uint8 option)
\ HalLcdWriteValue:
288 {
\ 000000 74F2 MOV A,#-0xe
\ 000002 12.... LCALL ?BANKED_ENTER_XDATA
\ 000005 ; Saved register size: 14
\ 000005 ; Auto size: 25
\ 000005 74E7 MOV A,#-0x19
\ 000007 12.... LCALL ?ALLOC_XSTACK8
289 #if (HAL_LCD == TRUE)
290 uint8 buf[LCD_MAX_BUF];
291
292 _ltoa( value, &buf[0], radix );
\ 00000A ; Setup parameters for call to function _ltoa
\ 00000A 85..82 MOV DPL,?XSP + 0
\ 00000D 85..83 MOV DPH,?XSP + 1
\ 000010 8582.. MOV ?V0 + 4,DPL
\ 000013 8583.. MOV ?V0 + 5,DPH
\ 000016 78.. MOV R0,#?V0 + 4
\ 000018 12.... LCALL ?PUSH_XSTACK_I_TWO
\ 00001B REQUIRE ?Subroutine3
\ 00001B ; // Fall through to label ?Subroutine3
293 HalLcdWriteString( (char*)buf, option );
294 #endif /* HAL_LCD */
295 }
\ In segment BANKED_CODE, align 1, keep-with-next
\ ?Subroutine3:
\ 000000 90.... MOV DPTR,#(_ltoa & 0xffff)
\ 000003 74.. MOV A,#((_ltoa >> 16) & 0xff)
\ 000005 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 000008 7402 MOV A,#0x2
\ 00000A 12.... LCALL ?DEALLOC_XSTACK8
\ 00000D 7419 MOV A,#0x19
\ 00000F 12.... LCALL ?DEALLOC_XSTACK8
\ 000012 7F06 MOV R7,#0x6
\ 000014 02.... LJMP ?BANKED_LEAVE_XDATA
296
297 /**************************************************************************************************
298 * @fn HalLcdWriteScreen
299 *
300 * @brief Write a value to the LCD
301 *
302 * @param line1 - string that will be displayed on line 1
303 * line2 - string that will be displayed on line 2
304 *
305 * @return None
306 **************************************************************************************************/
\ In segment BANKED_CODE, align 1, keep-with-next
307 void HalLcdWriteScreen( char *line1, char *line2 )
\ HalLcdWriteScreen:
308 {
\ 000000 ; Saved register size: 0
\ 000000 ; Auto size: 0
309 #if (HAL_LCD == TRUE)
310 HalLcdWriteString( line1, HAL_LCD_LINE_1 );
311 HalLcdWriteString( line2, HAL_LCD_LINE_2 );
312 #endif /* HAL_LCD */
313 }
\ 000000 02.... LJMP ?BRET
314
315 /**************************************************************************************************
316 * @fn HalLcdWriteStringValue
317 *
318 * @brief Write a string followed by a value to the LCD
319 *
320 * @param title -
321 * value -
322 * format -
323 * line -
324 *
325 * @return None
326 **************************************************************************************************/
\ In segment BANKED_CODE, align 1, keep-with-next
327 void HalLcdWriteStringValue( char *title, uint16 value, uint8 format, uint8 line )
\ HalLcdWriteStringValue:
328 {
\ 000000 74F2 MOV A,#-0xe
\ 000002 12.... LCALL ?BANKED_ENTER_XDATA
\ 000005 ; Saved register size: 14
\ 000005 ; Auto size: 25
\ 000005 74E7 MOV A,#-0x19
\ 000007 12.... LCALL ?ALLOC_XSTACK8
\ 00000A 8A.. MOV ?V0 + 0,R2
\ 00000C 8B.. MOV ?V0 + 1,R3
\ 00000E EC MOV A,R4
\ 00000F FE MOV R6,A
\ 000010 ED MOV A,R5
\ 000011 FF MOV R7,A
\ 000012 89.. MOV ?V0 + 3,R1
329 #if (HAL_LCD == TRUE)
330 uint8 tmpLen;
331 uint8 buf[LCD_MAX_BUF];
332 uint32 err;
333
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -