|
|
|
|
@@ -3,7 +3,6 @@
|
|
|
|
|
#define __Stm32F4_Encoder_H__
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define GPIO_Speed_50MHz 0x02 /*!< Fast speed */
|
|
|
|
|
|
|
|
|
|
// #define GPIO_MODER_MODER0 ((uint32_t)0x00000003)
|
|
|
|
|
@@ -34,9 +33,6 @@
|
|
|
|
|
#define GPIO_Pin_15 ((uint16_t)0x8000) /* Pin 15 selected */
|
|
|
|
|
#define GPIO_Pin_All ((uint16_t)0xFFFF) /* All pins selected */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct TIM_TimeBaseInitTypeDef
|
|
|
|
|
{
|
|
|
|
|
uint16_t TIM_Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
|
|
|
|
|
@@ -62,17 +58,12 @@ typedef struct TIM_TimeBaseInitTypeDef
|
|
|
|
|
@note This parameter is valid only for TIM1 and TIM8. */
|
|
|
|
|
} TIM_TimeBaseInitTypeDef;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
uint16_t setcount;
|
|
|
|
|
|
|
|
|
|
} encoder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
uint16_t TIM_OCMode; /*!< Specifies the TIM mode.
|
|
|
|
|
@@ -104,8 +95,6 @@ typedef struct
|
|
|
|
|
@note This parameter is valid only for TIM1 and TIM8. */
|
|
|
|
|
} TIM_OCInitTypeDef;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@@ -125,8 +114,6 @@ typedef struct
|
|
|
|
|
This parameter can be a number between 0x0 and 0xF */
|
|
|
|
|
} TIM_ICInitTypeDef;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@@ -153,7 +140,6 @@ typedef struct
|
|
|
|
|
This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */
|
|
|
|
|
} TIM_BDTRInitTypeDef;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define GPIO_PinSource0 ((uint8_t)0x00)
|
|
|
|
|
#define GPIO_PinSource1 ((uint8_t)0x01)
|
|
|
|
|
#define GPIO_PinSource2 ((uint8_t)0x02)
|
|
|
|
|
@@ -177,8 +163,8 @@ typedef struct
|
|
|
|
|
#define GPIO_AF_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */
|
|
|
|
|
#define GPIO_AF_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
|
|
|
|
|
|
|
|
|
|
#define TIM4 ((TIM_TypeDef *) TIM4_BASE)
|
|
|
|
|
#define TIM8 ((TIM_TypeDef *) TIM8_BASE)
|
|
|
|
|
// #define TIM4 ((TIM_TypeDef *)TIM4_BASE)
|
|
|
|
|
// #define TIM8 ((TIM_TypeDef *)TIM8_BASE)
|
|
|
|
|
#define TIM_EncoderMode_TI12 ((uint16_t)0x0003)
|
|
|
|
|
#define TIM_ICPolarity_Rising ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_ICPolarity_Falling ((uint16_t)0x0002)
|
|
|
|
|
@@ -213,7 +199,6 @@ typedef struct
|
|
|
|
|
((PERIPH) == TIM13) || \
|
|
|
|
|
((PERIPH) == TIM14))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define IS_TIM_LIST2_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
|
|
|
|
|
((PERIPH) == TIM2) || \
|
|
|
|
|
((PERIPH) == TIM3) || \
|
|
|
|
|
@@ -246,8 +231,6 @@ typedef struct
|
|
|
|
|
((TIMx) == TIM5) || \
|
|
|
|
|
((TIMx) == TIM11))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OCMode_Timing ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_OCMode_Active ((uint16_t)0x0010)
|
|
|
|
|
#define TIM_OCMode_Inactive ((uint16_t)0x0020)
|
|
|
|
|
@@ -269,13 +252,11 @@ typedef struct
|
|
|
|
|
((MODE) == TIM_ForcedAction_Active) || \
|
|
|
|
|
((MODE) == TIM_ForcedAction_InActive))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OPMode_Single ((uint16_t)0x0008)
|
|
|
|
|
#define TIM_OPMode_Repetitive ((uint16_t)0x0000)
|
|
|
|
|
//#define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMode_Single) || \
|
|
|
|
|
// ((MODE) == TIM_OPMode_Repetitive))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_Channel_1 ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_Channel_2 ((uint16_t)0x0004)
|
|
|
|
|
#define TIM_Channel_3 ((uint16_t)0x0008)
|
|
|
|
|
@@ -292,7 +273,6 @@ typedef struct
|
|
|
|
|
((CHANNEL) == TIM_Channel_2) || \
|
|
|
|
|
((CHANNEL) == TIM_Channel_3))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_CKD_DIV1 ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_CKD_DIV2 ((uint16_t)0x0100)
|
|
|
|
|
#define TIM_CKD_DIV4 ((uint16_t)0x0200)
|
|
|
|
|
@@ -300,7 +280,6 @@ typedef struct
|
|
|
|
|
((DIV) == TIM_CKD_DIV2) || \
|
|
|
|
|
((DIV) == TIM_CKD_DIV4))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_CounterMode_Up ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_CounterMode_Down ((uint16_t)0x0010)
|
|
|
|
|
#define TIM_CounterMode_CenterAligned1 ((uint16_t)0x0020)
|
|
|
|
|
@@ -312,13 +291,11 @@ typedef struct
|
|
|
|
|
// ((MODE) == TIM_CounterMode_CenterAligned2) || \
|
|
|
|
|
// ((MODE) == TIM_CounterMode_CenterAligned3))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OCPolarity_High ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_OCPolarity_Low ((uint16_t)0x0002)
|
|
|
|
|
//#define IS_TIM_OC_POLARITY(POLARITY) (((POLARITY) == TIM_OCPolarity_High) || \
|
|
|
|
|
// ((POLARITY) == TIM_OCPolarity_Low))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OCNPolarity_High ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_OCNPolarity_Low ((uint16_t)0x0008)
|
|
|
|
|
//#define IS_TIM_OCN_POLARITY(POLARITY) (((POLARITY) == TIM_OCNPolarity_High) || \
|
|
|
|
|
@@ -329,43 +306,36 @@ typedef struct
|
|
|
|
|
#define IS_TIM_OUTPUT_STATE(STATE) (((STATE) == TIM_OutputState_Disable) || \
|
|
|
|
|
((STATE) == TIM_OutputState_Enable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OutputNState_Disable ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_OutputNState_Enable ((uint16_t)0x0004)
|
|
|
|
|
#define IS_TIM_OUTPUTN_STATE(STATE) (((STATE) == TIM_OutputNState_Disable) || \
|
|
|
|
|
((STATE) == TIM_OutputNState_Enable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_CCx_Enable ((uint16_t)0x0001)
|
|
|
|
|
#define TIM_CCx_Disable ((uint16_t)0x0000)
|
|
|
|
|
#define IS_TIM_CCX(CCX) (((CCX) == TIM_CCx_Enable) || \
|
|
|
|
|
((CCX) == TIM_CCx_Disable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_CCxN_Enable ((uint16_t)0x0004)
|
|
|
|
|
#define TIM_CCxN_Disable ((uint16_t)0x0000)
|
|
|
|
|
#define IS_TIM_CCXN(CCXN) (((CCXN) == TIM_CCxN_Enable) || \
|
|
|
|
|
((CCXN) == TIM_CCxN_Disable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_Break_Enable ((uint16_t)0x1000)
|
|
|
|
|
#define TIM_Break_Disable ((uint16_t)0x0000)
|
|
|
|
|
//#define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_Break_Enable) || \
|
|
|
|
|
// ((STATE) == TIM_Break_Disable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_BreakPolarity_Low ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_BreakPolarity_High ((uint16_t)0x2000)
|
|
|
|
|
//#define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BreakPolarity_Low) || \
|
|
|
|
|
// ((POLARITY) == TIM_BreakPolarity_High))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_AutomaticOutput_Enable ((uint16_t)0x4000)
|
|
|
|
|
#define TIM_AutomaticOutput_Disable ((uint16_t)0x0000)
|
|
|
|
|
//#define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AutomaticOutput_Enable) || \
|
|
|
|
|
// ((STATE) == TIM_AutomaticOutput_Disable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_LOCKLevel_OFF ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_LOCKLevel_1 ((uint16_t)0x0100)
|
|
|
|
|
#define TIM_LOCKLevel_2 ((uint16_t)0x0200)
|
|
|
|
|
@@ -375,19 +345,16 @@ typedef struct
|
|
|
|
|
// ((LEVEL) == TIM_LOCKLevel_2) || \
|
|
|
|
|
// ((LEVEL) == TIM_LOCKLevel_3))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OSSIState_Enable ((uint16_t)0x0400)
|
|
|
|
|
#define TIM_OSSIState_Disable ((uint16_t)0x0000)
|
|
|
|
|
//#define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSIState_Enable) || \
|
|
|
|
|
// ((STATE) == TIM_OSSIState_Disable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OSSRState_Enable ((uint16_t)0x0800)
|
|
|
|
|
#define TIM_OSSRState_Disable ((uint16_t)0x0000)
|
|
|
|
|
//#define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSRState_Enable) || \
|
|
|
|
|
// ((STATE) == TIM_OSSRState_Disable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OCIdleState_Set ((uint16_t)0x0100)
|
|
|
|
|
#define TIM_OCIdleState_Reset ((uint16_t)0x0000)
|
|
|
|
|
//#define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIdleState_Set) || \
|
|
|
|
|
@@ -399,7 +366,6 @@ typedef struct
|
|
|
|
|
//#define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIdleState_Set) || \
|
|
|
|
|
// ((STATE) == TIM_OCNIdleState_Reset))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_ICPolarity_Rising ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_ICPolarity_Falling ((uint16_t)0x0002)
|
|
|
|
|
#define TIM_ICPolarity_BothEdge ((uint16_t)0x000A)
|
|
|
|
|
@@ -407,17 +373,15 @@ typedef struct
|
|
|
|
|
// ((POLARITY) == TIM_ICPolarity_Falling)|| \
|
|
|
|
|
// ((POLARITY) == TIM_ICPolarity_BothEdge))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_ICSelection_DirectTI ((uint16_t)0x0001) /*!< TIM Input 1, 2, 3 or 4 is selected to be
|
|
|
|
|
#define TIM_ICSelection_DirectTI ((uint16_t)0x0001) /*!< TIM Input 1, 2, 3 or 4 is selected to be \
|
|
|
|
|
connected to IC1, IC2, IC3 or IC4, respectively */
|
|
|
|
|
#define TIM_ICSelection_IndirectTI ((uint16_t)0x0002) /*!< TIM Input 1, 2, 3 or 4 is selected to be
|
|
|
|
|
#define TIM_ICSelection_IndirectTI ((uint16_t)0x0002) /*!< TIM Input 1, 2, 3 or 4 is selected to be \
|
|
|
|
|
connected to IC2, IC1, IC4 or IC3, respectively. */
|
|
|
|
|
#define TIM_ICSelection_TRC ((uint16_t)0x0003) /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to TRC. */
|
|
|
|
|
//#define IS_TIM_IC_SELECTION(SELECTION) (((SELECTION) == TIM_ICSelection_DirectTI) || \
|
|
|
|
|
// ((SELECTION) == TIM_ICSelection_IndirectTI) || \
|
|
|
|
|
// ((SELECTION) == TIM_ICSelection_TRC))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// #define TIM_ICPSC_DIV1 ((uint16_t)0x0000) /*!< Capture performed each time an edge is detected on the capture input. */
|
|
|
|
|
// #define TIM_ICPSC_DIV2 ((uint16_t)0x0004) /*!< Capture performed once every 2 events. */
|
|
|
|
|
// #define TIM_ICPSC_DIV4 ((uint16_t)0x0008) /*!< Capture performed once every 4 events. */
|
|
|
|
|
@@ -427,7 +391,6 @@ typedef struct
|
|
|
|
|
// ((PRESCALER) == TIM_ICPSC_DIV4) || \
|
|
|
|
|
// ((PRESCALER) == TIM_ICPSC_DIV8))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_IT_Update ((uint16_t)0x0001)
|
|
|
|
|
// #define TIM_IT_CC1 ((uint16_t)0x0002)
|
|
|
|
|
// #define TIM_IT_CC2 ((uint16_t)0x0004)
|
|
|
|
|
@@ -447,7 +410,6 @@ typedef struct
|
|
|
|
|
((IT) == TIM_IT_Trigger) || \
|
|
|
|
|
((IT) == TIM_IT_Break))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// #define TIM_DMABase_CR1 ((uint16_t)0x0000)
|
|
|
|
|
// #define TIM_DMABase_CR2 ((uint16_t)0x0001)
|
|
|
|
|
// #define TIM_DMABase_SMCR ((uint16_t)0x0002)
|
|
|
|
|
@@ -489,7 +451,6 @@ typedef struct
|
|
|
|
|
// ((BASE) == TIM_DMABase_DCR) || \
|
|
|
|
|
// ((BASE) == TIM_DMABase_OR))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// #define TIM_DMABurstLength_1Transfer ((uint16_t)0x0000)
|
|
|
|
|
// #define TIM_DMABurstLength_2Transfers ((uint16_t)0x0100)
|
|
|
|
|
// #define TIM_DMABurstLength_3Transfers ((uint16_t)0x0200)
|
|
|
|
|
@@ -527,7 +488,6 @@ typedef struct
|
|
|
|
|
// ((LENGTH) == TIM_DMABurstLength_17Transfers) || \
|
|
|
|
|
// ((LENGTH) == TIM_DMABurstLength_18Transfers))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// #define TIM_DMA_Update ((uint16_t)0x0100)
|
|
|
|
|
// #define TIM_DMA_CC1 ((uint16_t)0x0200)
|
|
|
|
|
// #define TIM_DMA_CC2 ((uint16_t)0x0400)
|
|
|
|
|
@@ -537,8 +497,6 @@ typedef struct
|
|
|
|
|
// #define TIM_DMA_Trigger ((uint16_t)0x4000)
|
|
|
|
|
// #define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0x80FF) == 0x0000) && ((SOURCE) != 0x0000))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_ExtTRGPSC_OFF ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000)
|
|
|
|
|
#define TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000)
|
|
|
|
|
@@ -548,7 +506,6 @@ typedef struct
|
|
|
|
|
((PRESCALER) == TIM_ExtTRGPSC_DIV4) || \
|
|
|
|
|
((PRESCALER) == TIM_ExtTRGPSC_DIV8))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// #define TIM_TS_ITR0 ((uint16_t)0x0000)
|
|
|
|
|
// #define TIM_TS_ITR1 ((uint16_t)0x0010)
|
|
|
|
|
// #define TIM_TS_ITR2 ((uint16_t)0x0020)
|
|
|
|
|
@@ -570,18 +527,15 @@ typedef struct
|
|
|
|
|
((SELECTION) == TIM_TS_ITR2) || \
|
|
|
|
|
((SELECTION) == TIM_TS_ITR3))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_TIxExternalCLK1Source_TI1 ((uint16_t)0x0050)
|
|
|
|
|
#define TIM_TIxExternalCLK1Source_TI2 ((uint16_t)0x0060)
|
|
|
|
|
#define TIM_TIxExternalCLK1Source_TI1ED ((uint16_t)0x0040)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000)
|
|
|
|
|
#define TIM_ExtTRGPolarity_NonInverted ((uint16_t)0x0000)
|
|
|
|
|
#define IS_TIM_EXT_POLARITY(POLARITY) (((POLARITY) == TIM_ExtTRGPolarity_Inverted) || \
|
|
|
|
|
((POLARITY) == TIM_ExtTRGPolarity_NonInverted))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_PSCReloadMode_Update ((uint16_t)0x0000)
|
|
|
|
|
#define TIM_PSCReloadMode_Immediate ((uint16_t)0x0001)
|
|
|
|
|
#define IS_TIM_PRESCALER_RELOAD(RELOAD) (((RELOAD) == TIM_PSCReloadMode_Update) || \
|
|
|
|
|
@@ -592,7 +546,6 @@ typedef struct
|
|
|
|
|
#define IS_TIM_FORCED_ACTION(ACTION) (((ACTION) == TIM_ForcedAction_Active) || \
|
|
|
|
|
((ACTION) == TIM_ForcedAction_InActive))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_EncoderMode_TI1 ((uint16_t)0x0001)
|
|
|
|
|
#define TIM_EncoderMode_TI2 ((uint16_t)0x0002)
|
|
|
|
|
#define TIM_EncoderMode_TI12 ((uint16_t)0x0003)
|
|
|
|
|
@@ -600,7 +553,6 @@ typedef struct
|
|
|
|
|
// ((MODE) == TIM_EncoderMode_TI2) || \
|
|
|
|
|
// ((MODE) == TIM_EncoderMode_TI12))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// #define TIM_EventSource_Update ((uint16_t)0x0001)
|
|
|
|
|
// #define TIM_EventSource_CC1 ((uint16_t)0x0002)
|
|
|
|
|
// #define TIM_EventSource_CC2 ((uint16_t)0x0004)
|
|
|
|
|
@@ -611,28 +563,23 @@ typedef struct
|
|
|
|
|
// #define TIM_EventSource_Break ((uint16_t)0x0080)
|
|
|
|
|
// #define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0xFF00) == 0x0000) && ((SOURCE) != 0x0000))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow
|
|
|
|
|
or the setting of UG bit, or an update generation
|
|
|
|
|
#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow \
|
|
|
|
|
or the setting of UG bit, or an update generation \
|
|
|
|
|
through the slave mode controller. */
|
|
|
|
|
#define TIM_UpdateSource_Regular ((uint16_t)0x0001) /*!< Source of update is counter overflow/underflow. */
|
|
|
|
|
#define IS_TIM_UPDATE_SOURCE(SOURCE) (((SOURCE) == TIM_UpdateSource_Global) || \
|
|
|
|
|
((SOURCE) == TIM_UpdateSource_Regular))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OCPreload_Enable ((uint16_t)0x0008)
|
|
|
|
|
#define TIM_OCPreload_Disable ((uint16_t)0x0000)
|
|
|
|
|
#define IS_TIM_OCPRELOAD_STATE(STATE) (((STATE) == TIM_OCPreload_Enable) || \
|
|
|
|
|
((STATE) == TIM_OCPreload_Disable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OCFast_Enable ((uint16_t)0x0004)
|
|
|
|
|
#define TIM_OCFast_Disable ((uint16_t)0x0000)
|
|
|
|
|
#define IS_TIM_OCFAST_STATE(STATE) (((STATE) == TIM_OCFast_Enable) || \
|
|
|
|
|
((STATE) == TIM_OCFast_Disable))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_OCClear_Enable ((uint16_t)0x0080)
|
|
|
|
|
#define TIM_OCClear_Disable ((uint16_t)0x0000)
|
|
|
|
|
#define IS_TIM_OCCLEAR_STATE(STATE) (((STATE) == TIM_OCClear_Enable) || \
|
|
|
|
|
@@ -655,9 +602,6 @@ typedef struct
|
|
|
|
|
// ((SOURCE) == TIM_TRGOSource_OC3Ref) || \
|
|
|
|
|
// ((SOURCE) == TIM_TRGOSource_OC4Ref))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TIM_SlaveMode_Reset ((uint16_t)0x0004)
|
|
|
|
|
#define TIM_SlaveMode_Gated ((uint16_t)0x0005)
|
|
|
|
|
#define TIM_SlaveMode_Trigger ((uint16_t)0x0006)
|
|
|
|
|
@@ -685,26 +629,16 @@ typedef struct
|
|
|
|
|
#define TIM11_GPIO ((uint16_t)0x0000)
|
|
|
|
|
#define TIM11_HSE ((uint16_t)0x0002)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum EncTimer {
|
|
|
|
|
Tim2,
|
|
|
|
|
Tim3,
|
|
|
|
|
Tim4,
|
|
|
|
|
Tim8
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Encoder
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
int _pin;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void eattach(int enco);
|
|
|
|
|
TIM_TypeDef *tim_base;
|
|
|
|
|
Encoder();
|
|
|
|
|
void SetCount( enum EncTimer enc, int64_t Counter);
|
|
|
|
|
uint16_t GetCount( enum EncTimer enc);
|
|
|
|
|
void attachh(int encoNumber);
|
|
|
|
|
uint16_t c;
|
|
|
|
|
void SetCount(int64_t Counter);
|
|
|
|
|
uint16_t GetCount();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void rcc_config();
|
|
|
|
|
|