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"
|
||||
|
||||
|
||||
void alimentation_init(void){
|
||||
void ALIMENTATION_Init(void){
|
||||
RCC -> CFGR |= (0x1<<15);
|
||||
RCC-> CFGR &= ~ (0x1<<14);
|
||||
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_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_EnableIT_EOS(ADC1);
|
||||
//wait 0,2 µs, calibration is advised
|
||||
//LL_ADC_StartCalibration(ADC1);
|
||||
}
|
||||
|
||||
float ALIMENTATION_GetBatteryLevel(void){
|
||||
float u2;
|
||||
unsigned int niv_batterie;
|
||||
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_StartConversionSWStart(ADC1);
|
||||
while (LL_ADC_IsActiveFlag_EOS(ADC1) != 1);
|
||||
|
@ -53,11 +44,10 @@ unsigned int niv_batterie;
|
|||
return level;
|
||||
}
|
||||
|
||||
int is_level_enough(void){
|
||||
if (get_battery_level()<(0.8*12)){
|
||||
int ALIMENTATION_IsLevelEnough(void){
|
||||
if (ALIMENTATION_GetBatteryLevel()<(0.8*12)){
|
||||
return 0;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,9 +18,9 @@
|
|||
Les fonctions qui gèrent les IO (ajout par rapport à l'activité 1)
|
||||
=======================================================================================*/
|
||||
|
||||
void alimentation_init(void);
|
||||
float get_battery_level(void);
|
||||
int is_level_enough(void);
|
||||
void ALIMENTATION_Init(void);
|
||||
float ALIMENTATION_GetBatteryLevel(void);
|
||||
int ALIMENTATION_IsLevelEnough(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,7 +56,7 @@ int main(void)
|
|||
{
|
||||
/* Configure the system clock to 72 MHz */
|
||||
SystemClock_Config();
|
||||
alimentation_init();
|
||||
ALIMENTATION_Init();
|
||||
accelero_init();
|
||||
RF_INPUT_Init();
|
||||
DC_MOTOR_Init();
|
||||
|
@ -73,7 +73,7 @@ int main(void)
|
|||
while (1)
|
||||
{
|
||||
if(CONTROL_LOOP_Flag){
|
||||
battery_level_good = is_level_enough();
|
||||
battery_level_good = ALIMENTATION_IsLevelEnough();
|
||||
angle_roulis_good = accelero_angle_bon();
|
||||
|
||||
if(!angle_roulis_good){
|
||||
|
|
Loading…
Reference in a new issue