13a25720303fed831465f724a254d275dd9f6307
[goodfet] / firmware / platforms / tilaunchpad.h
1 /*! \file tilaunchpad.h
2   \author Peter Lorenzen
3   \brief Port descriptions for the TI-launchpad platform.
4 // Port setup on TI Launchpad
5 // P1.3 RTS input
6 // P1.4 DTR input
7 // P1.5 DSR output
8 // P1.6 CTS output
9 // P2.4 P4.7 P5.1 P5.2 SBWDIO 47k pull-up
10 // P3.1 SDA
11 // P3.3 SCL
12 // P3.4 TXD0    to TUSB3410
13 // P3.5 RXD0    to TUSB3410
14 // P3.6 TXD1    BTXD
15 // P3.7 RXD1    BRXD
16 // P4.6 Reset to TUSB3410
17 // P4.7 P2.4 P5.1 P5.2 SBWDIO 47k pull-up
18 // P5.1 P4.7 P2.4 P5.2 SBWDIO 47k pull-up
19 // P5.2 P4.7 P2.4 P5.1 SBWDIO 47k pull-up       labelled RST
20 // P5.3         SBWTCK 47k pull-down            labelled TEST
21 // P5.5         SMCLK 12 Mhz send to TUSG3410
22
23 The Launchpad has only four pins easily available
24 but this is fine for f.ex chipcon
25 P5.3 TCK        SCK
26 P5.2 IO         MISO MOSI
27 P3.7 rxd1       RST
28 P3.6 txd1       used for led in chipcon application
29
30 P2.4 could probably be made available without too much destruction
31 a normal goodfet has
32 Port SPI  JTAG
33 ----+----+------
34 P5.0 SS   TMS
35 P5.1 MOSI TDI   TCLK
36 P5.2 MISO TDO
37 P5.2 SCK  TCK
38
39 //These are not on P5
40 P2.6 RST
41 P4.0 TST
42
43 P1.0 LED
44
45 */
46 #define TI_LAUNCHPAD 1
47
48 #include <signal.h>
49 #include <io.h>
50 #include <iomacros.h>
51
52 // Here is how I try to remember rs232 signaling
53 // think of halfduplex rs485, and this makes total sense.
54 #define DTR BIT4                // -> Minicom has opened the device in handshake on mode
55 #define DSR BIT5                // <- TI Launchpad signals back that it is turned ON
56 #define RTS BIT3                // -> Minicom request control of rs485 bus
57 #define CTS BIT6                // <- we reply yes we got the rs485 bus - just carry on on
58
59 #define SBWDIO  BIT2
60 #define SBWTCK  BIT3
61
62 #define SPIOUT P5OUT
63 #define SPIDIR P5DIR
64 #define SPIIN  P5IN
65 #define SPIREN P5REN
66
67 // network byte order converters
68 #define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \
69                                  (((uint16_t)(x) & 0x00FF) << 8))
70 #define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \
71                                   (((uint32_t)(x) & 0x00FF0000) >> 8) | \
72                                   (((uint32_t)(x) & 0x0000FF00) << 8) | \
73                                   (((uint32_t)(x) & 0x000000FF) << 24))
74
75 #define ntohs htons
76 #define ntohl htonl
77
78
79 void delay_us(unsigned int us);
80 void delay_ms(unsigned int ms);
81 void delay_sec(unsigned int s);
82 void led_init(char pin);
83 void led_on();
84 void led_off();
85 void led_toggle();
86 void led_blink(int n);          // long - n shorts
87