mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-20 01:58:32 -04:00
Continue work on the SmartFusion demo.
This commit is contained in:
parent
505bee983c
commit
b42d4da7db
7 changed files with 445 additions and 563 deletions
|
@ -52,54 +52,54 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
This simple demo project runs on the STM32 Discovery board, which is
|
||||
populated with an STM32F100RB Cortex-M3 microcontroller. The discovery board
|
||||
makes an ideal low cost evaluation platform, but the 8K of RAM provided on the
|
||||
STM32F100RB does not allow the simple application to demonstrate all of all the
|
||||
FreeRTOS kernel features. Therefore, this simple demo only actively
|
||||
demonstrates task, queue, timer and interrupt functionality. In addition, the
|
||||
demo is configured to include malloc failure, idle and stack overflow hook
|
||||
functions.
|
||||
|
||||
The idle hook function:
|
||||
The idle hook function queries the amount of FreeRTOS heap space that is
|
||||
remaining (see vApplicationIdleHook() defined in this file). The demo
|
||||
application is configured use 7K or the available 8K of RAM as the FreeRTOS heap.
|
||||
Memory is only allocated from this heap during initialisation, and this demo
|
||||
only actually uses 1.6K bytes of the configured 7K available - leaving 5.4K
|
||||
bytes of heap space unallocated.
|
||||
|
||||
The main() Function:
|
||||
main() creates one software timer, one queue, and two tasks. It then starts the
|
||||
scheduler.
|
||||
|
||||
The Queue Send Task:
|
||||
The queue send task is implemented by the prvQueueSendTask() function in this
|
||||
file. prvQueueSendTask() sits in a loop that causes it to repeatedly block for
|
||||
200 milliseconds, before sending the value 100 to the queue that was created
|
||||
within main(). Once the value is sent, the task loops back around to block for
|
||||
another 200 milliseconds.
|
||||
|
||||
The Queue Receive Task:
|
||||
The queue receive task is implemented by the prvQueueReceiveTask() function
|
||||
in this file. prvQueueReceiveTask() sits in a loop that causes repeatedly
|
||||
attempt to read data from the queue that was created within main(). When data
|
||||
is received, the task checks the value of the data, and if the value equals
|
||||
the expected 100, toggles the green LED. The 'block time' parameter passed to
|
||||
the queue receive function specifies that the task should be held in the Blocked
|
||||
state indefinitely to wait for data to be available on the queue. The queue
|
||||
receive task will only leave the Blocked state when the queue send task writes
|
||||
to the queue. As the queue send task writes to the queue every 200
|
||||
milliseconds, the queue receive task leaves the Blocked state every 200
|
||||
milliseconds, and therefore toggles the green LED every 200 milliseconds.
|
||||
|
||||
The LED Software Timer and the Button Interrupt:
|
||||
The user button B1 is configured to generate an interrupt each time it is
|
||||
pressed. The interrupt service routine switches the red LED on, and resets the
|
||||
LED software timer. The LED timer has a 5000 millisecond (5 second) period, and
|
||||
uses a callback function that is defined to just turn the red LED off.
|
||||
Therefore, pressing the user button will turn the red LED on, and the LED will
|
||||
remain on until a full five seconds pass without the button being pressed.
|
||||
* This simple demo project runs on the STM32 Discovery board, which is
|
||||
* populated with an STM32F100RB Cortex-M3 microcontroller. The discovery board
|
||||
* makes an ideal low cost evaluation platform, but the 8K of RAM provided on the
|
||||
* STM32F100RB does not allow the simple application to demonstrate all of all the
|
||||
* FreeRTOS kernel features. Therefore, this simple demo only actively
|
||||
* demonstrates task, queue, timer and interrupt functionality. In addition, the
|
||||
* demo is configured to include malloc failure, idle and stack overflow hook
|
||||
* functions.
|
||||
*
|
||||
* The idle hook function:
|
||||
* The idle hook function queries the amount of FreeRTOS heap space that is
|
||||
* remaining (see vApplicationIdleHook() defined in this file). The demo
|
||||
* application is configured use 7K or the available 8K of RAM as the FreeRTOS heap.
|
||||
* Memory is only allocated from this heap during initialisation, and this demo
|
||||
* only actually uses 1.6K bytes of the configured 7K available - leaving 5.4K
|
||||
* bytes of heap space unallocated.
|
||||
*
|
||||
* The main() Function:
|
||||
* main() creates one software timer, one queue, and two tasks. It then starts the
|
||||
* scheduler.
|
||||
*
|
||||
* The Queue Send Task:
|
||||
* The queue send task is implemented by the prvQueueSendTask() function in this
|
||||
* file. prvQueueSendTask() sits in a loop that causes it to repeatedly block for
|
||||
* 200 milliseconds, before sending the value 100 to the queue that was created
|
||||
* within main(). Once the value is sent, the task loops back around to block for
|
||||
* another 200 milliseconds.
|
||||
*
|
||||
* The Queue Receive Task:
|
||||
* The queue receive task is implemented by the prvQueueReceiveTask() function
|
||||
* in this file. prvQueueReceiveTask() sits in a loop that causes repeatedly
|
||||
* attempt to read data from the queue that was created within main(). When data
|
||||
* is received, the task checks the value of the data, and if the value equals
|
||||
* the expected 100, toggles the green LED. The 'block time' parameter passed to
|
||||
* the queue receive function specifies that the task should be held in the Blocked
|
||||
* state indefinitely to wait for data to be available on the queue. The queue
|
||||
* receive task will only leave the Blocked state when the queue send task writes
|
||||
* to the queue. As the queue send task writes to the queue every 200
|
||||
* milliseconds, the queue receive task leaves the Blocked state every 200
|
||||
* milliseconds, and therefore toggles the green LED every 200 milliseconds.
|
||||
*
|
||||
* The LED Software Timer and the Button Interrupt:
|
||||
* The user button B1 is configured to generate an interrupt each time it is
|
||||
* pressed. The interrupt service routine switches the red LED on, and resets the
|
||||
* LED software timer. The LED timer has a 5000 millisecond (5 second) period, and
|
||||
* uses a callback function that is defined to just turn the red LED off.
|
||||
* Therefore, pressing the user button will turn the red LED on, and the LED will
|
||||
* remain on until a full five seconds pass without the button being pressed.
|
||||
*/
|
||||
|
||||
/* Kernel includes. */
|
||||
|
@ -472,3 +472,21 @@ volatile size_t xFreeStackSpace;
|
|||
reduced accordingly. */
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
char *pcGetTaskStatusMessage( void )
|
||||
{
|
||||
/* Not bothered about a critical section here although technically because of
|
||||
the task priorities the pointer could change it will be atomic if not near
|
||||
atomic and its not critical. */
|
||||
if( pcStatusMessage == NULL )
|
||||
{
|
||||
return "All tasks running without error";
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( char * ) pcStatusMessage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue