|
NinjaFlight
|
#include <stdbool.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <platform.h>#include "common/utils.h"#include "common/atomic.h"#include "nvic.h"#include "gpio.h"#include "system.h"#include "timer.h"#include "timer_impl.h"
Data Structures | |
| struct | timerConfig_s |
| struct | timerChannelInfo_t |
| struct | timerInfo_t |
Macros | |
| #define | TIM_N(n) (1 << (n)) |
| #define | USED_TIMER_COUNT BITCOUNT(USED_TIMERS) |
| #define | CC_CHANNELS_PER_TIMER 4 |
| #define | TIM_IT_CCx(ch) (TIM_IT_CC1 << ((ch) / 4)) |
| #define | TIMER_INDEX(i) BITCOUNT((TIM_N(i) - 1) & USED_TIMERS) |
| #define | _CASE_SHF 10 |
| #define | _CASE_(tim, index) case ((unsigned)tim >> _CASE_SHF): return index; break |
| #define | _CASE(i) _CASE_(TIM##i##_BASE, TIMER_INDEX(i)) |
| #define | _DEF(i) TIM##i |
| #define | _TIM_IRQ_HANDLER2(name, i, j) |
| #define | _TIM_IRQ_HANDLER(name, i) |
Typedefs | |
| typedef struct timerConfig_s | timerConfig_t |
Functions | |
| void | configTimeBase (TIM_TypeDef *tim, uint16_t period, uint8_t mhz) |
| void | timerConfigure (const timerHardware_t *timerHardwarePtr, uint16_t period, uint8_t mhz) |
| void | timerChInit (const timerHardware_t *timHw, channelType_t type, int irqPriority) |
| void | timerChCCHandlerInit (timerCCHandlerRec_t *self, timerCCHandlerCallback *fn) |
| void | timerChOvrHandlerInit (timerOvrHandlerRec_t *self, timerOvrHandlerCallback *fn) |
| void | timerChConfigCallbacks (const timerHardware_t *timHw, timerCCHandlerRec_t *edgeCallback, timerOvrHandlerRec_t *overflowCallback) |
| void | timerChConfigCallbacksDual (const timerHardware_t *timHw, timerCCHandlerRec_t *edgeCallbackLo, timerCCHandlerRec_t *edgeCallbackHi, timerOvrHandlerRec_t *overflowCallback) |
| void | timerChITConfigDualLo (const timerHardware_t *timHw, FunctionalState newState) |
| void | timerChITConfig (const timerHardware_t *timHw, FunctionalState newState) |
| void | timerChClearCCFlag (const timerHardware_t *timHw) |
| void | timerChConfigGPIO (const timerHardware_t *timHw, GPIO_Mode mode) |
| void | timerChConfigIC (const timerHardware_t *timHw, bool polarityRising, unsigned inputFilterTicks) |
| void | timerChConfigICDual (const timerHardware_t *timHw, bool polarityRising, unsigned inputFilterTicks) |
| void | timerChICPolarity (const timerHardware_t *timHw, bool polarityRising) |
| volatile timCCR_t * | timerChCCRHi (const timerHardware_t *timHw) |
| volatile timCCR_t * | timerChCCRLo (const timerHardware_t *timHw) |
| volatile timCCR_t * | timerChCCR (const timerHardware_t *timHw) |
| void | timerChConfigOC (const timerHardware_t *timHw, bool outEnable, bool stateHigh) |
| void | timerInit (void) |
| void | timerStart (void) |
| void | timerForceOverflow (TIM_TypeDef *tim) |
| #define _CASE | ( | i | ) | _CASE_(TIM##i##_BASE, TIMER_INDEX(i)) |
| #define _CASE_ | ( | tim, | |
| index | |||
| ) | case ((unsigned)tim >> _CASE_SHF): return index; break |
| #define _CASE_SHF 10 |
| #define _DEF | ( | i | ) | TIM##i |
| #define _TIM_IRQ_HANDLER | ( | name, | |
| i | |||
| ) |
| #define _TIM_IRQ_HANDLER2 | ( | name, | |
| i, | |||
| j | |||
| ) |
| #define CC_CHANNELS_PER_TIMER 4 |
| #define TIM_IT_CCx | ( | ch | ) | (TIM_IT_CC1 << ((ch) / 4)) |
| #define TIM_N | ( | n | ) | (1 << (n)) |
| #define USED_TIMER_COUNT BITCOUNT(USED_TIMERS) |
| typedef struct timerConfig_s timerConfig_t |
| void configTimeBase | ( | TIM_TypeDef * | tim, |
| uint16_t | period, | ||
| uint8_t | mhz | ||
| ) |
| void timerChCCHandlerInit | ( | timerCCHandlerRec_t * | self, |
| timerCCHandlerCallback * | fn | ||
| ) |
| volatile timCCR_t* timerChCCR | ( | const timerHardware_t * | timHw | ) |
| volatile timCCR_t* timerChCCRHi | ( | const timerHardware_t * | timHw | ) |
| volatile timCCR_t* timerChCCRLo | ( | const timerHardware_t * | timHw | ) |
| void timerChClearCCFlag | ( | const timerHardware_t * | timHw | ) |
| void timerChConfigCallbacks | ( | const timerHardware_t * | timHw, |
| timerCCHandlerRec_t * | edgeCallback, | ||
| timerOvrHandlerRec_t * | overflowCallback | ||
| ) |
| void timerChConfigCallbacksDual | ( | const timerHardware_t * | timHw, |
| timerCCHandlerRec_t * | edgeCallbackLo, | ||
| timerCCHandlerRec_t * | edgeCallbackHi, | ||
| timerOvrHandlerRec_t * | overflowCallback | ||
| ) |
| void timerChConfigGPIO | ( | const timerHardware_t * | timHw, |
| GPIO_Mode | mode | ||
| ) |

