TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
TM_PWMIN_Functions

Library Functions. More...

Functions

TM_PWMIN_Result_t TM_PWMIN_InitTimer (TIM_TypeDef *TIMx, TM_PWMIN_t *PWMIN_Data, TM_PWMIN_Channel_t PWMIN_Channel, TM_PWMIN_PinsPack_t PinsPack, float MinExpectedFrequency, IRQn_Type TIMx_IRQn)
 Initializes and prepares timer for PWM input capture. More...
 
TM_PWMIN_Result_t TM_PWMIN_Get (TM_PWMIN_t *PWMIN_Data)
 Reads data from measured input PWM signal. More...
 
TM_PWMIN_Result_t TM_PWMIN_InterruptHandler (TM_PWMIN_t *PWMIN_Data)
 Most important function. This function handles TIMx interrupts to calculate PWM input data. More...
 

Detailed Description

Library Functions.

Function Documentation

TM_PWMIN_Result_t TM_PWMIN_Get ( TM_PWMIN_t PWMIN_Data)

Reads data from measured input PWM signal.

Note
Data are valid if frequency is greater than 0
Parameters
*PWMIN_DataPointer to TM_PWMIN_t struct. Frequency and Duty cycle will be stored in this structure.
Return values
Memberof TM_PWMIN_Result_t
TM_PWMIN_Result_t TM_PWMIN_InitTimer ( TIM_TypeDef *  TIMx,
TM_PWMIN_t PWMIN_Data,
TM_PWMIN_Channel_t  PWMIN_Channel,
TM_PWMIN_PinsPack_t  PinsPack,
float  MinExpectedFrequency,
IRQn_Type  TIMx_IRQn 
)

Initializes and prepares timer for PWM input capture.

Parameters
*TIMxPointer to TIM you will use for PWM input capture
*PWMIN_DataPointer to an empty TM_PWMIN_t structure
PWMIN_ChannelChannel you will use on timer. This parameter can be a value of TM_PWMIN_Channel_t enumeration
PinsPackPinspack you will use for your channel. This parameter can be a value of TM_PWMIN_PinsPack_t enumeration
MinExpectedFrequencyType minimal input frequency you expect in input. If you don't know what to expect, set to 1
TIMx_IRQnIRQ for NVIC settings. For TIM2 it can be TIM2_IRQn, for TIM3,4,5,... it can be TIMx_IRQn, where x is a number of timer. This parameter can be a value of IRQn_Type enumeration
Return values
Memberof TM_PWMIN_Result_t
TM_PWMIN_Result_t TM_PWMIN_InterruptHandler ( TM_PWMIN_t PWMIN_Data)

Most important function. This function handles TIMx interrupts to calculate PWM input data.

Note
You need to call it in your TIMx handler.
//For TIM2, you will do:
void TIM2_IRQHandler(void) {
    TM_PWMIN_InterruptHandler(&PWMIN_TIM2_Data);
}
Parameters
*PWMIN_DataPointer to TM_PWMIN_t structure
Return values
Memberof TM_PWMIN_Result_t