/* 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 */ /*------------------------------------------------------------------------ taskutility.C - -------------------------------------------------------------------------*/ /*************************@INCLUDE_START************************/ #include "mb96348hs.h" #include "FreeRTOS.h" #include "task.h" static void vUART1Task( void *pvParameters ); /**************************@INCLUDE_END*************************/ /*********************@GLOBAL_VARIABLES_START*******************/ const char ASCII[] = "0123456789ABCDEF"; xTaskHandle UART_TaskHandle; void InitUart1(void) { /* Initialize UART asynchronous mode */ BGR1 = configCLKP1_CLOCK_HZ / 9600; /* 9600 Baud @ CLKP1 - 56 MHz */ SCR1 = 0x17; /* 8N1 */ SMR1 = 0x0d; /* enable SOT3, Reset, normal mode */ SSR1 = 0x02; /* LSB first, enable receive interrupts */ PIER08_IE5 = 1; /* enable input */ DDR08_D5 = 0; /* switch P08_5 to input */ DDR08_D6 = 1; /* switch P08_6 to output */ } void Putch1(char ch) /* sends a char */ { while (SSR1_TDRE == 0); /* wait for transmit buffer empty */ TDR1 = ch; /* put ch into buffer */ } char Getch1(void) /* waits for and returns incomming char */ { volatile unsigned ch; while(SSR1_RDRF == 0); /* wait for data received */ if (SSR1_ORE) /* overrun error */ { ch = RDR1; /* reset error flags */ return (char)(-1); } else return (RDR1); /* return char */ } void Puts1(const char *Name1) /* Puts a String to UART */ { volatile portSHORT i,len; len = strlen(Name1); for (i=0; i> div)&0xF); /* get hex-digit value */ Putch1(digit + ((digit < 0xA) ? '0' : 'A' - 0xA)); div-=4; /* next digit shift */ } } void Putdec1(unsigned long x, int digits) { portSHORT i; portCHAR buf[10],sign=1; if (digits < 0) { /* should be print of zero? */ digits *= (-1); sign =1; } buf[digits]='\0'; /* end sign of string */ for (i=digits; i>0; i--) { buf[i-1] = ASCII[x % 10]; x = x/10; } if ( sign ) { for (i=0; buf[i]=='0'; i++) { /* no print of zero */ if ( i= i ; j-- ) { Puthex1(trace_buff[j],2); } Puts1(" | "); l++; if ( l == 4) { Puts1("\n"); l = 0; } } Puts1("\r--------------------------------------------------------"); break; default: break; } Puts1("\n"); } } __interrupt void UART1_RxISR ( void ) { SSR1_RIE=0; vTaskResume( UART_TaskHandle ); }