refactoring/reformatting fun...
authorBernhard Urban <lewurm@gmx.net>
Mon, 14 Dec 2009 01:12:32 +0000 (02:12 +0100)
committerBernhard Urban <lewurm@gmx.net>
Mon, 14 Dec 2009 01:12:32 +0000 (02:12 +0100)
dude, i think the don't even have a tab key in japan.

pkernel/Makefile
pkernel/main.c
pkernel/uart.c

index c08634de44e49d4a4addc1a260f630e565432eda..fb5fa164b4c96bfc4e0a62101c44e297ea62ea50 100644 (file)
@@ -35,7 +35,6 @@ LDFLAGS += -sc DATA/Data+INIT/Data+SSTACK/Data+USTACK/Data=D_RAM
 LDFLAGS += -sc IRAM/Code=ID_RAM
 LDFLAGS += -sc CODE+@INIT+@IRAM+CONST=ROM_AREA
 LDFLAGS += -sc CODE_START/Code=0x000F4000
-LDFLAGS += -sc INTVECT/Const=0x000FFC00
 LDFLAGS += -check_locate -pl 60 -pw 132 -Xals
 LDFLAGS += -Xalr -na -w 1 -Xdof -Xset_rora -cwno -a $(CPUT)
 
index 89fc2c85f0a415eb04839d99c4a7a0b86e154905..37501b282b8f2f98a3d6cc9d294e7eb1fc3ec1d2 100644 (file)
@@ -12,33 +12,18 @@ void increaseled(void)
 void main(void)
 {
        unsigned char error = 0;
-       unsigned char global_error = 0; 
        unsigned int i, baseaddr;
-       unsigned int toflash[] = {0x9b00,
-                                                               0x0d4e,
-                                                               0xcff1,
-                                                               0x1601,
-                                                               0x9b05,
-                                                               0x04c7,
-                                                               0xc106,
-                                                               0x1656,
-                                                               0xe0fb}; //len = 9
+       unsigned int toflash[] = {0x9b00, 0x0d4e, 0xcff1, 0x1601, 0x9b05, 0x04c7, 0xc106, 0x1656, 0xe0fb}; //len = 9
        
-       PORTEN = 0x3;           /* enable I/O Ports */
-                               /* This feature is not supported by MB91V460A */
-                               /* For all other devices the I/O Ports must be enabled*/
+       PORTEN = 0x3; /* enable I/O Ports */
 
-       /*      Enable LEDs     */
+       /*Enable LEDs*/
        DDR14 = 0xFF;
        PDR14 = 0xff;
 
-       /*      Initialize UART4        */
+       /*Initialize UART4*/
        InitUart4();
 
-       /*      Output Welcome Message  */
-       Puts4(" \n\n");
-       Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n");
-
 #if 1
        i = 0;
        baseaddr = 0xf4000;
@@ -47,6 +32,7 @@ void main(void)
                Puts4("\nerased: ");
                Puts4(error == 1 ? "[success] " : "[failed] ");
                Puthex4(baseaddr + i, 6);
+               increaseled();
        }
 #endif
        i=0;
@@ -63,6 +49,7 @@ void main(void)
        i = 0;
        baseaddr = 0xf4000;
        for(; i<9; i++) {
+               increaseled();
                Puts4("\nwrite: ");
                error = FLASH_WriteHalfWord(baseaddr + (2*i), toflash[i]);
                Puts4(error == 1 ? "[sucess] " : "[failed] ");
@@ -72,20 +59,8 @@ void main(void)
                Puthex4(baseaddr + (2*i), 6);
        }
 
-       /*      Output Ready Meassage   */
-       if( global_error != 0 )
-       {
-               Puts4("\n********* FLASH Programming Demo failed **********\n");
-       }
-       else
-       {
-               Puts4("\n********* FLASH Programming Demo done **********\n");
+       while(1) {
+               HWWD_CL = 0;
        }
-
-    while(1)
-    {    
-         
-       HWWD_CL = 0;   
-    }   
 }
 
index 256500ef6bba12dc14300160bccc720a520c6d8a..71eb44ba8f6dd33610c584a7c03686c6c0b934fc 100644 (file)
@@ -1,9 +1,3 @@
-/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */
-/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
-/* ELIGIBILITY FOR ANY PURPOSES.                                             */
-/*                 (C) Fujitsu Microelectronics Europe GmbH                  */
-/*---------------------------------------------------------------------------*/
-
 #include "mb91465k.h"
 
 #pragma section CODE=IRAM,attr=CODE
