more init stuff
[my-code/fpga.git] / fx2 / fx2.c
1 /*
2  * fx2 firmware 
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  * number of priorities:
7  * - switch on board power
8  * - allow high speed usb transfer
9  * - do jtag
10  * 
11  */
12
13 /* constant definitions */
14 #define TRUE    1
15 #define FALSE   0
16 #define POWER_ON        1;
17 #define POWER_OFF       0;
18
19 /* type definitions */
20 typedef unsigned char u8;
21 typedef unsigned short u16;
22 typedef unsigned int u32;
23
24 /* fx2 register */
25 sfr at 0xb5 OED;
26 sfr at 0xb0 IOD;
27
28 void power_on() {
29
30         OED|=(1<<7);
31         IOD|=(1<<7);
32 }
33
34 void slave_fifo_init() {
35
36         /* set bit 0 and 1 - fifo slave config */       
37         IFCONFIG|=0x03;
38
39         /* async mode */
40         IFCONFIG|=0x04;
41
42         /* 8 bit fifo to all endpoints */
43         EP2FIFOCFG&=^(1<<0);
44         EP4FIFOCFG&=^(1<<0);
45         EP6FIFOCFG&=^(1<<0);
46         EP8FIFOCFG&=^(1<<0);
47
48         /* default indexed flag configuration:
49          *
50          * flag a: programmable level
51          * flag b: full
52          * flag c: empty
53          *
54          * todo: -> fixed configuration
55          */
56
57
58 }
59
60 void fx2_init() {
61
62         /* swicth on power */
63         power_on();
64
65         /* slave fifo init */
66         slave_fifo_init();
67
68 }
69
70 void main() {
71
72         /* initialize the fx2 */
73         fx2_init();
74
75         /* do the job ... */
76         while(1) {
77         
78         }
79
80 }
81