FreeCalypso > hg > freecalypso-tools
view target-utils/simagent/simup.c @ 773:6d1b22d4926f
simagent: inverse coding convention table implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 12 Mar 2021 21:20:56 +0000 |
parents | 81f9e4b4f55c |
children | 130c46b83760 |
line wrap: on
line source
#include <sys/types.h> #include <strings.h> #include "types.h" #include "abbdefs.h" #include "simregs.h" #define WAIT_ONE_TDMA 60000 extern u16 abb_reg_read(); extern void abb_reg_write(); int sim_if_state; u16 conf1_reg; void cmd_sim_up(argbulk) char *argbulk; { char *argv[2]; u16 abb_sim_reg; unsigned count; if (sim_if_state) { printf("ERROR: SIM interface is already up\n"); return; } if (parse_args(argbulk, 1, 1, argv, 0) < 0) return; if (!strcmp(argv[0], "1.8")) abb_sim_reg = 2; else if (!strcmp(argv[0], "3")) abb_sim_reg = 3; else { printf("ERROR: \"1.8\" or \"3\" argument expected\n"); return; } abb_reg_write(VRPCSIM, abb_sim_reg); sim_if_state = 1; /* wait for regulator like TI's SIM_StartVolt() */ for (count = 0; ; ) { abb_sim_reg = abb_reg_read(VRPCSIM); if (abb_sim_reg & 4) break; if (++count >= 5) { printf("ERROR: VRSIM is not in proper regulation\n"); return; } wait_ARM_cycles(WAIT_ONE_TDMA); } /* TI's SIM_ManualStart() code follows */ SIMREGS.conf1 = conf1_reg = 0x8004; SIMREGS.cmd = SIM_CMD_CLKEN; SIMREGS.cmd = SIM_CMD_CLKEN | SIM_CMD_STOP; wait_ARM_cycles(WAIT_ONE_TDMA * 4); SIMREGS.cmd = SIM_CMD_CLKEN | SIM_CMD_SWRST; wait_ARM_cycles(WAIT_ONE_TDMA); SIMREGS.conf2 = 0x0940; //enter in manual mode to start the ATR sequence SIMREGS.conf1 = conf1_reg |= SIM_CONF1_BYPASS; wait_ARM_cycles(WAIT_ONE_TDMA); SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SVCCLEV; wait_ARM_cycles(WAIT_ONE_TDMA); abb_sim_reg |= 8; abb_reg_write(VRPCSIM, abb_sim_reg); wait_ARM_cycles(WAIT_ONE_TDMA); SIMREGS.conf1 = conf1_reg &= ~SIM_CONF1_SIOLOW; wait_ARM_cycles(WAIT_ONE_TDMA); SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SCLKEN; SIMREGS.conf1 = conf1_reg &= ~SIM_CONF1_TXRX; //set to receive mode wait_ARM_cycles(WAIT_ONE_TDMA * 3); /* flush any garbage in the Rx FIFO */ for (count = 0; ; ) { if (SIMREGS.stat & SIM_STAT_FEMPTY) break; (void) SIMREGS.drx; if (++count >= 32) { printf("ERROR: Rx FIFO flush does not end\n"); return; } } #if 0 /* lift the card out of reset! */ SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SRSTLEV; #endif }