From 83991e64d011db19cd35ece144cb645e31dfa94f Mon Sep 17 00:00:00 2001 From: Sanchez Manon Date: Tue, 11 Apr 2023 09:38:22 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9ception=20(telecommande=20->=20bateau)?= =?UTF-8?q?=20de=20la=20commande=20de=20rotation=20du=20plateau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projet-voilier/src/Orientation.c | 30 ++++++++++++++++++++++++++++++ projet-voilier/src/Orientation.h | 6 ++++++ projet-voilier/src/main.c | 16 ++++++---------- 3 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 projet-voilier/src/Orientation.c create mode 100644 projet-voilier/src/Orientation.h diff --git a/projet-voilier/src/Orientation.c b/projet-voilier/src/Orientation.c new file mode 100644 index 0000000..68d726a --- /dev/null +++ b/projet-voilier/src/Orientation.c @@ -0,0 +1,30 @@ +#include "Driver_GPIO.h" +#include "stm32f10x.h" +#include "stdio.h" +#include "Driver_UART.h" + +MyUART_Struct_TypeDef MY_UART; + +void telecommande_init(void) +{ + MyGPIO_Struct_TypeDef UART; + UART.GPIO_Pin = 10; + UART.GPIO_Conf = AltOut_Ppull; + UART.GPIO = GPIOB; + MyGPIO_Init(&UART); + + UART.GPIO_Pin = 11; + UART.GPIO_Conf = In_Floating; + UART.GPIO = GPIOB; + MyGPIO_Init(&UART); + + //MyUART_Struct_TypeDef MY_UART; + MY_UART.baudrate = 9600; + MY_UART.UART = USART3; // USART3_TX : PB10 + MyUART_Init(&MY_UART); +} + +char telecommande_direction(void) +{ + return MyUART_ReceiveByte(&MY_UART); +} diff --git a/projet-voilier/src/Orientation.h b/projet-voilier/src/Orientation.h new file mode 100644 index 0000000..9530cc1 --- /dev/null +++ b/projet-voilier/src/Orientation.h @@ -0,0 +1,6 @@ +#ifndef ORIENTATION_H +#define ORIENTATION_H +void telecommande_init(void); +char telecommande_direction(void); + +#endif diff --git a/projet-voilier/src/main.c b/projet-voilier/src/main.c index f989c88..ac1cfb4 100644 --- a/projet-voilier/src/main.c +++ b/projet-voilier/src/main.c @@ -6,18 +6,14 @@ #include "Driver_ADC.h" #include "MySPI.h" #include "Driver_IMU.h" +#include "Orientation.h" + signed char direction = 0; int main() { -//Pour le Driver_IMU - char DATAX0 = 0x32; - unsigned char values[6]; - - MyGPIO_Struct_TypeDef GPIO_ADC1; - - driver_adc_1_launch_read(); - - driver_IMU_init(); + //Pour la direction + //Initialisation de l'UART pour le XBEE + telecommande_init(); while(1) { - driver_IMU_read(DATAX0, 6, values); + direction = telecommande_direction(); //direction = valeur pour l'orientation des voiles } }