37501b282b8f2f98a3d6cc9d294e7eb1fc3ec1d2
[pyfrprog.git] / pkernel / main.c
1 #include "mb91465k.h"
2 #include "flash.h"
3
4 #pragma section CODE=IRAM,attr=CODE
5
6 void increaseled(void)
7 {
8         PDR14 = (PDR14+1)%256;
9         HWWD_CL = 0;
10 }
11
12 void main(void)
13 {
14         unsigned char error = 0;
15         unsigned int i, baseaddr;
16         unsigned int toflash[] = {0x9b00, 0x0d4e, 0xcff1, 0x1601, 0x9b05, 0x04c7, 0xc106, 0x1656, 0xe0fb}; //len = 9
17         
18         PORTEN = 0x3; /* enable I/O Ports */
19
20         /*Enable LEDs*/
21         DDR14 = 0xFF;
22         PDR14 = 0xff;
23
24         /*Initialize UART4*/
25         InitUart4();
26
27 #if 1
28         i = 0;
29         baseaddr = 0xf4000;
30         for (; i <0x30; i+=4) {
31                 error = FLASH_SectorErase(baseaddr + i);
32                 Puts4("\nerased: ");
33                 Puts4(error == 1 ? "[success] " : "[failed] ");
34                 Puthex4(baseaddr + i, 6);
35                 increaseled();
36         }
37 #endif
38         i=0;
39         Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n");
40         while(i < 0x20)
41         {
42                 Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4(" ");
43                 i++;
44                 if( (i % 0x10) == 0 ) Puts4("\n");
45         }
46         Puts4("\n");
47
48
49         i = 0;
50         baseaddr = 0xf4000;
51         for(; i<9; i++) {
52                 increaseled();
53                 Puts4("\nwrite: ");
54                 error = FLASH_WriteHalfWord(baseaddr + (2*i), toflash[i]);
55                 Puts4(error == 1 ? "[sucess] " : "[failed] ");
56                 Puts4("0x");
57                 Puthex4(toflash[i], 4);
58                 Puts4(" @0x");
59                 Puthex4(baseaddr + (2*i), 6);
60         }
61
62         while(1) {
63                 HWWD_CL = 0;
64         }
65 }
66