/************************************************************************************************** * @fn HalLcd_HW_Init * * @brief Initilize HW LCD Driver. * * @param None * * @return None **************************************************************************************************/ void HalLcd_HW_Init(void) { /* Initialize LCD IO lines */ halLcd_ConfigIO(); /* Initialize SPI */ halLcd_ConfigSPI(); /* Perform reset */ LCD_ACTIVATE_RESET(); HalLcd_HW_WaitUs(15000); // 15 ms LCD_RELEASE_RESET(); HalLcd_HW_WaitUs(15); // 15 us /* Perform the initialization sequence */ FUNCTION_SET(CGRAM | COM_FORWARD | THREE_LINE); /* Set contrast */ HalLcd_HW_SetContrast(15); /* Set power */ SET_POWER_SAVE_MODE(OSC_OFF | POWER_SAVE_ON); SET_POWER_CTRL(VOLTAGE_DIVIDER_ON | CONVERTER_AND_REG_ON); SET_BIAS_CTRL(BIAS_1_5); HalLcd_HW_WaitUs(21000);// 21 ms /* Clear the display */ HalLcd_HW_Clear(); HalLcd_HW_ClearAllSpecChars(); SET_DISPLAY_CTRL(DISPLAY_CTRL_ON | DISPLAY_CTRL_BLINK_OFF | DISPLAY_CTRL_CURSOR_OFF); }
/************************************************************************************************** * @fn HalLcd_HW_Init * * @brief Initilize HW LCD Driver. * * @param None * * @return None **************************************************************************************************/ void HalLcd_HW_Init(void) { /* Initialize LCD IO lines */ halLcd_ConfigIO(); /* Initialize SPI */ halLcd_ConfigSPI(); HalLcd_HW_Control(0xaf); //开显示 HalLcd_HW_Control(0x40); //显示起始行为0 HalLcd_HW_Control(0xa0); //RAM列地址与列驱动同顺序 HalLcd_HW_Control(0xa6); //正向显示 HalLcd_HW_Control(0xa4); //显示全亮功能关闭 HalLcd_HW_Control(0xa2); //LCD偏压比1/9 HalLcd_HW_Control(0xc8); //行驱动方向为反向 HalLcd_HW_Control(0x2f); //启用内部LCD驱动电源 HalLcd_HW_Control(0xf8); //升压电路设置指令代码 HalLcd_HW_Control(0x00); //倍压设置为4X HalLcd_HW_SetContrast(0x68);//set contrast 对比度 /* Clear the display */ HalLcd_HW_Clear(); }
void HalLcd_HW_Init(void) { /* Initialize SPI */ UCB0CTL1 |= UCSWRST; UCB0CTL0 |= UCMST | UCSYNC | UCCKPH | UCMSB; /* MSB, Master mode, Sync mode, Data capture on the first UCLK edge */ UCB0CTL1 |= UCSSEL1; /* SMCLK */ UCB0BR0 = 4; UCB0BR1 = 0; LCD_SPI_INIT_PORTS(); LCD_SPI_END(); UCB0CTL1 &= ~UCSWRST; /* Init I/O */ LCD_CTRL_INIT_PORTS(); /* Perform reset */ LCD_ACTIVATE_RESET(); HalLcd_HW_Wait(15); // 15 ms LCD_RELEASE_RESET(); HalLcd_HW_Wait(15); // 15 us /* Perform the initialization sequence */ FUNCTION_SET(CGRAM | COM_FORWARD | THREE_LINE); /* Set contrast */ HalLcd_HW_SetContrast(15); /* Set power */ SET_POWER_SAVE_MODE(OSC_OFF | POWER_SAVE_ON); SET_POWER_CTRL(VOLTAGE_DIVIDER_ON | CONVERTER_AND_REG_ON); SET_BIAS_CTRL(BIAS_1_5); HalLcd_HW_Wait(20);// 21 ms /* Clear the display */ HalLcd_HW_Clear(); HalLcd_HW_ClearAllSpecChars(); SET_DISPLAY_CTRL(DISPLAY_CTRL_ON | DISPLAY_CTRL_BLINK_OFF | DISPLAY_CTRL_CURSOR_OFF); }