Close

First use of generated code

A project log for MCU pin setup

Generic visual pin layout setup tool for development boards, including a setup-based automatic code generator.

Norbert Fekete 04/07/2017 at 13:580 Comments

Here is the first cross-MCU code which was used as a test.

A simple blink, which runs on a FreeRTOS task.

#include "mps.h"

void TaskBlink(void *pvParams)
{
  for (;;)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("LED on");
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("LED off");
    delay(1000);
  }
}

void setup() {
  initializeMPS();
  pinMode(LED_BUILTIN, OUTPUT);
  task(TaskBlink);
}

void loop() {}

For Arduino, the Arduino-FreeRTOS library is needed, can be installed in Arduino IDE's Library Manager.

For ESP32, the ESP-IDF needs to be set up, leave the "main.c" totally empty, and put this code into e.g.: "app.cpp". I know it is a bad workaround, will think about it more.

In "make menuconfig", the idle loop for FreeRTOS must be enabled! It uses that for the main loop. It is ugly too, I know.

But with this, the code is nice and readable, and is the same for Arduino Pro Mini and ESP32.

Next step, do a video tutorial about this.

Discussions