FreeCalypso > hg > freecalypso-hwlab
view lunalcd/common.c @ 65:cdf2c99e5025
lunalcd project started
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 19 Mar 2020 01:31:05 +0000 |
parents | |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> static enum { MODE_L8, MODE_U8, MODE_16, MODE_USB } mode; set_output_mode(kw) char *kw; { if (!strcmp(kw, "l8")) mode = MODE_L8; else if (!strcmp(kw, "u8")) mode = MODE_U8; else if (!strcmp(kw, "16")) mode = MODE_16; else if (!strcmp(kw, "usb")) mode = MODE_USB; else { fprintf(stderr, "error: mode \"%s\" not understood\n", kw); exit(1); } } write_ir(val16) unsigned val16; { if (mode != MODE_USB) printf("w16 fffe4802 200\n"); switch (mode) { case MODE_L8: printf("w16 02000000 %02x\n", val16 >> 8); printf("w16 02000000 %02x\n", val16 & 0xFF); break; case MODE_U8: printf("w16 02000000 %02x00\n", val16 >> 8); printf("w16 02000000 %02x00\n", val16 & 0xFF); break; case MODE_16: printf("w16 02000000 %04x\n", val16); break; case MODE_USB: printf("wi %04x\n", val16); } } write_dr(val16) unsigned val16; { if (mode != MODE_USB) printf("w16 fffe4802 600\n"); switch (mode) { case MODE_L8: printf("w16 02000002 %02x\n", val16 >> 8); printf("w16 02000002 %02x\n", val16 & 0xFF); break; case MODE_U8: printf("w16 02000002 %02x00\n", val16 >> 8); printf("w16 02000002 %02x00\n", val16 & 0xFF); break; case MODE_16: printf("w16 02000002 %04x\n", val16); break; case MODE_USB: printf("wd %04x\n", val16); } } bulk_wd_prep() { if (mode != MODE_USB) printf("w16 fffe4802 600\n"); } bulk_wd(val16) unsigned val16; { switch (mode) { case MODE_L8: printf("w16 02000002 %02x\n", val16 >> 8); printf("w16 02000002 %02x\n", val16 & 0xFF); break; case MODE_U8: printf("w16 02000002 %02x00\n", val16 >> 8); printf("w16 02000002 %02x00\n", val16 & 0xFF); break; case MODE_16: printf("w16 02000002 %04x\n", val16); break; case MODE_USB: printf("wd %04x\n", val16); } }