| void timerChConfigIC | ( | const timerHardware_t * | timHw, |
| bool | polarityRising, | ||
| unsigned | inputFilterTicks | ||
| ) |
| void timerChConfigICDual | ( | const timerHardware_t * | timHw, |
| bool | polarityRising, | ||
| unsigned | inputFilterTicks | ||
| ) |
| void timerChConfigOC | ( | const timerHardware_t * | timHw, |
| bool | outEnable, | ||
| bool | stateHigh | ||
| ) |
| void timerChICPolarity | ( | const timerHardware_t * | timHw, |
| bool | polarityRising | ||
| ) |
| void timerChInit | ( | const timerHardware_t * | timHw, |
| channelType_t | type, | ||
| int | irqPriority | ||
| ) |

| void timerChITConfig | ( | const timerHardware_t * | timHw, |
| FunctionalState | newState | ||
| ) |
| void timerChITConfigDualLo | ( | const timerHardware_t * | timHw, |
| FunctionalState | newState | ||
| ) |
| void timerChOvrHandlerInit | ( | timerOvrHandlerRec_t * | self, |
| timerOvrHandlerCallback * | fn | ||
| ) |
| void timerConfigure | ( | const timerHardware_t * | timerHardwarePtr, |
| uint16_t | period, | ||
| uint8_t | mhz | ||
| ) |

| void timerForceOverflow | ( | TIM_TypeDef * | tim | ) |
Force an overflow for a given timer. Saves the current value of the counter in the relevant timerConfig's forcedOverflowTimerValue variable.
| TIM_Typedef | *tim The timer to overflow |
| void timerInit | ( | void | ) |

| void timerStart | ( | void | ) |

| timerChannelInfo_t timerChannelInfo[USABLE_TIMER_CHANNEL_COUNT] |
| timerConfig_t timerConfig[USED_TIMER_COUNT] |
| timerInfo_t timerInfo[USED_TIMER_COUNT] |
| TIM_TypeDef* const usedTimers[USED_TIMER_COUNT] |