diff options
Diffstat (limited to '3rd-party/LCDHD44780.c')
| -rw-r--r-- | 3rd-party/LCDHD44780.c | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/3rd-party/LCDHD44780.c b/3rd-party/LCDHD44780.c index 32c8ce2..e7837d0 100644 --- a/3rd-party/LCDHD44780.c +++ b/3rd-party/LCDHD44780.c @@ -29,7 +29,6 @@ void init_gpio(void) { // Set all pins to output bcm2835_gpio_fsel(LCD_RS, BCM2835_GPIO_FSEL_OUTP); - bcm2835_gpio_fsel(LCD_RW, BCM2835_GPIO_FSEL_OUTP); bcm2835_gpio_fsel(LCD_D4, BCM2835_GPIO_FSEL_OUTP); bcm2835_gpio_fsel(LCD_D5, BCM2835_GPIO_FSEL_OUTP); bcm2835_gpio_fsel(LCD_D6, BCM2835_GPIO_FSEL_OUTP); @@ -40,7 +39,6 @@ void init_gpio(void) // Set all pins to LOW bcm2835_gpio_clr(LCD_RS); - bcm2835_gpio_clr(LCD_RW); bcm2835_gpio_clr(LCD_D4); bcm2835_gpio_clr(LCD_D5); bcm2835_gpio_clr(LCD_D5); @@ -78,65 +76,6 @@ void pulse_e(void) (LCD_DATA) ? bcm2835_delayMicroseconds(E_DATA_PULSE) :bcm2835_delayMicroseconds(E_CMD_PULSE); } -uint8_t busy_wait(void) -{ - // FIXME: this function does not work! - // With RW grounded it shouldn't work. - // But as long as the display is driven - // by 5V the GPIO ports on a raspberry pi - // would get to much voltage - - uint8_t addr; - bool wait = true; - uint16_t counter = 0; - - set_data_pins_to_input(); - - bcm2835_gpio_clr(LCD_RS); - bcm2835_gpio_set(LCD_RW); - - while(wait && (counter < MAX_WAIT)) - { - addr = 0; - pulse_e(); - - // read high bits - if (bcm2835_gpio_lev(LCD_D4)) - addr = (addr | 0x10); - if (bcm2835_gpio_lev(LCD_D5)) - addr = (addr | 0x20); - if (bcm2835_gpio_lev(LCD_D6)) - addr = (addr | 0x40); - if (bcm2835_gpio_lev(LCD_D7)) - addr = (addr | 0x80); - - // Toogle ENABLE pin in us - pulse_e(); - - // read low bits - if (bcm2835_gpio_lev(LCD_D4)) - addr = (addr | 0x01); - if (bcm2835_gpio_lev(LCD_D5)) - addr = (addr | 0x02); - if (bcm2835_gpio_lev(LCD_D6)) - addr = (addr | 0x04); - if (bcm2835_gpio_lev(LCD_D7)) - addr = (addr | 0x08); - - wait = (addr & 0x80); - counter += 1; - - bcm2835_delay(1); - } - - bcm2835_gpio_clr(LCD_RW); - set_data_pins_to_output(); - - // return address but mask out highest bit (busy flag) - // 0x7F = 0 1 1 1 1 1 1 1 - return (addr & 0x7F); -} - void init_lcd(void) { init_gpio(); @@ -435,72 +374,6 @@ void write_string(char *str) } } -uint8_t read_from_lcd(uint8_t mode) -{ - // FIXME: this function currently does not work! - // Assuming, the display is driven by 5V - // then the GPIO Ports on a Raspberry Pi - // would get 5V what definitly is too much - uint8_t addr = 0x00; - - bcm2835_gpio_clr(LCD_E); - - bcm2835_gpio_clr(LCD_D4); - bcm2835_gpio_clr(LCD_D5); - bcm2835_gpio_clr(LCD_D6); - bcm2835_gpio_clr(LCD_D7); - - switch (mode) { - case LCD_CMD: - bcm2835_gpio_clr(LCD_RS); - // fprintf(stdout, "Set RS to cmd mode\n"); - break; - case LCD_DATA: - bcm2835_gpio_set(LCD_RS); - // fprintf(stdout, "Set RS to data mode for '%c'\n", byte); - break; - default: - // fprintf(stderr, "mode for setting GPIO pin unknown: %i\n", mode); - exit(EXIT_FAILURE); - } - - set_data_pins_to_input(); - bcm2835_delay(5); - - bcm2835_gpio_set(LCD_RW); - - pulse_e(); - - // read high bits - if (bcm2835_gpio_lev(LCD_D4)) - addr = (addr | 0x10); - if (bcm2835_gpio_lev(LCD_D5)) - addr = (addr | 0x20); - if (bcm2835_gpio_lev(LCD_D6)) - addr = (addr | 0x40); - if (bcm2835_gpio_lev(LCD_D7)) - addr = (addr | 0x80); - - // Toogle ENABLE pin in us - pulse_e(); - - // read low bits - if (bcm2835_gpio_lev(LCD_D4)) - addr = (addr | 0x01); - if (bcm2835_gpio_lev(LCD_D5)) - addr = (addr | 0x02); - if (bcm2835_gpio_lev(LCD_D6)) - addr = (addr | 0x04); - if (bcm2835_gpio_lev(LCD_D7)) - addr = (addr | 0x08); - - bcm2835_gpio_clr(LCD_RW); - - set_data_pins_to_output(); - - return addr; -} - void gpio_reset(void) { // bcm2835_gpio_fsel(LCD_RS, BCM2835_GPIO_PUD_OFF); @@ -518,7 +391,6 @@ void gpio_reset(void) // bcm2835_gpio_fsel(LCD_D7, BCM2835_GPIO_FSEL_INPT); bcm2835_gpio_clr(LCD_RS); - bcm2835_gpio_clr(LCD_RW); bcm2835_gpio_clr(LCD_E); bcm2835_gpio_clr(LCD_D4); bcm2835_gpio_clr(LCD_D5); |
