From a1d5cd57d83999684361e39547183b2ee2c3b229 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Fri, 7 Apr 2023 13:21:27 +0200 Subject: [PATCH] Signed number for UART --- driver/uart.c | 4 ++-- driver/uart.h | 2 +- implementation/remote.c | 13 ++++++++----- implementation/remote.h | 4 ++-- keilproject/Source/Principale.c | 8 ++++---- keilproject/voilier.uvoptx | 24 ++++++++++++++++++++---- keilproject/voilier.uvprojx | 2 +- 7 files changed, 38 insertions(+), 19 deletions(-) diff --git a/driver/uart.c b/driver/uart.c index 60c081f..ff29c1a 100644 --- a/driver/uart.c +++ b/driver/uart.c @@ -2,9 +2,9 @@ #include "gpio.h" //faire GPIO -void (* pFncUART) (uint16_t data); /* d�claration d�un pointeur de fonction */ +void (* pFncUART) (uint8_t data); /* d�claration d�un pointeur de fonction */ -void MyUART_Init_Periph (void (* ptrFonction)(uint16_t)) +void MyUART_Init_Periph (void (* ptrFonction)(uint8_t)) { pFncUART = ptrFonction; /* affectation du pointeur */ } diff --git a/driver/uart.h b/driver/uart.h index e95c565..262a4c5 100644 --- a/driver/uart.h +++ b/driver/uart.h @@ -32,5 +32,5 @@ void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr); void MyUART_InitGPIO(MyUART_Struct_Typedef * UARTStructPtr); void MyUART_Send(MyUART_Struct_Typedef *UART, uint8_t data); uint8_t MyUART_Receive(MyUART_Struct_Typedef *UART); -void MyUART_Init_Periph (void (* ptrFonction)(uint16_t)); +void MyUART_Init_Periph (void (* ptrFonction)(uint8_t)); #endif diff --git a/implementation/remote.c b/implementation/remote.c index b464a8a..f5394ac 100644 --- a/implementation/remote.c +++ b/implementation/remote.c @@ -1,16 +1,19 @@ #include "remote.h" -#include "../driver/gpio.h" +#include "gpio.h" MyUART_Struct_Typedef uartCool = {USART1,9600,lengthBit8,parityNone,stopBit1}; -void remote(uint16_t data) +void remote(uint8_t data) { - MyUART_Send(&uartCool,data); //0x97 -> +100 (1001 0111?) 0x64 -> -100 (0110 0100) - //0xFE -> 2 , 0x02 ->-2 - if(data > 50) + MyUART_Send(&uartCool,data); + int8_t signedData = (int8_t)data; + if(signedData > 0) { MyGPIO_Set(GPIOA,5); } + else { + MyGPIO_Reset(GPIOA,5); + } } void initRemote(void) diff --git a/implementation/remote.h b/implementation/remote.h index aee32c7..581bfd4 100644 --- a/implementation/remote.h +++ b/implementation/remote.h @@ -1,10 +1,10 @@ #ifndef REMOTE_H #define REMOTE_H -#include "../driver/uart.h" +#include "uart.h" //XBEE 9600 baud, zero parite, 1 bit de stop, -void remote(uint16_t data); +void remote(uint8_t data); void initRemote(void); void testRemote(void); diff --git a/keilproject/Source/Principale.c b/keilproject/Source/Principale.c index 673048e..70e4ee1 100644 --- a/keilproject/Source/Principale.c +++ b/keilproject/Source/Principale.c @@ -1,8 +1,8 @@ #include "stm32f10x.h" -#include "../../driver/MyI2C.h" -#include "../../driver/MySPI.h" -#include "../../implementation/remote.h" -#include "../../driver/gpio.h" +#include "MyI2C.h" +#include "MySPI.h" +#include "remote.h" +#include "gpio.h" int main (void) { diff --git a/keilproject/voilier.uvoptx b/keilproject/voilier.uvoptx index b84204d..02e7df9 100644 --- a/keilproject/voilier.uvoptx +++ b/keilproject/voilier.uvoptx @@ -388,18 +388,34 @@ 0 0 - 15 + 10 1 -
134219676
+
134219708
0 0 0 0 0 1 - .\Source\Principale.c + ..\implementation\remote.c - \\cool_reel\Source/Principale.c\15 + \\cool_reel\../implementation/remote.c\10 +
+ + 1 + 0 + 9 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + ..\implementation\remote.c + +
diff --git a/keilproject/voilier.uvprojx b/keilproject/voilier.uvprojx index 7f7e21a..6858c3b 100644 --- a/keilproject/voilier.uvprojx +++ b/keilproject/voilier.uvprojx @@ -767,7 +767,7 @@ - .\Include + .\Include;..\driver;..\implementation