on test and not completed based on nucleo_hello_encoder library

Dependencies:   mbed

Fork of Nucleo_Hello_Encoder by David Lowe

main.cpp

Committer:
c128
Date:
2015-09-29
Revision:
2:70f92ce7d983
Parent:
1:3d2fffa6e19f
Child:
3:5c895f9199d6

File content as of revision 2:70f92ce7d983:

/*
 * Using STM32's counter peripherals to interface rotary encoders.
 * Encoders are supported on F4xx's TIM1,2,3,4,5. TIM2 & TIM5 have 32bit count, others 16bit.
 * Beware mbed uses TIM5 for system timer, others for PWM.
 * Check your platform's PeripheralPins.c & PeripheralNames.h if you need both PWM & encoders.
 *
 * Edit HAL_TIM_Encoder_MspInitFx.cpp to suit your mcu & board's available pinouts & pullups/downs.
 *
 * Thanks to:
 * http://petoknm.wordpress.com/2015/01/05/rotary-encoder-and-stm32/
 *
 * References:
 * http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00122015.pdf
 * http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/DM00096844.pdf
 * http://www.st.com/web/en/resource/technical/document/application_note/DM00042534.pdf
 * http://www.st.com/web/en/resource/technical/document/datasheet/DM00102166.pdf
 * 
 * David Lowe Jan 2015
 */

#include "mbed.h"
#include "counter.h"

TIM_IC_InitTypeDef counterSet1;
TIM_HandleTypeDef timer1;

int main()
{

    CounterInit(counterSet1, timer1, TIM1, 0xffff);
   
    
    printf("STM HAL encoder demo\n\r");
    
    while(1) {
        int16_t count1;
        
        count1=TIM1->CNT; //OK 401 411 TICKER 030

        printf("%d\r\n", count1);
        wait(1.0);
    }
}