void hd44780_wr_hi_nibble(uint8_t data) { if (data & 0x10) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT4); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT4); } if (data & 0x20) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT5); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT5); } if (data & 0x40) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT6); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT6); } if (data & 0x80) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT7); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT7); } /* set the EN signal */hd44780_EN_On(); /* wait */hd44780_EN_high_delay(); /* reset the EN signal */ hd44780_EN_Off(); }
void hd44780_wr_lo_nibble( unsigned char data ) { if ( data & 0x01 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT4 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT4 ); } if ( data & 0x02 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT5 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT5 ); } if ( data & 0x04 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT6 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT6 ); } if ( data & 0x08 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT7 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT7 ); } /* set the EN signal */ hd44780_EN_On(); /* wait */ hd44780_EN_high_delay(); /* reset the EN signal */ hd44780_EN_Off(); }
void hd44780_init(void) { while (buttons_active) {} hd44780_active=1; controlLEDs_enable(0); /* clear control bits */ hd44780_EN_Off(); hd44780_RS_Off(); // hd44780_RW_Off(); /* sets the configured values - can be set again only after reset */ hd44780_function( HD44780_CONF_BUS, HD44780_CONF_LINES, HD44780_CONF_FONT, HD44780_FONT_TABLE); /* turn the display off with no cursor or blinking */ hd44780_display( HD44780_DISP_OFF, HD44780_DISP_CURS_OFF, HD44780_DISP_BLINK_OFF); /* clear the display */ hd44780_clear(); /* addr increment, shift cursor */ hd44780_entry( HD44780_ENTRY_SHIFT_CURS, HD44780_ENTRY_ADDR_INC); hd44780_load_symbol(0x0, symbol_menu_pointer); hd44780_load_symbol(0x8, symbol_check); /*cursor to zero position*/ hd44780_ddram_addr(0); hd44780_active=0; controlLEDs_enable(1); }
void hd44780_wr_lo_nibble( unsigned char data ) { if ( data & 0x01 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT4,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT4,GPIO_PIN_RESET); } if ( data & 0x02 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT5,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT5,GPIO_PIN_RESET); } if ( data & 0x04 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT6,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT6,GPIO_PIN_RESET); } if ( data & 0x08 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT7,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT7,GPIO_PIN_RESET); } /* set the EN signal */ hd44780_EN_On(); /* wait */ hd44780_EN_high_delay(); /* reset the EN signal */ hd44780_EN_Off(); }
void hd44780_wr_hi_nibble( unsigned char data ) { if ( data & 0x10 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT4,GPIO_PIN_SET); //GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT4 ); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT4,GPIO_PIN_RESET); } if ( data & 0x20 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT5,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT5,GPIO_PIN_RESET); } if ( data & 0x40 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT6,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT6,GPIO_PIN_RESET); } if ( data & 0x80 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT7,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT7,GPIO_PIN_RESET); } /* set the EN signal */ hd44780_EN_On(); /* wait */ hd44780_EN_high_delay(); /* reset the EN signal */ hd44780_EN_Off(); }
/********************************************************************************************* Function name : HD44780_Init Author : Grant Phillips Date Modified : 16/10/2013 Compiler : Keil ARM-MDK (uVision V4.70.0.0) Description : Initializes the HD44780 lcd module Special Note(s) : NONE Parameters : NONE Return value : NONE *********************************************************************************************/ void HD44780_Init(void) { //GPIO Initialization GPIO_InitTypeDef GPIO_InitStruct; /* Configure the peripheral clocks for the HD44780 data and control lines */ //RCC_AHBPeriphClockCmd(HD44780_RCC_AHBPeriph, ENABLE); __GPIOC_CLK_ENABLE(); /* Configure the HD44780 Data lines (DB7 - DB4) as outputs*/ GPIO_InitStruct.Pin = HD44780_DATABIT7 | HD44780_DATABIT6 | HD44780_DATABIT5 | HD44780_DATABIT4; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = 0; HAL_GPIO_Init(HD44780_DATAPORT, &GPIO_InitStruct); /* Configure the HD44780 Control lines (RS, RW, EN) as outputs*/ GPIO_InitStruct.Pin = HD44780_RS_BIT | HD44780_RW_BIT | HD44780_EN_BIT; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = 0; HAL_GPIO_Init(HD44780_DATAPORT, &GPIO_InitStruct); /* clear control bits */ hd44780_EN_Off(); hd44780_RS_Off(); hd44780_RW_Off(); /* wait initial delay for LCD to settle */ /* reset procedure - 3 function calls resets the device */ hd44780_init_delay(); hd44780_wr_hi_nibble( HD44780_CMD_RESET ); hd44780_init_delay2(); hd44780_wr_hi_nibble( HD44780_CMD_RESET ); hd44780_init_delay3(); hd44780_wr_hi_nibble( HD44780_CMD_RESET ); #if HD44780_CONF_BUS == HD44780_FUNC_BUS_4BIT /* 4bit interface */ hd44780_wr_hi_nibble( HD44780_CMD_FUNCTION ); #endif /* HD44780_CONF_BUS == HD44780_FUNC_BUS_4BIT */ /* sets the configured values - can be set again only after reset */ hd44780_function( HD44780_CONF_BUS, HD44780_CONF_LINES, HD44780_CONF_FONT ); /* turn the display on with no cursor or blinking */ hd44780_display( HD44780_DISP_ON, HD44780_DISP_CURS_OFF, HD44780_DISP_BLINK_OFF ); /* clear the display */ hd44780_clear(); /* addr increment, shift cursor */ hd44780_entry( HD44780_ENTRY_ADDR_INC, HD44780_ENTRY_SHIFT_CURS ); }
/* 8bit bus version */ void hd44780_write( unsigned char data ) { /* set the data bits */ if ( data & 0x01 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT0 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT0 ); } if ( data & 0x02 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT1 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT1 ); } if ( data & 0x04 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT2 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT2 ); } if ( data & 0x08 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT3 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT3 ); } if ( data & 0x10 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT4 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT4 ); } if ( data & 0x20 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT5 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT5 ); } if ( data & 0x40 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT6 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT6 ); } if ( data & 0x80 ) { GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT7 ); } else { GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT7 ); } /* tell the lcd that we have a command to read in */ hd44780_EN_On(); /* wait long enough so that the lcd can see the command */ hd44780_EN_high_delay(); /* reset the ce line */ hd44780_EN_Off(); hd44780_init_end_delay(); }
/* 8bit bus version */ void hd44780_write( unsigned char data ) { /* set the data bits */ if ( data & 0x01 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT0,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT0,GPIO_PIN_RESET); } if ( data & 0x02 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT1,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT1,GPIO_PIN_RESET); } if ( data & 0x04 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT2,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT2,GPIO_PIN_RESET); } if ( data & 0x08 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT3,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT3,GPIO_PIN_RESET); } if ( data & 0x10 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT4,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT4,GPIO_PIN_RESET); } if ( data & 0x20 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT5,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT5,GPIO_PIN_RESET); } if ( data & 0x40 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT6,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT6,GPIO_PIN_RESET); } if ( data & 0x80 ) { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT7,GPIO_PIN_SET); } else { HAL_GPIO_WritePin(HD44780_DATAPORT, HD44780_DATABIT7,GPIO_PIN_RESET); } /* tell the lcd that we have a command to read in */ hd44780_EN_On(); /* wait long enough so that the lcd can see the command */ hd44780_EN_high_delay(); /* reset the ce line */ hd44780_EN_Off(); hd44780_init_end_delay(); }
void hd44780_write(uint8_t data) { while (buttons_active){ } hd44780_active=1; controlLEDs_enable(0); /* set the data bits */ uint16_t dataportValue = HD44780_DATAPORT->IDR; HD44780_DATAPORT->ODR = (dataportValue & 0xFF00) + data; //In the current project the display uses PE0-PE7 GPIO, so it is possible to switch them by one command /* if (data & 0x01) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT0); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT0); } if (data & 0x02) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT1); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT1); } if (data & 0x04) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT2); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT2); } if (data & 0x08) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT3); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT3); } if (data & 0x10) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT4); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT4); } if (data & 0x20) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT5); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT5); } if (data & 0x40) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT6); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT6); } if (data & 0x80) { GPIO_SetBits(HD44780_DATAPORT, HD44780_DATABIT7); } else { GPIO_ResetBits(HD44780_DATAPORT, HD44780_DATABIT7); } */ /* tell the lcd that we have a command to read in */hd44780_EN_On(); /* wait long enough so that the lcd can see the command */hd44780_EN_high_delay(); /* reset the ce line */hd44780_EN_Off(); hd44780_init_end_delay(); hd44780_active=0; controlLEDs_enable(1); }