diff --git a/Drivers/Include/Driver_UART.h b/Drivers/Include/Driver_UART.h
new file mode 100644
index 0000000..23134ad
--- /dev/null
+++ b/Drivers/Include/Driver_UART.h
@@ -0,0 +1,22 @@
+#ifndef MYUART_H
+#define MYUART_H
+
+#include "stm32f10x.h"
+
+typedef struct {
+ USART_TypeDef * UART;
+ unsigned int baudrate;
+}MyUART_Struct_Typedef;
+
+void UART_send(char data);
+char UART_read(char data, MyUART_Struct_Typedef * UART);
+void UART_init(MyUART_Struct_Typedef * UART);
+void USART1_IRQHandler(void);
+void USART2_IRQHandler(void);
+void USART3_IRQHandler(void);
+void UART_InitGPIO(MyUART_Struct_Typedef * UART);
+void UART_interruption (MyUART_Struct_Typedef * UART);
+
+
+
+#endif
diff --git a/Drivers/Sources/Driver_ADC.c b/Drivers/Sources/Driver_ADC.c
new file mode 100644
index 0000000..2218bc9
--- /dev/null
+++ b/Drivers/Sources/Driver_ADC.c
@@ -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/Sources/Driver_UART.c b/Drivers/Sources/Driver_UART.c
new file mode 100644
index 0000000..87bcfd3
--- /dev/null
+++ b/Drivers/Sources/Driver_UART.c
@@ -0,0 +1,144 @@
+#include "Driver_UART.h"
+#include "Driver_GPIO.h"
+
+
+char received_data1, received_data2, received_data3;
+
+void UART_init(MyUART_Struct_Typedef * UART)
+ {
+ if(UART->UART ==USART1)
+ RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
+ else if(UART->UART ==USART2)
+ RCC->APB1ENR |= RCC_APB1ENR_USART2EN;
+ else if(UART->UART ==USART3)
+ RCC->APB1ENR |= RCC_APB1ENR_USART3EN;
+
+
+ RCC->APB2ENR |= RCC_APB2ENR_USART1EN; // Validation horloge USART1
+ USART1->CR1 |= USART_CR1_UE; // Activer l'USART
+ USART1->CR1 &= ~USART_CR1_M; // Choisir la taille 8bits de donnée
+ USART1->CR2 |= USART_CR2_STOP; // 1 seul bit de stop
+ //USART1->BRR |= 468 << 4; // Fixe le baud rate à 9600bps partie entière
+ //USART1->BRR |= 75; // Fixe le baud rate à 9600bps partie fractionnaire
+ UART->UART->BRR = 72000000/(UART->baudrate);
+ USART1->CR1 |= USART_CR1_TE; // Autoriser la transmission
+ USART1->CR1 |= USART_CR1_RE; // Activer la réception
+ // USART1->CR1 |= USART_CR1_TCIE; // Activer l'interruption de transmission
+ USART1->CR1 |= USART_CR1_RXNEIE; // Activer l'interruption de réception
+ UART_interruption(UART);
+
+ }
+
+void UART_send(char data)
+ {
+ while(!(USART1->SR & USART_SR_TXE) | !(USART2->SR & USART_SR_TXE)){} //Attendre l'autorisation de transmission
+ USART1->DR |= data;
+ while(!(USART1->SR & USART_SR_TC) | !(USART2->SR & USART_SR_TC)){} //Attendre la fin de transmission
+ }
+
+char UART_read(char data, MyUART_Struct_Typedef * UART)
+ {
+ if(UART->UART == USART1)
+ return received_data1;
+ else if (UART->UART == USART2)
+ return received_data2;
+ else if (UART->UART == USART3)
+ return received_data3;
+ else
+ return 0;
+ }
+
+
+void USART1_IRQHandler(void)
+{
+ if (USART1->SR & USART_SR_RXNE) // si une donnée a été reçue
+ {
+ received_data1 = USART1->DR; // lire la donnée reçue
+ }
+
+ if (USART1->SR & USART_SR_TC) // si la transmission est terminée
+ {
+ USART1->SR &= ~USART_SR_TC; // effacer le bit de transmission terminée
+ }
+}
+
+void USART2_IRQHandler(void)
+{
+ if (USART2->SR & USART_SR_RXNE) // si une donnée a été reçue
+ {
+ received_data2 = USART2->DR; // lire la donnée reçue
+ }
+
+ if (USART2->SR & USART_SR_TC) // si la transmission est terminée
+ {
+ USART2->SR &= ~USART_SR_TC; // effacer le bit de transmission terminée
+ }
+}
+
+void USART3_IRQHandler(void)
+{
+ if (USART3->SR & USART_SR_RXNE) // si une donnée a été reçue
+ {
+ received_data3 = USART3->DR; // lire la donnée reçue
+ }
+
+ if (USART3->SR & USART_SR_TC) // si la transmission est terminée
+ {
+ USART3->SR &= ~USART_SR_TC; // effacer le bit de transmission terminée
+ }
+}
+
+
+void UART_interruption (MyUART_Struct_Typedef * UART)
+{
+ UART->UART->CR1 |= USART_CR1_RXNEIE;
+
+ if (UART->UART==USART1)
+ {
+ NVIC->ISER[1] |= (1<<(USART1_IRQn-32));
+ }
+ if (UART->UART==USART2)
+ {
+ NVIC->ISER[1] |= (1<<(USART2_IRQn-32));
+ }
+ if (UART->UART==USART3)
+ {
+ NVIC->ISER[1] |= (1<<(USART3_IRQn-32));
+ }
+}
+
+void UART_InitGPIO(MyUART_Struct_Typedef * UART)
+{
+ if(UART->UART == USART1)
+ {
+ MyUART_Struct_Typedef UART1 = {USART1,9600};
+ MyGPIO_Struct_TypeDef PA9 = {GPIOA,9,AltOut_Ppull};
+ MyGPIO_Struct_TypeDef PA10 = {GPIOA,10,In_PullUp};
+ MyGPIO_Init (&PA9);
+ MyGPIO_Init (&PA10);
+ UART_init(&UART1);
+ }
+ else if(UART->UART == USART2) {
+ MyUART_Struct_Typedef UART2 = {USART2,9600};
+ MyGPIO_Struct_TypeDef PA2 = {GPIOA,2,AltOut_Ppull};
+ MyGPIO_Struct_TypeDef PA3 = {GPIOA,3,In_Floating};
+ MyGPIO_Init (&PA2);
+ MyGPIO_Init (&PA3);
+ UART_init(&UART2);
+ }
+ else if(UART->UART == USART3) {
+ MyUART_Struct_Typedef UART3 = {USART3,9600};
+ MyGPIO_Struct_TypeDef PA10 = {GPIOA,10,AltOut_Ppull};
+ MyGPIO_Struct_TypeDef PA11 = {GPIOA,11,In_PullUp};
+ MyGPIO_Init (&PA10);
+ MyGPIO_Init (&PA11);
+ UART_init(&UART3);
+ }
+ else {
+ return;
+ }
+
+}
+
+
+
diff --git a/GPIO_Test/GPIO_Test.uvoptx b/GPIO_Test/GPIO_Test.uvoptx
index cfed698..d71aa60 100644
--- a/GPIO_Test/GPIO_Test.uvoptx
+++ b/GPIO_Test/GPIO_Test.uvoptx
@@ -125,7 +125,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=297,604,718,1031,0)(121=-1,-1,-1,-1,0)(122=546,289,967,716,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=911,135,1505,886,0)(131=997,343,1591,1094,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=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)
+ (1010=937,133,1313,690,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=1357,482,1778,909,0)(121=-1,-1,-1,-1,0)(122=546,289,967,716,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=911,135,1505,886,0)(131=997,343,1591,1094,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=1375,56,1823,470,0)(161=1383,268,1831,682,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=240,283,843,1034,0)(151=-1,-1,-1,-1,0)
0
@@ -143,7 +143,24 @@
-U -O206 -S8 -C0 -P00 -N00("") -D00(00000000) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)
-
+
+
+ 0
+ 0
+ 69
+ 1
+ 134219582
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ U:\INSA\Microcontrôleur\Projet_Voilier_grp\Voilier\GPIO_Test\Sources\Main.c
+
+ \\GPIO_Test\Sources/Main.c\69
+
+
0
@@ -152,7 +169,7 @@
1
0
0
- 0
+ 1
0
0
1
@@ -337,9 +354,9 @@
0
1
- 1
+ 0
0
- 0
+ 1
0
0
1
@@ -416,24 +433,24 @@
1
3
- 5
+ 1
0
0
0
- ..\Drivers\Include\Driver_GPIO.h
- Driver_GPIO.h
+ ..\Drivers\Sources\Driver_UART.c
+ Driver_UART.c
0
0
1
4
- 5
+ 1
0
0
0
- ..\Drivers\Include\Driver_Timer.h
- Driver_Timer.h
+ C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c
+ Driver_ADC.c
0
0
@@ -441,7 +458,7 @@
SRC
- 1
+ 0
0
0
0
@@ -449,7 +466,7 @@
2
5
1
- 1
+ 0
0
0
.\Sources\Main.c
@@ -469,7 +486,7 @@
::Device
- 1
+ 0
0
0
1
diff --git a/GPIO_Test/GPIO_Test.uvprojx b/GPIO_Test/GPIO_Test.uvprojx
index b649e18..61c2421 100644
--- a/GPIO_Test/GPIO_Test.uvprojx
+++ b/GPIO_Test/GPIO_Test.uvprojx
@@ -394,14 +394,14 @@
..\Drivers\Sources\Driver_Timer.c
- Driver_GPIO.h
- 5
- ..\Drivers\Include\Driver_GPIO.h
+ Driver_UART.c
+ 1
+ ..\Drivers\Sources\Driver_UART.c
- Driver_Timer.h
- 5
- ..\Drivers\Include\Driver_Timer.h
+ Driver_ADC.c
+ 1
+ C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c
@@ -811,14 +811,14 @@
..\Drivers\Sources\Driver_Timer.c
- Driver_GPIO.h
- 5
- ..\Drivers\Include\Driver_GPIO.h
+ Driver_UART.c
+ 1
+ ..\Drivers\Sources\Driver_UART.c
- Driver_Timer.h
- 5
- ..\Drivers\Include\Driver_Timer.h
+ Driver_ADC.c
+ 1
+ C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c