ULINK driver: Remove typedefs in OpenULINK firmware: Use typedefs from stdint.h ...
[fw/openocd] / src / jtag / drivers / OpenULINK / src / main.c
1 /***************************************************************************
2  *   Copyright (C) 2011 by Martin Schmoelzer                               *
3  *   <martin.schmoelzer@student.tuwien.ac.at>                              *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #include "main.h"
22
23 #include "io.h"
24 #include "usb.h"
25 #include "protocol.h"
26
27 extern void sudav_isr(void)    __interrupt SUDAV_ISR;
28 extern void sof_isr(void)      __interrupt;
29 extern void sutok_isr(void)    __interrupt;
30 extern void suspend_isr(void)  __interrupt;
31 extern void usbreset_isr(void) __interrupt;
32 extern void ibn_isr(void)      __interrupt;
33 extern void ep0in_isr(void)    __interrupt;
34 extern void ep0out_isr(void)   __interrupt;
35 extern void ep1in_isr(void)    __interrupt;
36 extern void ep1out_isr(void)   __interrupt;
37 extern void ep2in_isr(void)    __interrupt;
38 extern void ep2out_isr(void)   __interrupt;
39 extern void ep3in_isr(void)    __interrupt;
40 extern void ep3out_isr(void)   __interrupt;
41 extern void ep4in_isr(void)    __interrupt;
42 extern void ep4out_isr(void)   __interrupt;
43 extern void ep5in_isr(void)    __interrupt;
44 extern void ep5out_isr(void)   __interrupt;
45 extern void ep6in_isr(void)    __interrupt;
46 extern void ep6out_isr(void)   __interrupt;
47 extern void ep7in_isr(void)    __interrupt;
48 extern void ep7out_isr(void)   __interrupt;
49
50 void io_init(void)
51 {
52   /* PORTxCFG register bits select alternate functions (1 == alternate function,
53    *                                                    0 == standard I/O)
54    * OEx register bits turn on/off output buffer (1 == output, 0 == input)
55    * OUTx register bits determine pin state of output
56    * PINx register bits reflect pin state (high == 1, low == 0) */
57
58   /* PORT A */
59   PORTACFG = PIN_OE;
60   OEA = PIN_U_OE | PIN_OE | PIN_RUN_LED | PIN_COM_LED;
61   OUTA = PIN_RUN_LED | PIN_COM_LED;
62
63   /* PORT B */
64   PORTBCFG = 0x00;
65   OEB = PIN_TDI | PIN_TMS | PIN_TCK | PIN_TRST | PIN_BRKIN | PIN_RESET
66       | PIN_OCDSE;
67
68   /* TRST and RESET signals are low-active but inverted by hardware, so we clear
69    * these signals here! */
70   OUTB = 0x00;
71
72   /* PORT C */
73   PORTCCFG = PIN_WR;
74   OEC = PIN_TXD0 | PIN_WR;
75   OUTC = 0x00;
76 }
77
78 int main(void)
79 {
80   io_init();
81   usb_init();
82
83   /* Enable Interrupts */
84   EA = 1;
85
86   /* Begin executing command(s). This function never returns. */
87   command_loop();
88
89   /* Never reached, but SDCC complains about missing return statement */
90   return 0;
91 }