comparison target-utils/simtest/setup.c @ 457:d96ea6ae6aa5

simtest: setup implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Feb 2019 17:15:57 +0000
parents
children 06ad5e30e8d0
comparison
equal deleted inserted replaced
456:3884d823b36e 457:d96ea6ae6aa5
1 #include "types.h"
2 #include "abbdefs.h"
3 #include "simregs.h"
4
5 #define WAIT_ONE_TDMA 48000
6
7 extern u16 abb_reg_read();
8 extern void abb_reg_write();
9
10 u16 conf1_reg;
11
12 void
13 cmd_setup(argbulk)
14 char *argbulk;
15 {
16 u16 abb_sim_reg;
17
18 abb_sim_reg = abb_reg_read(VRPCSIM);
19 if (!(abb_sim_reg & 2)) {
20 printf("ERROR: VRSIM is not enabled\n");
21 return;
22 }
23 if (!(abb_sim_reg & 4)) {
24 printf("ERROR: VRSIM is not in proper regulation\n");
25 return;
26 }
27
28 /* TI's SIM_ManualStart() code follows */
29 SIMREGS.conf1 = conf1_reg = 0x8004;
30 SIMREGS.cmd = SIM_CMD_CLKEN;
31
32 SIMREGS.cmd = SIM_CMD_CLKEN | SIM_CMD_STOP;
33 wait_ARM_cycles(WAIT_ONE_TDMA * 4);
34
35 SIMREGS.cmd = SIM_CMD_CLKEN | SIM_CMD_SWRST;
36 wait_ARM_cycles(WAIT_ONE_TDMA);
37
38 SIMREGS.conf2 = 0x0940;
39
40 //enter in manual mode to start the ATR sequence
41 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_BYPASS;
42 wait_ARM_cycles(WAIT_ONE_TDMA);
43
44 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SVCCLEV;
45 wait_ARM_cycles(WAIT_ONE_TDMA);
46
47 abb_sim_reg |= 8;
48 abb_reg_write(VRPCSIM, abb_sim_reg);
49 wait_ARM_cycles(WAIT_ONE_TDMA);
50
51 SIMREGS.conf1 = conf1_reg &= ~SIM_CONF1_SIOLOW;
52 wait_ARM_cycles(WAIT_ONE_TDMA);
53
54 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SCLKEN;
55 SIMREGS.conf1 = conf1_reg &= ~SIM_CONF1_TXRX; //set to receive mode
56 }