Annotation of funnyos/dev/lcd/44780_dev.c, Revision 1.1
1.1 ! nbrk 1: /*
! 2: * $Id$
! 3: */
! 4: #include <sys/types.h>
! 5: #include <sys/device.h>
! 6: #include <sys/gpio.h>
! 7: #include <dev/lcd/44780var.h>
! 8: #include <dev/lcd/44780reg.h>
! 9:
! 10:
! 11: /*
! 12: * Driver for Hitachi 44780-based LCD.
! 13: */
! 14:
! 15: int h44780_attach(struct device *, uint32_t, uint8_t);
! 16: void h44780_write(struct h44780_dd *ddp, uint16_t data);
! 17: void h44780_strobe(struct h44780_dd *ddp);
! 18: void h44780_init(struct h44780_dd *ddp);
! 19:
! 20: struct driver h44780_dr = {
! 21: sizeof(struct h44780_dd),
! 22: h44780_attach,
! 23: NULL,
! 24: NULL
! 25: };
! 26:
! 27:
! 28: int
! 29: h44780_attach(struct device *self, uint32_t loc, uint8_t flags)
! 30: {
! 31: struct h44780_dd *ddp = self->dv_devdata;
! 32: ddp->h_bop = self->dv_parent->dv_aux;
! 33:
! 34: printf("Hitachi 44780 LCD controller\n");
! 35:
! 36: h44780_init(ddp);
! 37:
! 38: return(0);
! 39: }
! 40:
! 41:
! 42: void
! 43: h44780_write(struct h44780_dd *ddp, uint16_t data)
! 44: {
! 45: printf("h44780_write: write 0x%x\n", data);
! 46: ddp->h_bop->write(ddp->h_bop->selfdd, data);
! 47:
! 48: }
! 49:
! 50:
! 51: void
! 52: h44780_strobe(struct h44780_dd *ddp)
! 53: {
! 54: ddp->h_bop->strobe(ddp->h_bop->selfdd);
! 55:
! 56: }
! 57:
! 58:
! 59: void
! 60: h44780_init(struct h44780_dd *ddp)
! 61: {
! 62: h44780_write(ddp, H44780_CMD_IFLEN | H44780_DL | H44780_N | H44780_F);
! 63: // h44780_strobe(ddp);
! 64: H44780_DELAY;
! 65: h44780_write(ddp, H44780_CMD_IFLEN | H44780_DL | H44780_N | H44780_F);
! 66: // h44780_strobe(ddp);
! 67: H44780_DELAY;
! 68: h44780_write(ddp, H44780_CMD_IFLEN | H44780_DL | H44780_N | H44780_F);
! 69: // h44780_strobe(ddp);
! 70: H44780_DELAY;
! 71: h44780_write(ddp, H44780_CMD_ENABLE | H44780_B | H44780_C | H44780_D);
! 72: // h44780_strobe(ddp);
! 73: H44780_DELAY;
! 74: h44780_write(ddp, H44780_CMD_CLS);
! 75: // h44780_strobe(ddp);
! 76: H44780_DELAY;
! 77: h44780_write(ddp, H44780_CMD_SETDIR | H44780_ID | H44780_S);
! 78: // h44780_strobe(ddp);
! 79: h44780_write(ddp, 0);
! 80: // h44780_strobe(ddp);
! 81: H44780_DELAY;
! 82: h44780_write(ddp, 0x38);
! 83: // h44780_strobe(ddp);
! 84: H44780_DELAY;
! 85: h44780_write(ddp, 0);
! 86: // h44780_strobe(ddp);
! 87: H44780_DELAY;
! 88: h44780_write(ddp, 0x0f);
! 89: // h44780_strobe(ddp);
! 90: }
! 91:
! 92:
CVSweb