Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*** INCLUDES *******************************************************/
- #include "HardwareProfile.h"
- /* FreeRTOS.org includes. */
- #include "FreeRTOS.h"
- #include "task.h"
- #include "croutine.h"
- #include "list.h"
- #include "semphr.h"
- #include "queue.h"
- #include "timers.h"
- /* Standard includes. */
- #include <stdio.h>
- void vInitApp(void);
- void button1Task( void *pvParameters );
- void button2Task( void *pvParameters );
- void LEDTask( void *pvParameters );
- QueueHandle_t xQueue;
- int main(void)
- {
- vInitApp();
- xQueue = xQueueCreate( 5, sizeof( portBASE_TYPE ) );
- xTaskCreate( button1Task, "Button 1", 256, NULL, 2, NULL );
- xTaskCreate( button2Task, "Button 2", 256, NULL, 2, NULL );
- xTaskCreate( LEDTask, "LED 2", 256, NULL, 10, NULL );
- vTaskStartScheduler();
- for( ;; );
- return 0;
- }//end main
- /********************************************************************
- * Task 1
- ********************************************************************/
- void button1Task( void *pvParameters )
- {
- portBASE_TYPE xValueToSend = 0x5;
- for( ;; )
- {
- if(mGetButtonStatePB1()==1)
- xQueueSend(xQueue,(void*)&xValueToSend, portMAX_DELAY );
- }
- }
- void button2Task( void *pvParameters )
- {
- portBASE_TYPE xValueToSend = 0xA;
- for( ;; )
- {
- if(mGetButtonStatePB2()==1)
- xQueueSend(xQueue,(void*)&xValueToSend, portMAX_DELAY );
- }
- }
- void LEDTask( void *pvParameters )
- {
- portBASE_TYPE xReceivedValue;
- for( ;; )
- {
- if( xQueueReceive(xQueue, &(xReceivedValue), ( 1000 / portTICK_RATE_MS ) ) == pdPASS )
- {
- mWriteLEDs(xReceivedValue);
- }
- else
- mWriteLEDs(0);
- }
- }
- void vApplicationIdleHook( void )
- {
- // if(counter>10000)
- // mToggleLED( 1 );// Toggle LED 1
- }
- /**
- * @brief Initialise the hardware
- * - Init LED
- * - Init Buttons
- **/
- void vInitApp(void)
- {
- mInitLEDs(); /* Initialisation of LEDs */
- mInitButtons(); /* Initialisation of Button */
- }
- void __attribute__ ((__interrupt__, __auto_psv__)) _StackError(void)
- {
- while(1){
- Nop();
- }
- }
- /*-----------------------------------------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement