Beispiel #1
0
void output_byte(uint8_t rs, uint8_t data, uint8_t en)
{
    output_nibble(rs, HIGH_NIBBLE(data), en);
    output_nibble(rs, LOW_NIBBLE(data), en);

#ifdef HD44780_READBACK
    /* wait until command is executed by checking busy flag, with timeout */

    /* max execution time is for return home command,
     * which takes at most 1.52ms = 1520us */
    uint8_t busy, timeout = 200;
    do {
        busy = input_byte(0,en) & _BV(BUSY_FLAG);
        _delay_us(10);
        timeout--;
    } while (busy && timeout > 0);
    #ifdef DEBUG
    if (timeout == 0)
        debug_printf("lcd timeout!\n");
    #endif
#else
    /* just wait the maximal time a command can take... */
    _delay_ms(2);
#endif
}
void config_lcd_display() {

	clear_rs();
	clear_rw();
	clear_e();

	rs_output();
	rw_output();
	e_output();
	config_bus_output();
	
	_delay_ms(15);
	output_nibble(0x30);
	_delay_ms(6);
	output_nibble(0x30);
	_delay_ms(2);
	output_nibble(0x30);
	_delay_ms(2);
	output_nibble(0x20);

	busy_wait();
	
	write_command_lcd(0x28);
	write_command_lcd(0x08);
	write_command_lcd(0x01);
	write_command_lcd(0x06);
}	
static void write_register(uint8_t data, bool register_sel) {

	busy_wait();
	
	if(register_sel) set_rs();
	else		 clear_rs();

	clear_rw();
	config_bus_output();
	output_nibble(data);
	output_nibble(data << 4);
	config_bus_input();
}
Beispiel #4
0
void hd44780_init(void)
{
    /* verschiedene Hardware initialisieren */
    hd44780_hw_init();
    _delay_ms(40);

#if HD44780_TYPE == HD44780_KS0066U
    /* Hardware initialisiert -> Standardprozedur KS0066U Datenblatt 4bit Mode */
    output_nibble(0, 0x02);
#else
    /* Hardware initialisiert -> Standardprozedur HD44780 Datenblatt 4bit Mode */
    output_nibble(0, 0x03);

    _delay_ms(4);
    clock_write();

    _delay_ms(1);
    clock_write();

    _delay_ms(1);
    output_nibble(0, 0x02);		//4bit mode
    _delay_ms(1);
    /* init done */
#endif

    /* configure for 4 bit, 2 lines, 5x9 font (datasheet, page 24) */
    output_byte(0, CMD_FUNCTIONSET(0, 1, 0));

    /* turn on display, cursor and blinking */
    hd44780_config(0,0);

    /* clear display */
    hd44780_clear();

    /* set shift and increment */
    output_byte(0, CMD_ENTRY_MODE(1, 0));

    /* set ddram address */
    output_byte(0, CMD_SETDRAMADR(0));

    /* open file descriptor */
    lcd = fdevopen(hd44780_put, NULL);

    /* set current virtual postion */
    current_pos = 0;
}
Beispiel #5
0
//push a nibble of data through the the LCD's DB4~7 pins, clocking with the Enable pin.
//We don't care what RS and RW are, here.
void pushNibble(uint8_t value) {
    output_nibble(LCD_INTERFACE_PORT, value);
    pulseEnablePin();
}
Beispiel #6
0
void hd44780_init(void)
{
    /* verschiedene Hardware initialisieren */
    hd44780_hw_init();
    _delay_ms(40);

#if CONF_HD44780_TYPE == HD44780_KS0066U
    /* Hardware initialisiert -> Standardprozedur KS0066U Datenblatt 4bit Mode */
    output_nibble(0, 0x02, 1);
#else
    /* Hardware initialisiert -> Standardprozedur HD44780 Datenblatt 4bit Mode */
    output_nibble(0, 0x03,1);

    _delay_ms(4);
#ifdef HD44780_2WIRE
    output_nibble(0, 0x03,1);
#else
    clock_write(1);
#endif /*HD44780_2WIRE*/

    _delay_ms(1);
#ifdef HD44780_2WIRE
	output_nibble(0, 0x03,1);
#else
    clock_write(1);
#endif /*HD44780_2WIRE*/

    _delay_ms(1);
    output_nibble(0, 0x02,1);		//4bit mode
    _delay_ms(1);
    /* init done */
#endif /*CONF_HD44780_TYPE*/

    /* configure for 4 bit, 2 lines, 5x8 font (datasheet, page 24) */
    output_byte(0, CMD_FUNCTIONSET(0, 1, 0), 1);

    /* turn on display, cursor and blinking */
    hd44780_config(0,0,1);

    /* clear display */
    hd44780_clear(1);
    /* set shift and increment */
    output_byte(0, CMD_ENTRY_MODE(1, 0),1);

    /* set ddram address */
    output_byte(0, CMD_SETDRAMADR(0),1);

/*Configure Controller 2 */
#ifdef HD44780_MULTIENSUPPORT
    /* verschiedene Hardware initialisieren */
    hd44780_hw_init();
    _delay_ms(40);

#if CONF_HD44780_TYPE == HD44780_KS0066U
    /* Hardware initialisiert -> Standardprozedur KS0066U Datenblatt 4bit Mode */
    output_nibble(0, 0x02, 2);
#else
    /* Hardware initialisiert -> Standardprozedur HD44780 Datenblatt 4bit Mode */
    output_nibble(0, 0x03,2);

    _delay_ms(4);
    clock_write(2);

    _delay_ms(1);
    clock_write(2);

    _delay_ms(1);
    output_nibble(0, 0x02,2);		//4bit mode
    _delay_ms(1);
    /* init done */
#endif

    /* configure for 4 bit, 2 lines, 5x9 font (datasheet, page 24) */
    output_byte(0, CMD_FUNCTIONSET(0, 1, 0), 2);

    /* turn on display, cursor and blinking */
    hd44780_config(0,0,2);

    /* clear display */
    hd44780_clear(2);
    /* set shift and increment */
    output_byte(0, CMD_ENTRY_MODE(1, 0),2);

    /* set ddram address */
    output_byte(0, CMD_SETDRAMADR(0),2);
#endif

    /* set current virtual postion */
    current_pos = 0;


}