diff --git a/ProjetsKEIL/Drivers/Source/Principale.c b/ProjetsKEIL/Drivers/Source/Principale.c index 1110976..8a259e2 100644 --- a/ProjetsKEIL/Drivers/Source/Principale.c +++ b/ProjetsKEIL/Drivers/Source/Principale.c @@ -4,15 +4,16 @@ 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); - TIM2->PSC = 7199; - TIM2->ARR = 499; - TIM2->CR1 = TIM2->CR1 | (0x01<CNT; - }while(1) ; - -} + MyGPIO_Init(&bouton); + while(1){ + if(MyGPIO_Read(GPIOC,13)) + { + MyGPIO_Reset(GPIOA,5); + } else { + MyGPIO_Set(GPIOA,5); + } + }; + } \ No newline at end of file diff --git a/ProjetsKEIL/Drivers/gpiodriver.uvoptx b/ProjetsKEIL/Drivers/gpiodriver.uvoptx index bdb47fa..49eb306 100644 --- a/ProjetsKEIL/Drivers/gpiodriver.uvoptx +++ b/ProjetsKEIL/Drivers/gpiodriver.uvoptx @@ -155,6 +155,22 @@ \\cool_Simule\Source/Principale.c\15 + + 1 + 0 + 19 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + .\Source\Principale.c + + +
diff --git a/ProjetsKEIL/Drivers/gpiodriver.uvprojx b/ProjetsKEIL/Drivers/gpiodriver.uvprojx index 1f4091c..384cd3b 100644 --- a/ProjetsKEIL/Drivers/gpiodriver.uvprojx +++ b/ProjetsKEIL/Drivers/gpiodriver.uvprojx @@ -16,7 +16,7 @@ STM32F103RB STMicroelectronics - Keil.STM32F1xx_DFP.2.3.0 + Keil.STM32F1xx_DFP.2.4.0 http://www.keil.com/pack/ IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE @@ -186,6 +186,7 @@ 0 0 0 + 0 0 0 8 @@ -421,7 +422,7 @@ STM32F103RB STMicroelectronics - Keil.STM32F1xx_DFP.2.3.0 + Keil.STM32F1xx_DFP.2.4.0 http://www.keil.com/pack/ IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE @@ -591,6 +592,7 @@ 0 0 0 + 0 0 0 8 @@ -840,7 +842,7 @@ RTE\Device\STM32F103RB\RTE_Device.h - + @@ -849,7 +851,7 @@ RTE\Device\STM32F103RB\startup_stm32f10x_md.s - + @@ -858,7 +860,7 @@ RTE\Device\STM32F103RB\system_stm32f10x.c - + diff --git a/ProjetsKEIL/Drivers/timerdriver.c b/ProjetsKEIL/Drivers/timerdriver.c new file mode 100644 index 0000000..2670370 --- /dev/null +++ b/ProjetsKEIL/Drivers/timerdriver.c @@ -0,0 +1,50 @@ +#include "timerdriver.h" + +void MyTimer_Base_Init(MyTimer_Struct_TypeDef * Timer) +{ + //TIM1 uses the APB2ENR register from RCC. The others uses the APB1ENR, so we check this value. + if(Timer->Timer == TIM1) + { + RCC->APB2ENR |= TimerX2Int(Timer->Timer); + } else { + RCC->APB1ENR |= TimerX2Int(Timer->Timer); + } + Timer->Timer->ARR = Timer->ARR; + Timer->Timer->PSC = Timer->PSC; +} + +int TimerX2Int(TIM_TypeDef * TimerX) +{ + if(TimerX == TIM1) + { + return (0x01 << 11); + } else if (TimerX == TIM2){ + return (0x01 << 0); + } else if (TimerX == TIM3){ + return (0x01 << 1); + } else if (TimerX == TIM4){ + return (0x01 << 2); + } /*else if (TimerX == TIM5){ + return (0x01 << 3); + } else if (TimerX == TIM6){ + return (0x01 << 4); + } else if (TimerX == TIM7){ + return (0x01 << 5); + } else if (TimerX == TIM8){ + return (0x01 << 13); + } else if (TimerX == TIM9){ //For now we dont do timer > 4 + return (0x01 << 19); + } else if (TimerX == TIM10){ + return (0x01 << 20); + } else if (TimerX == TIM11){ + return (0x01 << 21); + } else if (TimerX == TIM12){ + return (0x01 << 6); + } else if (TimerX == TIM13){ + return (0x01 << 7); + } else if (TimerX == TIM14){ + return (0x01 << 8); + }*/ else { + return -1; + }; +} \ No newline at end of file diff --git a/ProjetsKEIL/Drivers/timerdriver.h b/ProjetsKEIL/Drivers/timerdriver.h new file mode 100644 index 0000000..4e64dd2 --- /dev/null +++ b/ProjetsKEIL/Drivers/timerdriver.h @@ -0,0 +1,19 @@ +#ifndef TIMERDRIVER_H +#define TIMERDRIVER_H +#include "stm32f10x.h" + +#define CEN 0x0 + +typedef struct { + TIM_TypeDef * Timer; //TIM1 -> TIM4 + unsigned short ARR; + unsigned short PSC; +} MyTimer_Struct_TypeDef; + +void MyTimer_Base_Init(MyTimer_Struct_TypeDef * Timer); +int TimerX2Int(TIM_TypeDef * TimerX); + +#define MyTimer_Base_Start(Timer) (Timer->CR1 |= (0x01<CR1 &= ~(0x01<CNT; }while(1) ; } diff --git a/ProjetsKEIL/timer_interruption/timer_interruption.uvoptx b/ProjetsKEIL/timer_interruption/timer_interruption.uvoptx index f4c3c93..4d77c3c 100644 --- a/ProjetsKEIL/timer_interruption/timer_interruption.uvoptx +++ b/ProjetsKEIL/timer_interruption/timer_interruption.uvoptx @@ -75,7 +75,7 @@ 1 0 - 0 + 1 18 @@ -125,7 +125,7 @@ 0 DLGDARM - (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) + (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=486,94,907,521,1)(121=464,533,885,960,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=21,94,615,845,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) 0 @@ -138,72 +138,7 @@ UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)) - - - 0 - 0 - 15 - 1 -
134218832
- 0 - 0 - 0 - 0 - 0 - 1 - .\Source\Principale.c - - \\cool_Simule\Source/Principale.c\15 -
- - 1 - 0 - 13 - 1 -
134218816
- 0 - 0 - 0 - 0 - 0 - 1 - .\Source\Principale.c - - \\cool_Simule\Source/Principale.c\13 -
- - 2 - 0 - 14 - 1 -
134218824
- 0 - 0 - 0 - 0 - 0 - 1 - .\Source\Principale.c - - \\cool_Simule\Source/Principale.c\14 -
- - 3 - 0 - 12 - 1 -
134218808
- 0 - 0 - 0 - 0 - 0 - 1 - .\Source\Principale.c - - \\cool_Simule\Source/Principale.c\12 -
-
+ 0 @@ -258,16 +193,6 @@ - - - System Viewer\GPIOA - 35905 - - - System Viewer\GPIOB - 35904 - - 1 1 @@ -332,7 +257,7 @@ 1 0 - 1 + 0 18 @@ -517,11 +442,23 @@ 0 0 0 - ..\..\..\gpiodriver\gpiodriver.c + ..\Drivers\gpiodriver.c gpiodriver.c 0 0
+ + 1 + 3 + 1 + 0 + 0 + 0 + ..\Drivers\timerdriver.c + timerdriver.c + 0 + 0 + diff --git a/ProjetsKEIL/timer_interruption/timer_interruption.uvprojx b/ProjetsKEIL/timer_interruption/timer_interruption.uvprojx index 6ae299a..b58c002 100644 --- a/ProjetsKEIL/timer_interruption/timer_interruption.uvprojx +++ b/ProjetsKEIL/timer_interruption/timer_interruption.uvprojx @@ -10,13 +10,14 @@ Simulé 0x4 ARM-ADS - 5060960::V5.06 update 7 (build 960)::.\ARMCC - 0 + 6190000::V6.19::ARMCLANG + 6190000::V6.19::ARMCLANG + 1 STM32F103RB STMicroelectronics - Keil.STM32F1xx_DFP.2.3.0 + Keil.STM32F1xx_DFP.2.4.0 http://www.keil.com/pack/ IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE @@ -186,6 +187,7 @@ 0 0 0 + 0 0 0 8 @@ -313,7 +315,7 @@ 1 - 1 + 2 0 0 1 @@ -322,7 +324,7 @@ 0 0 0 - 2 + 3 0 0 0 @@ -391,7 +393,12 @@ gpiodriver.c 1 - ..\..\..\gpiodriver\gpiodriver.c + ..\Drivers\gpiodriver.c + + + timerdriver.c + 1 + ..\Drivers\timerdriver.c @@ -416,7 +423,7 @@ STM32F103RB STMicroelectronics - Keil.STM32F1xx_DFP.2.3.0 + Keil.STM32F1xx_DFP.2.4.0 http://www.keil.com/pack/ IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE @@ -586,6 +593,7 @@ 0 0 0 + 0 0 0 8 @@ -791,7 +799,12 @@ gpiodriver.c 1 - ..\..\..\gpiodriver\gpiodriver.c + ..\Drivers\gpiodriver.c + + + timerdriver.c + 1 + ..\Drivers\timerdriver.c @@ -811,15 +824,15 @@ - - + + - + @@ -830,7 +843,7 @@ RTE\Device\STM32F103RB\RTE_Device.h - + @@ -839,7 +852,7 @@ RTE\Device\STM32F103RB\startup_stm32f10x_md.s - + @@ -848,7 +861,7 @@ RTE\Device\STM32F103RB\system_stm32f10x.c - +