Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Nucleo_Encoder_16_bits.cpp
- Revision:
- 7:d7c793ec5c04
- Parent:
- 6:978bd0579f1b
--- a/Nucleo_Encoder_16_bits.cpp Fri Jan 25 07:58:34 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-#include "Nucleo_Encoder_16_bits.h"
-
-namespace mbed
-{
-
- Nucleo_Encoder_16_bits::Nucleo_Encoder_16_bits(TIM_TypeDef * _TIM)
- {
- TIM = _TIM;
- // Initialisation of the TIM module as an encoder counter
- EncoderInit(&encoder, &timer, _TIM, 0xffff, TIM_ENCODERMODE_TI12);
-
- // Update (aka over- and underflow) interrupt enabled
- TIM->DIER |= 0x0001;
- // The initialisation process generates an update interrupt, so we'll have to clear the update flag before anything else
- TIM->SR &= 0xfffe;
- }
-
- Nucleo_Encoder_16_bits::Nucleo_Encoder_16_bits(TIM_TypeDef * _TIM, uint32_t _maxcount, uint32_t _encmode)
- {
- TIM = _TIM;
- // Initialisation of the TIM module as an encoder counter
- EncoderInit(&encoder, &timer, _TIM, _maxcount, _encmode);
-
- // Update (aka over- and underflow) interrupt enabled
- TIM->DIER |= 0x0001;
- // The initialisation process generates an update interrupt, so we'll have to clear the update flag before anything else
- TIM->SR &= 0xfffe;
- }
-
- Nucleo_Encoder_16_bits::Nucleo_Encoder_16_bits(TIM_Encoder_InitTypeDef * _encoder, TIM_HandleTypeDef * _timer, TIM_TypeDef * _TIM, uint32_t _maxcount, uint32_t _encmode)
- {
- timer = *_timer;
- encoder = *_encoder;
- TIM = _TIM;
- // Initialisation of the TIM module as an encoder counter
- EncoderInit(&encoder, &timer, _TIM, _maxcount, _encmode);
-
- // Update (aka over- and underflow) interrupt enabled
- TIM->DIER |= 0x0001;
- // The initialisation process generates an update interrupt, so we'll have to clear the update flag before anything else
- TIM->SR &= 0xfffe;
- }
-
-
- int32_t Nucleo_Encoder_16_bits::GetCounter(bool reset)
- {
- int16_t count = TIM->CNT;
- if(reset){
- switch((uint32_t)TIM){
- case TIM1_BASE :
- TIM1->CNT = 0;
- break;
-
- case TIM2_BASE :
- TIM2->CNT = 0;
- break;
-
- case TIM3_BASE :
- TIM3->CNT = 0;
- break;
-
- case TIM4_BASE :
- TIM4->CNT = 0;
- break;
-
- case TIM5_BASE :
- TIM5->CNT = 0;
- break;
-
- case TIM8_BASE :
- TIM8->CNT = 0;
- break;
-
- case TIM9_BASE :
- TIM9->CNT = 0;
- break;
-
- case TIM12_BASE :
- TIM12->CNT = 0;
- break;
-
- }
- }
- else{
- switch((uint32_t)TIM)
- {
- case TIM1_BASE :
- return (int32_t)count;
-
- case TIM2_BASE :
- return (int32_t)count;
-
- case TIM3_BASE :
- return (int32_t)count;
-
- case TIM4_BASE :
- return (int32_t)count;
-
- case TIM5_BASE :
- return (int32_t)count;
-
- case TIM8_BASE :
- return (int32_t)count;
-
- case TIM9_BASE :
- return (int32_t)count;
-
- case TIM12_BASE :
- return (int32_t)count;
-
- }
- }
-
- return (int32_t)count;
- }
-
-
- TIM_HandleTypeDef* Nucleo_Encoder_16_bits::GetTimer()
- {
- return &timer;
- }
-
-}
\ No newline at end of file