diff --git a/.gitignore b/.gitignore
index 43314a8..f77ef35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,4 +27,3 @@
-
diff --git a/driver/Driver_ADC.c b/driver/Driver_ADC.c
index d834661..c1c0829 100644
--- a/driver/Driver_ADC.c
+++ b/driver/Driver_ADC.c
@@ -1,16 +1,34 @@
-#include "Driver_ADC.h"
#include "stm32f10x.h"
#include "stdio.h"
-
-void init_adc1 (void)
+#include "Driver_ADC.h"
+void erreur (void)
{
+ while(1);
+}
+
+void (*ADC1_2_fx) (void) = &erreur;
+
+
+/**
+*************************************************************************************************
+* @brief Activation et configuration de l'ADC1.
+* @param -> Priorité de l'intérruption.
+* @Note -> Fonction à lancer systématiquement avant d’aller plus en détail dans les conf plus fines (PWM, codeur inc...)
+*************************************************************************************************
+*/
+void driver_adc_1_init (char Prio, void (*IT_function)(void))
+{
+ //On règle la fréquence à 12Mhz
+ RCC->CFGR |= RCC_CFGR_ADCPRE_DIV6;
+ //Validation de l'horloge ACD1
+ RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
//Activation de l'external trig
ADC1->CR2 |= ADC_CR2_EXTTRIG;
//Activation SWSTART
ADC1->CR2 |= ADC_CR2_EXTSEL;
- //On règle la fréquence à 12Mhz
- RCC->CFGR |= RCC_CFGR_ADCPRE_DIV6;
- //Activation de l'ADC
+ //Validation de l'horloge ACD1
+ RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
+ //Activation de l'ADC1
ADC1->CR2 |= ADC_CR2_ADON;
//Fixe le nb de conversion, ici 1
ADC1->SQR1 &= ADC_SQR1_L;
@@ -22,18 +40,28 @@ void init_adc1 (void)
while((ADC1->CR2 & ADC_CR2_CAL));
//Activation de l'intéruption sur le flag EOC
ADC1->CR1 |= ADC_CR1_EOCIE;
+ //Activation de l'intéruption et configuration du niveau de priorité
+ NVIC_EnableIRQ(ADC1_2_IRQn);
+ NVIC_SetPriority(ADC1_2_IRQn, Prio);
+ //Fonction à appeler à l'intéruption
+ ADC1_2_fx = IT_function;
}
-void launch_read_adc1 (void)
+void driver_adc_1_launch_read (void)
{
//Lancement de la conversion
ADC1->CR2 |= ADC_CR2_SWSTART;
}
-int read_adc1 (void)
+uint16_t driver_adc_1_read (void)
{
- //On abaisse le flag pour la prochaine lecture
- ADC1->SR &= ~ADC_SR_EOC;
//Retour de la conversion
return ADC1->DR &~ ((0x0F) << 12);
}
+void ADC1_2_IRQHandler(void)
+{
+ //On abaisse le flag pour la prochaine lecture
+ ADC1->SR &= ~ADC_SR_EOC;
+ //On lance la fonction de l'utilisateur
+ (*ADC1_2_fx)();
+}
diff --git a/driver/Driver_ADC.h b/driver/Driver_ADC.h
index 3533f1d..f1b80d0 100644
--- a/driver/Driver_ADC.h
+++ b/driver/Driver_ADC.h
@@ -2,8 +2,8 @@
#define DRIVER_ADC_H
#include "stm32f10x.h"
-void init_adc1 (void);
-void launch_read_adc1 (void);
-int read_adc1 (void);
+void driver_adc_1_init (char Prio, void (*IT_function)(void));
+void driver_adc_1_launch_read (void);
+uint16_t driver_adc_1_read (void);
#endif
diff --git a/projet-voilier/projet-voilier.uvoptx b/projet-voilier/projet-voilier.uvoptx
index dbd50ad..69fe4d7 100644
--- a/projet-voilier/projet-voilier.uvoptx
+++ b/projet-voilier/projet-voilier.uvoptx
@@ -26,7 +26,7 @@
0x4
ARM-ADS
- 12000000
+ 8000000
1
1
@@ -79,8 +79,8 @@
18
- 0
- 1
+ 1
+ 0
1
1
1
@@ -117,25 +117,96 @@
BIN\UL2CM3.DLL
+
+ 0
+ ARMRTXEVENTFLAGS
+ -L70 -Z18 -C0 -M0 -T1
+
+
+ 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=75,104,496,531,0)(121=-1,-1,-1,-1,0)(122=75,104,496,531,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=1125,344,1728,1095,1)(151=-1,-1,-1,-1,0)
+
+
+ 0
+ ARMDBGFLAGS
+ -T0
+
0
UL2CM3
UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM))
-
+
+
+ 0
+ 0
+ 23
+ 1
+ 134219356
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ .\src\main.c
+
+ \\projet_voilier\src/main.c\23
+
+
+ 1
+ 0
+ 9
+ 1
+ 134219402
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ .\src\main.c
+
+ \\projet_voilier\src/main.c\9
+
+
+ 2
+ 0
+ 62
+ 1
+ 134218310
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ ..\driver\Driver_ADC.c
+
+ \\projet_voilier\../driver/Driver_ADC.c\62
+
+
+
+
+ 0
+ 1
+ val
+
+
0
0
1
- 0
+ 1
0
0
0
0
- 0
+ 1
0
0
0
@@ -181,7 +252,7 @@
0x4
ARM-ADS
- 12000000
+ 8000000
1
1
@@ -280,7 +351,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=75,104,496,509,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=120,153,405,449,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=75,104,496,509,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=120,153,405,449,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=1048,459,1651,1093,1)(151=-1,-1,-1,-1,0)
0
@@ -303,7 +374,63 @@
UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM))
-
+
+
+ 0
+ 0
+ 62
+ 1
+ 134218062
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ ..\driver\Driver_ADC.c
+
+ \\projet_voilier_reel\../driver/Driver_ADC.c\62
+
+
+ 1
+ 0
+ 27
+ 1
+ 134219156
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ .\src\main.c
+
+ \\projet_voilier_reel\src/main.c\27
+
+
+ 2
+ 0
+ 64
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ ..\driver\Driver_ADC.c
+
+
+
+
+
+
+ 0
+ 1
+ val
+
+
0
diff --git a/projet-voilier/src/main.c b/projet-voilier/src/main.c
index 098ca35..3e66617 100644
--- a/projet-voilier/src/main.c
+++ b/projet-voilier/src/main.c
@@ -2,13 +2,29 @@
#include "Driver_GPIO.h"
#include "Driver_Timer.h"
#include "Driver_ADC.h"
-int main() {
+void toto (void)
+{
+ static uint16_t val;
+ val = driver_adc_1_read();
+}
+
+int main() {
MyGPIO_Struct_TypeDef LED;
+ MyGPIO_Struct_TypeDef GPIO_ADC1;
+
LED.GPIO_Pin = 5;
LED.GPIO_Conf = Out_Ppull;
LED.GPIO = GPIOA;
MyGPIO_Init(&LED);
MyGPIO_Set(LED.GPIO, LED.GPIO_Pin);
+
+ GPIO_ADC1.GPIO_Pin = 1;
+ GPIO_ADC1.GPIO_Conf = In_Analog;
+ GPIO_ADC1.GPIO = GPIOC;
+ MyGPIO_Init(&GPIO_ADC1);
+
+ driver_adc_1_init(0x01,&toto);
+ driver_adc_1_launch_read();
while(1);
}