diff --git a/driver/uart.c b/driver/uart.c
index 7fe717f..42395d2 100644
--- a/driver/uart.c
+++ b/driver/uart.c
@@ -61,6 +61,29 @@ void MyUART_ActiveIT(USART_TypeDef * UART, uint8_t Prio)
NVIC->ISER[1] |= (0x1<<(IRQNumber-32)); //Active l'interruption au niveau NVIC (p.119 manuel programming pour ISER[0])
}
+void MyUART_InitGPIO(MyUART_Struct_Typedef * UARTStructPtr)
+{
+ MyGPIO_Struct_TypeDef rxd,txd;
+ if(UARTStructPtr->UART == USART1)
+ {
+ rxd = (MyGPIO_Struct_TypeDef){GPIOA,10,In_PullUp};
+ txd = (MyGPIO_Struct_TypeDef){GPIOA,9,AltOut_Ppull};
+ }
+ else if(UARTStructPtr->UART == USART2) {
+ rxd = (MyGPIO_Struct_TypeDef){GPIOA,3,In_Floating};
+ txd = (MyGPIO_Struct_TypeDef){GPIOA,2,AltOut_Ppull};
+ }
+ else if(UARTStructPtr->UART == USART3) {
+ rxd = (MyGPIO_Struct_TypeDef){GPIOB,11,In_PullUp};
+ txd = (MyGPIO_Struct_TypeDef){GPIOB,10,AltOut_Ppull};
+ }
+ else {
+ return;
+ }
+ MyGPIO_Init(&rxd);
+ MyGPIO_Init(&txd);
+}
+
void MyUART_Send(MyUART_Struct_Typedef *UART, uint8_t data)
{
UART->UART->DR = data;
diff --git a/driver/uart.h b/driver/uart.h
index b116c41..a124025 100644
--- a/driver/uart.h
+++ b/driver/uart.h
@@ -29,6 +29,7 @@ typedef struct {
}MyUART_Struct_Typedef;
void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr);
+void MyUART_InitGPIO(MyUART_Struct_Typedef * UARTStructPtr);
int MyUART_setClockBit(MyUART_Struct_Typedef * UARTStructPtr);
void MyUART_Send(MyUART_Struct_Typedef *UART, uint8_t data);
uint8_t MyUART_Receive(MyUART_Struct_Typedef *UART);
diff --git a/keilproject/Source/Principale.c b/keilproject/Source/Principale.c
index d94ffca..35174fc 100644
--- a/keilproject/Source/Principale.c
+++ b/keilproject/Source/Principale.c
@@ -6,32 +6,20 @@
int main (void)
{
- //rxd input pull up, txd output none
- MyGPIO_Struct_TypeDef led = {GPIOA,5,Out_PullUp}; //led
- MyGPIO_Struct_TypeDef rxd1 = {GPIOA,10,In_PullUp};
- MyGPIO_Struct_TypeDef txd1 = {GPIOA,9,AltOut_Ppull};
- MyGPIO_Struct_TypeDef rxd2 = {GPIOA,3,In_Floating};
- MyGPIO_Struct_TypeDef txd2 = {GPIOA,2,AltOut_Ppull};
- MyGPIO_Struct_TypeDef rxd3 = {GPIOB,11,In_PullUp};
- MyGPIO_Struct_TypeDef txd3 = {GPIOB,10,AltOut_Ppull};
- MyUART_Struct_Typedef uartCool = {USART3,9600,lengthBit8,parityNone,stopBit1};
+ //MyGPIO_Struct_TypeDef led = {GPIOA,5,Out_PullUp}; //led
+ //MyGPIO_Init(&led); //test des leds pour ignorer les contraintes liées aux différents ports
- MyGPIO_Init(&led);
- MyGPIO_Init(&rxd1);
- MyGPIO_Init(&txd1);
- MyGPIO_Init(&rxd2);
- MyGPIO_Init(&txd2);
- MyGPIO_Init(&rxd3);
- MyGPIO_Init(&txd3);
+ MyUART_Struct_Typedef uartCool = {USART2,9600,lengthBit8,parityNone,stopBit1};
+
+ MyUART_InitGPIO(&uartCool);
MyUART_Init(&uartCool);
while(1){
if(MyUART_Read(&uartCool) == 0x61)
{
MyGPIO_Set(GPIOA,5);
- MyUART_Send(&uartCool,'k');
MyUART_Send(&uartCool,'o');
- MyUART_Send(&uartCool,'\n');
+ MyUART_Send(&uartCool,'k');
}
};
}
diff --git a/keilproject/voilier.uvoptx b/keilproject/voilier.uvoptx
index bd34282..592bf50 100644
--- a/keilproject/voilier.uvoptx
+++ b/keilproject/voilier.uvoptx
@@ -433,6 +433,54 @@
+
+ 3
+ 0
+ 17
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ .\Source\Principale.c
+
+
+
+
+ 4
+ 0
+ 19
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ .\Source\Principale.c
+
+
+
+
+ 5
+ 0
+ 20
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ .\Source\Principale.c
+
+
+
diff --git a/keilproject/voilier.uvprojx b/keilproject/voilier.uvprojx
index d5e4a4f..7f7e21a 100644
--- a/keilproject/voilier.uvprojx
+++ b/keilproject/voilier.uvprojx
@@ -17,7 +17,7 @@
STM32F103RB
STMicroelectronics
- Keil.STM32F1xx_DFP.2.4.0
+ Keil.STM32F1xx_DFP.2.3.0
http://www.keil.com/pack/
IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE
@@ -187,7 +187,6 @@
0
0
0
- 0
0
0
8
@@ -439,13 +438,13 @@
Réel
0x4
ARM-ADS
- 5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7
+ 5060960::V5.06 update 7 (build 960)::.\ARMCC
0
STM32F103RB
STMicroelectronics
- Keil.STM32F1xx_DFP.2.4.0
+ Keil.STM32F1xx_DFP.2.3.0
http://www.keil.com/pack/
IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE
@@ -615,7 +614,6 @@
0
0
0
- 0
0
0
8
@@ -887,7 +885,7 @@
RTE\Device\STM32F103RB\RTE_Device.h
-
+
@@ -896,7 +894,7 @@
RTE\Device\STM32F103RB\startup_stm32f10x_md.s
-
+
@@ -905,7 +903,7 @@
RTE\Device\STM32F103RB\system_stm32f10x.c
-
+