Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 4:aafd73c67be1
- Parent:
- 2:ce1e2d72919d
diff -r ce1e2d72919d -r aafd73c67be1 main.cpp
--- a/main.cpp Fri Oct 01 14:18:53 2021 +0000
+++ b/main.cpp Fri Jan 07 16:31:24 2022 +0000
@@ -26,8 +26,8 @@
DigitalIn EndschalterZu(PB_3);
PwmOut heben(PC_6);
PwmOut senken(PC_7);
-AnalogIn Poti(PA_0);
-DigitalOut Leuchte(PC_0);
+AnalogIn Geschwindigkeit(PA_0);
+DigitalOut Warnleuchte(PC_0);
int zustand=Init;
float tastgrad;
@@ -41,17 +41,16 @@
void blinkenAus()
{
TIM6->CR1=0;
- Leuchte=0;
+ Warnleuchte=0;
}
-void isr_Timer()
+void isrTimer()
{
- Leuchte=!Leuchte;
- HAL_NVIC_ClearPendingIRQ(TIM6_IRQn);
TIM6->SR=0;
+ Warnleuchte=!Warnleuchte;
}
-void Timer_init()
+void initTimer()
{
RCC->APB1ENR |= 0b10000; //TIM6
TIM6->PSC=31999; //1ms
@@ -59,7 +58,7 @@
TIM6->CNT=0; //Counter startet bei 0
TIM6->SR=0; //UIF =0
TIM6->DIER=1; //Interrupt Freigabe
- NVIC_SetVector(TIM6_IRQn,(uint32_t)&isr_Timer);
+ NVIC_SetVector(TIM6_IRQn,(uint32_t)&isrTimer);
HAL_NVIC_EnableIRQ(TIM6_IRQn);
__enable_irq();
}
@@ -67,13 +66,13 @@
void oeffnen()
{
senken=0;
- heben=Poti;
+ heben=Geschwindigkeit;
}
void schliessen()
{
heben=0;
- senken=Poti;
+ senken=Geschwindigkeit;
}
void lcdOut(int nr)
@@ -119,22 +118,25 @@
EndschalterZu.mode(PullDown);
Lichtschranke.fall(&schnellstop);
Lichtschranke.enable_irq();
+ __enable_irq();
heben.period_us(100);
senken.period_us(100);
- Timer_init();
+ initTimer();
}
int main()
{
- init();
- zustand=Geschlossen;
- motorstop();
- lcdOut(1);
while (true) {
switch(zustand)
{
+ case Init:
+ init();
+ zustand=Geschlossen;
+ motorstop();
+ lcdOut(1);
+ break;
case Geschlossen: if (TorOeffnen==1)
{
zustand=Oeffnen;