| BlueNRG-1 Peripherals drivers APIs

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

BlueNRG1_mft.h
Go to the documentation of this file.
1
23 /* Define to prevent recursive inclusion -------------------------------------*/
24 #ifndef BLUENRG1_MFT_H
25 #define BLUENRG1_MFT_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Includes ------------------------------------------------------------------*/
32 #include "BlueNRG1.h"
33
49 typedef struct
50 {
51 uint8_t MFT_Mode;
54 uint8_t MFT_Clock1;
57 uint8_t MFT_Clock2;
60 uint8_t MFT_Prescaler;
62 uint16_t MFT_CRA;
64 uint16_t MFT_CRB;
66 } MFT_InitType;
67
68
82 #define IS_MFT(PERIPH) (((PERIPH) == MFT1) || ((PERIPH) == MFT2))
83
92 #define MFT_MODE_1 ((uint8_t)0x00)
93 #define MFT_MODE_1a ((uint8_t)0x80)
94 #define MFT_MODE_2 ((uint8_t)0x01)
95 #define MFT_MODE_3 ((uint8_t)0x02)
96 #define MFT_MODE_4 ((uint8_t)0x03)
98 #define IS_MFT_MODE(MODE) (((MODE) == MFT_MODE_1) || \
99 ((MODE) == MFT_MODE_1a) || \
100 ((MODE) == MFT_MODE_2) || \
101 ((MODE) == MFT_MODE_3) || \
102 ((MODE) == MFT_MODE_4))
103
112 #define MFT_IT_TNA ((uint32_t)0x1)
113 #define MFT_IT_TNB ((uint32_t)0x2)
114 #define MFT_IT_TNC ((uint32_t)0x4)
115 #define MFT_IT_TND ((uint32_t)0x8)
117 #define IS_MFT_INTERRUPT(IT) ((((IT) & (~0xF)) == 0x00) && ((IT) != 0x00))
118
127 #define MFT_NO_CLK ((uint8_t)0x00)
128 #define MFT_PRESCALED_CLK ((uint8_t)0x01)
129 #define MFT_EXTERNAL_EVENT ((uint8_t)0x02)
130 #define MFT_PULSE_ACCUMULATE ((uint8_t)0x03)
131 #define MFT_LOW_SPEED_CLK ((uint8_t)0x04)
133 #define IS_MFT_CLOCK_SEL(MODE) (((MODE) == MFT_NO_CLK) || \
134 ((MODE) == MFT_PRESCALED_CLK) || \
135 ((MODE) == MFT_EXTERNAL_EVENT) || \
136 ((MODE) == MFT_PULSE_ACCUMULATE) || \
137 ((MODE) == MFT_LOW_SPEED_CLK))
138
148 #define MFT_FALLING ((uint32_t)0x0) /* on rising edge */
149 #define MFT_RISING ((uint32_t)0x1) /* on falling edge */
150
151 #define IS_MFT_Tn_EDGE(REG) (((REG) == MFT_FALLING) || ((REG) == MFT_RISING) )
152
161 #define MFT_TnB_TRIGGER ((uint32_t)0x0) /* trigger on TnB edge */
162 #define MFT_SOFTWARE_TRIGGER ((uint32_t)0x1) /* trigger software */
163
164 #define IS_MFT_PULSETRAIN_TRIGGER(MODE) (((MODE) == MFT_TnB_TRIGGER) || ((MODE) == MFT_SOFTWARE_TRIGGER))
165
174 #define MFT_TnA 0 /* select internal pin TnA */
175 #define MFT_TnB 1 /* select internal pin TnB */
176
177 #define IS_MFT_TnX(VALUE) (((VALUE) == MFT_TnA) || ((VALUE) == MFT_TnB))
178
187 #define MFT_PWM0_PIN GPIO_Pin_2 /* The PWM0 pin */
188 #define MFT_PWM1_PIN GPIO_Pin_3 /* The PWM1 pin */
189
190 #define IS_MFT_PWMX_PIN(VALUE) (((VALUE) == MFT_PWM0_PIN) || ((VALUE) == MFT_PWM1_PIN))
191
201 #define MFT1_TIMERA ((uint32_t)0x0) /* Timer MFT1 and input TnA */
202 #define MFT1_TIMERB ((uint32_t)0x1) /* Timer MFT1 and input TnB */
203 #define MFT2_TIMERA ((uint32_t)0x2) /* Timer MFT2 and input TnA */
204 #define MFT2_TIMERB ((uint32_t)0x3) /* Timer MFT2 and input TnB */
205
206 #define IS_MFT_TIMER(VALUE) ((VALUE) <= 3)
207
208 #define IS_MFT_INPUT_IO(VALUE) ((VALUE) < 15)
209
222 void MFT_DeInit(MFT_Type* MFTx);
223 void MFT_Init(MFT_Type* MFTx, MFT_InitType* MFT_InitStruct);
224 void MFT_Cmd(MFT_Type* MFTx, FunctionalState NewState);
225 void MFT_StructInit(MFT_InitType* MFT_InitStruct);
226 void MFT_TnEDGES(MFT_Type* MFTx, uint32_t MFT_TnA_edge, uint32_t MFT_TnB_edge);
227 void MFT_PulseTrainTriggerSelect(MFT_Type* MFTx, uint32_t MFT_Trigger);
228 void MFT_PulseTrainSoftwareTrigger(MFT_Type* MFTx);
229 void MFT_TnXEN(MFT_Type* MFTx, uint8_t TnX, FunctionalState NewState);
230 void MFT_SelectCapturePin( uint32_t MFT_TimerType, uint8_t MFT_Pin);
231 void MFT_SetCounter(MFT_Type* MFTx, uint16_t MFT_Cnt1, uint16_t MFT_Cnt2);
232 void MFT_SetCounter1(MFT_Type* MFTx, uint16_t MFT_Cnt);
233 uint16_t MFT_GetCounter1(MFT_Type* MFTx);
234 void MFT_SetCounter2(MFT_Type* MFTx, uint16_t MFT_Cnt);
235 uint16_t MFT_GetCounter2(MFT_Type* MFTx);
236 void MFT_EnableIT(MFT_Type* MFTx, uint8_t MFT_IrqSource, FunctionalState NewState);
237 void MFT_ClearIT(MFT_Type* MFTx, uint8_t MFT_IrqSource);
238 ITStatus MFT_StatusIT(MFT_Type* MFTx, uint8_t MFT_IrqSource);
239
240
253 #ifdef __cplusplus
254 }
255 #endif
256
257 #endif /*BLUENRG1_MFT_H */
258
259 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
MFT_SetCounter1
void MFT_SetCounter1(MFT_Type *MFTx, uint16_t MFT_Cnt)
Set the timer counter1.
Definition: BlueNRG1_mft.c:308
MFT_Init
void MFT_Init(MFT_Type *MFTx, MFT_InitType *MFT_InitStruct)
Initializes the MFTx peripheral according to the specified parameters in the MFT_InitStruct.
Definition: BlueNRG1_mft.c:102
MFT_GetCounter2
uint16_t MFT_GetCounter2(MFT_Type *MFTx)
Get the timer counter2.
Definition: BlueNRG1_mft.c:353
MFT_EnableIT
void MFT_EnableIT(MFT_Type *MFTx, uint8_t MFT_IrqSource, FunctionalState NewState)
Enable specific MFT interrupt.
Definition: BlueNRG1_mft.c:374
MFT_TnXEN
void MFT_TnXEN(MFT_Type *MFTx, uint8_t TnX, FunctionalState NewState)
Set or Reset TnAEN bit.
Definition: BlueNRG1_mft.c:235
MFT_StructInit
void MFT_StructInit(MFT_InitType *MFT_InitStruct)
Fills each MFT_InitStruct member with its default value.
Definition: BlueNRG1_mft.c:142
MFT_PulseTrainSoftwareTrigger
void MFT_PulseTrainSoftwareTrigger(MFT_Type *MFTx)
Pulse-train trigger generation in Mode 1a.
Definition: BlueNRG1_mft.c:217
MFT_ClearIT
void MFT_ClearIT(MFT_Type *MFTx, uint8_t MFT_IrqSource)
Clear specific MFT interrupt.
Definition: BlueNRG1_mft.c:399
MFT_InitType::MFT_CRB
uint16_t MFT_CRB
Definition: BlueNRG1_mft.h:64
MFT_InitType::MFT_Clock1
uint8_t MFT_Clock1
Definition: BlueNRG1_mft.h:54
MFT_SelectCapturePin
void MFT_SelectCapturePin(uint32_t MFT_TimerType, uint8_t MFT_Pin)
Set or Reset TnAEN bit.
Definition: BlueNRG1_mft.c:261
MFT_StatusIT
ITStatus MFT_StatusIT(MFT_Type *MFTx, uint8_t MFT_IrqSource)
Return interrupt status.
Definition: BlueNRG1_mft.c:419
MFT_DeInit
void MFT_DeInit(MFT_Type *MFTx)
DeInit the MFTx peripheral.
Definition: BlueNRG1_mft.c:84
MFT_InitType::MFT_Prescaler
uint8_t MFT_Prescaler
Definition: BlueNRG1_mft.h:60
MFT_InitType
Structure definition of MFT initialization.
Definition: BlueNRG1_mft.h:49
MFT_TnEDGES
void MFT_TnEDGES(MFT_Type *MFTx, uint32_t MFT_TnA_edge, uint32_t MFT_TnB_edge)
Configure edges sensibility of TnA and TnB.
Definition: BlueNRG1_mft.c:184
MFT_InitType::MFT_Clock2
uint8_t MFT_Clock2
Definition: BlueNRG1_mft.h:57
MFT_SetCounter2
void MFT_SetCounter2(MFT_Type *MFTx, uint16_t MFT_Cnt)
Set the timer counter2.
Definition: BlueNRG1_mft.c:338
MFT_InitType::MFT_CRA
uint16_t MFT_CRA
Definition: BlueNRG1_mft.h:62
MFT_GetCounter1
uint16_t MFT_GetCounter1(MFT_Type *MFTx)
Get the timer counter1.
Definition: BlueNRG1_mft.c:323
MFT_Cmd
void MFT_Cmd(MFT_Type *MFTx, FunctionalState NewState)
Enable/Disable the MFT.
Definition: BlueNRG1_mft.c:160
MFT_InitType::MFT_Mode
uint8_t MFT_Mode
Definition: BlueNRG1_mft.h:51
MFT_SetCounter
void MFT_SetCounter(MFT_Type *MFTx, uint16_t MFT_Cnt1, uint16_t MFT_Cnt2)
Set the timer counter.
Definition: BlueNRG1_mft.c:291
MFT_PulseTrainTriggerSelect
void MFT_PulseTrainTriggerSelect(MFT_Type *MFTx, uint32_t MFT_Trigger)
Select trigger source for pulse-train generation in Mode 1a.
Definition: BlueNRG1_mft.c:203