girouette finished. To merge with encoder.
This commit is contained in:
parent
5fd72bef34
commit
b5d8a74b41
3 changed files with 54 additions and 16 deletions
|
@ -5,29 +5,66 @@
|
||||||
|
|
||||||
int index_passed = 0;
|
int index_passed = 0;
|
||||||
|
|
||||||
void init(void){
|
void INCR_ENCODER_Init(void){
|
||||||
// use timer in encoder mode (14.3.16)
|
// use timer in encoder mode (14.3.16)
|
||||||
// attach interrupt to pa5 for i
|
// attach interrupt to pa5 for i
|
||||||
// enable gpio clock
|
// enable gpio clock
|
||||||
// configure pin
|
// configure pin
|
||||||
// attach interrupt?
|
// attach interrupt?
|
||||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
||||||
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_AFIO);
|
||||||
|
|
||||||
|
|
||||||
|
LL_GPIO_InitTypeDef index_pin_conf, a_pin_conf, b_pin_conf;
|
||||||
|
|
||||||
LL_GPIO_InitTypeDef index_pin_conf;
|
|
||||||
index_pin_conf.Mode = LL_GPIO_MODE_FLOATING;
|
|
||||||
index_pin_conf.Pin = LL_GPIO_PIN_5;
|
index_pin_conf.Pin = LL_GPIO_PIN_5;
|
||||||
|
index_pin_conf.Mode = LL_GPIO_MODE_FLOATING;
|
||||||
|
|
||||||
|
a_pin_conf.Pin = LL_GPIO_PIN_6;
|
||||||
|
a_pin_conf.Mode = LL_GPIO_MODE_FLOATING;
|
||||||
|
|
||||||
|
|
||||||
|
b_pin_conf.Pin = LL_GPIO_PIN_7;
|
||||||
|
b_pin_conf.Mode = LL_GPIO_MODE_FLOATING;
|
||||||
|
|
||||||
|
|
||||||
LL_GPIO_Init(GPIOC, &index_pin_conf);
|
LL_GPIO_Init(GPIOC, &index_pin_conf);
|
||||||
|
LL_GPIO_Init(GPIOC, &a_pin_conf);
|
||||||
|
LL_GPIO_Init(GPIOC, &b_pin_conf);
|
||||||
|
|
||||||
|
|
||||||
|
LL_EXTI_InitTypeDef exti;
|
||||||
|
|
||||||
|
exti.Line_0_31 = LL_EXTI_LINE_5;
|
||||||
|
exti.LineCommand = ENABLE;
|
||||||
|
exti.Mode = LL_EXTI_MODE_IT;
|
||||||
|
exti.Trigger = LL_EXTI_TRIGGER_RISING;
|
||||||
|
|
||||||
|
LL_EXTI_Init(&exti);
|
||||||
|
|
||||||
|
LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE5);
|
||||||
|
|
||||||
NVIC_SetPriority(EXTI9_5_IRQn, 12); // prio??
|
NVIC_SetPriority(EXTI9_5_IRQn, 12); // prio??
|
||||||
NVIC_EnableIRQ(EXTI9_5_IRQn);
|
NVIC_EnableIRQ(EXTI9_5_IRQn);
|
||||||
|
|
||||||
|
//TIMER HERE
|
||||||
}
|
}
|
||||||
|
|
||||||
void EXTI9_5_IRQHandler(void){
|
void EXTI9_5_IRQHandler(void){
|
||||||
index_passed = 1;
|
index_passed = 1;
|
||||||
// TODO clear pending
|
//Set cnt to 0
|
||||||
|
|
||||||
|
// clear pending (EXTI necessary ?)
|
||||||
|
LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_5);
|
||||||
|
NVIC_ClearPendingIRQ(EXTI9_5_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int isAbsolute(void);
|
int INCR_ENCODER_IsAbsolute(void)
|
||||||
|
{
|
||||||
|
return index_passed;
|
||||||
|
};
|
||||||
|
|
||||||
int getAngle(void);
|
int INCR_ENCODER_GetAngle(void)
|
||||||
|
{
|
||||||
|
//TODO return cnt or fct(cnt)
|
||||||
|
};
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
void init(void);
|
void INCR_ENCODER_Init(void);
|
||||||
|
|
||||||
int isAbsolute(void);
|
int INCR_ENCODER_IsAbsolute(void);
|
||||||
|
|
||||||
int getAngle(void);
|
int INCR_ENCODER_GetAngle(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
||||||
|
|
||||||
#include "Chrono.h"
|
#include "Chrono.h"
|
||||||
|
#include "IncrEncoder.h"
|
||||||
|
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
|
|
||||||
|
@ -50,17 +51,17 @@ int main(void)
|
||||||
|
|
||||||
/* Add your application code here */
|
/* Add your application code here */
|
||||||
// Configuration chronomètre
|
// Configuration chronomètre
|
||||||
Chrono_Conf(TIM3);
|
// Chrono_Conf(TIM3);
|
||||||
|
//
|
||||||
// Lancement chronomètre
|
// // Lancement chronomètre
|
||||||
Chrono_Start();
|
// Chrono_Start();
|
||||||
|
|
||||||
|
|
||||||
|
INCR_ENCODER_Init();
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
Chrono_Background();
|
//Chrono_Background();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue