Code buggé depuis l'ajout du truc de GPIO.c

This commit is contained in:
Olivier Chevilley 2023-04-04 15:19:16 +02:00
parent a6bd0409e6
commit 695a1f765d
8 changed files with 103 additions and 14 deletions

View file

@ -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_Set ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ;
void MyGPIO_Reset ( 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_Toggle ( GPIO_TypeDef * GPIO , char GPIO_Pin ) ;
void MyGPIO_ActiveIT (GPIO_TypeDef * GPIO, char GPIO_Pin, char Prio, void (*IT_function)(void))
#endif #endif

View file

@ -1,5 +1,8 @@
#include "GPIO.h" #include "GPIO.h"
void (*gpio_ptr_func)(void);
// interruption NVIC p197 RM8 et ISER p119
void MyGPIO_Init ( MyGPIO_Struct_TypeDef * GPIOStructPtr ) void MyGPIO_Init ( MyGPIO_Struct_TypeDef * GPIOStructPtr )
{ {
if(GPIOStructPtr->GPIO==GPIOA) 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<<EXTI0_IRQn;
NVIC->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
}

View file

@ -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) void TIM2_IRQHandler (void)
{ {
if(tim_ptr2_func!=0) if(tim_ptr2_func!=0)

View file

@ -2,7 +2,6 @@
#include "GPIO.h" #include "GPIO.h"
void (*uart_rx_ptr_func)(void); void (*uart_rx_ptr_func)(void);
void (*uart_tx_ptr_func)(void);
char buffer[1000]={0}; char buffer[1000]={0};
void MyUART_init(void) // que pour du 9600 bauds void MyUART_init(void) // que pour du 9600 bauds

View file

@ -0,0 +1,8 @@
#ifndef MYGIROUETTE_H
#define MYGIROUETTE_H
#include "stm32f10x.h"
#include "GPIO.h"
#endif

View file

@ -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);*/
}

View file

@ -144,16 +144,16 @@
<Type>0</Type> <Type>0</Type>
<LineNumber>15</LineNumber> <LineNumber>15</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>134219150</Address> <Address>0</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject> <SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess> <BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount> <BreakIfRCount>0</BreakIfRCount>
<Filename>.\Sources\Principal.c</Filename> <Filename>.\Sources\Principal.c</Filename>
<ExecCommand></ExecCommand> <ExecCommand></ExecCommand>
<Expression>\\TP1\Sources/Principal.c\15</Expression> <Expression></Expression>
</Bp> </Bp>
</Breakpoint> </Breakpoint>
<WatchWindow1> <WatchWindow1>
@ -194,9 +194,9 @@
<DebugFlag> <DebugFlag>
<trace>0</trace> <trace>0</trace>
<periodic>1</periodic> <periodic>1</periodic>
<aLwin>1</aLwin> <aLwin>0</aLwin>
<aCover>0</aCover> <aCover>0</aCover>
<aSer1>1</aSer1> <aSer1>0</aSer1>
<aSer2>0</aSer2> <aSer2>0</aSer2>
<aPa>0</aPa> <aPa>0</aPa>
<viewmode>1</viewmode> <viewmode>1</viewmode>
@ -449,7 +449,19 @@
<GroupNumber>1</GroupNumber> <GroupNumber>1</GroupNumber>
<FileNumber>2</FileNumber> <FileNumber>2</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Sources\Girouette.c</PathWithFileName>
<FilenameWithoutPath>Girouette.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>3</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\DRIVERS\Src\GPIO.c</PathWithFileName> <PathWithFileName>..\DRIVERS\Src\GPIO.c</PathWithFileName>
@ -459,9 +471,9 @@
</File> </File>
<File> <File>
<GroupNumber>1</GroupNumber> <GroupNumber>1</GroupNumber>
<FileNumber>3</FileNumber> <FileNumber>4</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\Drivers\Src\TIMER.c</PathWithFileName> <PathWithFileName>..\Drivers\Src\TIMER.c</PathWithFileName>
@ -471,9 +483,9 @@
</File> </File>
<File> <File>
<GroupNumber>1</GroupNumber> <GroupNumber>1</GroupNumber>
<FileNumber>4</FileNumber> <FileNumber>5</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\Drivers\Src\ADC.c</PathWithFileName> <PathWithFileName>..\Drivers\Src\ADC.c</PathWithFileName>
@ -483,9 +495,9 @@
</File> </File>
<File> <File>
<GroupNumber>1</GroupNumber> <GroupNumber>1</GroupNumber>
<FileNumber>5</FileNumber> <FileNumber>6</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\Drivers\Src\UART.c</PathWithFileName> <PathWithFileName>..\Drivers\Src\UART.c</PathWithFileName>

View file

@ -339,7 +339,7 @@
<MiscControls></MiscControls> <MiscControls></MiscControls>
<Define></Define> <Define></Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>..\Drivers\Inc</IncludePath> <IncludePath>..\Drivers\Inc;.\Includes</IncludePath>
</VariousControls> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@ -388,6 +388,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>.\Sources\Principal.c</FilePath> <FilePath>.\Sources\Principal.c</FilePath>
</File> </File>
<File>
<FileName>Girouette.c</FileName>
<FileType>1</FileType>
<FilePath>.\Sources\Girouette.c</FilePath>
</File>
<File> <File>
<FileName>GPIO.c</FileName> <FileName>GPIO.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
@ -800,6 +805,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>.\Sources\Principal.c</FilePath> <FilePath>.\Sources\Principal.c</FilePath>
</File> </File>
<File>
<FileName>Girouette.c</FileName>
<FileType>1</FileType>
<FilePath>.\Sources\Girouette.c</FilePath>
</File>
<File> <File>
<FileName>GPIO.c</FileName> <FileName>GPIO.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>