Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GPIO.h Source File

GPIO.h

00001 #include "stm32f4xx.h" 
00002 
00003     // PA_1 is A of right
00004     // PA_0 is B of right
00005     // PA_5 is A of left
00006     // PB_3 is B of left
00007 
00008 #define ALT_FUNC_MODE 0x03
00009 //#define 
00010  
00011 // set GPIO pins to alternate for the pins corresponding to A/B for eacah encoder, and 2 alternate function registers need to be selected for each type
00012 // of alternate function specified
00013 // 4 modes sets AHB1ENR
00014 // Now TMR: enable clock with timer, APB1ENR
00015 // set period, autoreload value, ARR value 2^32-1, CR1 - TMR resets itself, ARPE and EN
00016 //
00017 // Encoder mode: disable timer before changing timer to encoder
00018 // CCMR1/2 1/2 depends on channel 1/2 or 3/4, depends on upper bits, depending which channels you use
00019 // CCMR sets sample rate and set the channel to input
00020 // CCER, which edge to trigger on, cannot be 11(not allowed for encoder mode), CCER for both channels
00021 // SMCR - encoder mode
00022 // CR1 reenabales
00023 // then read CNT reg of timer