mirror of
https://git.etud.insa-toulouse.fr/boujon/voilier-team-1.git
synced 2025-06-08 16:00:49 +02:00
Variation girouette
This commit is contained in:
parent
25b871f48e
commit
b838f0ee8d
5 changed files with 114 additions and 24 deletions
53
implementation/girouette.c
Normal file
53
implementation/girouette.c
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#include "girouette.h"
|
||||||
|
|
||||||
|
void MyGirouette_Init(TIM_TypeDef *TIMX)
|
||||||
|
{
|
||||||
|
|
||||||
|
//configuration gpiob6 et gpiob7 en entrées In_Floating imposer par le timer4
|
||||||
|
MyGPIO_Struct_TypeDef MyGPIO={GPIOB,6,In_Floating};
|
||||||
|
MyGPIO_Init(&MyGPIO);
|
||||||
|
MyGPIO.GPIO_Pin=7;
|
||||||
|
MyGPIO_Init(&MyGPIO);
|
||||||
|
//config pa0 en entrées
|
||||||
|
MyGPIO.GPIO_Pin=0;
|
||||||
|
MyGPIO.GPIO=GPIOA;
|
||||||
|
MyGPIO_Init(&MyGPIO);
|
||||||
|
//configuration TIM4 reset a 360
|
||||||
|
MyTimer_Struct_Typedef MyTimerGirouette ={TIMX,719,0};
|
||||||
|
MyTimer_Base_Init(&MyTimerGirouette);
|
||||||
|
|
||||||
|
TIMX->SMCR &=~0x07;
|
||||||
|
TIMX->SMCR |=TIM_SMCR_SMS_1;
|
||||||
|
TIMX->CCMR1 &=~(0xF2F2);
|
||||||
|
TIMX->CCMR1 |= TIM_CCMR1_CC1S_0;
|
||||||
|
TIMX->CCMR1 |= TIM_CCMR1_CC2S_0; //CC2S dans CCMR1 et pas CCMR2
|
||||||
|
TIMX->CCER &=~TIM_CCER_CC1P;
|
||||||
|
TIMX->CCER &=~TIM_CCER_CC2P;
|
||||||
|
TIMX->CCMR1&=~(0x0F<<4); //IC1F
|
||||||
|
TIMX->CCMR1&=~(0x0F<<12);//IC2F
|
||||||
|
TIMX->CR1 |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int MyGirouette_Angle(TIM_TypeDef *TIMX)
|
||||||
|
{
|
||||||
|
return TIMX->CNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MyGirouette_Init_IT_Z(uint8_t GPIO_Pin)
|
||||||
|
{
|
||||||
|
|
||||||
|
EXTI->IMR |= (0x01<<GPIO_Pin); // Autorisation de l'interruption de la ligne
|
||||||
|
EXTI->RTSR|= (0x01<<GPIO_Pin); // Activation du déclenchement de l'interruption sur un front montant
|
||||||
|
AFIO->EXTICR[0] &= ~(0x0000000F);// L'interruption « EXTI0 » doit être provoquée par une modification PA0
|
||||||
|
NVIC->ISER[0] |= (1 << (6 & 0x1F)); // Autorisation de l'interruption « EXTI0 » NUMERO 6,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EXTI0_IRQHandler(void)__irq {
|
||||||
|
TIM4->CNT=0;
|
||||||
|
//rabaisse flag
|
||||||
|
}
|
||||||
|
|
10
implementation/girouette.h
Normal file
10
implementation/girouette.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef MYMOTOR_H
|
||||||
|
#define MYMOTOR_H
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
#include "../driver/gpio.h"
|
||||||
|
#include "../driver/timer.h"
|
||||||
|
|
||||||
|
int MyGirouette_Angle(TIM_TypeDef *TIMX);
|
||||||
|
void MyGirouette_Init(TIM_TypeDef *TIMX);
|
||||||
|
|
||||||
|
#endif
|
|
@ -4,34 +4,20 @@
|
||||||
#include "../../driver/timer.h"
|
#include "../../driver/timer.h"
|
||||||
#include "../../driver/gpio.h"
|
#include "../../driver/gpio.h"
|
||||||
|
|
||||||
void Girouette_Angle(void);
|
|
||||||
int Angle_Girouette=0;
|
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
//configuration gpiob6 et gpiob7 en entrées pull up
|
int Angle_Girouette=0;
|
||||||
MyGPIO_Struct_TypeDef MyGPIO={GPIOB,6,In_PullUp};
|
|
||||||
MyGPIO_Init(&MyGPIO);
|
//init girouette
|
||||||
MyGPIO.GPIO_Pin=7;
|
MyGirouette_Init(TIM4);
|
||||||
MyGPIO_Init(&MyGPIO);
|
MyGirouette_Init_IT_Z(0);
|
||||||
//configuration TIM4 reset a 360
|
//lecture angle
|
||||||
MyTimer_Struct_Typedef MyTimerGirouette ={TIM4,359,1};
|
while(1){
|
||||||
MyTimer_Base_Init(&MyTimerGirouette);
|
Angle_Girouette=MyGirouette_Angle(TIM4);
|
||||||
TIM4->SMCR &=~0x07;
|
};
|
||||||
TIM4->SMCR |=~0x011;
|
|
||||||
TIM4->CCMR1 |= TIM_CCMR1_CC1S_0;
|
|
||||||
TIM4->CCMR1 |= TIM_CCMR1_CC2S_0;
|
|
||||||
TIM4->CCER &=~TIM_CCER_CC1P;
|
|
||||||
TIM4->CCER &=~TIM_CCER_CC1NP;
|
|
||||||
TIM4->CCER &=~TIM_CCER_CC2P;
|
|
||||||
TIM4->CCER &=~TIM_CCER_CC2NP;
|
|
||||||
TIM4->CCMR1&=~TIM_CCER_IC1F;
|
|
||||||
TIM1->CR1 |= 1;
|
|
||||||
Angle_Girouette=TIM4->CNT;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while(1){};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -628,6 +628,26 @@
|
||||||
</File>
|
</File>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
<Group>
|
||||||
|
<GroupName>implementation</GroupName>
|
||||||
|
<tvExp>1</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<cbSel>0</cbSel>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>3</GroupNumber>
|
||||||
|
<FileNumber>7</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>..\implementation\girouette.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>girouette.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
|
</Group>
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>::CMSIS</GroupName>
|
<GroupName>::CMSIS</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
|
|
|
@ -422,6 +422,16 @@
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
|
<Group>
|
||||||
|
<GroupName>implementation</GroupName>
|
||||||
|
<Files>
|
||||||
|
<File>
|
||||||
|
<FileName>girouette.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\implementation\girouette.c</FilePath>
|
||||||
|
</File>
|
||||||
|
</Files>
|
||||||
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>::CMSIS</GroupName>
|
<GroupName>::CMSIS</GroupName>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -434,7 +444,8 @@
|
||||||
<TargetName>Réel</TargetName>
|
<TargetName>Réel</TargetName>
|
||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
<ToolsetNumber>0x4</ToolsetNumber>
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
<ToolsetName>ARM-ADS</ToolsetName>
|
||||||
<pCCUsed>6190000::V6.19::ARMCLANG</pCCUsed>
|
<pArmCC>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pArmCC>
|
||||||
|
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
|
||||||
<uAC6>0</uAC6>
|
<uAC6>0</uAC6>
|
||||||
<TargetOption>
|
<TargetOption>
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
|
@ -845,6 +856,16 @@
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
|
<Group>
|
||||||
|
<GroupName>implementation</GroupName>
|
||||||
|
<Files>
|
||||||
|
<File>
|
||||||
|
<FileName>girouette.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\implementation\girouette.c</FilePath>
|
||||||
|
</File>
|
||||||
|
</Files>
|
||||||
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>::CMSIS</GroupName>
|
<GroupName>::CMSIS</GroupName>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
Loading…
Add table
Reference in a new issue