/*
Program
This needs to be built with the board package of MBedOS
(Arduino MbedOS RP2040 boards --> Raspberry Pi Pico
If you try to upload this program with other Pico board choices,
the board will become unresponsive.
CAUTION1: You need to follow the steps that you did when you
connected the new board for the first time (pressing BOOTSEL)
whenever the program becomes unresponsive because of wrong
assembly programs which may hang the board due to some
errors in your program.
*/
#include<stdio.h>
#include<stdlib.h>
// Uncomment this if when you copy this code to run it on HW
//#define RUN_ON_HW
#ifdef RUN_ON_HW
#define Serial1 Serial
#endif
void myPrint(char* fnName, unsigned int result);
// Define external assembly function
extern "C" {
unsigned int my_asm_add_two_constants(void);
}
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
Serial1.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
unsigned int asm_ret_val;
asm_ret_val = my_asm_add_two_constants();
myPrint("my_asm_add_two_constants", asm_ret_val);
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
} // end of loop()
void myPrint(char* fnName, unsigned int printVal){
Serial1.print("The value returned from the assembly fn ");
Serial1.print(fnName);
Serial1.print(" : "); Serial1.println(printVal);
} // myPrint(char*, int)