leds "show" 0xaa when finished flashing process
[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 int i, baseaddr;
15         unsigned int toflash[] = {0x9b00, 0x0d4e, 0xcff1, 0x1601, 0x9b05, 0x04c7, 0xc106, 0x1656, 0xe0fb}; //len = 9
16         
17         PORTEN = 0x3; /* enable I/O Ports */
18
19         /*Enable LEDs*/
20         DDR14 = 0xFF;
21         PDR14 = 0x00;
22         increaseled();
23
24         /*Initialize UART4*/
25         InitUart4();
26
27 #if 1
28         i = 0;
29         baseaddr = 0xf4000;
30         for (; i <0x30; i+=4) {
31                 (void) FLASH_SectorErase(baseaddr + i);
32                 increaseled();
33         }
34 #endif
35
36         i = 0;
37         baseaddr = 0xf4000;
38         for(; i<9; i++) {
39                 increaseled();
40                 (void) FLASH_WriteHalfWord(baseaddr + (2*i), toflash[i]);
41         }
42
43         PDR14 = 0x55; //signal that we finished now!
44
45         while(1) {
46                 HWWD_CL = 0;
47         }
48 }
49