Compare commits

..

No commits in common. "Moteur" and "master" have entirely different histories.

10 changed files with 24 additions and 302 deletions

View file

@ -300,7 +300,7 @@
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>6</nTsel>
<nTsel>5</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
@ -317,7 +317,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGDARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=504,37,1150,710,0)(110=60,88,280,548,0)(111=752,104,972,564,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=864,64,1285,491,0)(121=892,96,1313,523,0)(122=674,103,1095,530,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=709,11,1303,762,0)(131=736,17,1330,768,0)(132=599,17,1193,768,0)(133=295,17,889,768,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,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=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
<Name>(1010=-1,-1,-1,-1,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=98,107,519,534,0)(121=-1,-1,-1,-1,0)(122=674,103,1095,530,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=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,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=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -350,24 +350,7 @@
<Name>-U-O142 -O2254 -S0 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>25</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219120</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Services\Moteur.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Services/Moteur.c\25</Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
@ -375,14 +358,6 @@
<ItemText>time</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
<Mm>
<WinNumber>1</WinNumber>
<SubType>0</SubType>
<ItemText>My_GPIO_Init_Struct</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
</MemoryWindow1>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
@ -403,7 +378,7 @@
<AscS3>0</AscS3>
<aSer3>0</aSer3>
<eProf>0</eProf>
<aLa>1</aLa>
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
@ -425,18 +400,6 @@
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<LogicAnalyzers>
<Wi>
<IntNumber>0</IntNumber>
<FirstString>((porta &amp; 0x00000002) &gt;&gt; 1 &amp; 0x2) &gt;&gt; 1</FirstString>
<SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
</Wi>
<Wi>
<IntNumber>1</IntNumber>
<FirstString>((porta &amp; 0x00000004) &gt;&gt; 2 &amp; 0x4) &gt;&gt; 2</FirstString>
<SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
</Wi>
</LogicAnalyzers>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>
@ -457,7 +420,7 @@
<GroupNumber>1</GroupNumber>
<FileNumber>1</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>../Src/main.c</PathWithFileName>
@ -473,18 +436,6 @@
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>2</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Services\Moteur.c</PathWithFileName>
<FilenameWithoutPath>Moteur.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -495,9 +446,9 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>3</FileNumber>
<FileNumber>2</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\MyTimer.c</PathWithFileName>
@ -505,18 +456,6 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>4</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\MyPWM.c</PathWithFileName>
<FilenameWithoutPath>MyPWM.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -527,7 +466,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>5</FileNumber>
<FileNumber>3</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -539,7 +478,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>6</FileNumber>
<FileNumber>4</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -551,7 +490,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>7</FileNumber>
<FileNumber>5</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -563,7 +502,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>8</FileNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -575,7 +514,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>9</FileNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -595,7 +534,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>10</FileNumber>
<FileNumber>8</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -615,7 +554,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>11</FileNumber>
<FileNumber>9</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -635,7 +574,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>12</FileNumber>
<FileNumber>10</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>

View file

@ -391,13 +391,6 @@
</Group>
<Group>
<GroupName>User Services</GroupName>
<Files>
<File>
<FileName>Moteur.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\Moteur.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>MyDrivers</GroupName>
@ -407,11 +400,6 @@
<FileType>1</FileType>
<FilePath>..\MyDrivers\MyTimer.c</FilePath>
</File>
<File>
<FileName>MyPWM.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\MyPWM.c</FilePath>
</File>
</Files>
</Group>
<Group>
@ -607,11 +595,11 @@
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>4101</DriverSelection>
<DriverSelection>4107</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
<Flash3>"" ()</Flash3>
<Flash3></Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
@ -864,13 +852,6 @@
</Group>
<Group>
<GroupName>User Services</GroupName>
<Files>
<File>
<FileName>Moteur.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\Moteur.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>MyDrivers</GroupName>
@ -880,11 +861,6 @@
<FileType>1</FileType>
<FilePath>..\MyDrivers\MyTimer.c</FilePath>
</File>
<File>
<FileName>MyPWM.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\MyPWM.c</FilePath>
</File>
</Files>
</Group>
<Group>

View file

@ -1,65 +0,0 @@
#include "MyPWM.h"
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
#include "stm32f1xx_ll_tim.h"
void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel)
{
LL_TIM_OC_InitTypeDef My_LL_Tim_OC_Init_Struct;
//Configuration du output channel en PWM
LL_TIM_OC_StructInit(&My_LL_Tim_OC_Init_Struct);
//Configure le mode de la PWM : PWM1 = 1 jusqu'à la CompareValue puis 0, PWM2 = l'inverse
My_LL_Tim_OC_Init_Struct.OCMode = LL_TIM_OCMODE_PWM1;
LL_TIM_OC_Init(Timer,channel,&My_LL_Tim_OC_Init_Struct);
//Activation du channel pour le timer considéré
LL_TIM_CC_EnableChannel(Timer, channel);
}
//Configurer obligatoirement les channels 1 et 2 sur IC1 et IC2 ou IC3 et IC4
void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2)
{
LL_TIM_IC_InitTypeDef My_LL_Tim_IC_Init_Struct;
//Configuration du channel1 (front montant, mappé sur TI1 = valeurs par défaut)
LL_TIM_IC_StructInit(&My_LL_Tim_IC_Init_Struct);
LL_TIM_IC_Init(Timer,channel1,&My_LL_Tim_IC_Init_Struct);
//Configuration du channel2 (front descendant, mappé sur TI1 = valeurs modifiées)
LL_TIM_IC_StructInit(&My_LL_Tim_IC_Init_Struct);
//Détection sur front descendant
My_LL_Tim_IC_Init_Struct.ICPolarity = LL_TIM_IC_POLARITY_FALLING;
//Mappage sur TI1
My_LL_Tim_IC_Init_Struct.ICActiveInput = LL_TIM_ACTIVEINPUT_INDIRECTTI;
LL_TIM_IC_Init(Timer,channel2,&My_LL_Tim_IC_Init_Struct);
//Definition du trigger
LL_TIM_SetTriggerInput(Timer, LL_TIM_TS_TI1FP1);
//Configure le mode esclave en mode RESET
LL_TIM_SetSlaveMode(Timer, LL_TIM_SLAVEMODE_RESET);
//Activation des 2 channels pour le timer considéré
LL_TIM_CC_EnableChannel(Timer, channel1);
LL_TIM_CC_EnableChannel(Timer, channel2);
}
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int channel)
{
if (channel==LL_TIM_CHANNEL_CH1) LL_TIM_OC_SetCompareCH1(Timer, CompareValue);
else if (channel==LL_TIM_CHANNEL_CH2) LL_TIM_OC_SetCompareCH2(Timer, CompareValue);
else if (channel==LL_TIM_CHANNEL_CH3) LL_TIM_OC_SetCompareCH3(Timer, CompareValue);
else LL_TIM_OC_SetCompareCH4(Timer, CompareValue);
}
int MyPWM_Duty_Cycle_Permilles(TIM_TypeDef * Timer, int channel1, int channel2) {
if(channel1 == LL_TIM_CHANNEL_CH1 && channel2 == LL_TIM_CHANNEL_CH2) {
return LL_TIM_IC_GetCaptureCH2(Timer) / LL_TIM_IC_GetCaptureCH1(Timer) * 1000;
}
else {
return -1;
}
}

