diff --git a/Drivers/Inc/GPIO.h b/Drivers/Inc/GPIO.h index 2bd5695..d84a12b 100644 --- a/Drivers/Inc/GPIO.h +++ b/Drivers/Inc/GPIO.h @@ -25,5 +25,6 @@ int MyGPIO_Read ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ; // renvoie 0 ou autre void MyGPIO_Set ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ; void MyGPIO_Reset ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ; void MyGPIO_Toggle ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ; +void MyGPIO_ActiveIT (GPIO_TypeDef * GPIO, char GPIO_Pin, char Prio, void (*IT_function)(void)) #endif diff --git a/Drivers/Src/GPIO.c b/Drivers/Src/GPIO.c index a6b0668..e7b522f 100644 --- a/Drivers/Src/GPIO.c +++ b/Drivers/Src/GPIO.c @@ -1,5 +1,8 @@ #include "GPIO.h" +void (*gpio_ptr_func)(void); +// interruption NVIC p197 RM8 et ISER p119 + void MyGPIO_Init ( MyGPIO_Struct_TypeDef * GPIOStructPtr ) { if(GPIOStructPtr->GPIO==GPIOA) @@ -68,3 +71,40 @@ void MyGPIO_Toggle ( GPIO_TypeDef * GPIO , char GPIO_Pin ) } } +void MyGPIO_ActiveIT (GPIO_TypeDef * GPIO, char GPIO_Pin, char Prio, void (*IT_function)(void)) //p210 +{ + RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; + if (GPIO==GPIOA) + { + AFIO->EXTICR[0] |= (AFIO_EXTICR1_EXTI0_PA << (4*GPIO_Pin)); + } + else if (GPIO==GPIOB) + { + AFIO->EXTICR[0] |= (AFIO_EXTICR1_EXTI0_PB << (4*GPIO_Pin)); + } + else if (GPIO==GPIOC) + { + AFIO->EXTICR[0] |= (AFIO_EXTICR1_EXTI0_PC << (4*GPIO_Pin)); + } + else if (GPIO==GPIOD) + { + AFIO->EXTICR[0] |= (AFIO_EXTICR1_EXTI0_PD << (4*GPIO_Pin)); + } + // manque ligne pour activer l'interruption + NVIC->ISER[0] |= 0x01<IP[EXTI0_IRQn] |= Prio << 4; +} + +void EXTI0_IRQHandler(void) +{ + if (EXTI->RTSR) //on test si RTSR est différent de 0 + { + if(gpio_ptr_func!=0) + { + (*gpio_ptr_func)(); + } + } + EXTI->RTSR &=0xFFFFF; + + //reset flag +} diff --git a/Drivers/Src/TIMER.c b/Drivers/Src/TIMER.c index 76e67aa..e1aa544 100644 --- a/Drivers/Src/TIMER.c +++ b/Drivers/Src/TIMER.c @@ -61,6 +61,12 @@ void MyTimer_ActiveIT (TIM_TypeDef * Timer, char Prio, void (*IT_function)(void) } +void init_encoder_timer(TIM_TypeDef * Timer) //voir page 391 +{ + Timer->SMCR = 0x1; + +} + void TIM2_IRQHandler (void) { if(tim_ptr2_func!=0) diff --git a/Drivers/Src/UART.c b/Drivers/Src/UART.c index b84c1a6..0aa7a02 100644 --- a/Drivers/Src/UART.c +++ b/Drivers/Src/UART.c @@ -2,7 +2,6 @@ #include "GPIO.h" void (*uart_rx_ptr_func)(void); -void (*uart_tx_ptr_func)(void); char buffer[1000]={0}; void MyUART_init(void) // que pour du 9600 bauds diff --git a/Projet_voile/Includes/Girouette.h b/Projet_voile/Includes/Girouette.h new file mode 100644 index 0000000..d3eb84e --- /dev/null +++ b/Projet_voile/Includes/Girouette.h @@ -0,0 +1,8 @@ +#ifndef MYGIROUETTE_H +#define MYGIROUETTE_H +#include "stm32f10x.h" +#include "GPIO.h" + + + +#endif diff --git a/Projet_voile/Sources/Girouette.c b/Projet_voile/Sources/Girouette.c new file mode 100644 index 0000000..634c02e --- /dev/null +++ b/Projet_voile/Sources/Girouette.c @@ -0,0 +1,13 @@ +#include "Girouette.h" + +int bordage(void){ + /*MyGPIO_Struct_TypeDef signalA = (GPIOC, 6, In_PullDown); + MyGPIO_Struct_TypeDef signalB = (GPIOC, 7, In_PullDown); + MyGPIO_Struct_TypeDef signalI = (GPIOC, 8, In_PullDown); + + MyGPIO_Init(&signalA); + MyGPIO_Init(&signalB); + MyGPIO_Init(&signalI);*/ + + +} \ No newline at end of file diff --git a/Projet_voile/TP1.uvoptx b/Projet_voile/TP1.uvoptx index 4d68f84..bc6d311 100644 --- a/Projet_voile/TP1.uvoptx +++ b/Projet_voile/TP1.uvoptx @@ -144,16 +144,16 @@ 0 15 1 -
134219150
+
0
0 0 0 0 0 - 1 + 0 .\Sources\Principal.c - \\TP1\Sources/Principal.c\15 + @@ -194,9 +194,9 @@ 0 1 - 1 + 0 0 - 1 + 0 0 0 1 @@ -449,7 +449,19 @@ 1 2 1 - 0 + 1 + 0 + 0 + .\Sources\Girouette.c + Girouette.c + 0 + 0 + + + 1 + 3 + 1 + 1 0 0 ..\DRIVERS\Src\GPIO.c @@ -459,9 +471,9 @@ 1 - 3 + 4 1 - 0 + 1 0 0 ..\Drivers\Src\TIMER.c @@ -471,9 +483,9 @@ 1 - 4 + 5 1 - 0 + 1 0 0 ..\Drivers\Src\ADC.c @@ -483,9 +495,9 @@ 1 - 5 + 6 1 - 0 + 1 0 0 ..\Drivers\Src\UART.c diff --git a/Projet_voile/TP1.uvprojx b/Projet_voile/TP1.uvprojx index 3755d44..e03a12f 100644 --- a/Projet_voile/TP1.uvprojx +++ b/Projet_voile/TP1.uvprojx @@ -339,7 +339,7 @@ - ..\Drivers\Inc + ..\Drivers\Inc;.\Includes @@ -388,6 +388,11 @@ 1 .\Sources\Principal.c + + Girouette.c + 1 + .\Sources\Girouette.c + GPIO.c 1 @@ -800,6 +805,11 @@ 1 .\Sources\Principal.c + + Girouette.c + 1 + .\Sources\Girouette.c + GPIO.c 1