diff --git a/keil_project/MDK-ARM/Project.uvoptx b/keil_project/MDK-ARM/Project.uvoptx index 65bfff3..fd59681 100644 --- a/keil_project/MDK-ARM/Project.uvoptx +++ b/keil_project/MDK-ARM/Project.uvoptx @@ -130,7 +130,7 @@ 0 DLGTARM - (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=100,127,658,622,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=834,164,1255,569,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=1036,200,1639,834,1)(151=-1,-1,-1,-1,0) 0 @@ -153,7 +153,24 @@ -U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) - + + + 0 + 0 + 70 + 1 +
134224736
+ 0 + 0 + 0 + 0 + 0 + 1 + ../Src/main.c + + \\NUCLEO_F103RB\../Src/main.c\70 +
+
0 @@ -180,6 +197,16 @@ 1 Chrono_Time + + 5 + 1 + xx + + + 6 + 1 + yy + 0 @@ -338,7 +365,7 @@ 0 DLGDARM - (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=999,0,1799,923,0)(151=-1,-1,-1,-1,0) + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=1188,122,1791,873,0)(151=-1,-1,-1,-1,0) 0 @@ -375,23 +402,23 @@ 0 0 - 45 + 40 1 -
134220608
+
134223706
0 0 0 0 0 1 - ../Src/main.c + ..\Services\RFInput.c - \\NUCLEO_F103RB\../Src/main.c\45 + \\NUCLEO_F103RB\../Services/RFInput.c\40
1 0 - 49 + 71 1
0
0 @@ -400,23 +427,7 @@ 0 0 0 - startup_stm32f103xb.s - - -
- - 2 - 0 - 40 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - ..\Services\RFInput.c + ../Src/main.c
@@ -463,6 +474,11 @@ 1 battery_level + + 5 + 1 + xx + 0 @@ -600,7 +616,7 @@ 2 6 1 - 1 + 0 0 0 ..\Services\emetteur_rf.c @@ -624,7 +640,7 @@ 2 8 1 - 1 + 0 0 0 ..\Services\RFInput.c diff --git a/keil_project/Services/accelerometer.c b/keil_project/Services/accelerometer.c index 29496cb..0e9be97 100644 --- a/keil_project/Services/accelerometer.c +++ b/keil_project/Services/accelerometer.c @@ -13,11 +13,17 @@ void accelero_init(void){ LL_ADC_InitTypeDef adc; LL_ADC_REG_InitTypeDef adcReg; + LL_GPIO_StructInit(&pc0); pc0.Pin = LL_GPIO_PIN_0; pc0.Mode = LL_GPIO_MODE_ANALOG; + LL_GPIO_Init(GPIOA, &pc0); + + LL_GPIO_StructInit(&pc1); pc1.Pin = LL_GPIO_PIN_1; pc1.Mode = LL_GPIO_MODE_ANALOG; + LL_GPIO_Init(GPIOA, &pc1); + adc.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; adc.SequencersScanMode = LL_ADC_SEQ_SCAN_DISABLE; @@ -45,7 +51,7 @@ void accelero_init(void){ double accelero_get_x(void){ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_10); + LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_1); LL_ADC_REG_StartConversionSWStart(ADC1); while (LL_ADC_IsActiveFlag_EOS(ADC1) != 1){ //__asm__"nope"; diff --git a/keil_project/Services/alimentation.c b/keil_project/Services/alimentation.c index 94c7b08..e54e5df 100644 --- a/keil_project/Services/alimentation.c +++ b/keil_project/Services/alimentation.c @@ -7,14 +7,14 @@ void alimentation_init(void){ LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1); LL_APB1_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC); - LL_GPIO_InitTypeDef pc0, pc2; + LL_GPIO_InitTypeDef pc2; LL_ADC_InitTypeDef adc; LL_ADC_REG_InitTypeDef adcReg; - pc0.Pin = LL_GPIO_PIN_0; - pc0.Mode = LL_GPIO_MODE_ANALOG; - pc2.Pin = LL_GPIO_PIN_2; + LL_GPIO_StructInit(&pc2); + pc2.Pin = LL_GPIO_PIN_0; pc2.Mode = LL_GPIO_MODE_ANALOG; + LL_GPIO_Init(GPIOC, &pc2); adc.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; @@ -45,7 +45,8 @@ 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); + LL_ADC_REG_StartConversionSWStart(ADC1); + while (LL_ADC_IsActiveFlag_EOS(ADC1) != 1); battery_level = LL_ADC_REG_ReadConversionData12(ADC1); u2 = (battery_level*3.3)/4095.0; float level = u2*13.0; @@ -58,4 +59,5 @@ unsigned int niv_batterie; }else{ return 1; } - } \ No newline at end of file + } + \ No newline at end of file diff --git a/keil_project/Services/alimentation.h b/keil_project/Services/alimentation.h index 63574dd..503541f 100644 --- a/keil_project/Services/alimentation.h +++ b/keil_project/Services/alimentation.h @@ -23,4 +23,4 @@ float get_battery_level(void); int is_level_enough(void); -#endif \ No newline at end of file +#endif diff --git a/keil_project/Src/main.c b/keil_project/Src/main.c index bae5259..46d750c 100644 --- a/keil_project/Src/main.c +++ b/keil_project/Src/main.c @@ -43,27 +43,33 @@ int val2 = 0; int counter = 0; float level; int level_enough; +double xx,yy; +int bon; int main(void) { /* Configure the system clock to 72 MHz */ SystemClock_Config(); - alimentation_init(); + //alimentation_init(); RF_INPUT_Init(); DC_MOTOR_Init(); SAIL_Init(); + accelero_init(); /* Infinite loop */ while (1) { - LL_mDelay(10); - counter = (counter + 1) % 100; - DC_MOTOR_SetSpeed(counter); - val = RF_INPUT_GetPeriodUs(); - val2 = RF_INPUT_GetDutyTimeUs(); - SAIL_SetAngle(counter); - level = get_battery_level(); - level_enough = is_level_enough(); + LL_mDelay(100); + //counter = (counter + 1) % 100; + //DC_MOTOR_SetSpeed(counter); + //val = RF_INPUT_GetPeriodUs(); + //val2 = RF_INPUT_GetDutyTimeUs(); + //SAIL_SetAngle(counter); + //level = get_battery_level(); + //level_enough = is_level_enough(); + xx = accelero_get_x(); + //yy = accelero_get_y(); + //bon = accelero_angle_bon(); } }