From 0488126f3e78ba8682488cfc49d232d2762dd90f Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Mon, 14 Dec 2009 02:12:32 +0100 Subject: [PATCH] refactoring/reformatting fun... dude, i think the don't even have a tab key in japan. --- pkernel/Makefile | 1 - pkernel/main.c | 41 +++------------- pkernel/uart.c | 125 ++++++++++++++++++----------------------------- 3 files changed, 55 insertions(+), 112 deletions(-) diff --git a/pkernel/Makefile b/pkernel/Makefile index c08634d..fb5fa16 100644 --- a/pkernel/Makefile +++ b/pkernel/Makefile @@ -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) diff --git a/pkernel/main.c b/pkernel/main.c index 89fc2c8..37501b2 100644 --- a/pkernel/main.c +++ b/pkernel/main.c @@ -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; - } } diff --git a/pkernel/uart.c b/pkernel/uart.c index 256500e..71eb44b 100644 --- a/pkernel/uart.c +++ b/pkernel/uart.c @@ -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> 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> 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