]>
cvs.zerfleddert.de Git - raggedstone/blob - xps/raggedstone.c
1 #include "xparameters.h"
8 #define DISP7(a,b,c,d,e,f,g) (0|((~(a|b<<1|c<<2|d<<3|e<<4|f<<5|g<<6))&0xff))
10 void display_num(unsigned short num
) {
11 unsigned int val
= 0x00;
15 XGpio_mSetDataDirection(XPAR_SEVENSEG_BASEADDR
, 1, 0x00000000);
18 digit
= ((num
>>(4*i
)) & 0xf);
21 val
= DISP7(1,1,1,1,1,1,0);
24 val
= DISP7(0,1,1,0,0,0,0);
27 val
= DISP7(1,1,0,1,1,0,1);
30 val
= DISP7(1,1,1,1,0,0,1);
33 val
= DISP7(0,1,1,0,0,1,1);
36 val
= DISP7(1,0,1,1,0,1,1);
39 val
= DISP7(1,0,1,1,1,1,1);
42 val
= DISP7(1,1,1,0,0,0,0);
45 val
= DISP7(1,1,1,1,1,1,1);
48 val
= DISP7(1,1,1,1,0,1,1);
51 val
= DISP7(1,1,1,0,1,1,1);
54 val
= DISP7(0,0,1,1,1,1,1);
57 val
= DISP7(1,0,0,1,1,1,0);
60 val
= DISP7(0,1,1,1,1,0,1);
63 val
= DISP7(1,0,0,1,1,1,1);
66 val
= DISP7(1,0,0,0,1,1,1);
70 val
|= 1 << (8+(3-i
));
75 XGpio_mSetDataReg(XPAR_SEVENSEG_BASEADDR
, 1, val
);
77 for (val
= 0; val
< 100000; val
++);
81 void flash_chip_erase() {
82 volatile unsigned char *flash
= (volatile unsigned char*)XPAR_FLASH_MEM0_BASEADDR
;
92 void flash_erase_sector(unsigned int addr
) {
93 volatile unsigned char *flash
= (volatile unsigned char*)XPAR_FLASH_MEM0_BASEADDR
;
103 void flash_program_byte(unsigned int addr
, unsigned char value
) {
104 volatile unsigned char *flash
= (volatile unsigned char*)XPAR_FLASH_MEM0_BASEADDR
;
105 unsigned int count
= 0xffffffff;
107 if (flash
[addr
] != 0xff)
115 while (flash
[addr
] != value
&& count
) { count
--; }
118 void flash_identify(int enable
) {
119 volatile unsigned char *flash
= (volatile unsigned char*)XPAR_FLASH_MEM0_BASEADDR
;
123 flash
[0x555] = enable
?0x90:0xF0;
128 volatile unsigned char *flash
= (volatile unsigned char*)XPAR_FLASH_MEM0_BASEADDR
;
130 XGpio_mSetDataDirection(XPAR_LEDS_BASEADDR
, 1, 0x00000000);
131 XGpio_mSetDataReg(XPAR_LEDS_BASEADDR
, 1, 0x00);
132 print("\r\nHallo Raggedstone!\r\n");
133 for (i
= 0; i
< 1500000000; i
++);
136 putnum(flash
[0]|flash
[1]<<8|flash
[2]<<16|flash
[3]<<24);
139 putnum(flash
[0]|flash
[1]<<8|flash
[2]<<16|flash
[3]<<24);
142 for (i
= 0; i
< 1500000000; i
++);
145 print("Hallo Raggedstone ");
148 XGpio_mSetDataReg(XPAR_LEDS_BASEADDR
, 1, (i
& 0xf00)>>8);