mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-15 16:15:08 -05:00
Fix formatting in kernel demo application files (#1148)
* Fix formatting in kernel demo application files * Fix header check fail in the demo files * Add ignored patterns in core header check file * Fix formatting * Update vApplicationStackOverflowHook for AVR_ATMega4809_MPLAB.X/main.c Co-authored-by: Soren Ptak <ptaksoren@gmail.com> * Update vApplicationStackOverflowHook for AVR_ATMega4809_MPLAB.X/main.c Co-authored-by: Soren Ptak <ptaksoren@gmail.com> * Update vApplicationStackOverflowHook for AVR_Dx_IAR/main.c Co-authored-by: Soren Ptak <ptaksoren@gmail.com> * Update vApplicationStackOverflowHook for AVR_Dx_IAR/main.c Co-authored-by: Soren Ptak <ptaksoren@gmail.com> * Update vApplicationStackOverflowHook for AVR_Dx_MPLAB.X/main.c Co-authored-by: Soren Ptak <ptaksoren@gmail.com> * Update vApplicationMallocFailedHook for AVR_Dx_MPLAB.X/main.c Co-authored-by: Soren Ptak <ptaksoren@gmail.com> * Fix formatting AVR32_UC3 --------- Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
This commit is contained in:
parent
85ed21bcfb
commit
121fbe295b
169 changed files with 22211 additions and 21557 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeRTOS V202212.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
@ -81,44 +81,44 @@
|
|||
#include "comtest2.h"
|
||||
|
||||
/* Task priorities. */
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
/* Constants related to the LCD. */
|
||||
#define mainMAX_LINE ( 240 )
|
||||
#define mainROW_INCREMENT ( 24 )
|
||||
#define mainMAX_COLUMN ( 20 )
|
||||
#define mainCOLUMN_START ( 319 )
|
||||
#define mainCOLUMN_INCREMENT ( 16 )
|
||||
#define mainMAX_LINE ( 240 )
|
||||
#define mainROW_INCREMENT ( 24 )
|
||||
#define mainMAX_COLUMN ( 20 )
|
||||
#define mainCOLUMN_START ( 319 )
|
||||
#define mainCOLUMN_INCREMENT ( 16 )
|
||||
|
||||
/* The maximum number of message that can be waiting for display at any one
|
||||
time. */
|
||||
#define mainLCD_QUEUE_SIZE ( 3 )
|
||||
* time. */
|
||||
#define mainLCD_QUEUE_SIZE ( 3 )
|
||||
|
||||
/* The check task uses the sprintf function so requires a little more stack. */
|
||||
#define mainCHECK_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE + 50 )
|
||||
#define mainCHECK_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE + 50 )
|
||||
|
||||
/* Dimensions the buffer into which the jitter time is written. */
|
||||
#define mainMAX_MSG_LEN 25
|
||||
#define mainMAX_MSG_LEN 25
|
||||
|
||||
/* The time between cycles of the 'check' task. */
|
||||
#define mainCHECK_DELAY ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
|
||||
#define mainCHECK_DELAY ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
|
||||
|
||||
/* The number of nano seconds between each processor clock. */
|
||||
#define mainNS_PER_CLOCK ( ( unsigned long ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) )
|
||||
#define mainNS_PER_CLOCK ( ( unsigned long ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) )
|
||||
|
||||
/* Baud rate used by the comtest tasks. */
|
||||
#define mainCOM_TEST_BAUD_RATE ( 115200 )
|
||||
#define mainCOM_TEST_BAUD_RATE ( 115200 )
|
||||
|
||||
/* The LED used by the comtest tasks. See the comtest.c file for more
|
||||
information. */
|
||||
#define mainCOM_TEST_LED ( 3 )
|
||||
* information. */
|
||||
#define mainCOM_TEST_LED ( 3 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -138,12 +138,13 @@ static void prvConfigureLCD( void );
|
|||
* access the LCD directly. Other tasks wanting to display a message send
|
||||
* the message to the gatekeeper.
|
||||
*/
|
||||
static void vLCDTask( void *pvParameters );
|
||||
static void vLCDTask( void * pvParameters );
|
||||
|
||||
/*
|
||||
* Retargets the C library printf function to the USART.
|
||||
*/
|
||||
int fputc( int ch, FILE *f );
|
||||
int fputc( int ch,
|
||||
FILE * f );
|
||||
|
||||
/*
|
||||
* Checks the status of all the demo tasks then prints a message to the
|
||||
|
|
@ -155,7 +156,7 @@ int fputc( int ch, FILE *f );
|
|||
* Messages are not written directly to the terminal, but passed to vLCDTask
|
||||
* via a queue.
|
||||
*/
|
||||
static void vCheckTask( void *pvParameters );
|
||||
static void vCheckTask( void * pvParameters );
|
||||
|
||||
/*
|
||||
* Configures the timers and interrupts for the fast interrupt test as
|
||||
|
|
@ -172,90 +173,92 @@ QueueHandle_t xLCDQueue;
|
|||
|
||||
int main( void )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
debug();
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
debug();
|
||||
#endif
|
||||
|
||||
prvSetupHardware();
|
||||
prvSetupHardware();
|
||||
|
||||
/* Create the queue used by the LCD task. Messages for display on the LCD
|
||||
are received via this queue. */
|
||||
xLCDQueue = xQueueCreate( mainLCD_QUEUE_SIZE, sizeof( xLCDMessage ) );
|
||||
/* Create the queue used by the LCD task. Messages for display on the LCD
|
||||
* are received via this queue. */
|
||||
xLCDQueue = xQueueCreate( mainLCD_QUEUE_SIZE, sizeof( xLCDMessage ) );
|
||||
|
||||
/* Start the standard demo tasks. */
|
||||
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
|
||||
/* Start the standard demo tasks. */
|
||||
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
|
||||
vCreateBlockTimeTasks();
|
||||
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
|
||||
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
||||
vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
|
||||
vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
|
||||
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
|
||||
vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
|
||||
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
|
||||
|
||||
/* Start the tasks defined within this file/specific to this demo. */
|
||||
/* Start the tasks defined within this file/specific to this demo. */
|
||||
xTaskCreate( vCheckTask, "Check", mainCHECK_TASK_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
/* The suicide tasks must be created last as they need to know how many
|
||||
tasks were running prior to their creation in order to ascertain whether
|
||||
or not the correct/expected number of tasks are running at any given time. */
|
||||
/* The suicide tasks must be created last as they need to know how many
|
||||
* tasks were running prior to their creation in order to ascertain whether
|
||||
* or not the correct/expected number of tasks are running at any given time. */
|
||||
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
|
||||
|
||||
/* Configure the timers used by the fast interrupt timer test. */
|
||||
vSetupTimerTest();
|
||||
/* Configure the timers used by the fast interrupt timer test. */
|
||||
vSetupTimerTest();
|
||||
|
||||
/* Start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
/* Start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* Will only get here if there was not enough heap space to create the
|
||||
idle task. */
|
||||
return 0;
|
||||
/* Will only get here if there was not enough heap space to create the
|
||||
* idle task. */
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vLCDTask( void *pvParameters )
|
||||
void vLCDTask( void * pvParameters )
|
||||
{
|
||||
xLCDMessage xMessage;
|
||||
xLCDMessage xMessage;
|
||||
|
||||
/* Initialise the LCD and display a startup message. */
|
||||
prvConfigureLCD();
|
||||
LCD_DrawMonoPict( ( unsigned long * ) pcBitmap );
|
||||
/* Initialise the LCD and display a startup message. */
|
||||
prvConfigureLCD();
|
||||
LCD_DrawMonoPict( ( unsigned long * ) pcBitmap );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait for a message to arrive that requires displaying. */
|
||||
while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );
|
||||
for( ; ; )
|
||||
{
|
||||
/* Wait for a message to arrive that requires displaying. */
|
||||
while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS )
|
||||
{
|
||||
}
|
||||
|
||||
/* Display the message. Print each message to a different position. */
|
||||
printf( ( char const * ) xMessage.pcMessage );
|
||||
}
|
||||
/* Display the message. Print each message to a different position. */
|
||||
printf( ( char const * ) xMessage.pcMessage );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vCheckTask( void *pvParameters )
|
||||
static void vCheckTask( void * pvParameters )
|
||||
{
|
||||
TickType_t xLastExecutionTime;
|
||||
xLCDMessage xMessage;
|
||||
static signed char cPassMessage[ mainMAX_MSG_LEN ];
|
||||
extern unsigned short usMaxJitter;
|
||||
TickType_t xLastExecutionTime;
|
||||
xLCDMessage xMessage;
|
||||
static signed char cPassMessage[ mainMAX_MSG_LEN ];
|
||||
extern unsigned short usMaxJitter;
|
||||
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
xMessage.pcMessage = cPassMessage;
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
xMessage.pcMessage = cPassMessage;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Perform this check every mainCHECK_DELAY milliseconds. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );
|
||||
for( ; ; )
|
||||
{
|
||||
/* Perform this check every mainCHECK_DELAY milliseconds. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );
|
||||
|
||||
/* Has an error been found in any task? */
|
||||
/* Has an error been found in any task? */
|
||||
|
||||
if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN BLOCK Q\n";
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN BLOCK TIME\n";
|
||||
}
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN BLOCK Q\n";
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN BLOCK TIME\n";
|
||||
}
|
||||
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN SEMAPHORE\n";
|
||||
|
|
@ -272,162 +275,165 @@ extern unsigned short usMaxJitter;
|
|||
{
|
||||
xMessage.pcMessage = "ERROR IN MATH\n";
|
||||
}
|
||||
else if( xAreComTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN COM TEST\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( ( char * ) cPassMessage, "PASS [%uns]\n", ( ( unsigned long ) usMaxJitter ) * mainNS_PER_CLOCK );
|
||||
}
|
||||
else if( xAreComTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN COM TEST\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( ( char * ) cPassMessage, "PASS [%uns]\n", ( ( unsigned long ) usMaxJitter ) * mainNS_PER_CLOCK );
|
||||
}
|
||||
|
||||
/* Send the message to the LCD gatekeeper for display. */
|
||||
xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
|
||||
}
|
||||
/* Send the message to the LCD gatekeeper for display. */
|
||||
xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupHardware( void )
|
||||
{
|
||||
/* Start with the clocks in their expected state. */
|
||||
RCC_DeInit();
|
||||
/* Start with the clocks in their expected state. */
|
||||
RCC_DeInit();
|
||||
|
||||
/* Enable HSE (high speed external clock). */
|
||||
RCC_HSEConfig( RCC_HSE_ON );
|
||||
/* Enable HSE (high speed external clock). */
|
||||
RCC_HSEConfig( RCC_HSE_ON );
|
||||
|
||||
/* Wait till HSE is ready. */
|
||||
while( RCC_GetFlagStatus( RCC_FLAG_HSERDY ) == RESET )
|
||||
{
|
||||
}
|
||||
/* Wait till HSE is ready. */
|
||||
while( RCC_GetFlagStatus( RCC_FLAG_HSERDY ) == RESET )
|
||||
{
|
||||
}
|
||||
|
||||
/* 2 wait states required on the flash. */
|
||||
*( ( unsigned long * ) 0x40022000 ) = 0x02;
|
||||
/* 2 wait states required on the flash. */
|
||||
*( ( unsigned long * ) 0x40022000 ) = 0x02;
|
||||
|
||||
/* HCLK = SYSCLK */
|
||||
RCC_HCLKConfig( RCC_SYSCLK_Div1 );
|
||||
/* HCLK = SYSCLK */
|
||||
RCC_HCLKConfig( RCC_SYSCLK_Div1 );
|
||||
|
||||
/* PCLK2 = HCLK */
|
||||
RCC_PCLK2Config( RCC_HCLK_Div1 );
|
||||
/* PCLK2 = HCLK */
|
||||
RCC_PCLK2Config( RCC_HCLK_Div1 );
|
||||
|
||||
/* PCLK1 = HCLK/2 */
|
||||
RCC_PCLK1Config( RCC_HCLK_Div2 );
|
||||
/* PCLK1 = HCLK/2 */
|
||||
RCC_PCLK1Config( RCC_HCLK_Div2 );
|
||||
|
||||
/* PLLCLK = 8MHz * 9 = 72 MHz. */
|
||||
RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_9 );
|
||||
/* PLLCLK = 8MHz * 9 = 72 MHz. */
|
||||
RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_9 );
|
||||
|
||||
/* Enable PLL. */
|
||||
RCC_PLLCmd( ENABLE );
|
||||
/* Enable PLL. */
|
||||
RCC_PLLCmd( ENABLE );
|
||||
|
||||
/* Wait till PLL is ready. */
|
||||
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
|
||||
{
|
||||
}
|
||||
/* Wait till PLL is ready. */
|
||||
while( RCC_GetFlagStatus( RCC_FLAG_PLLRDY ) == RESET )
|
||||
{
|
||||
}
|
||||
|
||||
/* Select PLL as system clock source. */
|
||||
RCC_SYSCLKConfig( RCC_SYSCLKSource_PLLCLK );
|
||||
/* Select PLL as system clock source. */
|
||||
RCC_SYSCLKConfig( RCC_SYSCLKSource_PLLCLK );
|
||||
|
||||
/* Wait till PLL is used as system clock source. */
|
||||
while( RCC_GetSYSCLKSource() != 0x08 )
|
||||
{
|
||||
}
|
||||
/* Wait till PLL is used as system clock source. */
|
||||
while( RCC_GetSYSCLKSource() != 0x08 )
|
||||
{
|
||||
}
|
||||
|
||||
/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */
|
||||
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC
|
||||
| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE );
|
||||
/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */
|
||||
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC
|
||||
| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE );
|
||||
|
||||
/* SPI2 Periph clock enable */
|
||||
RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE );
|
||||
/* SPI2 Periph clock enable */
|
||||
RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE );
|
||||
|
||||
|
||||
/* Set the Vector Table base address at 0x08000000 */
|
||||
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );
|
||||
/* Set the Vector Table base address at 0x08000000 */
|
||||
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );
|
||||
|
||||
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );
|
||||
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );
|
||||
|
||||
/* Configure HCLK clock as SysTick clock source. */
|
||||
SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK );
|
||||
/* Configure HCLK clock as SysTick clock source. */
|
||||
SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK );
|
||||
|
||||
vParTestInitialise();
|
||||
vParTestInitialise();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvConfigureLCD( void )
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/* Configure LCD Back Light (PA8) as output push-pull */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init( GPIOA, &GPIO_InitStructure );
|
||||
/* Configure LCD Back Light (PA8) as output push-pull */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init( GPIOA, &GPIO_InitStructure );
|
||||
|
||||
/* Set the Backlight Pin */
|
||||
GPIO_WriteBit(GPIOA, GPIO_Pin_8, Bit_SET);
|
||||
/* Set the Backlight Pin */
|
||||
GPIO_WriteBit( GPIOA, GPIO_Pin_8, Bit_SET );
|
||||
|
||||
/* Initialize the LCD */
|
||||
LCD_Init();
|
||||
/* Initialize the LCD */
|
||||
LCD_Init();
|
||||
|
||||
/* Set the Back Color */
|
||||
LCD_SetBackColor( White );
|
||||
/* Set the Back Color */
|
||||
LCD_SetBackColor( White );
|
||||
|
||||
/* Set the Text Color */
|
||||
LCD_SetTextColor( 0x051F );
|
||||
/* Set the Text Color */
|
||||
LCD_SetTextColor( 0x051F );
|
||||
|
||||
LCD_Clear();
|
||||
LCD_Clear();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int fputc( int ch, FILE *f )
|
||||
int fputc( int ch,
|
||||
FILE * f )
|
||||
{
|
||||
static unsigned short usColumn = 0, usRefColumn = mainCOLUMN_START;
|
||||
static unsigned char ucLine = 0;
|
||||
static unsigned short usColumn = 0, usRefColumn = mainCOLUMN_START;
|
||||
static unsigned char ucLine = 0;
|
||||
|
||||
if( ( usColumn == 0 ) && ( ucLine == 0 ) )
|
||||
{
|
||||
LCD_Clear();
|
||||
}
|
||||
if( ( usColumn == 0 ) && ( ucLine == 0 ) )
|
||||
{
|
||||
LCD_Clear();
|
||||
}
|
||||
|
||||
if( ch != '\n' )
|
||||
{
|
||||
/* Display one character on LCD */
|
||||
LCD_DisplayChar( ucLine, usRefColumn, (u8) ch );
|
||||
if( ch != '\n' )
|
||||
{
|
||||
/* Display one character on LCD */
|
||||
LCD_DisplayChar( ucLine, usRefColumn, ( u8 ) ch );
|
||||
|
||||
/* Decrement the column position by 16 */
|
||||
usRefColumn -= mainCOLUMN_INCREMENT;
|
||||
/* Decrement the column position by 16 */
|
||||
usRefColumn -= mainCOLUMN_INCREMENT;
|
||||
|
||||
/* Increment the character counter */
|
||||
usColumn++;
|
||||
if( usColumn == mainMAX_COLUMN )
|
||||
{
|
||||
ucLine += mainROW_INCREMENT;
|
||||
usRefColumn = mainCOLUMN_START;
|
||||
usColumn = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Move back to the first column of the next line. */
|
||||
ucLine += mainROW_INCREMENT;
|
||||
usRefColumn = mainCOLUMN_START;
|
||||
usColumn = 0;
|
||||
}
|
||||
/* Increment the character counter */
|
||||
usColumn++;
|
||||
|
||||
/* Wrap back to the top of the display. */
|
||||
if( ucLine >= mainMAX_LINE )
|
||||
{
|
||||
ucLine = 0;
|
||||
}
|
||||
if( usColumn == mainMAX_COLUMN )
|
||||
{
|
||||
ucLine += mainROW_INCREMENT;
|
||||
usRefColumn = mainCOLUMN_START;
|
||||
usColumn = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Move back to the first column of the next line. */
|
||||
ucLine += mainROW_INCREMENT;
|
||||
usRefColumn = mainCOLUMN_START;
|
||||
usColumn = 0;
|
||||
}
|
||||
|
||||
return ch;
|
||||
/* Wrap back to the top of the display. */
|
||||
if( ucLine >= mainMAX_LINE )
|
||||
{
|
||||
ucLine = 0;
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Keep the linker happy. */
|
||||
void assert_failed( unsigned char* pcFile, unsigned long ulLine )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
}
|
||||
}
|
||||
void assert_failed( unsigned char * pcFile,
|
||||
unsigned long ulLine )
|
||||
{
|
||||
for( ; ; )
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue