c8d4e18b094618ea7bf463a290344a1e4d4c4b1a
[fw/openocd] / src / jtag / drivers / OpenULINK / src / main.c
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2011 by Martin Schmoelzer                               *
5  *   <martin.schmoelzer@student.tuwien.ac.at>                              *
6  ***************************************************************************/
7
8 #include "main.h"
9
10 #include "io.h"
11 #include "usb.h"
12 #include "protocol.h"
13
14 extern void sudav_isr(void)    __interrupt SUDAV_ISR;
15 extern void sof_isr(void)      __interrupt;
16 extern void sutok_isr(void)    __interrupt;
17 extern void suspend_isr(void)  __interrupt;
18 extern void usbreset_isr(void) __interrupt;
19 extern void ibn_isr(void)      __interrupt;
20 extern void ep0in_isr(void)    __interrupt;
21 extern void ep0out_isr(void)   __interrupt;
22 extern void ep1in_isr(void)    __interrupt;
23 extern void ep1out_isr(void)   __interrupt;
24 extern void ep2in_isr(void)    __interrupt;
25 extern void ep2out_isr(void)   __interrupt;
26 extern void ep3in_isr(void)    __interrupt;
27 extern void ep3out_isr(void)   __interrupt;
28 extern void ep4in_isr(void)    __interrupt;
29 extern void ep4out_isr(void)   __interrupt;
30 extern void ep5in_isr(void)    __interrupt;
31 extern void ep5out_isr(void)   __interrupt;
32 extern void ep6in_isr(void)    __interrupt;
33 extern void ep6out_isr(void)   __interrupt;
34 extern void ep7in_isr(void)    __interrupt;
35 extern void ep7out_isr(void)   __interrupt;
36
37 void io_init(void)
38 {
39         /* PORTxCFG register bits select alternate functions (1 == alternate function,
40          *                                                    0 == standard I/O)
41          * OEx register bits turn on/off output buffer (1 == output, 0 == input)
42          * OUTx register bits determine pin state of output
43          * PINx register bits reflect pin state (high == 1, low == 0) */
44
45         /* PORT A */
46         PORTACFG = PIN_OE;
47         OEA = PIN_U_OE | PIN_OE | PIN_RUN_LED | PIN_COM_LED;
48         OUTA = PIN_RUN_LED | PIN_COM_LED;
49
50         /* PORT B */
51         PORTBCFG = 0x00;
52         OEB = PIN_TDI | PIN_TMS | PIN_TCK | PIN_TRST | PIN_BRKIN | PIN_RESET
53                 | PIN_OCDSE;
54
55         /* TRST and RESET signals are low-active but inverted by hardware, so we clear
56          * these signals here! */
57         OUTB = 0x00;
58
59         /* PORT C */
60         PORTCCFG = PIN_WR;
61         OEC = PIN_TXD0 | PIN_WR;
62         OUTC = 0x00;
63 }
64
65 int main(void)
66 {
67         io_init();
68         usb_init();
69
70         /* Enable Interrupts */
71         EA = 1;
72
73         /* Begin executing command(s). This function never returns. */
74         command_loop();
75
76         /* Never reached, but SDCC complains about missing return statement */
77         return 0;
78 }