diff --git a/Drivers/Include/Driver_ADC.h b/Drivers/Include/Driver_ADC.h
new file mode 100644
index 0000000..2218bc9
--- /dev/null
+++ b/Drivers/Include/Driver_ADC.h
@@ -0,0 +1,21 @@
+#ifndef MYADC_H
+#define MYADC_H
+
+#include "stm32f10x.h"
+#include "Driver_GPIO.h"
+
+typedef struct
+{
+ ADC_TypeDef * ADC;
+ char Channel;
+} MyADC_Struct_TypeDef;
+
+
+void MyADC_Base_Init(MyADC_Struct_TypeDef * ADC);
+void MyADC_Base_Start(ADC_TypeDef * ADC);
+void MyADC_Base_Stop(ADC_TypeDef * ADC);
+void MyADC_Base_Interuption(ADC_TypeDef * ADC);
+int MyADC_Base_Result (MyADC_Struct_TypeDef * ADC);
+void MyADC_Init_Periph (void (*fct)(void));
+
+#endif
diff --git a/Drivers/Include/Driver_GPIO.h b/Drivers/Include/Driver_GPIO.h
index 10cc25c..4109e4d 100644
--- a/Drivers/Include/Driver_GPIO.h
+++ b/Drivers/Include/Driver_GPIO.h
@@ -23,4 +23,5 @@ int MyGPIO_Read ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ; // renvoie 0 ou autre
void MyGPIO_Set ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ;
void MyGPIO_Reset ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ;
void MyGPIO_Toggle ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ;
+
#endif
diff --git a/Drivers/Sources/Driver_GPIO.c b/Drivers/Sources/Driver_GPIO.c
index 695d4a7..bac8120 100644
--- a/Drivers/Sources/Driver_GPIO.c
+++ b/Drivers/Sources/Driver_GPIO.c
@@ -2,35 +2,47 @@
//---------------------FONCTION D'INITIALISATION-----------------//
-void MyGPIO_Init ( MyGPIO_Struct_TypeDef * GPIOStructPtr){
+void MyGPIO_Init ( MyGPIO_Struct_TypeDef * GPIOStructPtr )
+{
-//INITIALISATION DE LA CLOCK CORRESPONDANT AU GPIO A, B ou C
- if (GPIOStructPtr->GPIO == GPIOA) {
- RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
- } else if (GPIOStructPtr->GPIO == GPIOB) {
- RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
- } else if (GPIOStructPtr->GPIO == GPIOC) {
- RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
- } else if (GPIOStructPtr->GPIO == GPIOD) {
- RCC->APB2ENR |= RCC_APB2ENR_IOPDEN;
+ /* Activation of the GPIO port specific clock */
+ if (GPIOStructPtr->GPIO == GPIOA)
+ {
+ RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
+ }
+ else if (GPIOStructPtr->GPIO == GPIOB)
+ {
+ RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
+ }
+ else if (GPIOStructPtr->GPIO == GPIOC)
+ {
+ RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
+ }
+ else if (GPIOStructPtr->GPIO == GPIOD)
+ {
+ RCC->APB2ENR |= RCC_APB2ENR_IOPDEN;
+ }
+
+
+ /* Reset, and then configuration writing of the selected GPIO Pin */
+ if(GPIOStructPtr->GPIO_Pin <= 8)
+ {
+ GPIOStructPtr->GPIO->CRL &= ~0xF<<(4*(GPIOStructPtr->GPIO_Pin));
+ GPIOStructPtr->GPIO->CRL |= (GPIOStructPtr->GPIO_Conf)<<(4*(GPIOStructPtr->GPIO_Pin));
+ }
+ else
+ {
+ GPIOStructPtr->GPIO->CRH &= ~0xF<<(4*((GPIOStructPtr->GPIO_Pin)%8));
+ GPIOStructPtr->GPIO->CRH |= (GPIOStructPtr->GPIO_Conf)<<(4*((GPIOStructPtr->GPIO_Pin)%8));
}
-//CONFIGURATION DE LA PIN UTILISEE (voir table20 p9.1)
- if(GPIOStructPtr->GPIO_Pin < 8){
- GPIOStructPtr->GPIO->CRL &= ~(0xF << (4 * GPIOStructPtr->GPIO_Pin));
- GPIOStructPtr->GPIO->CRL |= (GPIOStructPtr->GPIO_Conf << (4 * GPIOStructPtr->GPIO_Pin));
+ if(GPIOStructPtr->GPIO_Conf == (char)In_PullDown)
+ {
+ GPIOStructPtr->GPIO->ODR &= ~(0x1<<(GPIOStructPtr->GPIO_Pin));
}
- else {
- GPIOStructPtr->GPIO->CRH &= ~(0xF << (4 * GPIOStructPtr->GPIO_Pin - 8));
- GPIOStructPtr->GPIO->CRH |= (GPIOStructPtr->GPIO_Conf << (4 * GPIOStructPtr->GPIO_Pin - 8));
- }
-
-//CONFIGURATION DE L'ODR EN ENTREE (pull up et down uniquement)
- if(GPIOStructPtr->GPIO_Conf == In_PullUp){
- GPIOStructPtr->GPIO->ODR = 0x1;
- }
- else if(GPIOStructPtr->GPIO_Conf == In_PullDown){
- GPIOStructPtr->GPIO->ODR = 0x0;
+ else if(GPIOStructPtr->GPIO_Conf == (char)In_PullUp)
+ {
+ GPIOStructPtr->GPIO->ODR |= 0x1<<(GPIOStructPtr->GPIO_Pin);
}
}
@@ -62,3 +74,4 @@ void MyGPIO_Reset ( GPIO_TypeDef * GPIO , char GPIO_Pin ){
void MyGPIO_Toggle ( GPIO_TypeDef * GPIO , char GPIO_Pin ){
GPIO->ODR ^= (1 << GPIO_Pin);
}
+
diff --git a/Drivers/Sources/Driver_Timer.c b/Drivers/Sources/Driver_Timer.c
index 678672a..6784afe 100644
--- a/Drivers/Sources/Driver_Timer.c
+++ b/Drivers/Sources/Driver_Timer.c
@@ -42,5 +42,5 @@ void MyTimer_PWM( MyTimer_Struct_TypeDef * Timer, uint16_t cycle){
Timer->Timer->CCER |= TIM_CCER_CC1E; // Canal CH1 validé par bit CC1E (registre CCER)
Timer->Timer->CR1 |= TIM_CR1_CEN; // Lancement du timer
- Timer->Timer->CCR1 = (cycle * Timer->ARR) / 100; // Fixer la durée à 20%
+ Timer->Timer->CCR1 = (cycle * Timer->ARR) / 100; // Fixer la durée à 20%
}
diff --git a/GPIO_Test/GPIO_Test.uvoptx b/GPIO_Test/GPIO_Test.uvoptx
index d71aa60..181a686 100644
--- a/GPIO_Test/GPIO_Test.uvoptx
+++ b/GPIO_Test/GPIO_Test.uvoptx
@@ -446,7 +446,11 @@
1
4
1
+<<<<<<< HEAD
0
+=======
+ 1
+>>>>>>> feature-branch
0
0
C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c
diff --git a/GPIO_Test/Sources/Main.c b/GPIO_Test/Sources/Main.c
index 8d83a8c..a5fb1a2 100644
--- a/GPIO_Test/Sources/Main.c
+++ b/GPIO_Test/Sources/Main.c
@@ -1,12 +1,24 @@
#include "Driver_GPIO.h"
#include "Driver_Timer.h"
+#include "Driver_UART.h"
+#include "Driver_ADC.h"
+
+
+char data[] = "Hello World";
+int i = 0;
+int len = sizeof(data) - 1; // -1 pour ne pas envoyer le caractère nul
+void ADC_interrup(void);
int main (void){
//Déclaration d'une LED et d'un BP par structure GPIO
MyGPIO_Struct_TypeDef LED;
MyGPIO_Struct_TypeDef BP;
+ MyUART_Struct_Typedef UART;
//Déclaration d'un Timer 500 ms
MyTimer_Struct_TypeDef TIM500ms;
+
+ //Déclaration ADC de Test
+ MyADC_Struct_TypeDef ADCTEST;
//Config LED PA5
LED.GPIO_Conf = Out_Ppull;
LED.GPIO_Pin = 5;
@@ -25,6 +37,9 @@ int main (void){
TIM500ms.ARR = 5000;
MyTimer_Base_Init(&TIM500ms);
+ //InitUART
+ UART.UART = USART1;
+
/*
TIM2->DIER |= 1<< 0 ; //INTERRUPTION PERIPH
//TIM2->DIER |= TIM_DIER_UIE ;
@@ -36,13 +51,28 @@ int main (void){
MyTimer_PWM(&TIM500ms, 50);
- while(1){
-// if (MyGPIO_Read(BP.GPIO,BP.GPIO_Pin)==0){
-// MyGPIO_Set(LED.GPIO,LED.GPIO_Pin);
-// }else{
-// MyGPIO_Reset(LED.GPIO,LED.GPIO_Pin);
-// }
+
+
+
+ //NVIC_EnableIRQ(USART1_IRQn);// Activer les interruptions
+ UART_InitGPIO(&UART);
+ // Envoyer les données
+ for (i = 0; i < len; i++) {
+ UART_send(data[i]);
+ }
+ //UART_read(data[i], &UART);
+
+ //ADC
+ //TEST ADC//
+ ADCTEST.ADC = ADC1;
+ ADCTEST.Channel = 0;
+ MyADC_Base_Init(&ADCTEST);
+ MyADC_Base_Interuption(ADCTEST.ADC);
+ MyADC_Init_Periph(ADC_interrup);
+
+ while(1){
+ MyADC_Base_Start(ADCTEST.ADC);
}
}
@@ -52,4 +82,14 @@ void TIM2_IRQHandler (void)
MyGPIO_Toggle(GPIOA,5);
TIM2->SR &= ~(1<<0);
}
-*/
\ No newline at end of file
+*/
+void Timer_interup(void)
+{
+ MyGPIO_Toggle(GPIOA,5);
+}
+
+//Interruption du programme par trigger de l'ADC
+void ADC_interrup()
+{
+
+}