@@ -11,84 +5,61 @@ const char ASCII[] = "0123456789ABCDEF";
 
 void InitUart4(void)
 {
-  // Initialize UART asynchronous mode
-  // BGR04 = 1666; //  9600 Baud @ 16MHz
-  // BGR04 = 832;  // 19200 Baud @ 16MHz
-  BGR04 = 416;  // 38400 Baud @ 16MHz
-  SCR04 = 0x17;    // 8N1
-  SMR04 = 0x0d;    // enable SOT3, Reset, normal mode
-  SSR04 = 0x00;    // LSB first
-  PFR19 = (PFR19 & 0xFC) | 0x03;       // enable UART: SIN,SOT for async. transfer
-  EPFR19 = 0x00;   // enable UART
+       // Initialize UART asynchronous mode
+       BGR04 = 416; // 38400 Baud @ 16MHz
+       SCR04 = 0x17; // 8N1
+       SMR04 = 0x0d; // enable SOT3, Reset, normal mode
+       SSR04 = 0x00; // LSB first
+       PFR19 = (PFR19 & 0xFC) | 0x03; // enable UART: SIN,SOT for async. transfer
+       EPFR19 = 0x00; // enable UART
 }
 
-void Putch4(unsigned char ch)         /* sends a char */
+void Putch4(unsigned char ch) /* sends a char */
 {
-  while (SSR04_TDRE == 0);    /* wait for transmit buffer empty        */
-  TDR04 = ch;                 /* put ch into buffer                    */
+       while (SSR04_TDRE == 0); /* wait for transmit buffer empty */
+       TDR04 = ch; /* put ch into buffer */
 }
 
-unsigned char Getch4(void)            /* waits for and returns incomming char  */
+unsigned char Getch4(void) /* waits for and returns incomming char     */
 {
-  volatile unsigned ch;
-
-  for(;;)
-  {
-  
-     while(SSR04_RDRF == 0)     /* wait for data received      */
-       HWWD = 0x00; 
-  
-     ch = RDR04;
-  
-     if ((SSR04 & 0xE0) != 0)    /* Check for errors PE, ORE, FRE */
-     {
-         SCR04_CRE = 1;            /* Clear error flags        */
-     }
-     else   
-        return (ch);            /* return char                         */
-  }
+       volatile unsigned ch;
+       for(;;) {
+               while(SSR04_RDRF == 0) /* wait for data received */
+                       HWWD = 0x00;
+               ch = RDR04;
+
+               if ((SSR04 & 0xE0) != 0) { /* Check for errors PE, ORE, FRE */
+                       SCR04_CRE = 1; /* Clear error flags */
+               } else {
+                       return (ch); /* return char*/
+               }
+       }
 }
 
 
-void Puts4(const char *Name2)  /* Puts a String to UART */
+void Puts4(const char *Name2)
 {
-  volatile int i,len;
-   
-  len = strlen(Name2);
+       volatile int i,len;
+       len = strlen(Name2);
        
-  for (i=0; i<strlen(Name2); i++)   /* go through string                     */
-  {
-    if (Name2[i] == 10)
-      Putch4(13);
-    Putch4(Name2[i]);              /* send it out                           */
-  }
+       for(i=0; i<strlen(Name2); i++) {
+       if(Name2[i] == 10)
+               Putch4(13);
+       Putch4(Name2[i]);
+       }
 }
 
 
-char Echo4(void)        /* Echo UART and return ch */
-{
-  char ch;
-  
-  Puts4("UART 4 receive: ");      // send text to UART
-  ch = RDR04;                     // readout character              
-  Putch4(ch);                         // send character to UART                 
-  if (ch==13)  
-    Putch4(10);
-
-  return (ch);
-}
-
 void Puthex4(unsigned long n, unsigned char digits)
 {
-   unsigned char digit=0,div=0,i;
+       unsigned char digit=0,div=0,i;
 
-   div=(4*(digits-1)); /* init shift divisor */
-   for (i=0;i<digits;i++)
-   {
-     digit = ((n >> div)&0xF); /* get hex-digit value */
-        Putch4(digit + ((digit < 0xA) ? '0' : 'A' - 0xA));
-     div-=4;                   /* next digit shift */
-   }
+       div=(4*(digits-1));     /* init shift divisor */
+       for (i=0;i<digits;i++) {
+               digit = ((n >> div)&0xF); /* get hex-digit value */
+               Putch4(digit + ((digit < 0xA) ? '0' : 'A' - 0xA));
+               div-=4; /* next digit shift */
+       }
 }
 
 void Putdec4(unsigned long x, int digits)
@@ -97,8 +68,8 @@ void Putdec4(unsigned long x, int digits)
        char buf[10],sign=1;
        
        if (digits < 0) {     /* should be print of zero? */
-         digits *= (-1);
-         sign =1;
+               digits *= (-1);
+               sign =1;
        }  
        buf[digits]='\0';                       /* end sign of string */
        
@@ -107,14 +78,12 @@ void Putdec4(unsigned long x, int digits)
                x = x/10;
        }
 
-    if ( sign )
-    {
-         for (i=0; buf[i]=='0'; i++) { /* no print of zero */
-               if ( i<digits-1)
-                       buf[i] = ' ';
-         }             
-    }
-    
-       Puts4(buf);                                     /* send string */
+       if (sign) {
+               for (i=0; buf[i]=='0'; i++) { /* no print of zero */
+                       if ( i<digits-1)
+                               buf[i] = ' ';
+               }
+       }
+       Puts4(buf); /* send string */
 }