mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 21:41:59 -04:00
Add run-time stats to the Kintex7 Microblaze demo.
This commit is contained in:
parent
acfbb7dd14
commit
51aa373c4c
|
@ -106,9 +106,9 @@ this demo on the FreeRTOS.org web site for more information. */
|
||||||
|
|
||||||
/* Constants that describe the hardware and memory usage. */
|
/* Constants that describe the hardware and memory usage. */
|
||||||
#define configCPU_CLOCK_HZ ( Not used in this demo as it is determined by the hardware )
|
#define configCPU_CLOCK_HZ ( Not used in this demo as it is determined by the hardware )
|
||||||
#define configMINIMAL_STACK_SIZE ( ( uint16_t ) 220 )
|
#define configMINIMAL_STACK_SIZE ( ( uint16_t ) 170 )
|
||||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 50 * 1024 ) ) /* No effect if heap_3.c is used. */
|
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 80 * 1024 ) ) /* No effect if heap_3.c is used. */
|
||||||
#define configMAX_TASK_NAME_LEN ( 12 )
|
#define configMAX_TASK_NAME_LEN ( 10 )
|
||||||
|
|
||||||
/* Constants that build features in or out. */
|
/* Constants that build features in or out. */
|
||||||
#define configUSE_MUTEXES 1
|
#define configUSE_MUTEXES 1
|
||||||
|
@ -133,8 +133,8 @@ this demo on the FreeRTOS.org web site for more information. */
|
||||||
|
|
||||||
/* Constants related to the generation of run time stats. */
|
/* Constants related to the generation of run time stats. */
|
||||||
#define configGENERATE_RUN_TIME_STATS 1
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vMainConfigTimerForRunTimeStats(); /* Only used when configGENERATE_RUN_TIME_STATS is 1. */
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* Only used when configGENERATE_RUN_TIME_STATS is 1. In this case the timer is setup when the tick timer is set up. */
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulMainGetRunTimeCounterValue(); /* Only used when configGENERATE_RUN_TIME_STATS is 1. */
|
#define portGET_RUN_TIME_COUNTER_VALUE() ulMainGetRunTimeCounterValue() /* Only used when configGENERATE_RUN_TIME_STATS is 1. */
|
||||||
|
|
||||||
/* Software timer definitions. */
|
/* Software timer definitions. */
|
||||||
#define configUSE_TIMERS 1
|
#define configUSE_TIMERS 1
|
||||||
|
@ -175,11 +175,10 @@ are multiple command interpreters running at once (for example, one on a UART
|
||||||
and one on TCP/IP). This is done to prevent an output buffer being defined by
|
and one on TCP/IP). This is done to prevent an output buffer being defined by
|
||||||
each implementation - which would waste RAM. In this case, there is only one
|
each implementation - which would waste RAM. In this case, there is only one
|
||||||
command interpreter running. */
|
command interpreter running. */
|
||||||
#define configCOMMAND_INT_MAX_OUTPUT_SIZE 1024
|
#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2048
|
||||||
|
|
||||||
/* Prevent the function prototypes being included from asm files. */
|
/* Prevent the function prototypes being included from asm files. */
|
||||||
#ifndef __ASSEMBLER__
|
#ifndef __ASSEMBLER__
|
||||||
void vMainConfigTimerForRunTimeStats( void );
|
|
||||||
uint32_t ulMainGetRunTimeCounterValue( void );
|
uint32_t ulMainGetRunTimeCounterValue( void );
|
||||||
void vAssertCalled( const char * pcFile, unsigned long ulLine );
|
void vAssertCalled( const char * pcFile, unsigned long ulLine );
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -147,7 +147,7 @@
|
||||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2UL )
|
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2UL )
|
||||||
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3UL )
|
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3UL )
|
||||||
#define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
#define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||||
#define mainUART_COMMAND_CONSOLE_STACK_SIZE ( configMINIMAL_STACK_SIZE * 3UL )
|
#define mainUART_COMMAND_CONSOLE_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2UL )
|
||||||
#define mainCOM_TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
#define mainCOM_TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||||
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||||
#define mainQUEUE_OVERWRITE_PRIORITY ( tskIDLE_PRIORITY )
|
#define mainQUEUE_OVERWRITE_PRIORITY ( tskIDLE_PRIORITY )
|
||||||
|
|
|
@ -84,8 +84,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#warning Try reducing minimal stack size.
|
|
||||||
|
|
||||||
/* Standard includes. */
|
/* Standard includes. */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
@ -136,8 +134,9 @@ void vApplicationIdleHook( void );
|
||||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
|
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
|
||||||
void vApplicationTickHook( void );
|
void vApplicationTickHook( void );
|
||||||
|
|
||||||
/* The dual timer is used to generate the RTOS tick interrupt. */
|
/* The dual timer is used to generate the RTOS tick interrupt and as a time base
|
||||||
static XTmrCtr xDualTimerInstance;
|
for the run time stats. */
|
||||||
|
static XTmrCtr xTickTimerInstance;
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -165,10 +164,6 @@ int main( void )
|
||||||
|
|
||||||
static void prvSetupHardware( void )
|
static void prvSetupHardware( void )
|
||||||
{
|
{
|
||||||
#warning Stacks are in BRAM.
|
|
||||||
#warning Caches are disabled.
|
|
||||||
// init_platform();
|
|
||||||
|
|
||||||
microblaze_disable_interrupts();
|
microblaze_disable_interrupts();
|
||||||
|
|
||||||
#if defined( XPAR_MICROBLAZE_USE_ICACHE ) && ( XPAR_MICROBLAZE_USE_ICACHE != 0 )
|
#if defined( XPAR_MICROBLAZE_USE_ICACHE ) && ( XPAR_MICROBLAZE_USE_ICACHE != 0 )
|
||||||
|
@ -275,12 +270,13 @@ below declares as an extern. */
|
||||||
void vApplicationSetupTimerInterrupt( void )
|
void vApplicationSetupTimerInterrupt( void )
|
||||||
{
|
{
|
||||||
portBASE_TYPE xStatus;
|
portBASE_TYPE xStatus;
|
||||||
const unsigned char ucTimerCounterNumber = ( unsigned char ) 0U;
|
const unsigned char ucTickTimerCounterNumber = ( unsigned char ) 0U;
|
||||||
|
const unsigned char ucRunTimeStatsCounterNumber = ( unsigned char ) 1U;
|
||||||
const unsigned long ulCounterValue = ( ( XPAR_TMRCTR_0_CLOCK_FREQ_HZ / configTICK_RATE_HZ ) - 1UL );
|
const unsigned long ulCounterValue = ( ( XPAR_TMRCTR_0_CLOCK_FREQ_HZ / configTICK_RATE_HZ ) - 1UL );
|
||||||
extern void vPortTickISR( void *pvUnused );
|
extern void vPortTickISR( void *pvUnused );
|
||||||
|
|
||||||
/* Initialise the timer/counter. */
|
/* Initialise the timer/counter. */
|
||||||
xStatus = XTmrCtr_Initialize( &xDualTimerInstance, XPAR_TMRCTR_0_DEVICE_ID );
|
xStatus = XTmrCtr_Initialize( &xTickTimerInstance, XPAR_TMRCTR_0_DEVICE_ID );
|
||||||
|
|
||||||
if( xStatus == XST_SUCCESS )
|
if( xStatus == XST_SUCCESS )
|
||||||
{
|
{
|
||||||
|
@ -298,19 +294,29 @@ extern void vPortTickISR( void *pvUnused );
|
||||||
vPortEnableInterrupt( XPAR_INTC_0_TMRCTR_0_VEC_ID );
|
vPortEnableInterrupt( XPAR_INTC_0_TMRCTR_0_VEC_ID );
|
||||||
|
|
||||||
/* Configure the timer interrupt handler. */
|
/* Configure the timer interrupt handler. */
|
||||||
XTmrCtr_SetHandler( &xDualTimerInstance, ( void * ) vPortTickISR, NULL );
|
XTmrCtr_SetHandler( &xTickTimerInstance, ( void * ) vPortTickISR, NULL );
|
||||||
|
|
||||||
/* Set the correct period for the timer. */
|
/* Set the correct period for the timer. */
|
||||||
XTmrCtr_SetResetValue( &xDualTimerInstance, ucTimerCounterNumber, ulCounterValue );
|
XTmrCtr_SetResetValue( &xTickTimerInstance, ucTickTimerCounterNumber, ulCounterValue );
|
||||||
|
|
||||||
/* Enable the interrupts. Auto-reload mode is used to generate a
|
/* Enable the interrupts. Auto-reload mode is used to generate a
|
||||||
periodic tick. Note that interrupts are disabled when this function is
|
periodic tick. Note that interrupts are disabled when this function is
|
||||||
called, so interrupts will not start to be processed until the first
|
called, so interrupts will not start to be processed until the first
|
||||||
task has started to run. */
|
task has started to run. */
|
||||||
XTmrCtr_SetOptions( &xDualTimerInstance, ucTimerCounterNumber, ( XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_DOWN_COUNT_OPTION ) );
|
XTmrCtr_SetOptions( &xTickTimerInstance, ucTickTimerCounterNumber, ( XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_DOWN_COUNT_OPTION ) );
|
||||||
|
|
||||||
/* Start the timer. */
|
/* Start the timer. */
|
||||||
XTmrCtr_Start( &xDualTimerInstance, ucTimerCounterNumber );
|
XTmrCtr_Start( &xTickTimerInstance, ucTickTimerCounterNumber );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The second timer is used as the time base for the run time stats.
|
||||||
|
Auto-reload mode is used to ensure the timer does not stop. */
|
||||||
|
XTmrCtr_SetOptions( &xTickTimerInstance, ucRunTimeStatsCounterNumber, XTC_AUTO_RELOAD_OPTION );
|
||||||
|
|
||||||
|
/* Start the timer. */
|
||||||
|
XTmrCtr_Start( &xTickTimerInstance, ucRunTimeStatsCounterNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity check that the function executed as expected. */
|
/* Sanity check that the function executed as expected. */
|
||||||
|
@ -344,12 +350,20 @@ void *malloc( size_t x )
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vMainConfigTimerForRunTimeStats( void )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
uint32_t ulMainGetRunTimeCounterValue( void )
|
uint32_t ulMainGetRunTimeCounterValue( void )
|
||||||
{
|
{
|
||||||
return 0;
|
static uint32_t ulOverflows = 0, ulLastTime = 0;
|
||||||
|
uint32_t ulTimeNow, ulReturn;
|
||||||
|
const uint32_t ulPrescale = 10, ulTCR2Offset = 24UL;
|
||||||
|
|
||||||
|
ulTimeNow = * ( ( uint32_t * ) ( XPAR_TMRCTR_0_BASEADDR + ulTCR2Offset ) );
|
||||||
|
|
||||||
|
if( ulTimeNow < ulLastTime )
|
||||||
|
{
|
||||||
|
ulOverflows += ( 1UL << ulPrescale );
|
||||||
|
}
|
||||||
|
|
||||||
|
ulReturn = ( ulTimeNow >> ulPrescale ) + ulOverflows;
|
||||||
|
|
||||||
|
return ulReturn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,285 @@
|
||||||
|
/*
|
||||||
|
Copyright 2001, 2002 Georges Menie (www.menie.org)
|
||||||
|
stdarg version contributed by Christian Ettinger
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
putchar is the only external dependency for this file,
|
||||||
|
if you have a working putchar, leave it commented out.
|
||||||
|
If not, uncomment the define below and
|
||||||
|
replace outbyte(c) by your own function call.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define putchar(c) c
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
static void printchar(char **str, int c)
|
||||||
|
{
|
||||||
|
//extern int putchar(int c);
|
||||||
|
|
||||||
|
if (str) {
|
||||||
|
**str = (char)c;
|
||||||
|
++(*str);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(void)putchar(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PAD_RIGHT 1
|
||||||
|
#define PAD_ZERO 2
|
||||||
|
|
||||||
|
static int prints(char **out, const char *string, int width, int pad)
|
||||||
|
{
|
||||||
|
register int pc = 0, padchar = ' ';
|
||||||
|
|
||||||
|
if (width > 0) {
|
||||||
|
register int len = 0;
|
||||||
|
register const char *ptr;
|
||||||
|
for (ptr = string; *ptr; ++ptr) ++len;
|
||||||
|
if (len >= width) width = 0;
|
||||||
|
else width -= len;
|
||||||
|
if (pad & PAD_ZERO) padchar = '0';
|
||||||
|
}
|
||||||
|
if (!(pad & PAD_RIGHT)) {
|
||||||
|
for ( ; width > 0; --width) {
|
||||||
|
printchar (out, padchar);
|
||||||
|
++pc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ( ; *string ; ++string) {
|
||||||
|
printchar (out, *string);
|
||||||
|
++pc;
|
||||||
|
}
|
||||||
|
for ( ; width > 0; --width) {
|
||||||
|
printchar (out, padchar);
|
||||||
|
++pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the following should be enough for 32 bit int */
|
||||||
|
#define PRINT_BUF_LEN 12
|
||||||
|
|
||||||
|
static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase)
|
||||||
|
{
|
||||||
|
char print_buf[PRINT_BUF_LEN];
|
||||||
|
register char *s;
|
||||||
|
register int t, neg = 0, pc = 0;
|
||||||
|
register unsigned int u = (unsigned int)i;
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
print_buf[0] = '0';
|
||||||
|
print_buf[1] = '\0';
|
||||||
|
return prints (out, print_buf, width, pad);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sg && b == 10 && i < 0) {
|
||||||
|
neg = 1;
|
||||||
|
u = (unsigned int)-i;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = print_buf + PRINT_BUF_LEN-1;
|
||||||
|
*s = '\0';
|
||||||
|
|
||||||
|
while (u) {
|
||||||
|
t = (unsigned int)u % b;
|
||||||
|
if( t >= 10 )
|
||||||
|
t += letbase - '0' - 10;
|
||||||
|
*--s = (char)(t + '0');
|
||||||
|
u /= b;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (neg) {
|
||||||
|
if( width && (pad & PAD_ZERO) ) {
|
||||||
|
printchar (out, '-');
|
||||||
|
++pc;
|
||||||
|
--width;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*--s = '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pc + prints (out, s, width, pad);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int print( char **out, const char *format, va_list args )
|
||||||
|
{
|
||||||
|
register int width, pad;
|
||||||
|
register int pc = 0;
|
||||||
|
char scr[2];
|
||||||
|
|
||||||
|
for (; *format != 0; ++format) {
|
||||||
|
if (*format == '%') {
|
||||||
|
++format;
|
||||||
|
width = pad = 0;
|
||||||
|
if (*format == '\0') break;
|
||||||
|
if (*format == '%') goto out;
|
||||||
|
if (*format == '-') {
|
||||||
|
++format;
|
||||||
|
pad = PAD_RIGHT;
|
||||||
|
}
|
||||||
|
while (*format == '0') {
|
||||||
|
++format;
|
||||||
|
pad |= PAD_ZERO;
|
||||||
|
}
|
||||||
|
for ( ; *format >= '0' && *format <= '9'; ++format) {
|
||||||
|
width *= 10;
|
||||||
|
width += *format - '0';
|
||||||
|
}
|
||||||
|
if( *format == 's' ) {
|
||||||
|
register char *s = (char *)va_arg( args, int );
|
||||||
|
pc += prints (out, s?s:"(null)", width, pad);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if( *format == 'd' ) {
|
||||||
|
pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if( *format == 'x' ) {
|
||||||
|
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if( *format == 'X' ) {
|
||||||
|
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if( *format == 'u' ) {
|
||||||
|
pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if( *format == 'c' ) {
|
||||||
|
/* char are converted to int then pushed on the stack */
|
||||||
|
scr[0] = (char)va_arg( args, int );
|
||||||
|
scr[1] = '\0';
|
||||||
|
pc += prints (out, scr, width, pad);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out:
|
||||||
|
printchar (out, *format);
|
||||||
|
++pc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out) **out = '\0';
|
||||||
|
va_end( args );
|
||||||
|
return pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int printf(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start( args, format );
|
||||||
|
return print( 0, format, args );
|
||||||
|
}
|
||||||
|
|
||||||
|
int sprintf(char *out, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start( args, format );
|
||||||
|
return print( &out, format, args );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int snprintf( char *buf, unsigned int count, const char *format, ... )
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
( void ) count;
|
||||||
|
|
||||||
|
va_start( args, format );
|
||||||
|
return print( &buf, format, args );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TEST_PRINTF
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
char *ptr = "Hello world!";
|
||||||
|
char *np = 0;
|
||||||
|
int i = 5;
|
||||||
|
unsigned int bs = sizeof(int)*8;
|
||||||
|
int mi;
|
||||||
|
char buf[80];
|
||||||
|
|
||||||
|
mi = (1 << (bs-1)) + 1;
|
||||||
|
printf("%s\n", ptr);
|
||||||
|
printf("printf test\n");
|
||||||
|
printf("%s is null pointer\n", np);
|
||||||
|
printf("%d = 5\n", i);
|
||||||
|
printf("%d = - max int\n", mi);
|
||||||
|
printf("char %c = 'a'\n", 'a');
|
||||||
|
printf("hex %x = ff\n", 0xff);
|
||||||
|
printf("hex %02x = 00\n", 0);
|
||||||
|
printf("signed %d = unsigned %u = hex %x\n", -3, -3, -3);
|
||||||
|
printf("%d %s(s)%", 0, "message");
|
||||||
|
printf("\n");
|
||||||
|
printf("%d %s(s) with %%\n", 0, "message");
|
||||||
|
sprintf(buf, "justif: \"%-10s\"\n", "left"); printf("%s", buf);
|
||||||
|
sprintf(buf, "justif: \"%10s\"\n", "right"); printf("%s", buf);
|
||||||
|
sprintf(buf, " 3: %04d zero padded\n", 3); printf("%s", buf);
|
||||||
|
sprintf(buf, " 3: %-4d left justif.\n", 3); printf("%s", buf);
|
||||||
|
sprintf(buf, " 3: %4d right justif.\n", 3); printf("%s", buf);
|
||||||
|
sprintf(buf, "-3: %04d zero padded\n", -3); printf("%s", buf);
|
||||||
|
sprintf(buf, "-3: %-4d left justif.\n", -3); printf("%s", buf);
|
||||||
|
sprintf(buf, "-3: %4d right justif.\n", -3); printf("%s", buf);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if you compile this file with
|
||||||
|
* gcc -Wall $(YOUR_C_OPTIONS) -DTEST_PRINTF -c printf.c
|
||||||
|
* you will get a normal warning:
|
||||||
|
* printf.c:214: warning: spurious trailing `%' in format
|
||||||
|
* this line is testing an invalid % at the end of the format string.
|
||||||
|
*
|
||||||
|
* this should display (on 32bit int machine) :
|
||||||
|
*
|
||||||
|
* Hello world!
|
||||||
|
* printf test
|
||||||
|
* (null) is null pointer
|
||||||
|
* 5 = 5
|
||||||
|
* -2147483647 = - max int
|
||||||
|
* char a = 'a'
|
||||||
|
* hex ff = ff
|
||||||
|
* hex 00 = 00
|
||||||
|
* signed -3 = unsigned 4294967293 = hex fffffffd
|
||||||
|
* 0 message(s)
|
||||||
|
* 0 message(s) with %
|
||||||
|
* justif: "left "
|
||||||
|
* justif: " right"
|
||||||
|
* 3: 0003 zero padded
|
||||||
|
* 3: 3 left justif.
|
||||||
|
* 3: 3 right justif.
|
||||||
|
* -3: -003 zero padded
|
||||||
|
* -3: -3 left justif.
|
||||||
|
* -3: -3 right justif.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
|
|
||||||
/* Scheduler includes. */
|
/* Scheduler includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "comtest_strings.h"
|
#include "comtest_strings.h"
|
||||||
|
|
||||||
|
@ -103,6 +104,10 @@ static XUartLite xUartLiteInstance;
|
||||||
/* The queue used to hold received characters. */
|
/* The queue used to hold received characters. */
|
||||||
static QueueHandle_t xRxedChars;
|
static QueueHandle_t xRxedChars;
|
||||||
|
|
||||||
|
/* Holds the handle of a task performing a Tx so it can be notified of when
|
||||||
|
the Tx has completed. */
|
||||||
|
static TaskHandle_t xUARTSendingTask = NULL;
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
||||||
|
@ -182,20 +187,40 @@ portBASE_TYPE xReturn;
|
||||||
|
|
||||||
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime )
|
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime )
|
||||||
{
|
{
|
||||||
|
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 150UL );
|
||||||
|
portBASE_TYPE xReturn;
|
||||||
|
|
||||||
( void ) pxPort;
|
( void ) pxPort;
|
||||||
( void ) xBlockTime;
|
( void ) xBlockTime;
|
||||||
|
|
||||||
|
/* Note this is the currently sending task. */
|
||||||
|
xUARTSendingTask = xTaskGetCurrentTaskHandle();
|
||||||
|
|
||||||
XUartLite_Send( &xUartLiteInstance, ( unsigned char * ) &cOutChar, sizeof( cOutChar ) );
|
XUartLite_Send( &xUartLiteInstance, ( unsigned char * ) &cOutChar, sizeof( cOutChar ) );
|
||||||
return pdPASS;
|
|
||||||
|
/* Wait in the Blocked state (so not using any CPU time) for the Tx to
|
||||||
|
complete. */
|
||||||
|
xReturn = ulTaskNotifyTake( pdTRUE, xMaxBlockTime );
|
||||||
|
|
||||||
|
return xReturn;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
|
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
|
||||||
{
|
{
|
||||||
|
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 150UL );
|
||||||
|
|
||||||
( void ) pxPort;
|
( void ) pxPort;
|
||||||
|
|
||||||
|
/* Note this is the currently sending task. */
|
||||||
|
xUARTSendingTask = xTaskGetCurrentTaskHandle();
|
||||||
|
|
||||||
/* Output uxStringLength bytes starting from pcString. */
|
/* Output uxStringLength bytes starting from pcString. */
|
||||||
XUartLite_Send( &xUartLiteInstance, ( unsigned char * ) pcString, usStringLength );
|
XUartLite_Send( &xUartLiteInstance, ( unsigned char * ) pcString, usStringLength );
|
||||||
|
|
||||||
|
/* Wait in the Blocked state (so not using any CPU time) for the Tx to
|
||||||
|
complete. */
|
||||||
|
ulTaskNotifyTake( pdTRUE, xMaxBlockTime );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -225,14 +250,21 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvTxHandler( void *pvUnused, unsigned portBASE_TYPE uxByteCount )
|
static void prvTxHandler( void *pvUnused, unsigned portBASE_TYPE uxUnused )
|
||||||
{
|
{
|
||||||
( void ) pvUnused;
|
BaseType_t xHigherPriorityTaskWoken = NULL;
|
||||||
( void ) uxByteCount;
|
|
||||||
|
|
||||||
/* Nothing to do here. The Xilinx library function takes care of the
|
( void ) pvUnused;
|
||||||
transmission. */
|
( void ) uxUnused;
|
||||||
portNOP();
|
|
||||||
|
/* Notify the sending that that the Tx has completed. */
|
||||||
|
if( xUARTSendingTask != NULL )
|
||||||
|
{
|
||||||
|
vTaskNotifyGiveFromISR( xUARTSendingTask, &xHigherPriorityTaskWoken );
|
||||||
|
xUARTSendingTask = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue