张会 在 提交
相关阅读:【爱普特 APT32F110 ev board 试用测评连载】+ 搭建开发环境并点灯
测试下断码LCD显示屏显示。
一、硬件部分
1.1、LCD相关的硬件部分电路图:
1.2、断码显示屏的逻辑表
二、驱动代码
2.1、lcd.c
//lcd.c #include <drv/lcd.h> #include <drv/gpio.h> #include <drv/pin.h> #include <drv/lcd.h> #include <drv/irq.h> #include <drv/rtc.h> #include <drv/iwdt.h> #include <drv/pm.h> #include <drv/reliability.h> #include "iostring.h" #include "board_config.h" uint8_t SendData[32] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}; static uint8_t s_RtcSec = 0; void init_lcd(void) { int iRet = 0; uint8_t i; uint8_t j=0; uint32_t wSegMsk = 0x0Cfffffc; //lcd seg2->26 uint8_t wComMsk = 0x0f; //lcd com0->3 csi_lcd_config_t tLcdCfg; csi_lcd_gpio_init(wSegMsk, wComMsk); //LCD GPIO ??:com0-com3 seg2-seg31 4*30 tLcdCfg.byClkSrc = LCD_CLKSRC_ISOSC; //LCD?????ISOSC tLcdCfg.byFreq = 80; //LCD???? =40Hz,????:30~100Hz tLcdCfg.byVlcd = LCD_VLCD_IN_3V2; //VLCD????3.2V tLcdCfg.byDutyBias = LCD_DUTY1_4_BIAS1_3; //LCD Duty = 1/4, Bias = 1/3 tLcdCfg.byDead = LCD_DEAD_2PHASE; //LCD?????,??3?????,????????? tLcdCfg.byDrvNet = LCD_DRVNET_PWLEV1; //LCD????(????), ??4?,??PWLEV0 > PWLEV1 > PWLEV2 > PWLEV3 tLcdCfg.byDpEn = DISABLE; //???????? tLcdCfg.byInt = LCD_INTSRC_NONE; //?????,?? iRet = csi_lcd_init(LCD, &tLcdCfg); if(iRet == CSI_OK) csi_lcd_start(LCD); //csi_lcd_set_blink(LCD, LCD_BLINK_SEG8, LCD_BLINK_FRE_F2, 2); //LCD ?????????LCD_BLINK_FRE_F2, ????????? csi_lcd_write_data(LCD, SendData, 2, 22); for(i = 2; i < 24; i++) { SendData[i] = 0x0f; } csi_lcd_write_data(LCD, SendData, 2, 22); } uint8_t i=0; uint8_t j=0; void lcd_test(void) { for(i = 2; i < 24; i++) { SendData[i] = 0x0f; } lcd_disprtc(SendData, 2, j); lcd_disprtc(SendData, 4, j); lcd_disprtc(SendData, 6, j); lcd_disprtc(SendData, 8, j); lcd_dispthl(SendData, 21,j); lcd_dispthl(SendData, 18,j); lcd_disptv(SendData, 16, j); lcd_disptv(SendData, 14, j); lcd_disptv(SendData, 12, j); lcd_disptv(SendData, 10, j); SendData[3]= (SendData[3]&0xf7) |0x08; SendData[5]= (SendData[5]&0xf7) |0x00; SendData[7]= (SendData[7]&0xf7) |0x00; SendData[9]= (SendData[9]&0xf7) |0x00; SendData[10]= (SendData[10]&0xf7) |0x00; SendData[14]= (SendData[14]&0xf7) |0x00; SendData[16]= (SendData[16]&0xf7) |0x00; SendData[18]= (SendData[18]&0xf7) |0x00; SendData[21]= (SendData[21]&0xf7) |0x00; csi_lcd_write_data(LCD, SendData, 2, 24); mdelay(500); j++; if(j>9) { j=0; } }
2.2、main.c
#include <string.h> #include <csi_drv.h> #include <iostring.h> #include "demo.h" #include "led.h" #include "key.h" #include "lcd.h" /* Private macro-----------------------------------------------------------*/ /* externs function--------------------------------------------------------*/ extern void system_init(void); extern void board_init(void); extern void user_demo(void); /* externs variablesr------------------------------------------------------*/ /* Private variablesr------------------------------------------------------*/ int main() { uint8_t key_val; system_init(); board_init(); init_led(); init_key(); init_lcd(); my_printf("Hello World~~~~~~~\n"); //print message while(1) { lcd_test(); } return 0; }
三、显示效果