From bea44470abbb817ac7d033dff0b1bc95fc8410da Mon Sep 17 00:00:00 2001 From: Cedric Date: Tue, 11 Apr 2023 14:53:48 +0200 Subject: [PATCH] =?UTF-8?q?Plateau=20=C3=A0=20finir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Drivers/Sources/Driver_UART.c | 10 ++--- Drivers/Voilier_fonction/Plateau.c | 15 ++++--- Drivers/Voilier_fonction/Plateau.h | 2 +- Drivers/Voilier_fonction/telecommande.c | 32 ++++++++++++++ Drivers/Voilier_fonction/telecommande.h | 12 ++++++ GPIO_Test/GPIO_Test.uvoptx | 57 ++++++------------------- GPIO_Test/GPIO_Test.uvprojx | 22 +++++----- GPIO_Test/Sources/Main.c | 23 ++++++++-- 8 files changed, 102 insertions(+), 71 deletions(-) create mode 100644 Drivers/Voilier_fonction/telecommande.c create mode 100644 Drivers/Voilier_fonction/telecommande.h diff --git a/Drivers/Sources/Driver_UART.c b/Drivers/Sources/Driver_UART.c index 305e1c3..93ed7d2 100644 --- a/Drivers/Sources/Driver_UART.c +++ b/Drivers/Sources/Driver_UART.c @@ -18,12 +18,12 @@ void UART_init(MyUART_Struct_Typedef * UART) 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 + //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_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); diff --git a/Drivers/Voilier_fonction/Plateau.c b/Drivers/Voilier_fonction/Plateau.c index 4c14f6d..dc6ac46 100644 --- a/Drivers/Voilier_fonction/Plateau.c +++ b/Drivers/Voilier_fonction/Plateau.c @@ -9,26 +9,29 @@ void Plateau_init(void) MyTimer_Struct_TypeDef Timer; MyGPIO_Struct_TypeDef Pin_Sens; + Pin_Sens.GPIO=GPIOB; + Pin_Sens.GPIO_Pin=1; + Pin_Sens.GPIO_Conf = Out_PullUp; + //Fréquence Timer.Timer = TIM3; Timer.ARR=3599; Timer.PSC=0; - Pin_Sens.GPIO=GPIOB; - Pin_Sens.GPIO_Pin=1; - Pin_Sens.GPIO_Conf = Out_PullUp; + MyTimer_Base_Init(&Timer); MyGPIO_Init(&Pin_Sens); - //MyTimer_PWM(TIM3, 50); + MyTimer_PWM(&Timer, 50); - //MyTimer_Base_Start(Timer); + MyTimer_Base_Start(TIM3); + Plateau_direction(DROITE); } -void MyMotor_ChangeDirection(uint8_t Sens) +void Plateau_direction(uint8_t Sens) { if(Sens == DROITE) MyGPIO_Set(GPIOB,1); diff --git a/Drivers/Voilier_fonction/Plateau.h b/Drivers/Voilier_fonction/Plateau.h index 04d90d4..13061e6 100644 --- a/Drivers/Voilier_fonction/Plateau.h +++ b/Drivers/Voilier_fonction/Plateau.h @@ -7,6 +7,6 @@ void Plateau_init(void); -void MyMotor_ChangeDirection(uint8_t Sens); +void Plateau_direction(uint8_t Sens); #endif diff --git a/Drivers/Voilier_fonction/telecommande.c b/Drivers/Voilier_fonction/telecommande.c new file mode 100644 index 0000000..2d2d23a --- /dev/null +++ b/Drivers/Voilier_fonction/telecommande.c @@ -0,0 +1,32 @@ +#include "telecommande.h" +#include "Driver_GPIO.h" +#include "Plateau.h" + +MyUART_Struct_Typedef UART_plateau = {USART1,9600}; + +void init_telecommande(void) +{ + UART_InitGPIO(&UART_plateau); + UART_init(&UART_plateau); +} + + +void telecommande_plateau (int data) +{ + int datar; + UART_send(data); + datar = data; + + if(datar >= 0) + Plateau_direction(DROITE); + else + Plateau_direction(GAUCHE); +} +void testRemote(void) +{ + UART_send('t'); + UART_send('e'); + UART_send('s'); + UART_send('t'); +} + diff --git a/Drivers/Voilier_fonction/telecommande.h b/Drivers/Voilier_fonction/telecommande.h new file mode 100644 index 0000000..28b6a07 --- /dev/null +++ b/Drivers/Voilier_fonction/telecommande.h @@ -0,0 +1,12 @@ +#ifndef TELECOMMANDE_H +#define TELECOMMANDE_H +#include "Driver_UART.h" +#include "stm32f10x.h" + + +void init_telecommande(void); +void telecommande_plateau (int data); +void testRemote(void); + + +#endif diff --git a/GPIO_Test/GPIO_Test.uvoptx b/GPIO_Test/GPIO_Test.uvoptx index 5260898..e9c20f5 100644 --- a/GPIO_Test/GPIO_Test.uvoptx +++ b/GPIO_Test/GPIO_Test.uvoptx @@ -75,7 +75,7 @@ 1 0 - 1 + 0 18 @@ -125,7 +125,7 @@ 0 DLGDARM - (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) + (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=1042,189,1463,616,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,40 +143,7 @@ -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 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\Sources\Main.c - - -
- - 1 - 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 @@ -290,7 +257,7 @@ 1 0 - 0 + 1 18 @@ -462,7 +429,7 @@ 1 4 1 - 1 + 0 0 0 ..\Drivers\Sources\Driver_ADC.c @@ -505,8 +472,8 @@ 0 0 0 - ..\Drivers\Voilier_fonction\Girouette.c - Girouette.c + ..\Drivers\Voilier_fonction\telecommande.c + telecommande.c 0 0 @@ -517,20 +484,20 @@ 0 0 0 - ..\Drivers\Voilier_fonction\Plateau.c - Plateau.c + ..\Drivers\Voilier_fonction\Girouette.c + Girouette.c 0 0 3 8 - 5 + 1 0 0 0 - ..\Drivers\Voilier_fonction\Plateau.h - Plateau.h + ..\Drivers\Voilier_fonction\Plateau.c + Plateau.c 0 0 diff --git a/GPIO_Test/GPIO_Test.uvprojx b/GPIO_Test/GPIO_Test.uvprojx index 585dcb1..af6b0a1 100644 --- a/GPIO_Test/GPIO_Test.uvprojx +++ b/GPIO_Test/GPIO_Test.uvprojx @@ -418,6 +418,11 @@ Voilier_fonction + + telecommande.c + 1 + ..\Drivers\Voilier_fonction\telecommande.c + Girouette.c 1 @@ -428,11 +433,6 @@ 1 ..\Drivers\Voilier_fonction\Plateau.c - - Plateau.h - 5 - ..\Drivers\Voilier_fonction\Plateau.h - @@ -776,7 +776,7 @@ - ..\Drivers\Include + ..\Drivers\Include;..\Drivers\Voilier_fonction @@ -855,6 +855,11 @@ Voilier_fonction + + telecommande.c + 1 + ..\Drivers\Voilier_fonction\telecommande.c + Girouette.c 1 @@ -865,11 +870,6 @@ 1 ..\Drivers\Voilier_fonction\Plateau.c - - Plateau.h - 5 - ..\Drivers\Voilier_fonction\Plateau.h - diff --git a/GPIO_Test/Sources/Main.c b/GPIO_Test/Sources/Main.c index 210fbe7..498fa44 100644 --- a/GPIO_Test/Sources/Main.c +++ b/GPIO_Test/Sources/Main.c @@ -2,12 +2,29 @@ #include "Driver_Timer.h" #include "Driver_UART.h" #include "Driver_ADC.h" +#include "Plateau.h" +#include "telecommande.h" - - + char data[] = "Hello World"; + int i = 0; + int len = sizeof(data) - 1; // -1 pour ne pas envoyer le caractère nul + + int main (void){ - while(1){ + init_telecommande(); + Plateau_init(); + Plateau_direction(DROITE); + + + testRemote(); + + + while(1){ } + + + + }