alimentation function renamingi and minor cleanup
This commit is contained in:
parent
a7af1cad1e
commit
ef3b6b03e2
3 changed files with 49 additions and 59 deletions
|
@ -1,7 +1,7 @@
|
||||||
#include "Alimentation.h"
|
#include "Alimentation.h"
|
||||||
|
|
||||||
|
|
||||||
void alimentation_init(void){
|
void ALIMENTATION_Init(void){
|
||||||
RCC -> CFGR |= (0x1<<15);
|
RCC -> CFGR |= (0x1<<15);
|
||||||
RCC-> CFGR &= ~ (0x1<<14);
|
RCC-> CFGR &= ~ (0x1<<14);
|
||||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
|
||||||
|
@ -29,21 +29,12 @@ void alimentation_init(void){
|
||||||
|
|
||||||
|
|
||||||
LL_ADC_REG_Init(ADC1, &adcReg);
|
LL_ADC_REG_Init(ADC1, &adcReg);
|
||||||
|
|
||||||
/*LL_ADC_SetChannelSamplingTime(ADC2, LL_ADC_CHANNEL_10, LL_ADC_SAMPLINGTIME_1CYCLE_5);
|
|
||||||
LL_ADC_SetChannelSamplingTime(ADC2, LL_ADC_CHANNEL_11, LL_ADC_SAMPLINGTIME_1CYCLE_5);
|
|
||||||
|
|
||||||
*/
|
|
||||||
LL_ADC_Enable(ADC1);
|
LL_ADC_Enable(ADC1);
|
||||||
|
}
|
||||||
|
|
||||||
//LL_ADC_EnableIT_EOS(ADC1);
|
float ALIMENTATION_GetBatteryLevel(void){
|
||||||
//wait 0,2 µs, calibration is advised
|
float u2;
|
||||||
//LL_ADC_StartCalibration(ADC1);
|
|
||||||
}
|
|
||||||
float u2;
|
|
||||||
unsigned int niv_batterie;
|
|
||||||
float battery_level;
|
float battery_level;
|
||||||
float get_battery_level(void){
|
|
||||||
LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_12);
|
LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_12);
|
||||||
LL_ADC_REG_StartConversionSWStart(ADC1);
|
LL_ADC_REG_StartConversionSWStart(ADC1);
|
||||||
while (LL_ADC_IsActiveFlag_EOS(ADC1) != 1);
|
while (LL_ADC_IsActiveFlag_EOS(ADC1) != 1);
|
||||||
|
@ -53,11 +44,10 @@ unsigned int niv_batterie;
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_level_enough(void){
|
int ALIMENTATION_IsLevelEnough(void){
|
||||||
if (get_battery_level()<(0.8*12)){
|
if (ALIMENTATION_GetBatteryLevel()<(0.8*12)){
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}else{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
Les fonctions qui gèrent les IO (ajout par rapport à l'activité 1)
|
Les fonctions qui gèrent les IO (ajout par rapport à l'activité 1)
|
||||||
=======================================================================================*/
|
=======================================================================================*/
|
||||||
|
|
||||||
void alimentation_init(void);
|
void ALIMENTATION_Init(void);
|
||||||
float get_battery_level(void);
|
float ALIMENTATION_GetBatteryLevel(void);
|
||||||
int is_level_enough(void);
|
int ALIMENTATION_IsLevelEnough(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,7 +56,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
/* Configure the system clock to 72 MHz */
|
/* Configure the system clock to 72 MHz */
|
||||||
SystemClock_Config();
|
SystemClock_Config();
|
||||||
alimentation_init();
|
ALIMENTATION_Init();
|
||||||
accelero_init();
|
accelero_init();
|
||||||
RF_INPUT_Init();
|
RF_INPUT_Init();
|
||||||
DC_MOTOR_Init();
|
DC_MOTOR_Init();
|
||||||
|
@ -73,7 +73,7 @@ int main(void)
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if(CONTROL_LOOP_Flag){
|
if(CONTROL_LOOP_Flag){
|
||||||
battery_level_good = is_level_enough();
|
battery_level_good = ALIMENTATION_IsLevelEnough();
|
||||||
angle_roulis_good = accelero_angle_bon();
|
angle_roulis_good = accelero_angle_bon();
|
||||||
|
|
||||||
if(!angle_roulis_good){
|
if(!angle_roulis_good){
|
||||||
|
|
Loading…
Reference in a new issue