Jack Hansdampf / Mbed OS ASM_Warteschleife_Inline
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  */
00005 
00006 #include "mbed.h"
00007 #include "platform/mbed_thread.h"
00008 
00009 
00010 // Blinking rate in milliseconds
00011 #define BLINKING_RATE_MS                                                    500
00012 
00013 void warte()
00014 {   
00015     asm("push   {R0,R1}          \n"
00016         "ldr R0,=32000000/5*3   \n"
00017         "mov R1,#1              \n"
00018         "1:                     \n"  
00019         "subs  R0,R1            \n"
00020         "bne   1b               \n"
00021         "pop   {R0,R1}          \n"
00022         );    
00023 }
00024 
00025 int main()
00026 {
00027     // Initialise the digital pin LED1 as an output
00028     DigitalOut led(PA_5);
00029 
00030     while (true) {
00031         led = !led;
00032         //thread_sleep_for(BLINKING_RATE_MS);
00033         //HAL_Delay(BLINKING_RATE_MS);
00034         warte();
00035     }
00036 }