lcd.c

来自「飞思卡尔液带晶驱动的MCU例程 飞思卡尔液带晶驱动的MCU例程」· C语言 代码 · 共 30 行

C
30
字号
#include "per_XDx512_L15Y.h"
#include "LCD.h"

/* start-up of the LCD driver. Parameters: bus frequency in kHz, contrast adjustment coefficient */
void LCD_start(unsigned int bus_frequency, int contrast_adj) {
                                /* calculate normal phase time and contrast adjustment phase time */
  LCD_contrast(bus_frequency, contrast_adj);
	                              /* update the active period and contrast variables by hand */
	LCD_data.active_period=LCD_data.period;	    
	LCD_data.active_contrast=LCD_data.contrast;
                                /* initialise state and state reload */
  LCD_data.phase = LCD_data.phase_reload = (LCD_BP_CNT+LCD_IDLE_CNT)-1; 
  LCD_data.polarity=0;
  LCD_ALL_PINS_LOW();           /* drive all pins low once they are configured as outputs */
  LCD_ALL_CONFIGURE();          /* configure all pins as outputs */
	LCD_INT_CONFIGURE();          /* configure the periodic interrupt source */
}

/* contrast adjustment: normal phase and contrast adjustment phase calculation */
void LCD_contrast(unsigned int bus_frequency, int contrast_adj) {
  LCD_data.period = ((((unsigned long int)1000/LCD_INT_DIVISOR*bus_frequency/LCD_FRAME_FREQUENCY)-LCD_IDLE_CNT*(unsigned long int)contrast_adj)/(LCD_BP_CNT+LCD_IDLE_CNT))-1;
	LCD_data.contrast = LCD_data.period + contrast_adj;
}

/* shutdown of the LCD driver */
void LCD_stop(void) {
	LCD_INT_STOP();               /* stop the interrupt source */
	LCD_ALL_PINS_LOW();			      /* drive all pins low */
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?