Giter Site home page Giter Site logo

freertos-teensy4's Introduction

Teensy 4.0 FreeRTOS Library for Teensyduino

This is a port of FreeRTOS 10.0 for the Teensy 4.0 running teensyduino

This is based on https://github.com/greiman/FreeRTOS-Arduino for the error handling.

The Arduino systick-ing is kept running after starting the scheduler, so delay, millis and micro work in tasks. For better performance, use vTaskDelay instead of delay

The documentation for FreeRTOS is located here: http://www.freertos.org/

FreeRTOS configuration

The default configuration is in FreeRTOSConfig_Default.h.

You can specify your own by having an include file named Teensy4FreeRTOSConfig.h, or you can add/replace to the default one by having an include file named Teensy4FreeRTOSConfig_addition.h.

Run-time stats

Activating run-time stats (configGENERATE_RUN_TIME_STATS) configures Timer3, this will affect the PWM on pins 6, 7, 8 and 9. Please avoid using them when using run-time stats as it might cause conflict.

If you still want to use them as PWM, please look at this library and mimick its actions for configuring the PWM without touching the timer.

For PlatformIO users

The way PlatformIO works makes it impossible to load a configuration header in a system-level library. If you installed this library using the library manager, your config files will not be read as PlatformIO isolates the library from your project files when building it.

To alleviate this problem, you can clone this repository in the lib folder of your project and add the config files in your include folder. PlatformIO will blindly search for includes in ../../include/ as per project configuration.

When the PlatformIO team implements a way to add per-project configuration files, I will update this method.

How-to

Please read FreeRTOS.html for more information.

See FreeRTOS_API.html for API documentation.

freertos-teensy4's People

Contributors

antoniozlp avatar juliandesvignes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

freertos-teensy4's Issues

portCONFIGURE_TIMER_FOR_RUN_TIME_STATS implementation missing

Dear Julian,

Thanks for the awesome work! I'm relatively new to FreeRTOS so hopefully I'm not making some stupid mistake here.

I'm trying to get vTaskGetRunTimeStats to work, and as I read from the documentation under the "Configuration and Usage", it seems like I need to define three macros to enable this feature.

  • The first one configGENERATE_RUN_TIME_STATS is in FreeRTOSConfig, and I changed it to 1
#define configGENERATE_RUN_TIME_STATS 0
  • The second one portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()I found the definition in Line 710 of src/FreeRTOS.h. However I did not see any implementation to it. If I leave as is and compile, this message will show up:

/src/FreeRTOS.h:698:4: error: #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base.

As the documentation says:

It is intended that the application designer uses the macro to configure a suitable time base. Some examples are provided below.

I'm suspecting there is some implementation on this missing if I'm right. The documentation provided some examples of the implementation but they are not for Teensy and I have no idea how this works.

System Information

  • Library version 10.0.4
  • Tried both on Arduino IDE 1.8.7 and pio 4.2.1

Code to reproduce

The code tries to use vTaskGetRunTimeStats. It will produce a linker error undefined reference to vTaskGetRunTimeStats' if left the FreeRTOS.h at default (#define configGENERATE_RUN_TIME_STATS 0`)

Once change that to 1, the issue I'm having will show up.

// Modified from https://github.com/discord-intech/FreeRTOS-Teensy4/blob/master/examples/blink_task.cpp

#include <FreeRTOS_TEENSY4.h>

static void Thread1(void* arg) {
  char buf[200];
  while (1) {
    Serial.println("Hello!");
    vTaskGetRunTimeStats(buf);
    vTaskDelay((200L * configTICK_RATE_HZ) / 1000L);
  }
}

void setup() {
  portBASE_TYPE s1;

  Serial.begin(9600);

  // create task at priority two
  s1 = xTaskCreate(Thread1, NULL, configMINIMAL_STACK_SIZE, NULL, 2, NULL);

  // check for creation errors
  if (s1 != pdPASS) {
    Serial.println("Creation problem");
    while (1);
  }

  Serial.println("Starting the scheduler !");

  // start scheduler
  vTaskStartScheduler();
  Serial.println("Insufficient RAM");
  while (1);
}
//------------------------------------------------------------------------------
// WARNING idle loop has a very small stack (configMINIMAL_STACK_SIZE)
// loop must never block
void loop() {
  // Not used.
}

Thanks a lot,
Scott

Compatibility with Teensy 4.1?

Is there any way to make this compatible with Teensy 4.1? I tried using this library in a project, and found that although it successfully compiles and uploads, tasks didn't seem to switch (got stuck on one task and never switches).

configTICK_RATE_HZ not honoured

Hi Julian - great work on this port.

However, changing the configTICK_RATE_HZ seems to have no effect on the actual scheduler.

In other words, the LED blink rate in the example program changes when the tick rate constant is changed.

Thanks,
Steve

Serial output corrupt within task

Hi Julian - tick rate now seems to be honoured - thanks.

New issue (was there before too): Serial output contains garbage or worse, crashes task. Steps to reproduce - modify blink_task.cpp example to output text during a task:

`
//------------------------------------------------------------------------------
/*

  • Thread 1, turn the LED off when signalled by thread 2.
    /
    // Declare the thread function for thread 1.
    static void Thread1(void
    arg) {
    while (1) {

    // Wait for signal from thread 2.
    xSemaphoreTake(sem, portMAX_DELAY);

    Serial.println("T1");

    // Turn LED off.
    digitalWrite(LED_PIN, LOW);
    }
    }
    `

Bytes received:
T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T1␀␀T

Thanks,
Steve

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.