Clock et timer fonctionnel

This commit is contained in:
Yohan Boujon 2023-03-20 16:50:50 +01:00
parent 6427dbd925
commit 8b8d9f558d
3 changed files with 11 additions and 62 deletions

View file

@ -1,20 +1,18 @@
#include "stm32f10x.h"
#include "../gpiodriver.h"
#define CEN 0x0
int main ( void )
int main (void)
{
int returnValue;
MyGPIO_Struct_TypeDef led = {GPIOA,5,Out_PullUp}; //led
MyGPIO_Struct_TypeDef bouton = {GPIOC,13,In_PullDown}; //bouton poussoir
MyGPIO_Init(&led);
MyGPIO_Init(&bouton);
TIM2->PSC = 7199;
TIM2->ARR = 499;
TIM2->CR1 = TIM2->CR1 | (0x01<<CEN);
//Pour reset le timer : RCC_APB1RSTR
do{
if(MyGPIO_Read(GPIOC,13))
{
MyGPIO_Reset(GPIOA,5);
} else {
MyGPIO_Set(GPIOA,5);
}
returnValue = TIM2->CNT;
}while(1) ;
}

View file

@ -2,7 +2,6 @@
void MyGPIO_Init(MyGPIO_Struct_TypeDef * GPIOStructPtr)
{
uint8_t voyons = GPIOStructPtr->GPIO_Pin;
RCC->APB2ENR |= GPIO2Int(GPIOStructPtr->GPIO);
//We get the pointer of the CRH/CRL depending on the IO_Pin number
volatile uint32_t * CRAny = GPIOStructPtr->GPIO_Pin >= 0x08 ? &(GPIOStructPtr->GPIO->CRH):&(GPIOStructPtr->GPIO->CRL);

View file

@ -75,7 +75,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>
@ -125,7 +125,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=-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=1468,53,1889,480,1)(121=1469,437,1890,864,1)(122=875,109,1296,536,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>
<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=1468,53,1889,480,1)(121=1469,437,1890,864,1)(122=875,109,1296,536,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=1285,87,1879,838,1)(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>
@ -144,7 +144,7 @@
<Type>0</Type>
<LineNumber>15</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218832</Address>
<Address>134218740</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
@ -155,54 +155,6 @@
<ExecCommand></ExecCommand>
<Expression>\\cool_Simule\Source/Principale.c\15</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>13</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218816</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\Source\Principale.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\cool_Simule\Source/Principale.c\13</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>14</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218824</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\Source\Principale.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\cool_Simule\Source/Principale.c\14</Expression>
</Bp>
<Bp>
<Number>3</Number>
<Type>0</Type>
<LineNumber>12</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218808</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\Source\Principale.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\cool_Simule\Source/Principale.c\12</Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
@ -332,7 +284,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
<IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>