FreeCalypso > hg > freecalypso-hwlab
view lunalcd/common.c @ 133:f3bdefbeae38
fc-uicc-tool: readbin and readrec commands implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 04 Feb 2021 01:45:16 +0000 |
parents | cdf2c99e5025 |
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); } }