1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

PIOS/RTC: Add functions to get the rate. Also changed Start to Init to be more

consistent with pios.
This commit is contained in:
James Cotton 2011-03-07 15:15:33 -06:00
parent 68ac5a271c
commit bdf862a712
5 changed files with 21 additions and 5 deletions

View File

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

View File

@ -1049,6 +1049,7 @@ void PIOS_Board_Init(void) {
#if defined(PIOS_INCLUDE_SPEKTRUM)
/* SPEKTRUM init must come before comms */
PIOS_RTC_Init(); // Spektrum uses RTC to check for frame failures
PIOS_SPEKTRUM_Init();
if (PIOS_USART_Init(&pios_usart_spektrum_id, &pios_usart_spektrum_cfg)) {

View File

@ -138,7 +138,7 @@ extern void vPortYieldFromISR( void );
extern void vPortEnterCritical( void );
extern void vPortExitCritical( void );
void PIOS_RTC_Start();
void PIOS_RTC_Init();
uint32_t PIOS_RTC_Counter();
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()

View File

@ -33,7 +33,11 @@
#if defined(PIOS_INCLUDE_RTC)
void PIOS_RTC_Start()
#ifndef PIOS_RTC_PRESCALAR
#define PIOS_RTC_PRESCALAR 0
#endif
void PIOS_RTC_Init()
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,
ENABLE);
@ -44,7 +48,7 @@ void PIOS_RTC_Start()
RTC_WaitForLastTask();
RTC_WaitForSynchro();
RTC_WaitForLastTask();
RTC_SetPrescaler(0); // counting at 8e6 / 128
RTC_SetPrescaler(PIOS_RTC_PRESCALAR); // counting at 8e6 / 128
RTC_WaitForLastTask();
RTC_SetCounter(0);
RTC_WaitForLastTask();
@ -55,6 +59,15 @@ uint32_t PIOS_RTC_Counter()
return RTC_GetCounter();
}
float PIOS_RTC_Rate()
{
return (float) (8e6 / 128) / (1 + PIOS_RTC_PRESCALAR);
}
float PIOS_RTC_MsPerTick()
{
return 1000.0f / PIOS_RTC_Rate();
}
#endif

View File

@ -31,8 +31,10 @@
#define PIOS_SERVO_H
/* Public Functions */
extern void PIOS_RTC_Start();
extern void PIOS_RTC_Init();
extern uint32_t PIOS_RTC_Counter();
extern float PIOS_RTC_Rate();
extern float PIOS_RTC_MsPerTick();
#endif /* PIOS_SERVO_H */