1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

OP-315 Use RTC at 65 khz as time base for task switching

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2941 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2011-03-03 04:28:34 +00:00 committed by peabody124
parent 528f74b512
commit 3e2c542eef
3 changed files with 28 additions and 2 deletions

View File

@ -75,9 +75,9 @@ NVIC value of 255. */
#if defined(DEBUG)
#define configGENERATE_RUN_TIME_STATS 1
#define INCLUDE_uxTaskGetRunTime 1
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() TaskTimerConfigure()
// Note: Using the tick count defeats the purpose here, need some timer on the scale of 10khz
#define portGET_RUN_TIME_COUNTER_VALUE() xTaskGetTickCount()
#define portGET_RUN_TIME_COUNTER_VALUE() RTC_GetCounter()
#endif

View File

@ -84,6 +84,27 @@ int32_t TaskMonitorRemove(TaskInfoRunningElem task)
}
}
/**
* Temporarily put function here for configuring RTC for task timing
* Only used in debug mode
*/
void TaskTimerConfigure( void )
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,
ENABLE);
PWR_BackupAccessCmd(ENABLE);
RCC_RTCCLKConfig(RCC_RTCCLKSource_HSE_Div128);
RCC_RTCCLKCmd(ENABLE);
RTC_WaitForLastTask();
RTC_WaitForSynchro();
RTC_WaitForLastTask();
RTC_SetPrescaler(0); // counting at 8e6 / 128
RTC_WaitForLastTask();
RTC_SetCounter(0);
RTC_WaitForLastTask();
}
/**
* Update the status of all tasks
*/

View File

@ -55,6 +55,8 @@
#ifndef PORTMACRO_H
#define PORTMACRO_H
#include "stdint.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -135,6 +137,9 @@ extern void vPortYieldFromISR( void );
extern void vPortEnterCritical( void );
extern void vPortExitCritical( void );
extern void TaskTimerConfigure( void );
extern uint32_t RTC_GetCounter( void );
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()