Steffen Rauleder
/
mbed-os-example-mbed5-blinky
lfb interrupt
02Schalterchen.cpp@0:f16b5c6f43ab, 2021-12-15 (annotated)
- Committer:
- rauleder
- Date:
- Wed Dec 15 10:15:08 2021 +0000
- Revision:
- 0:f16b5c6f43ab
erster MBED Beispiel
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rauleder | 0:f16b5c6f43ab | 1 | #if 1 |
rauleder | 0:f16b5c6f43ab | 2 | |
rauleder | 0:f16b5c6f43ab | 3 | /* mbed Microcontroller Library |
rauleder | 0:f16b5c6f43ab | 4 | * Copyright (c) 2019 ARM Limited |
rauleder | 0:f16b5c6f43ab | 5 | * SPDX-License-Identifier: Apache-2.0 |
rauleder | 0:f16b5c6f43ab | 6 | */ |
rauleder | 0:f16b5c6f43ab | 7 | |
rauleder | 0:f16b5c6f43ab | 8 | #include "mbed.h" |
rauleder | 0:f16b5c6f43ab | 9 | #include "platform/mbed_thread.h" |
rauleder | 0:f16b5c6f43ab | 10 | #include "LCD.h" |
rauleder | 0:f16b5c6f43ab | 11 | |
rauleder | 0:f16b5c6f43ab | 12 | // Blinking rate in milliseconds |
rauleder | 0:f16b5c6f43ab | 13 | #define BLINKING_RATE_MS 1000 |
rauleder | 0:f16b5c6f43ab | 14 | |
rauleder | 0:f16b5c6f43ab | 15 | DigitalOut statusled(PC_0); |
rauleder | 0:f16b5c6f43ab | 16 | InterruptIn taste1(PA_1); |
rauleder | 0:f16b5c6f43ab | 17 | InterruptIn taste2(PA_6); |
rauleder | 0:f16b5c6f43ab | 18 | lcd meinLCD; |
rauleder | 0:f16b5c6f43ab | 19 | void isr_aus() |
rauleder | 0:f16b5c6f43ab | 20 | { |
rauleder | 0:f16b5c6f43ab | 21 | statusled=0; |
rauleder | 0:f16b5c6f43ab | 22 | } |
rauleder | 0:f16b5c6f43ab | 23 | void isr_ein() |
rauleder | 0:f16b5c6f43ab | 24 | { |
rauleder | 0:f16b5c6f43ab | 25 | statusled=1; |
rauleder | 0:f16b5c6f43ab | 26 | } |
rauleder | 0:f16b5c6f43ab | 27 | |
rauleder | 0:f16b5c6f43ab | 28 | int main() |
rauleder | 0:f16b5c6f43ab | 29 | { |
rauleder | 0:f16b5c6f43ab | 30 | // Initialise the digital pin LED1 as an output |
rauleder | 0:f16b5c6f43ab | 31 | int zaehler=0; |
rauleder | 0:f16b5c6f43ab | 32 | DigitalOut led(LED1); |
rauleder | 0:f16b5c6f43ab | 33 | taste1.mode(PullDown); |
rauleder | 0:f16b5c6f43ab | 34 | taste2.mode(PullDown); |
rauleder | 0:f16b5c6f43ab | 35 | taste1.rise(&isr_aus); |
rauleder | 0:f16b5c6f43ab | 36 | taste2.rise(&isr_ein); |
rauleder | 0:f16b5c6f43ab | 37 | taste1.enable_irq(); |
rauleder | 0:f16b5c6f43ab | 38 | taste2.enable_irq(); |
rauleder | 0:f16b5c6f43ab | 39 | __enable_irq(); |
rauleder | 0:f16b5c6f43ab | 40 | meinLCD.clear(); |
rauleder | 0:f16b5c6f43ab | 41 | meinLCD.cursorpos(0x40); |
rauleder | 0:f16b5c6f43ab | 42 | meinLCD.printf("Hallo Welt"); |
rauleder | 0:f16b5c6f43ab | 43 | |
rauleder | 0:f16b5c6f43ab | 44 | while (true) { |
rauleder | 0:f16b5c6f43ab | 45 | led = !led; |
rauleder | 0:f16b5c6f43ab | 46 | zaehler++; |
rauleder | 0:f16b5c6f43ab | 47 | meinLCD.cursorpos(0x00); |
rauleder | 0:f16b5c6f43ab | 48 | meinLCD.printf("Zaehler = %d ",zaehler); |
rauleder | 0:f16b5c6f43ab | 49 | thread_sleep_for(BLINKING_RATE_MS); |
rauleder | 0:f16b5c6f43ab | 50 | } |
rauleder | 0:f16b5c6f43ab | 51 | } |
rauleder | 0:f16b5c6f43ab | 52 | #endif |