View file

@ -1,15 +0,0 @@
#ifndef PWM_H
#define PWM_H
#include "stm32f103xb.h"
void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);
void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2);
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int channel);
int MyPWM_Duty_Cycle_Permilles(TIM_TypeDef * Timer, int channel1, int channel2);
#endif

View file

@ -32,7 +32,7 @@ void (*Ptr_ItFct_TIM4)(void);
* int Psc : valeur à placer dans PSC
* @retval None
*/
void MyTimer_Conf(TIM_TypeDef * Timer, int Arr, int Psc)
void MyTimer_Conf(TIM_TypeDef * Timer, int Period)
{
LL_TIM_InitTypeDef My_LL_Tim_Init_Struct;
@ -42,6 +42,9 @@ void MyTimer_Conf(TIM_TypeDef * Timer, int Arr, int Psc)
else if (Timer==TIM3) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
int Psc = (Period*72*1000000)/256 + 2;
int Arr = (Period*72*1000000)/Psc + 1;
// chargement structure Arr, Psc, Up Count
My_LL_Tim_Init_Struct.Autoreload=Arr;
My_LL_Tim_Init_Struct.Prescaler=Psc;

View file

@ -18,7 +18,7 @@ Driver pour Timer 1
* int Psc : valeur à placer dans PSC
* @retval None
*/
void MyTimer_Conf(TIM_TypeDef * Timer, int Arr, int Psc);
void MyTimer_Conf(TIM_TypeDef * Timer,int Period);
/**

View file

@ -1,80 +0,0 @@
#include "Moteur.h"
#include "MyPWM.h"
#include "MyTimer.h"
#include "stm32f1xx_ll_bus.h"
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_tim.h"
void Moteur_Conf(void) {
//Fpwm = 10kHz = 72Mhz/(7200 = 0x1C20)
int Arr = 0x1C1F;
int Psc = 0x0;
//Activation horloge GPIO
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
//Config broche PA2 -> Sens
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
My_GPIO_Init_Struct.Pin = PinSens;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOPins, &My_GPIO_Init_Struct);
//Config broche PA1 -> PWM
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_1;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
//Activation horloge Timer
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
//Configuration initiale du Timer
MyTimer_Conf(TimerPWM, Arr, Psc);
//Configuration du Timer en PWM Output
MyPWM_Conf_Output(TimerPWM, channelPWM);
Moteur_Speed(0);
Moteur_Sens(0);
}
void Moteur_Speed(int speedPercentage) {
int Arr = 0x1C1F;
if(speedPercentage == 0) {
MyTimer_Stop(TimerPWM);
}
else {
MyTimer_Start(TimerPWM);
MyPWM_Set_Impulse_Duration(TimerPWM, Arr*speedPercentage/100, channelPWM);
}
}
void Moteur_Sens(int sens) {
if(sens == 0) {
LL_GPIO_ResetOutputPin(GPIOPins, PinSens);
}
else {
LL_GPIO_SetOutputPin(GPIOPins, PinSens);
}
}

View file

@ -1,18 +0,0 @@
#ifndef MOTEUR_H
#define MOTEUR_H
#include "stm32f103xb.h"
#define PinSens LL_GPIO_PIN_2
#define PinPWM LL_GPIO_PIN_1
#define GPIOPins GPIOA
#define TimerPWM TIM2
#define channelPWM LL_TIM_CHANNEL_CH2
void Moteur_Conf(void);
void Moteur_Speed(int speedPercentage);
void Moteur_Sens(int sens);
#endif

1
Services/services.txt Normal file
View file

@ -0,0 +1 @@
Mettre les services ici

View file

@ -19,10 +19,6 @@
#include "stm32f1xx_ll_rcc.h" // utile dans la fonction SystemClock_Config
#include "stm32f1xx_ll_utils.h" // utile dans la fonction SystemClock_Config
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
#include "stm32f1xx_ll_gpio.h"
#include "MyTimer.h"
#include "MyPWM.h"
#include "Moteur.h"
void SystemClock_Config(void);
@ -39,26 +35,11 @@ int main(void)
{
/* Configure the system clock to 72 MHz */
SystemClock_Config();
/*===Test Moteur===*/
//INIT GPIO MARCHE PAS->PB PIN
Moteur_Conf();
Moteur_Speed(30);
Moteur_Sens(0);
/* Infinite loop */
for (int i =0; i<0xFFFF; i++)
while (1)
{
}
Moteur_Speed(60);
Moteur_Sens(1);
while (1)
{
}
}