mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-01 11:53:53 -04:00
Prepare for V9.0.0 release:
+ Change version number from V9.0.0rc2 to V9.0.0.
This commit is contained in:
parent
e23eca901d
commit
2bd7884ace
1501 changed files with 4370 additions and 22029 deletions
251
FreeRTOS/Demo/CORTEX_M4F_CEC1302_MikroC/FreeRTOSConfig.h
Normal file
251
FreeRTOS/Demo/CORTEX_M4F_CEC1302_MikroC/FreeRTOSConfig.h
Normal file
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS 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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Set configCREATE_LOW_POWER_DEMO to one to run the simple blinky demo low power
|
||||
example, or 1 to run the more comprehensive test and demo application. See
|
||||
the comments at the top of main.c for more information. */
|
||||
#define configCREATE_LOW_POWER_DEMO 0
|
||||
|
||||
/* Some configuration is dependent on the demo being built. */
|
||||
#if( configCREATE_LOW_POWER_DEMO == 1 )
|
||||
|
||||
/* The low power demo uses a slow low power clock, so the SysTick clock,
|
||||
which is used by default by Cortex-M ports, is not used to generate the
|
||||
tick interrupt. */
|
||||
#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1
|
||||
|
||||
/* The slow clock used to generate the tick interrupt in the low power demo
|
||||
runs at 32768Hz. Ensure the clock is a multiple of the tick rate. */
|
||||
#define configTICK_RATE_HZ ( 128 )
|
||||
|
||||
/* The low power demo uses the tickless idle feature. */
|
||||
#define configUSE_TICKLESS_IDLE 1
|
||||
|
||||
#else
|
||||
|
||||
/* Some of the standard demo test tasks assume a tick rate of 1KHz, even
|
||||
though that is faster than would normally be warranted by a real
|
||||
application. */
|
||||
#define configTICK_RATE_HZ ( 1000 )
|
||||
|
||||
/* The full demo always has tasks to run so the tick will never be turned
|
||||
off. The blinky demo will use the default tickless idle implementation to
|
||||
turn the tick off. */
|
||||
#define configUSE_TICKLESS_IDLE 0
|
||||
|
||||
#endif
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||
#define configUSE_QUEUE_SETS 1
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 1
|
||||
#define configCPU_CLOCK_HZ 48000000
|
||||
#define configMAX_PRIORITIES ( 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 190 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 25 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 10 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 0
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 0
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
|
||||
/* Run time stats gathering definitions. */
|
||||
#define configGENERATE_RUN_TIME_STATS 0
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE()
|
||||
|
||||
/* This demo makes use of one or more example stats formatting functions. These
|
||||
format the raw data provided by the uxTaskGetSystemState() function in to human
|
||||
readable ASCII form. See the notes in the implementation of vTaskList() within
|
||||
FreeRTOS/Source/tasks.c for limitations. */
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* Software timer definitions. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define configTIMER_QUEUE_LENGTH 5
|
||||
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 1
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_eTaskGetState 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
|
||||
/* Cortex-M specific definitions. */
|
||||
#ifdef __NVIC_PRIO_BITS
|
||||
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
||||
#define configPRIO_BITS __NVIC_PRIO_BITS
|
||||
#else
|
||||
#define configPRIO_BITS 3 /* 7 priority levels */
|
||||
#endif
|
||||
|
||||
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||
function. */
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x7
|
||||
|
||||
/* The highest interrupt priority that can be used by any interrupt service
|
||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
|
||||
|
||||
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
|
||||
|
||||
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
|
||||
standard names. */
|
||||
#define xPortPendSVHandler PendSV_Handler
|
||||
#define vPortSVCHandler SVC_Handler
|
||||
#define xPortSysTickHandler SysTick_Handler
|
||||
|
||||
/* Cannot bracket x when using MikroC. */
|
||||
#define configASSERT( x ) if( x == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
|
||||
|
||||
/* Adjustments required to build the FreeRTOS source code when using the MikroC
|
||||
compiler follow --------------------------------------------------------------*/
|
||||
|
||||
/* NOTE! Must purge invalid paths if the MikroC project is moved. */
|
||||
/* MikroC won't build the FreeRTOS code when const is used, so remove it. */
|
||||
#define const
|
||||
|
||||
/* The compiler needs to be told functions that are only referenced by
|
||||
pointer are to be included in the build. NOTE: Omitting these lines will
|
||||
result in a run-time crash, not a linker error! */
|
||||
#pragma funcall main_full prvCheckTask prvRegTestTaskEntry1 prvRegTestTaskEntry2
|
||||
#pragma funcall vStartDynamicPriorityTasks xSuspendedTestQueue vContinuousIncrementTask vLimitedIncrementTask vCounterControlTask vQueueSendWhenSuspendedTask vQueueReceiveWhenSuspendedTask
|
||||
#pragma funcall vStartBlockingQueueTasks vBlockingQueueConsumer vBlockingQueueProducer vBlockingQueueConsumer vBlockingQueueProducer vBlockingQueueProducer vBlockingQueueConsumer
|
||||
#pragma funcall vStartMathTasks vCompetingMathTask1 vCompetingMathTask2 vCompetingMathTask3 vCompetingMathTask4
|
||||
#pragma funcall vStartEventGroupTasks prvTestSlaveTask prvTestMasterTask prvSyncTask xSyncTask2
|
||||
#pragma funcall vStartTaskNotifyTask prvNotifiedTask
|
||||
#pragma funcall vCreateBlockTimeTasks vPrimaryBlockTimeTestTask vSecondaryBlockTimeTestTask
|
||||
#pragma funcall vStartDynamicPriorityTasks vContinuousIncrementTask vLimitedIncrementTask vCounterControlTask vQueueSendWhenSuspendedTask vQueueReceiveWhenSuspendedTask
|
||||
#pragma funcall vStartGenericQueueTasks prvSendFrontAndBackTest prvLowPriorityMutexTask prvMediumPriorityMutexTask prvHighPriorityMutexTask
|
||||
#pragma funcall vStartTimerDemoTask prvTimerTestTask
|
||||
#pragma funcall prvTimerTestTask prvOneShotTimerCallback
|
||||
#pragma funcall prvTest1_CreateTimersWithoutSchedulerRunning prvAutoReloadTimerCallback prvISRAutoReloadTimerCallback prvISROneShotTimerCallback
|
||||
#pragma funcall vStartInterruptQueueTasks prvHigherPriorityNormallyEmptyTask prvHigherPriorityNormallyEmptyTask prvLowerPriorityNormallyEmptyTask prv1stHigherPriorityNormallyFullTask prv2ndHigherPriorityNormallyFullTask prvLowerPriorityNormallyFullTask
|
||||
#pragma funcall vStartBlockingQueueTasks vBlockingQueueConsumer vBlockingQueueProducer vBlockingQueueConsumer vBlockingQueueProducer vBlockingQueueProducer vBlockingQueueConsumer
|
||||
#pragma funcall vStartCountingSemaphoreTasks prvCountingSemaphoreTask
|
||||
#pragma funcall vStartRecursiveMutexTasks prvRecursiveMutexControllingTask prvRecursiveMutexBlockingTask prvRecursiveMutexPollingTask
|
||||
#pragma funcall vStartSemaphoreTasks prvSemaphoreTest
|
||||
#pragma funcall vCreateSuicidalTasks vCreateTasks
|
||||
#pragma funcall vCreateTasks vSuicidalTask vSuicidalTask
|
||||
|
||||
#define configTOGGLE_LED() do{ ulLED++; GPIO_OUTPUT_PIN_154_bit = ( ulLED & 0x01UL ); } while( 0 )
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* FREERTOS_CONFIG_H */
|
|
@ -0,0 +1,194 @@
|
|||
[DEVICE]
|
||||
Name=CEC1302
|
||||
Clock=16000000
|
||||
[MEMORY_MODEL]
|
||||
Value=0
|
||||
[BUILD_TYPE]
|
||||
Value=1
|
||||
[ACTIVE_TAB]
|
||||
Value=..\main.c
|
||||
[USE_EEPROM]
|
||||
Value=0
|
||||
[USE_HEAP]
|
||||
Value=0
|
||||
[HEAP_SIZE]
|
||||
Value=0
|
||||
[EEPROM_DEFINITION]
|
||||
Value=
|
||||
[FILES]
|
||||
Count=20
|
||||
File0=..\..\..\Source\tasks.c
|
||||
File1=..\..\..\Source\event_groups.c
|
||||
File2=..\..\..\Source\list.c
|
||||
File3=..\..\..\Source\queue.c
|
||||
File4=..\..\..\Source\timers.c
|
||||
File5=..\..\..\Source\portable\MikroC\ARM_CM4F\port.c
|
||||
File6=..\..\..\Source\portable\MemMang\heap_4.c
|
||||
File7=..\main.c
|
||||
File8=..\main_full\main_full.c
|
||||
File9=..\..\Common\Minimal\EventGroupsDemo.c
|
||||
File10=..\..\Common\Minimal\flop.c
|
||||
File11=..\..\Common\Minimal\TaskNotify.c
|
||||
File12=RegTest.c
|
||||
File13=..\main_low_power\low_power_tick_config.c
|
||||
File14=..\main_low_power\main_low_power.c
|
||||
File15=..\main_full\IntQueueTimer.c
|
||||
File16=..\..\Common\Minimal\IntQueue.c
|
||||
File17=..\..\Common\Minimal\GenQTest.c
|
||||
File18=..\..\Common\Minimal\TimerDemo.c
|
||||
File19=..\..\Common\Minimal\StaticAllocation.c
|
||||
[BINARIES]
|
||||
Count=0
|
||||
[IMAGES]
|
||||
Count=0
|
||||
ActiveImageIndex=-1
|
||||
[OPENED_FILES]
|
||||
Count=7
|
||||
File0=..\main_low_power\low_power_tick_config.c
|
||||
File1=..\main.c
|
||||
File2=..\..\..\Source\tasks.c
|
||||
File3=..\..\..\..\..\..\..\..\..\..\devtools\Mikroelektronika\mikroC PRO for ARM\Defs\CEC1302.c
|
||||
File4=..\main_full\IntQueueTimer.c
|
||||
File5=..\..\..\..\..\..\..\..\..\..\devtools\Mikroelektronika\mikroC PRO for ARM\Packages\MC_CEC1302\Uses\interrupt.h
|
||||
File6=..\..\Common\Minimal\TimerDemo.c
|
||||
[EEPROM]
|
||||
Count=0
|
||||
[ACTIVE_COMMENTS_FILES]
|
||||
Count=0
|
||||
[OTHER_FILES]
|
||||
Count=0
|
||||
[SEARCH_PATH]
|
||||
Count=13
|
||||
Path0=C:\devtools\Mikroelektronika\mikroC PRO for ARM\Defs\
|
||||
Path1=C:\devtools\Mikroelektronika\mikroC PRO for ARM\Uses\
|
||||
Path2=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Demo\CORTEX_M4F_CEC1302_MikroC\MikroC_Specific\
|
||||
Path3=C:\DevTools\Mikroelektronika\mikroC PRO for ARM\Uses\MCHP M4\
|
||||
Path4=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Source\
|
||||
Path5=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Source\portable\MikroC\ARM_CM4F\
|
||||
Path6=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Source\portable\MemMang\
|
||||
Path7=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Source\include\
|
||||
Path8=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Demo\Common\Minimal\
|
||||
Path9=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Demo\CORTEX_M4F_CEC1302_MikroC\
|
||||
Path10=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Demo\CORTEX_M4F_CEC1302_MikroC\main_full\
|
||||
Path11=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Demo\CORTEX_M4F_CEC1302_MikroC\main_low_power\
|
||||
Path12=C:\devtools\Mikroelektronika\mikroC PRO for ARM\Packages\MC_CEC1302\Uses\
|
||||
[HEADER_PATH]
|
||||
Count=6
|
||||
Path0=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Source\include\
|
||||
Path1=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Source\portable\MikroC\ARM_CM4F\
|
||||
Path2=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Demo\Common\include\
|
||||
Path3=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Demo\CORTEX_M4F_CEC1302_MikroC\
|
||||
Path4=C:\devtools\Mikroelektronika\mikroC PRO for ARM\Packages\MC_CEC1302\Uses\
|
||||
Path5=C:\E\Dev\FreeRTOS\Trial\Active\Microchip_CEC1302\WorkingCopy\Demo\CORTEX_M4F_CEC1302_MikroC\main_full\
|
||||
[HEADERS]
|
||||
Count=12
|
||||
File0=..\..\..\Source\include\deprecated_definitions.h
|
||||
File1=..\..\..\Source\include\event_groups.h
|
||||
File2=..\..\..\Source\include\list.h
|
||||
File3=..\..\..\Source\include\portable.h
|
||||
File4=..\..\..\Source\include\projdefs.h
|
||||
File5=..\..\..\Source\include\queue.h
|
||||
File6=..\..\..\Source\include\semphr.h
|
||||
File7=..\..\..\Source\include\StackMacros.h
|
||||
File8=..\..\..\Source\include\task.h
|
||||
File9=..\..\..\Source\include\timers.h
|
||||
File10=..\FreeRTOSConfig.h
|
||||
File11=..\..\..\Source\portable\MikroC\ARM_CM4F\portmacro.h
|
||||
[PLDS]
|
||||
Count=0
|
||||
[Useses]
|
||||
Count=81
|
||||
File0=C_String
|
||||
File1=C_Math
|
||||
File2=BTIMER_CEC1302
|
||||
File3=PCR_CEC1302
|
||||
File4=Interrupt_CEC1302
|
||||
File5=ADC
|
||||
File6=AES
|
||||
File7=Button
|
||||
File8=CAN_SPI
|
||||
File9=Compact_Flash
|
||||
File10=Compact_Flash_FAT16
|
||||
File11=Conversions
|
||||
File12=C_Stdlib
|
||||
File13=C_Type
|
||||
File14=EPSON_S1D13700
|
||||
File15=FFT
|
||||
File16=FIR
|
||||
File17=Glcd
|
||||
File18=Glcd_Fonts
|
||||
File19=I2C
|
||||
File20=IIR
|
||||
File21=Keypad4x4
|
||||
File22=Lcd
|
||||
File23=Lcd_Constants
|
||||
File24=Manchester
|
||||
File25=Matrices
|
||||
File26=MemManager
|
||||
File27=Mmc
|
||||
File28=Mmc_FAT16
|
||||
File29=Mmc_Fat16_Config
|
||||
File30=One_Wire
|
||||
File31=PKE
|
||||
File32=Port_Expander
|
||||
File33=PrintOut
|
||||
File34=PS2
|
||||
File35=PWM
|
||||
File36=Q15
|
||||
File37=Q31
|
||||
File38=RNG
|
||||
File39=RS485
|
||||
File40=RSA
|
||||
File41=SHA
|
||||
File42=Software_I2C
|
||||
File43=Software_SPI
|
||||
File44=Software_UART
|
||||
File45=Sound
|
||||
File46=SPI
|
||||
File47=SPI_Ethernet
|
||||
File48=SPI_Ethernet_24j600
|
||||
File49=SPI_Glcd
|
||||
File50=SPI_Lcd
|
||||
File51=SPI_Lcd8
|
||||
File52=SPI_T6963C
|
||||
File53=Sprintf
|
||||
File54=Sprinti
|
||||
File55=Sprintl
|
||||
File56=T6963C
|
||||
File57=TFT
|
||||
File58=TFT_16bit
|
||||
File59=TFT_16bit_Defs
|
||||
File60=TFT_Defs
|
||||
File61=TFT_TouchPanel
|
||||
File62=Time
|
||||
File63=TouchPanel
|
||||
File64=Trigonometry
|
||||
File65=UART
|
||||
File66=Vectors
|
||||
File67=ADC_CEC1302
|
||||
File68=BCLINK_CEC1302
|
||||
File69=GPIO_CEC1302_1
|
||||
File70=HTIMER_CEC1302
|
||||
File71=LED_CEC1302
|
||||
File72=PWM_CEC1302
|
||||
File73=RTC_CEC1302
|
||||
File74=SCANMATRIX_CEC1302
|
||||
File75=SMB_CEC1302
|
||||
File76=SPI_API_CEC1302
|
||||
File77=TACH_CEC1302
|
||||
File78=TIMER_CEC1302
|
||||
File79=UART_CEC1302
|
||||
File80=WDT_CEC1302
|
||||
[EXPANDED_NODES]
|
||||
Node0=Sources
|
||||
Count=1
|
||||
[PROGRAMMER_OPTIONS]
|
||||
Value=JTAG
|
||||
[PROGRAMMER_TYPE]
|
||||
Value=mE
|
||||
[DEBUGGER_TYPE]
|
||||
Value=CMSIS-DAP
|
||||
[AT_DEBUG_STARTUP]
|
||||
LOAD_BIN_TO_RAM=0
|
||||
START_EXEC_FROM_ADDR=0
|
||||
START_ADDR=-1
|
|
@ -0,0 +1,449 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS 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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
extern uint32_t ulRegTest1LoopCounter, ulRegTest2LoopCounter;
|
||||
|
||||
void vRegTest1Implementation( void )
|
||||
{
|
||||
__asm {
|
||||
|
||||
/* Fill the core registers with known values. */
|
||||
mov r0, #100
|
||||
mov r1, #101
|
||||
mov r2, #102
|
||||
mov r3, #103
|
||||
mov r4, #104
|
||||
mov r5, #105
|
||||
mov r6, #106
|
||||
mov r7, #107
|
||||
mov r8, #108
|
||||
mov r9, #109
|
||||
mov r10, #110
|
||||
mov r11, #111
|
||||
mov r12, #112
|
||||
|
||||
/* Fill the VFP registers with known values. */
|
||||
vmov d0, r0, r1
|
||||
vmov d1, r2, r3
|
||||
vmov d2, r4, r5
|
||||
vmov d3, r6, r7
|
||||
vmov d4, r8, r9
|
||||
vmov d5, r10, r11
|
||||
vmov d6, r0, r1
|
||||
vmov d7, r2, r3
|
||||
vmov d8, r4, r5
|
||||
vmov d9, r6, r7
|
||||
vmov d10, r8, r9
|
||||
vmov d11, r10, r11
|
||||
vmov d12, r0, r1
|
||||
vmov d13, r2, r3
|
||||
vmov d14, r4, r5
|
||||
vmov d15, r6, r7
|
||||
|
||||
reg1_loop:
|
||||
/* Check all the VFP registers still contain the values set above.
|
||||
First save registers that are clobbered by the test. */
|
||||
push ( r0-r1 )
|
||||
|
||||
vmov r0, r1, d0
|
||||
cmp r0, #100
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #101
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d1
|
||||
cmp r0, #102
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #103
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d2
|
||||
cmp r0, #104
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #105
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d3
|
||||
cmp r0, #106
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #107
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d4
|
||||
cmp r0, #108
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #109
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d5
|
||||
cmp r0, #110
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #111
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d6
|
||||
cmp r0, #100
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #101
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d7
|
||||
cmp r0, #102
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #103
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d8
|
||||
cmp r0, #104
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #105
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d9
|
||||
cmp r0, #106
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #107
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d10
|
||||
cmp r0, #108
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #109
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d11
|
||||
cmp r0, #110
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #111
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d12
|
||||
cmp r0, #100
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #101
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d13
|
||||
cmp r0, #102
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #103
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d14
|
||||
cmp r0, #104
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #105
|
||||
bne reg1_error_loopf
|
||||
vmov r0, r1, d15
|
||||
cmp r0, #106
|
||||
bne reg1_error_loopf
|
||||
cmp r1, #107
|
||||
bne reg1_error_loopf
|
||||
|
||||
/* Restore the registers that were clobbered by the test. */
|
||||
pop (r0-r1)
|
||||
|
||||
/* VFP register test passed. Jump to the core register test. */
|
||||
b reg1_loopf_pass
|
||||
|
||||
reg1_error_loopf:
|
||||
/* If this line is hit then a VFP register value was found to be
|
||||
incorrect. */
|
||||
b reg1_error_loopf
|
||||
|
||||
reg1_loopf_pass:
|
||||
|
||||
cmp r0, #100
|
||||
bne reg1_error_loop
|
||||
cmp r1, #101
|
||||
bne reg1_error_loop
|
||||
cmp r2, #102
|
||||
bne reg1_error_loop
|
||||
cmp r3, #103
|
||||
bne reg1_error_loop
|
||||
cmp r4, #104
|
||||
bne reg1_error_loop
|
||||
cmp r5, #105
|
||||
bne reg1_error_loop
|
||||
cmp r6, #106
|
||||
bne reg1_error_loop
|
||||
cmp r7, #107
|
||||
bne reg1_error_loop
|
||||
cmp r8, #108
|
||||
bne reg1_error_loop
|
||||
cmp r9, #109
|
||||
bne reg1_error_loop
|
||||
cmp r10, #110
|
||||
bne reg1_error_loop
|
||||
cmp r11, #111
|
||||
bne reg1_error_loop
|
||||
cmp r12, #112
|
||||
bne reg1_error_loop
|
||||
|
||||
/* Everything passed, increment the loop counter. */
|
||||
push ( r0-r1 )
|
||||
ldr r0, =_ulRegTest1LoopCounter
|
||||
ldr r1, [r0]
|
||||
adds r1, r1, #1
|
||||
str r1, [r0]
|
||||
pop ( r0-r1 )
|
||||
|
||||
/* Start again. */
|
||||
b reg1_loop
|
||||
|
||||
reg1_error_loop:
|
||||
/* If this line is hit then there was an error in a core register value.
|
||||
The loop ensures the loop counter stops incrementing. */
|
||||
b reg1_error_loop
|
||||
nop
|
||||
|
||||
} /* __asm */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vRegTest2Implementation( void )
|
||||
{
|
||||
__asm {
|
||||
/* Set all the core registers to known values. */
|
||||
mov r0, #-1
|
||||
mov r1, #1
|
||||
mov r2, #2
|
||||
mov r3, #3
|
||||
mov r4, #4
|
||||
mov r5, #5
|
||||
mov r6, #6
|
||||
mov r7, #7
|
||||
mov r8, #8
|
||||
mov r9, #9
|
||||
mov r10, #10
|
||||
mov r11, #11
|
||||
mov r12, #12
|
||||
|
||||
/* Set all the VFP to known values. */
|
||||
vmov d0, r0, r1
|
||||
vmov d1, r2, r3
|
||||
vmov d2, r4, r5
|
||||
vmov d3, r6, r7
|
||||
vmov d4, r8, r9
|
||||
vmov d5, r10, r11
|
||||
vmov d6, r0, r1
|
||||
vmov d7, r2, r3
|
||||
vmov d8, r4, r5
|
||||
vmov d9, r6, r7
|
||||
vmov d10, r8, r9
|
||||
vmov d11, r10, r11
|
||||
vmov d12, r0, r1
|
||||
vmov d13, r2, r3
|
||||
vmov d14, r4, r5
|
||||
vmov d15, r6, r7
|
||||
|
||||
reg2_loop:
|
||||
|
||||
/* Check all the VFP registers still contain the values set above.
|
||||
First save registers that are clobbered by the test. */
|
||||
push ( r0-r1 )
|
||||
|
||||
vmov r0, r1, d0
|
||||
cmp r0, #-1
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #1
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d1
|
||||
cmp r0, #2
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #3
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d2
|
||||
cmp r0, #4
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #5
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d3
|
||||
cmp r0, #6
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #7
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d4
|
||||
cmp r0, #8
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #9
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d5
|
||||
cmp r0, #10
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #11
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d6
|
||||
cmp r0, #-1
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #1
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d7
|
||||
cmp r0, #2
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #3
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d8
|
||||
cmp r0, #4
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #5
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d9
|
||||
cmp r0, #6
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #7
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d10
|
||||
cmp r0, #8
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #9
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d11
|
||||
cmp r0, #10
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #11
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d12
|
||||
cmp r0, #-1
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #1
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d13
|
||||
cmp r0, #2
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #3
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d14
|
||||
cmp r0, #4
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #5
|
||||
bne reg2_error_loopf
|
||||
vmov r0, r1, d15
|
||||
cmp r0, #6
|
||||
bne reg2_error_loopf
|
||||
cmp r1, #7
|
||||
bne reg2_error_loopf
|
||||
|
||||
/* Restore the registers that were clobbered by the test. */
|
||||
pop (r0-r1)
|
||||
|
||||
/* VFP register test passed. Jump to the core register test. */
|
||||
b reg2_loopf_pass
|
||||
|
||||
reg2_error_loopf:
|
||||
/* If this line is hit then a VFP register value was found to be
|
||||
incorrect. */
|
||||
b reg2_error_loopf
|
||||
|
||||
reg2_loopf_pass:
|
||||
|
||||
cmp r0, #-1
|
||||
bne reg2_error_loop
|
||||
cmp r1, #1
|
||||
bne reg2_error_loop
|
||||
cmp r2, #2
|
||||
bne reg2_error_loop
|
||||
cmp r3, #3
|
||||
bne reg2_error_loop
|
||||
cmp r4, #4
|
||||
bne reg2_error_loop
|
||||
cmp r5, #5
|
||||
bne reg2_error_loop
|
||||
cmp r6, #6
|
||||
bne reg2_error_loop
|
||||
cmp r7, #7
|
||||
bne reg2_error_loop
|
||||
cmp r8, #8
|
||||
bne reg2_error_loop
|
||||
cmp r9, #9
|
||||
bne reg2_error_loop
|
||||
cmp r10, #10
|
||||
bne reg2_error_loop
|
||||
cmp r11, #11
|
||||
bne reg2_error_loop
|
||||
cmp r12, #12
|
||||
bne reg2_error_loop
|
||||
|
||||
/* Increment the loop counter to indicate this test is still functioning
|
||||
correctly. */
|
||||
push ( r0-r1 )
|
||||
ldr r0, =_ulRegTest2LoopCounter
|
||||
ldr r1, [r0]
|
||||
adds r1, r1, #1
|
||||
str r1, [r0]
|
||||
|
||||
/* Yield to increase test coverage. */
|
||||
movs r0, #0x01
|
||||
ldr r1, =0xe000ed04 /*NVIC_INT_CTRL */
|
||||
lsl r0, r0, #28 /* Shift to PendSV bit */
|
||||
str r0, [r1]
|
||||
dsb
|
||||
|
||||
pop ( r0-r1 )
|
||||
|
||||
/* Start again. */
|
||||
b reg2_loop
|
||||
|
||||
reg2_error_loop:
|
||||
/* If this line is hit then there was an error in a core register value.
|
||||
This loop ensures the loop counter variable stops incrementing. */
|
||||
b reg2_error_loop
|
||||
|
||||
} /* __asm */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[{000214A0-0000-0000-C000-000000000046}]
|
||||
Prop3=19,2
|
||||
[InternetShortcut]
|
||||
URL=http://www.freertos.org/Microchip_CEC1302_ARM_Cortex-M4F_Low_Power_Demo.html
|
||||
IDList=
|
292
FreeRTOS/Demo/CORTEX_M4F_CEC1302_MikroC/main.c
Normal file
292
FreeRTOS/Demo/CORTEX_M4F_CEC1302_MikroC/main.c
Normal file
|
@ -0,0 +1,292 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS 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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* This project provides two demo applications. A simple blinky style project
|
||||
* that demonstrates low power tickless functionality, and a more comprehensive
|
||||
* test and demo application. The configCREATE_LOW_POWER_DEMO setting, which is
|
||||
* defined in FreeRTOSConfig.h, is used to select between the two. The simply
|
||||
* blinky low power demo is implemented and described in main_low_power.c. The
|
||||
* more comprehensive test and demo application is implemented and described in
|
||||
* main_full.c.
|
||||
*
|
||||
* This file implements the code that is not demo specific, including the
|
||||
* hardware setup and standard FreeRTOS hook functions.
|
||||
*
|
||||
* ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
|
||||
* THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
|
||||
* APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
|
||||
*
|
||||
*/
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Hardware register addresses and value. */
|
||||
#define mainVTOR ( * ( uint32_t * ) 0xE000ED08 )
|
||||
#define mainNVIC_AUX_ACTLR ( * ( uint32_t * ) 0xE000E008 )
|
||||
#define mainEC_INTERRUPT_CONTROL ( * ( volatile uint32_t * ) 0x4000FC18 )
|
||||
#define mainMMCR_PCR_PROCESSOR_CLOCK_CONTROL ( * ( volatile uint32_t * )( 0x40080120 ) )
|
||||
#define mainCPU_CLOCK_DIVIDER 1
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Configure the hardware as necessary to run this demo.
|
||||
*/
|
||||
static void prvSetupHardware( void );
|
||||
|
||||
/*
|
||||
* main_low_power() is used when configCREATE_LOW_POWER_DEMO is set to 1.
|
||||
* main_full() is used when configCREATE_LOW_POWER_DEMO is set to 0.
|
||||
*/
|
||||
#if( configCREATE_LOW_POWER_DEMO == 1 )
|
||||
|
||||
extern void main_low_power( void );
|
||||
|
||||
#else
|
||||
|
||||
extern void main_full( void );
|
||||
|
||||
/* Some of the tests and examples executed as part of the full demo make use
|
||||
of the tick hook to call API functions from an interrupt context. */
|
||||
extern void vFullDemoTickHook( void );
|
||||
|
||||
#endif /* #if configCREATE_LOW_POWER_DEMO == 1 */
|
||||
|
||||
/* Prototypes for the standard FreeRTOS callback/hook functions implemented
|
||||
within this file. */
|
||||
void vApplicationMallocFailedHook( void );
|
||||
void vApplicationIdleHook( void );
|
||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
|
||||
void vApplicationTickHook( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The variable that is incremented to represent each LED toggle. On the
|
||||
clicker hardware the LED state is set to the value of the least significant bit
|
||||
of this variable. On other hardware, where an LED is not used, the LED just
|
||||
keeps a count of the number of times the LED would otherwise have been toggled.
|
||||
See the comments in main_low_power.c and main_full.c for information on the
|
||||
expected LED toggle rate). */
|
||||
volatile uint32_t ulLED = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int main( void )
|
||||
{
|
||||
/* Configure the hardware ready to run the demo. */
|
||||
prvSetupHardware();
|
||||
|
||||
/* The configCREATE_LOW_POWER_DEMO setting is described at the top
|
||||
of this file. */
|
||||
#if( configCREATE_LOW_POWER_DEMO == 1 )
|
||||
{
|
||||
main_low_power();
|
||||
}
|
||||
#else
|
||||
{
|
||||
main_full();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Should not get here. */
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupHardware( void )
|
||||
{
|
||||
/* Disable M4 write buffer: fix MEC1322 hardware bug. */
|
||||
mainNVIC_AUX_ACTLR |= 0x07;
|
||||
|
||||
/* Set divider to 8 for 8MHz operation, MCLK in silicon chip is 64MHz,
|
||||
CPU=MCLK/Divider. */
|
||||
mainMMCR_PCR_PROCESSOR_CLOCK_CONTROL = mainCPU_CLOCK_DIVIDER;
|
||||
|
||||
/* Enable alternative NVIC vectors. */
|
||||
mainEC_INTERRUPT_CONTROL = pdTRUE;
|
||||
|
||||
/* Initialise the LED on the clicker board. */
|
||||
GPIO_Digital_Output( &GPIO_PORT_150_157, _GPIO_PINMASK_4 | _GPIO_PINMASK_5 );
|
||||
GPIO_OUTPUT_PIN_154_bit = 0;
|
||||
GPIO_OUTPUT_PIN_155_bit = 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationMallocFailedHook( void )
|
||||
{
|
||||
/* Called if a call to pvPortMalloc() fails because there is insufficient
|
||||
free memory available in the FreeRTOS heap. pvPortMalloc() is called
|
||||
internally by FreeRTOS API functions that create tasks, queues, software
|
||||
timers, and semaphores. The size of the FreeRTOS heap is set by the
|
||||
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
|
||||
|
||||
/* Force an assert. */
|
||||
configASSERT( ( volatile void * ) NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
|
||||
{
|
||||
( void ) pcTaskName;
|
||||
( void ) pxTask;
|
||||
|
||||
/* Run time stack overflow checking is performed if
|
||||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
|
||||
function is called if a stack overflow is detected. */
|
||||
|
||||
/* Force an assert. */
|
||||
configASSERT( ( volatile void * ) NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
volatile size_t xFreeHeapSpace;
|
||||
|
||||
/* This is just a trivial example of an idle hook. It is called on each
|
||||
cycle of the idle task. It must *NOT* attempt to block. In this case the
|
||||
idle task just queries the amount of FreeRTOS heap that remains. See the
|
||||
memory management section on the http://www.FreeRTOS.org web site for memory
|
||||
management options. If there is a lot of heap memory free then the
|
||||
configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
|
||||
RAM. */
|
||||
xFreeHeapSpace = xPortGetFreeHeapSize();
|
||||
|
||||
/* Remove compiler warning about xFreeHeapSpace being set but never used. */
|
||||
( void ) xFreeHeapSpace;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationTickHook( void )
|
||||
{
|
||||
/* The full demo includes tests that run from the tick hook. */
|
||||
#if( configCREATE_LOW_POWER_DEMO == 0 )
|
||||
{
|
||||
/* Some of the tests and demo tasks executed by the full demo include
|
||||
interaction from an interrupt - for which the tick interrupt is used
|
||||
via the tick hook function. */
|
||||
vFullDemoTickHook();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
|
||||
implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
|
||||
used by the Idle task. */
|
||||
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
|
||||
{
|
||||
/* If the buffers to be provided to the Idle task are declared inside this
|
||||
function then they must be declared static - otherwise they will be allocated on
|
||||
the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xIdleTaskTCB;
|
||||
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Idle task's
|
||||
state will be stored. */
|
||||
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Idle task's stack. */
|
||||
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
|
||||
Note that, as the array is necessarily of type StackType_t,
|
||||
configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
|
||||
application must provide an implementation of vApplicationGetTimerTaskMemory()
|
||||
to provide the memory that is used by the Timer service task. */
|
||||
void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )
|
||||
{
|
||||
/* If the buffers to be provided to the Timer task are declared inside this
|
||||
function then they must be declared static - otherwise they will be allocated on
|
||||
the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xTimerTaskTCB;
|
||||
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Timer
|
||||
task's state will be stored. */
|
||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Timer task's stack. */
|
||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
|
||||
Note that, as the array is necessarily of type StackType_t,
|
||||
configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS 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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file initialises three timers as follows:
|
||||
*
|
||||
* Basic timer channels 0 and 1 provide the interrupts that are used with the
|
||||
* IntQ standard demo tasks, which test interrupt nesting and using queues from
|
||||
* interrupts. The interrupts use slightly different frequencies so will
|
||||
* occasionally nest.
|
||||
*
|
||||
* Basic timer channel 2 provides a much higher frequency timer that tests the
|
||||
* nesting of interrupts that don't use the FreeRTOS API.
|
||||
*
|
||||
* All the timers can nest with the tick interrupt - creating a maximum
|
||||
* interrupt nesting depth of 4 (which is shown as a max nest count of 3 as the
|
||||
* tick interrupt does not increment the nesting count variable).
|
||||
*
|
||||
*/
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo includes. */
|
||||
#include "IntQueueTimer.h"
|
||||
#include "IntQueue.h"
|
||||
|
||||
/* Library includes. */
|
||||
#include "btimer.h"
|
||||
#include "interrupt.h"
|
||||
|
||||
/* The frequencies at which the first two timers expire are slightly offset to
|
||||
ensure they don't remain synchronised. The frequency of the highest priority
|
||||
interrupt is 20 times faster so really hammers the interrupt entry and exit
|
||||
code. */
|
||||
#define tmrTIMER_0_FREQUENCY ( 2000UL )
|
||||
#define tmrTIMER_1_FREQUENCY ( 2003UL )
|
||||
#define tmrTIMER_2_FREQUENCY ( 20000UL )
|
||||
|
||||
/* The basic timer channels used for generating the three interrupts. */
|
||||
#define tmrTIMER_CHANNEL_0 0 /* At tmrTIMER_0_FREQUENCY */
|
||||
#define tmrTIMER_CHANNEL_1 1 /* At tmrTIMER_1_FREQUENCY */
|
||||
#define tmrTIMER_CHANNEL_2 2 /* At tmrTIMER_2_FREQUENCY */
|
||||
|
||||
/* The high frequency interrupt is given a priority above the maximum at which
|
||||
interrupt safe FreeRTOS calls can be made. The priority of the lower frequency
|
||||
timers must still be above the tick interrupt priority. */
|
||||
#define tmrLOWER_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1 )
|
||||
#define tmrMEDIUM_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 0 )
|
||||
#define tmrHIGHER_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY - 1 )
|
||||
|
||||
/* Hardware register locations. */
|
||||
#define tmrGIRQ23_ENABLE_SET ( * ( volatile uint32_t * ) 0x4000C130 )
|
||||
|
||||
#define tmrRECORD_NESTING_DEPTH() \
|
||||
ulNestingDepth++; \
|
||||
if( ulNestingDepth > ulMaxRecordedNestingDepth ) \
|
||||
{ \
|
||||
ulMaxRecordedNestingDepth = ulNestingDepth; \
|
||||
}
|
||||
|
||||
/* Used to count the nesting depth, and record the maximum nesting depth. */
|
||||
volatile uint32_t ulNestingDepth = 0, ulMaxRecordedNestingDepth = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vInitialiseTimerForIntQueueTest( void )
|
||||
{
|
||||
const uint32_t ulTimer0Count = configCPU_CLOCK_HZ / tmrTIMER_0_FREQUENCY;
|
||||
const uint32_t ulTimer1Count = configCPU_CLOCK_HZ / tmrTIMER_1_FREQUENCY;
|
||||
const uint32_t ulTimer2Count = configCPU_CLOCK_HZ / tmrTIMER_2_FREQUENCY;
|
||||
const uint8_t ucEnable = 1;
|
||||
|
||||
tmrGIRQ23_ENABLE_SET = 0x03;
|
||||
|
||||
/* Initialise the three timers as described at the top of this file, and
|
||||
enable their interrupts in the NVIC. */
|
||||
btimer_init( tmrTIMER_CHANNEL_0, BTIMER_AUTO_RESTART | BTIMER_COUNT_DOWN | BTIMER_INT_EN, 0, ulTimer0Count, ulTimer0Count );
|
||||
btimer_interrupt_status_get_clr( tmrTIMER_CHANNEL_0 );
|
||||
interrupt_device_enable( BTMR0_IROUTE );
|
||||
interrupt_device_nvic_priority_set( BTMR0_IROUTE, tmrLOWER_PRIORITY );
|
||||
interrupt_device_nvic_pending_clear( BTMR0_IROUTE );
|
||||
interrupt_device_nvic_enable( BTMR0_IROUTE, ucEnable );
|
||||
btimer_start( tmrTIMER_CHANNEL_0 );
|
||||
|
||||
btimer_init( tmrTIMER_CHANNEL_1, BTIMER_AUTO_RESTART | BTIMER_COUNT_DOWN | BTIMER_INT_EN, 0, ulTimer1Count, ulTimer1Count );
|
||||
btimer_interrupt_status_get_clr( tmrTIMER_CHANNEL_1 );
|
||||
interrupt_device_enable( BTMR1_IROUTE );
|
||||
interrupt_device_nvic_priority_set( BTMR1_IROUTE, tmrMEDIUM_PRIORITY );
|
||||
interrupt_device_nvic_pending_clear( BTMR1_IROUTE );
|
||||
interrupt_device_nvic_enable( BTMR1_IROUTE, ucEnable );
|
||||
btimer_start( tmrTIMER_CHANNEL_1 );
|
||||
|
||||
btimer_init( tmrTIMER_CHANNEL_2, BTIMER_AUTO_RESTART | BTIMER_COUNT_DOWN | BTIMER_INT_EN, 0, ulTimer2Count, ulTimer2Count );
|
||||
btimer_interrupt_status_get_clr( tmrTIMER_CHANNEL_2 );
|
||||
interrupt_device_enable( BTMR2_IROUTE );
|
||||
interrupt_device_nvic_priority_set( BTMR2_IROUTE, tmrHIGHER_PRIORITY );
|
||||
interrupt_device_nvic_pending_clear( BTMR2_IROUTE );
|
||||
interrupt_device_nvic_enable( BTMR2_IROUTE, ucEnable );
|
||||
btimer_start( tmrTIMER_CHANNEL_2 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The TMR0 interrupt is used for different purposes by the low power and full
|
||||
demos respectively. */
|
||||
#if( configCREATE_LOW_POWER_DEMO == 0 )
|
||||
|
||||
void NVIC_Handler_TMR0( void ) iv IVT_INT_TIMER0 ics ICS_AUTO
|
||||
{
|
||||
tmrRECORD_NESTING_DEPTH();
|
||||
|
||||
/* Call the IntQ test function for this channel. */
|
||||
portYIELD_FROM_ISR( xFirstTimerHandler() );
|
||||
|
||||
ulNestingDepth--;
|
||||
}
|
||||
|
||||
#endif /* configCREATE_LOW_POWER_DEMO */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void NVIC_Handler_TMR1( void ) iv IVT_INT_TIMER1 ics ICS_AUTO
|
||||
{
|
||||
tmrRECORD_NESTING_DEPTH();
|
||||
|
||||
/* Just testing the xPortIsInsideInterrupt() functionality. */
|
||||
configASSERT( xPortIsInsideInterrupt() == pdTRUE );
|
||||
|
||||
/* Call the IntQ test function for this channel. */
|
||||
portYIELD_FROM_ISR( xSecondTimerHandler() );
|
||||
|
||||
ulNestingDepth--;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void NVIC_Handler_TMR2( void ) iv IVT_INT_TIMER2 ics ICS_AUTO
|
||||
{
|
||||
tmrRECORD_NESTING_DEPTH();
|
||||
ulNestingDepth--;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS 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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef INT_QUEUE_TIMER_H
|
||||
#define INT_QUEUE_TIMER_H
|
||||
|
||||
void vInitialiseTimerForIntQueueTest( void );
|
||||
BaseType_t xTimer0Handler( void );
|
||||
BaseType_t xTimer1Handler( void );
|
||||
|
||||
#endif
|
||||
|
384
FreeRTOS/Demo/CORTEX_M4F_CEC1302_MikroC/main_full/main_full.c
Normal file
384
FreeRTOS/Demo/CORTEX_M4F_CEC1302_MikroC/main_full/main_full.c
Normal file
|
@ -0,0 +1,384 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS 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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* NOTE 1: This project provides two demo applications. A simple blinky style
|
||||
* project that demonstrates the tickless low power features of FreeRTOS, and a
|
||||
* more comprehensive test and demo application. The configCREATE_LOW_POWER_DEMO
|
||||
* setting in FreeRTOSConifg.h is used to select between the two. See the notes
|
||||
* on using conifgCREATE_LOW_POWER_DEMO in main.c. This file implements the
|
||||
* comprehensive test and demo version.
|
||||
*
|
||||
* NOTE 2: This file only contains the source code that is specific to the
|
||||
* full demo. Generic functions, such FreeRTOS hook functions, and functions
|
||||
* required to configure the hardware, are defined in main.c.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* main_full() creates all the demo application tasks and software timers, then
|
||||
* starts the scheduler. The web documentation provides more details of the
|
||||
* standard demo application tasks, which provide no particular functionality,
|
||||
* but do provide a good example of how to use the FreeRTOS API.
|
||||
*
|
||||
* In addition to the standard demo tasks, the following tasks and tests are
|
||||
* defined and/or created within this file:
|
||||
*
|
||||
* "Reg test" tasks - These fill both the core and floating point registers with
|
||||
* known values, then check that each register maintains its expected value for
|
||||
* the lifetime of the task. Each task uses a different set of values. The reg
|
||||
* test tasks execute with a very low priority, so get preempted very
|
||||
* frequently. A register containing an unexpected value is indicative of an
|
||||
* error in the context switching mechanism.
|
||||
*
|
||||
* "Check" task - The check task period is initially set to three seconds. The
|
||||
* task checks that all the standard demo tasks, and the register check tasks,
|
||||
* are not only still executing, but are executing without reporting any errors.
|
||||
* If the check task discovers that a task has either stalled, or reported an
|
||||
* error, then it changes its own execution period from the initial three
|
||||
* seconds, to just 200ms. The check task also toggles an LED each time it is
|
||||
* called. This provides a visual indication of the system status: If the LED
|
||||
* toggles every three seconds, then no issues have been discovered. If the LED
|
||||
* toggles every 200ms, then an issue has been discovered with at least one
|
||||
* task.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
|
||||
/* Kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "timers.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/* Standard demo application includes. */
|
||||
#include "flop.h"
|
||||
#include "GenQTest.h"
|
||||
#include "TimerDemo.h"
|
||||
#include "IntQueue.h"
|
||||
#include "EventGroupsDemo.h"
|
||||
#include "TaskNotify.h"
|
||||
#include "StaticAllocation.h"
|
||||
|
||||
/* Priorities for the demo application tasks. */
|
||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2UL )
|
||||
#define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
|
||||
/* A block time of zero simply means "don't block". */
|
||||
#define mainDONT_BLOCK ( 0UL )
|
||||
|
||||
/* The period of the check task, in ms, provided no errors have been reported by
|
||||
any of the standard demo tasks. ms are converted to the equivalent in ticks
|
||||
using the pdMS_TO_TICKS() macro constant. */
|
||||
#define mainNO_ERROR_CHECK_TASK_PERIOD pdMS_TO_TICKS( 3000UL )
|
||||
|
||||
/* The period of the check task, in ms, if an error has been reported in one of
|
||||
the standard demo tasks. ms are converted to the equivalent in ticks using the
|
||||
pdMS_TO_TICKS() macro. */
|
||||
#define mainERROR_CHECK_TASK_PERIOD pdMS_TO_TICKS( 200UL )
|
||||
|
||||
/* Parameters that are passed into the register check tasks solely for the
|
||||
purpose of ensuring parameters are passed into tasks correctly. */
|
||||
#define mainREG_TEST_TASK_1_PARAMETER ( ( void * ) 0x12345678 )
|
||||
#define mainREG_TEST_TASK_2_PARAMETER ( ( void * ) 0x87654321 )
|
||||
|
||||
/* The base period used by the timer test tasks. */
|
||||
#define mainTIMER_TEST_PERIOD ( 50 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Called by main() to run the full demo (as opposed to the blinky demo) when
|
||||
* configCREATE_LOW_POWER_DEMO is set to 0.
|
||||
*/
|
||||
void main_full( void );
|
||||
|
||||
/*
|
||||
* The check task, as described at the top of this file.
|
||||
*/
|
||||
static void prvCheckTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Some of the tests and demo tasks executed by the full demo include
|
||||
* interaction from an interrupt - for which the tick interrupt is used via the
|
||||
* tick hook function.
|
||||
*/
|
||||
void vFullDemoTickHook( void );
|
||||
|
||||
/*
|
||||
* Register check tasks, and the tasks used to write over and check the contents
|
||||
* of the FPU registers, as described at the top of this file. The nature of
|
||||
* these files necessitates that they are written in an assembly file, but the
|
||||
* entry points are kept in the C file for the convenience of checking the task
|
||||
* parameter.
|
||||
*/
|
||||
static void prvRegTestTaskEntry1( void *pvParameters );
|
||||
extern void vRegTest1Implementation( void );
|
||||
static void prvRegTestTaskEntry2( void *pvParameters );
|
||||
extern void vRegTest2Implementation( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The following two variables are used to communicate the status of the
|
||||
register check tasks to the check task. If the variables keep incrementing,
|
||||
then the register check tasks have not discovered any errors. If a variable
|
||||
stops incrementing, then an error has been found. */
|
||||
volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;
|
||||
|
||||
/* The variable that is incremented to represent each LED toggle. On the
|
||||
clicker hardware the LED state is set to the value of the least significant bit
|
||||
of this variable. */
|
||||
extern volatile uint32_t ulLED;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void main_full( void )
|
||||
{
|
||||
/* Start all the other standard demo/test tasks. They have no particular
|
||||
functionality, but do demonstrate how to use the FreeRTOS API and test the
|
||||
kernel port. */
|
||||
vStartGenericQueueTasks( tskIDLE_PRIORITY );
|
||||
vStartMathTasks( mainFLOP_TASK_PRIORITY );
|
||||
vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
|
||||
vStartEventGroupTasks();
|
||||
vStartTaskNotifyTask();
|
||||
vStartInterruptQueueTasks();
|
||||
vStartStaticallyAllocatedTasks();
|
||||
|
||||
/* Create the register check tasks, as described at the top of this file */
|
||||
xTaskCreate( prvRegTestTaskEntry1, "Reg1", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_1_PARAMETER, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvRegTestTaskEntry2, "Reg2", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
/* Create the task that performs the 'check' functionality, as described at
|
||||
the top of this file. */
|
||||
xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* If all is well, the scheduler will now be running, and the following
|
||||
line will never be reached. If the following line does execute, then
|
||||
there was insufficient FreeRTOS heap memory available for the Idle and/or
|
||||
timer tasks to be created. See the memory management section on the
|
||||
FreeRTOS web site for more details on the FreeRTOS heap
|
||||
http://www.freertos.org/a00111.html. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckTask( void *pvParameters )
|
||||
{
|
||||
TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;
|
||||
TickType_t xLastExecutionTime;
|
||||
static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;
|
||||
unsigned long ulErrorFound = pdFALSE;
|
||||
|
||||
/* Just to stop compiler warnings. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
|
||||
works correctly. */
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
|
||||
/* Cycle for ever, delaying then checking all the other tasks are still
|
||||
operating without error. The onboard LED is toggled on each iteration.
|
||||
If an error is detected then the delay period is decreased from
|
||||
mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD. This has the
|
||||
effect of increasing the rate at which the onboard LED toggles, and in so
|
||||
doing gives visual feedback of the system status. */
|
||||
for( ;; )
|
||||
{
|
||||
/* Delay until it is time to execute again. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
|
||||
|
||||
/* Check all the demo tasks (other than the flash tasks) to ensure
|
||||
that they are all still running, and that none have detected an error. */
|
||||
if( xAreIntQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorFound = 1UL << 0UL;
|
||||
}
|
||||
|
||||
if( xAreMathsTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorFound = 1UL << 1UL;
|
||||
}
|
||||
|
||||
if( xAreStaticAllocationTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorFound = 1UL << 2UL;
|
||||
}
|
||||
|
||||
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorFound = 1UL << 5UL;
|
||||
}
|
||||
|
||||
if( xAreTimerDemoTasksStillRunning( ( TickType_t ) xDelayPeriod ) != pdPASS )
|
||||
{
|
||||
ulErrorFound = 1UL << 9UL;
|
||||
}
|
||||
|
||||
if( xAreEventGroupTasksStillRunning() != pdPASS )
|
||||
{
|
||||
ulErrorFound = 1UL << 12UL;
|
||||
}
|
||||
|
||||
if( xAreTaskNotificationTasksStillRunning() != pdPASS )
|
||||
{
|
||||
ulErrorFound = 1UL << 14UL;
|
||||
}
|
||||
|
||||
/* Check that the register test 1 task is still running. */
|
||||
if( ulLastRegTest1Value == ulRegTest1LoopCounter )
|
||||
{
|
||||
ulErrorFound = 1UL << 15UL;
|
||||
}
|
||||
ulLastRegTest1Value = ulRegTest1LoopCounter;
|
||||
|
||||
/* Check that the register test 2 task is still running. */
|
||||
if( ulLastRegTest2Value == ulRegTest2LoopCounter )
|
||||
{
|
||||
ulErrorFound = 1UL << 16UL;
|
||||
}
|
||||
ulLastRegTest2Value = ulRegTest2LoopCounter;
|
||||
|
||||
/* Toggle the check LED to give an indication of the system status. If
|
||||
the LED toggles every mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then
|
||||
everything is ok. A faster toggle indicates an error. */
|
||||
configTOGGLE_LED();
|
||||
|
||||
if( ulErrorFound != pdFALSE )
|
||||
{
|
||||
/* An error has been detected in one of the tasks - flash the LED
|
||||
at a higher frequency to give visible feedback that something has
|
||||
gone wrong. */
|
||||
xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;
|
||||
}
|
||||
|
||||
configASSERT( ulErrorFound == pdFALSE );
|
||||
|
||||
/* Just testing the xPortIsInsideInterrupt() functionality. */
|
||||
configASSERT( xPortIsInsideInterrupt() == pdFALSE );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvRegTestTaskEntry1( void *pvParameters )
|
||||
{
|
||||
/* Although the regtest task is written in assembler, its entry point is
|
||||
written in C for convenience of checking the task parameter is being passed
|
||||
in correctly. */
|
||||
if( pvParameters == mainREG_TEST_TASK_1_PARAMETER )
|
||||
{
|
||||
/* Start the part of the test that is written in assembler. */
|
||||
vRegTest1Implementation();
|
||||
}
|
||||
|
||||
/* The following line will only execute if the task parameter is found to
|
||||
be incorrect. The check task will detect that the regtest loop counter is
|
||||
not being incremented and flag an error. */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvRegTestTaskEntry2( void *pvParameters )
|
||||
{
|
||||
/* Although the regtest task is written in assembler, its entry point is
|
||||
written in C for convenience of checking the task parameter is being passed
|
||||
in correctly. */
|
||||
if( pvParameters == mainREG_TEST_TASK_2_PARAMETER )
|
||||
{
|
||||
/* Start the part of the test that is written in assembler. */
|
||||
vRegTest2Implementation();
|
||||
}
|
||||
|
||||
/* The following line will only execute if the task parameter is found to
|
||||
be incorrect. The check task will detect that the regtest loop counter is
|
||||
not being incremented and flag an error. */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vFullDemoTickHook( void )
|
||||
{
|
||||
/* Some of the tests and demo tasks executed by the full demo include
|
||||
interaction from an interrupt - for which the tick interrupt is used via
|
||||
the tick hook function. */
|
||||
|
||||
/* The full demo includes a software timer demo/test that requires
|
||||
prodding periodically from the tick interrupt. */
|
||||
vTimerPeriodicISRTests();
|
||||
|
||||
/* Call the periodic event group from ISR demo. */
|
||||
vPeriodicEventGroupsProcessing();
|
||||
|
||||
/* Call the code that 'gives' a task notification from an ISR. */
|
||||
xNotifyTaskFromISR();
|
||||
}
|
|
@ -0,0 +1,353 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS 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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <limits.h>
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Library includes. */
|
||||
#include "htimer.h"
|
||||
|
||||
/* This file contains functions that will override the default implementations
|
||||
in the RTOS port layer. Therefore only build this file if the low power demo
|
||||
is being built. */
|
||||
#if( configCREATE_LOW_POWER_DEMO == 1 )
|
||||
|
||||
/* ID of the hibernation timer used to generate the tick. */
|
||||
#define mainTICK_HTIMER_ID 0
|
||||
|
||||
/* Written to the hibernation timer control register to configure the timer for
|
||||
its higher resolution. */
|
||||
#define mainHTIMER_HIGH_RESOLUTION 0
|
||||
|
||||
/* The frequency of the hibernation timer when it is running at its higher
|
||||
resolution and low resolution respectively. */
|
||||
#define mainHIGHER_RESOLUTION_TIMER_HZ ( 32787 ) /* (1000000us / 30.5us) as each LSB is 30.5us. */
|
||||
#define mainLOW_RESOLUTION_TIMER_HZ ( 8UL ) /* ( 1000ms / 125ms ) as each LSB is 0.125s. */
|
||||
|
||||
/* Some registers are accessed directly as the library is not compatible with
|
||||
all the compilers used. */
|
||||
#define lpHTIMER_PRELOAD_REGISTER ( * ( volatile uint16_t * ) 0x40009800 )
|
||||
#define lpHTIMER_COUNT_REGISTER ( * ( volatile uint16_t * ) 0x40009808 )
|
||||
#define lpEC_GIRQ17_ENABLE_SET ( * ( volatile uint32_t * ) 0x4000C0B8 )
|
||||
#define lpHTIMER_INTERRUPT_CONTROL_BIT ( 1UL << 20UL )
|
||||
|
||||
/*
|
||||
* The low power demo does not use the SysTick, so override the
|
||||
* vPortSetupTickInterrupt() function with an implementation that configures
|
||||
* the low power clock. NOTE: This function name must not be changed as it
|
||||
* is called from the RTOS portable layer.
|
||||
*/
|
||||
void vPortSetupTimerInterrupt( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The reload value to use in the timer to generate the tick interrupt -
|
||||
assumes the timer is running at its higher resolution. */
|
||||
static const uint16_t usHighResolutionReloadValue = ( mainHIGHER_RESOLUTION_TIMER_HZ / ( uint16_t ) configTICK_RATE_HZ );
|
||||
|
||||
/* Calculate how many clock increments make up a single tick period. */
|
||||
static const uint32_t ulReloadValueForOneHighResolutionTick = ( mainHIGHER_RESOLUTION_TIMER_HZ / configTICK_RATE_HZ );
|
||||
|
||||
/* Calculate the maximum number of ticks that can be suppressed when using the
|
||||
high resolution clock and low resolution clock respectively. */
|
||||
static uint32_t ulMaximumPossibleSuppressedHighResolutionTicks = 0;
|
||||
|
||||
/* As the clock is only 2KHz, it is likely a value of 1 will be too much, so
|
||||
use zero - but leave the value here to assist porting to different clock
|
||||
speeds. */
|
||||
static const uint32_t ulStoppedTimerCompensation = 0UL;
|
||||
|
||||
/* Flag set from the tick interrupt to allow the sleep processing to know if
|
||||
sleep mode was exited because of an timer interrupt or a different interrupt. */
|
||||
static volatile uint32_t ulTickFlag = pdFALSE;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void NVIC_Handler_HIB_TMR( void ) iv IVT_INT_HTIMER ics ICS_AUTO
|
||||
{
|
||||
lpHTIMER_PRELOAD_REGISTER = usHighResolutionReloadValue;
|
||||
|
||||
/* Increment the RTOS tick. */
|
||||
if( xTaskIncrementTick() != pdFALSE )
|
||||
{
|
||||
/* A context switch is required. Context switching is performed in
|
||||
the PendSV interrupt. Pend the PendSV interrupt. */
|
||||
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
|
||||
}
|
||||
|
||||
/* The CPU woke because of a tick. */
|
||||
ulTickFlag = pdTRUE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortSetupTimerInterrupt( void )
|
||||
{
|
||||
/* Cannot be a const when using the MikroC compiler. */
|
||||
ulMaximumPossibleSuppressedHighResolutionTicks = ( ( uint32_t ) USHRT_MAX ) / ulReloadValueForOneHighResolutionTick;
|
||||
|
||||
/* Set up the hibernation timer to start at the value required by the
|
||||
tick interrupt. */
|
||||
htimer_enable( mainTICK_HTIMER_ID, usHighResolutionReloadValue, mainHTIMER_HIGH_RESOLUTION );
|
||||
|
||||
/* Enable the HTIMER interrupt. Equivalent to enable_htimer0_irq(); */
|
||||
lpEC_GIRQ17_ENABLE_SET |= lpHTIMER_INTERRUPT_CONTROL_BIT;
|
||||
|
||||
/* The hibernation timer is not an auto-reload timer, so gets reset
|
||||
from within the ISR itself. For that reason it's interrupt is set
|
||||
to the highest possible priority to ensure clock slippage is minimised. */
|
||||
NVIC_SetIntPriority( IVT_INT_HTIMER, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||
NVIC_IntEnable( IVT_INT_HTIMER );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Override the default definition of vPortSuppressTicksAndSleep() that is
|
||||
weakly defined in the FreeRTOS Cortex-M port layer with a version that manages
|
||||
the hibernation timer, as the tick is generated from the low power hibernation
|
||||
timer and not the SysTick as would normally be the case on a Cortex-M. */
|
||||
void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
|
||||
{
|
||||
uint32_t ulCompleteTickPeriods, ulReloadValue, ulCompletedTimerDecrements, ulCountAfterSleep, ulCountBeforeSleep;
|
||||
eSleepModeStatus eSleepAction;
|
||||
TickType_t xModifiableIdleTime;
|
||||
|
||||
/* THIS FUNCTION IS CALLED WITH THE SCHEDULER SUSPENDED. */
|
||||
|
||||
/* Make sure the hibernation timer reload value does not overflow the
|
||||
counter. */
|
||||
if( xExpectedIdleTime > ( TickType_t ) ulMaximumPossibleSuppressedHighResolutionTicks )
|
||||
{
|
||||
xExpectedIdleTime = ( TickType_t ) ulMaximumPossibleSuppressedHighResolutionTicks;
|
||||
}
|
||||
|
||||
/* Stop the timer momentarily. The time the timer is stopped for is
|
||||
accounted for as best it can be, but using the tickless mode will
|
||||
inevitably result in some tiny drift of the time maintained by the kernel
|
||||
with respect to calendar time. Take the count value first as clearing
|
||||
the preload value also seems to clear the count. */
|
||||
ulCountBeforeSleep = ( uint32_t ) lpHTIMER_COUNT_REGISTER;
|
||||
lpHTIMER_PRELOAD_REGISTER = 0;
|
||||
|
||||
/* Calculate the reload value required to wait xExpectedIdleTime tick
|
||||
periods. -1 is used as the current time slice will already be part way
|
||||
through, the part value coming from the current timer count value. */
|
||||
ulReloadValue = ulCountBeforeSleep + ( ulReloadValueForOneHighResolutionTick * ( xExpectedIdleTime - 1UL ) );
|
||||
|
||||
if( ulReloadValue > ulStoppedTimerCompensation )
|
||||
{
|
||||
/* Compensate for the fact that the timer is going to be stopped
|
||||
momentarily. */
|
||||
ulReloadValue -= ulStoppedTimerCompensation;
|
||||
}
|
||||
|
||||
/* Enter a critical section but don't use the taskENTER_CRITICAL() method as
|
||||
that will mask interrupts that should exit sleep mode. */
|
||||
__asm { cpsid i
|
||||
dsb
|
||||
isb };
|
||||
|
||||
/* The tick flag is set to false before sleeping. If it is true when sleep
|
||||
mode is exited then sleep mode was probably exited because the tick was
|
||||
suppressed for the entire xExpectedIdleTime period. */
|
||||
ulTickFlag = pdFALSE;
|
||||
|
||||
/* If a context switch is pending then abandon the low power entry as
|
||||
the context switch might have been pended by an external interrupt that
|
||||
requires processing. */
|
||||
eSleepAction = eTaskConfirmSleepModeStatus();
|
||||
if( eSleepAction == eAbortSleep )
|
||||
{
|
||||
/* Resetart the timer from whatever remains in the counter register,
|
||||
but 0 is not a valid value. */
|
||||
ulReloadValue = ulCountBeforeSleep - ulStoppedTimerCompensation;
|
||||
|
||||
if( ulReloadValue == 0 )
|
||||
{
|
||||
ulReloadValue = ulReloadValueForOneHighResolutionTick;
|
||||
ulCompleteTickPeriods = 1UL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulCompleteTickPeriods = 0UL;
|
||||
}
|
||||
|
||||
lpHTIMER_PRELOAD_REGISTER = ( uint16_t ) ulReloadValue;
|
||||
|
||||
/* Re-enable interrupts - see comments above the cpsid instruction()
|
||||
above. */
|
||||
__asm { cpsie i
|
||||
dsb
|
||||
isb };
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write the calculated reload value, which will also start the
|
||||
timer. */
|
||||
lpHTIMER_PRELOAD_REGISTER = ( uint16_t ) ulReloadValue;
|
||||
|
||||
/* Allow the application to define some pre-sleep processing. */
|
||||
xModifiableIdleTime = xExpectedIdleTime;
|
||||
configPRE_SLEEP_PROCESSING( xModifiableIdleTime );
|
||||
|
||||
/* xExpectedIdleTime being set to 0 by configPRE_SLEEP_PROCESSING()
|
||||
means the application defined code has already executed the sleep
|
||||
instructions. */
|
||||
if( xModifiableIdleTime > 0 )
|
||||
{
|
||||
__asm { dsb
|
||||
wfi
|
||||
isb };
|
||||
}
|
||||
|
||||
/* Allow the application to define some post sleep processing. */
|
||||
configPOST_SLEEP_PROCESSING( xModifiableIdleTime );
|
||||
|
||||
/* Stop the hibernation timer. Again, the time the tiemr is stopped
|
||||
for is accounted for as best it can be, but using the tickless mode
|
||||
will inevitably result in some tiny drift of the time maintained by the
|
||||
kernel with respect to calendar time. Take the count value first as
|
||||
setting the preload to zero also seems to clear the count. */
|
||||
ulCountAfterSleep = ( uint32_t ) lpHTIMER_COUNT_REGISTER;
|
||||
lpHTIMER_PRELOAD_REGISTER = 0;
|
||||
|
||||
/* Re-enable interrupts - see comments above the cpsid instruction()
|
||||
above. */
|
||||
__asm { cpsie i
|
||||
dsb
|
||||
isb };
|
||||
|
||||
|
||||
if( ulTickFlag != pdFALSE )
|
||||
{
|
||||
/* The tick interrupt has already executed, although because this
|
||||
function is called with the scheduler suspended the actual tick
|
||||
processing will not occur until after this function has exited.
|
||||
The timer has already been reloaded to count in ticks, and can just
|
||||
continue counting down from its current value. */
|
||||
ulReloadValue = ulCountAfterSleep;
|
||||
|
||||
/* Sanity check that the timer's reload value has indeed been
|
||||
reset. */
|
||||
configASSERT( ( uint32_t ) lpHTIMER_PRELOAD_REGISTER == ulReloadValueForOneHighResolutionTick );
|
||||
|
||||
/* The tick interrupt handler will already have pended the tick
|
||||
processing in the kernel. As the pending tick will be processed as
|
||||
soon as this function exits, the tick value maintained by the tick
|
||||
is stepped forward by one less than the time spent sleeping. The
|
||||
actual stepping of the tick appears later in this function. */
|
||||
ulCompleteTickPeriods = xExpectedIdleTime - 1UL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Something other than the tick interrupt ended the sleep. How
|
||||
many complete tick periods passed while the processor was
|
||||
sleeping? */
|
||||
ulCompletedTimerDecrements = ulReloadValue - ulCountAfterSleep;
|
||||
|
||||
/* Undo the adjustment that was made to the reload value to account
|
||||
for the fact that a time slice was part way through when this
|
||||
function was called before working out how many complete tick
|
||||
periods this represents. (could have used [ulExpectedIdleTime *
|
||||
ulReloadValueForOneHighResolutionTick] instead of ulReloadValue on
|
||||
the previous line, but this way avoids the multiplication). */
|
||||
ulCompletedTimerDecrements += ( ulReloadValueForOneHighResolutionTick - ulCountBeforeSleep );
|
||||
ulCompleteTickPeriods = ulCompletedTimerDecrements / ulReloadValueForOneHighResolutionTick;
|
||||
|
||||
/* The reload value is set to whatever fraction of a single tick
|
||||
period remains. */
|
||||
ulReloadValue = ( ( ulCompleteTickPeriods + 1UL ) * ulReloadValueForOneHighResolutionTick ) - ulCompletedTimerDecrements;
|
||||
}
|
||||
|
||||
/* Cannot use a reload value of 0 - it will not start the timer. */
|
||||
if( ulReloadValue == 0 )
|
||||
{
|
||||
/* There is no fraction remaining. */
|
||||
ulReloadValue = ulReloadValueForOneHighResolutionTick;
|
||||
ulCompleteTickPeriods++;
|
||||
}
|
||||
|
||||
/* Restart the timer so it runs down from the reload value. The reload
|
||||
value will get set to the value required to generate exactly one tick
|
||||
period the next time the tick interrupt executes. */
|
||||
lpHTIMER_PRELOAD_REGISTER = ( uint16_t ) ulReloadValue;
|
||||
}
|
||||
|
||||
/* Wind the tick forward by the number of tick periods that the CPU
|
||||
remained in a low power state. */
|
||||
vTaskStepTick( ulCompleteTickPeriods );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
#endif /* configCREATE_LOW_POWER_DEMO */
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS 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. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* NOTE 1: This project provides two demo applications. A simple blinky demo
|
||||
* that demonstrates tickless low power operation, and a more comprehensive
|
||||
* test and demo application. The configCREATE_LOW_POWER_DEMO setting in
|
||||
* FreeRTOSConfig.h is used to select between the two. See the notes on using
|
||||
* configCREATE_LOW_POWER_DEMO in main.c. This file implements the low power
|
||||
* version.
|
||||
*
|
||||
* NOTE 2: This file only contains the source code that is specific to the
|
||||
* low power demo. Generic functions, such FreeRTOS hook functions, and
|
||||
* functions required to configure the hardware are defined in main.c.
|
||||
******************************************************************************
|
||||
*
|
||||
* main_low_power() creates 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. It sends the value 100 to the queue every second.
|
||||
*
|
||||
* The Queue Receive Task:
|
||||
* The queue receive task is implemented by the prvQueueReceiveTask() function
|
||||
* in this file. prvQueueReceiveTask() blocks on the queue, blipping (quickly
|
||||
* turn on then off again) the LED each time it received the value 100 from the
|
||||
* queue send task. The queue send task writes to the queue every second, so
|
||||
* the LED will blip once a second.
|
||||
*
|
||||
* The RTOS tick is turned off when the queue send task and queue receive task
|
||||
* are both in the Blocked state.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/* Priorities at which the tasks are created. */
|
||||
#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
|
||||
/* The rate at which data is sent to the queue. The 200ms value is converted
|
||||
to ticks using the portTICK_PERIOD_MS constant. */
|
||||
#define mainQUEUE_SEND_FREQUENCY_MS pdMS_TO_TICKS( 1000 )
|
||||
|
||||
/* The number of items the queue can hold. This is 1 as the receive task
|
||||
will remove items as they are added, meaning the send task should always find
|
||||
the queue empty. */
|
||||
#define mainQUEUE_LENGTH ( 1 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Called by main when configCREATE_LOW_POWER_DEMO is set to 1 in
|
||||
* main.c.
|
||||
*/
|
||||
void main_low_power( void );
|
||||
|
||||
/*
|
||||
* The tasks as described in the comments at the top of this file.
|
||||
*/
|
||||
static void prvQueueReceiveTask( void *pvParameters );
|
||||
static void prvQueueSendTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The queue used by both tasks. */
|
||||
static QueueHandle_t xQueue = NULL;
|
||||
|
||||
/* The variable that is incremented to represent each LED toggle. On the
|
||||
clicker hardware the LED state is set to the value of the least significant bit
|
||||
of this variable. On other hardware, where an LED is not used, the LED just
|
||||
keeps a count of the number of times the LED would otherwise have been toggled.
|
||||
See the comments at the top of this file for information on the expected LED
|
||||
toggle rate. */
|
||||
extern volatile uint32_t ulLED;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void main_low_power( void )
|
||||
{
|
||||
/* Create the queue. */
|
||||
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) );
|
||||
|
||||
if( xQueue != NULL )
|
||||
{
|
||||
/* Start the two tasks as described in the comments at the top of this
|
||||
file. */
|
||||
xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */
|
||||
"Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
|
||||
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
|
||||
NULL, /* The parameter passed to the task - not used in this case. */
|
||||
mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */
|
||||
NULL ); /* The task handle is not required, so NULL is passed. */
|
||||
|
||||
xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Start the tasks and timer running. */
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
|
||||
/* If all is well, the scheduler will now be running, and the following
|
||||
line will never be reached. If the following line does execute, then
|
||||
there was insufficient FreeRTOS heap memory available for the Idle and/or
|
||||
timer tasks to be created. See the memory management section on the
|
||||
FreeRTOS web site for more details on the FreeRTOS heap
|
||||
http://www.freertos.org/a00111.html. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvQueueSendTask( void *pvParameters )
|
||||
{
|
||||
TickType_t xNextWakeTime;
|
||||
const uint32_t ulValueToSend = 100UL;
|
||||
|
||||
/* Remove compiler warning about unused parameter. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Initialise xNextWakeTime - this only needs to be done once. */
|
||||
xNextWakeTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Place this task in the blocked state until it is time to run again. */
|
||||
vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
|
||||
|
||||
/* Send to the queue - causing the queue receive task to unblock and
|
||||
toggle the LED. 0 is used as the block time so the sending operation
|
||||
will not block - it shouldn't need to block as the queue should always
|
||||
be empty at this point in the code. */
|
||||
xQueueSend( xQueue, &ulValueToSend, 0U );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvQueueReceiveTask( void *pvParameters )
|
||||
{
|
||||
uint32_t ulReceivedValue;
|
||||
const uint32_t ulExpectedValue = 100UL;
|
||||
const TickType_t xShortDelay = pdMS_TO_TICKS( 10 );
|
||||
|
||||
/* Remove compiler warning about unused parameter. */
|
||||
( void ) pvParameters;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until something arrives in the queue - this task will block
|
||||
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
|
||||
FreeRTOSConfig.h. */
|
||||
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
|
||||
|
||||
/* To get here something must have been received from the queue, but
|
||||
is it the expected value? If it is, toggle the LED. */
|
||||
if( ulReceivedValue == ulExpectedValue )
|
||||
{
|
||||
/* Blip the LED briefly to show the demo is running, but without
|
||||
leaving the LED on too long as energy is being conserved. */
|
||||
configTOGGLE_LED();
|
||||
vTaskDelay( xShortDelay );
|
||||
configTOGGLE_LED();
|
||||
|
||||
ulReceivedValue = 0U;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue