FreeCalypso > hg > freecalypso-hwlab
view lcdtest/busops.c @ 140:062141ce5755
fc-uicc-tool: select-[ui]sim: command dispatch bugfix
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 04 Feb 2021 05:01:30 +0000 |
parents | 4b7cac119fb5 |
children |
line wrap: on
line source
#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ftdi.h> #include "exitcodes.h" extern struct ftdi_context ftdi; do_ftdi_write(cmd, cmdlen) u_char *cmd; { if (ftdi_write_data(&ftdi, cmd, cmdlen) != cmdlen) { fprintf(stderr, "FTDI write error: %s\n", ftdi.error_str); exit(ERROR_FTDI); } } set_gpio_pins(rs, reset) { u_char cmd[3]; cmd[0] = 0x82; cmd[1] = (rs ? 1 : 0) | (reset ? 2 : 0); cmd[2] = 0x03; do_ftdi_write(cmd, 3); } reset_pulse() { set_gpio_pins(0, 0); usleep(50000); set_gpio_pins(0, 1); return(0); } write_ir(val16) unsigned val16; { u_char cmd[9]; /* set RS low */ cmd[0] = 0x82; cmd[1] = 0x02; cmd[2] = 0x03; /* write upper byte */ cmd[3] = 0x92; cmd[4] = 0; /* dummy addr */ cmd[5] = val16 >> 8; /* write lower byte */ cmd[6] = 0x92; cmd[7] = 0; /* dummy addr */ cmd[8] = val16; do_ftdi_write(cmd, 9); } write_dr(val16) unsigned val16; { u_char cmd[9]; /* set RS high */ cmd[0] = 0x82; cmd[1] = 0x03; cmd[2] = 0x03; /* write upper byte */ cmd[3] = 0x92; cmd[4] = 0; /* dummy addr */ cmd[5] = val16 >> 8; /* write lower byte */ cmd[6] = 0x92; cmd[7] = 0; /* dummy addr */ cmd[8] = val16; do_ftdi_write(cmd, 9); }