Assembly example.

Dependencies:   mbed

main.cpp

Committer:
hudakz
Date:
2019-03-09
Revision:
0:c40fd5b610ee

File content as of revision 0:c40fd5b610ee:

#include "mbed.h"
// This program will blink LED1 and LED4
// using assembly language for LED1 and
// API functions for LED4
// declare external assembly language function (in a *.s file)
extern "C" int my_asm(int value);
// declare LED outputs – let C set them up as output bits
DigitalOut myled1(LED1);
DigitalOut myled4(LED4);
 
int main() {

    int value = 0;


    // loop forever
    while(1) {
      //call assembly language function to control LED1
      my_asm(value);
      //API function to control LED4
      myled4 = value;
      // flip value and wait
      value = ~ value;
      wait(0.2);
    }
}