Correction de bug PWM input et ajout des fonctions de Voltage
This commit is contained in:
parent
7cf96b23f2
commit
48a92e07f9
4 changed files with 33 additions and 4 deletions
|
@ -191,12 +191,12 @@ void PWMi_conf(TIM_TypeDef * TIMx, uint32_t channels){
|
||||||
//TIM_DIER_CC1DE_Pos; Probablement pas utile
|
//TIM_DIER_CC1DE_Pos; Probablement pas utile
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_input_period(TIM_TypeDef * TIMx) {
|
int PWMi_getPeriod(TIM_TypeDef * TIMx) {
|
||||||
|
|
||||||
return TIMx -> CCR1;
|
return TIMx -> CCR1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_input_duty_cycle(TIM_TypeDef * TIMx) {
|
int PWMi_getDutyCycle(TIM_TypeDef * TIMx) {
|
||||||
|
|
||||||
return TIMx -> CCR2;
|
return TIMx -> CCR2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,11 @@ void Timer_stop(TIM_TypeDef * timer);
|
||||||
* PWM INPUT
|
* PWM INPUT
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
void PWMi_conf(TIM_TypeDef * timer, int channel);
|
void PWMi_conf(TIM_TypeDef * timer, uint32_t channel);
|
||||||
|
|
||||||
int PWMi_getDutyCycle(TIM_TypeDef * timer, int channel);
|
int PWMi_getDutyCycle(TIM_TypeDef * timer);
|
||||||
|
|
||||||
|
int PWMi_getPeriod(TIM_TypeDef * TIMx);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* PWM OUTPUT
|
* PWM OUTPUT
|
||||||
|
|
|
@ -1 +1,21 @@
|
||||||
#include "Voltage.h"
|
#include "Voltage.h"
|
||||||
|
|
||||||
|
|
||||||
|
void Voltage_conf() {
|
||||||
|
|
||||||
|
//On configure le pin qui recevra le signal, ici PC2
|
||||||
|
GPIO_conf(GPIOC, LL_GPIO_PIN_2, LL_GPIO_MODE_ANALOG, 0, 0);
|
||||||
|
|
||||||
|
//On configure l'ADC
|
||||||
|
ADC_conf(ADC2, 12);
|
||||||
|
|
||||||
|
//On démarre l'ADC
|
||||||
|
ADC_start(ADC2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
double Voltage_getVoltage() {
|
||||||
|
|
||||||
|
ADC_readVolt(ADC2);
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,11 @@
|
||||||
#ifndef VOLTAGE_H
|
#ifndef VOLTAGE_H
|
||||||
#define VOLTAGE_H
|
#define VOLTAGE_H
|
||||||
|
|
||||||
|
#include "ADC.h"
|
||||||
|
#include "GPIO.h"
|
||||||
|
|
||||||
|
void Voltage_conf();
|
||||||
|
|
||||||
|
double Voltage_getVoltage();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue