EventLibrary

This Sketch demonstrates the Event library that uses TI-RTOS’s event feature.

Hardware Required

  • MSP432P401R LaunchPad (Or any other LaunchPad that supports multi tasking. The analog pins input pin numbers might need to be changed to those that match the LaunchPad you are using).

Relevant groundwork

None

Circuit

Only your LaunchPad Board is needed for this example.

Code Explanation

The Event library has 3 functions.

  • begin() will setup the button library.

  • send() Which will send an event to anybody waiting for an event.

  • waitFor() waits for the event to be send and sleeps otherwise.

This library will allows you to send an event in one task and have another task wait for the event. The task waiting for the event to be send will sleep until the other task sends the event. In this example Sketch, the EventLibrary tab is the task sending the event and does this every 1000 ms. The Serial tab is the tab waiting for the event to be send.

Code

EventLibrary tab

#include "Energia.h"

#include "rtosGlobals.h"
#include "Event.h"

void setup()
{
    myEvent.begin();
}

void loop()
{
    myEvent.send();
    delay(1000);
}

Serial tab

#include "Energia.h"
#include "rtosGlobals.h"
#include "Event.h"

void serialSetup()
{
  Serial.begin(115200);
  delay(500);
}


void serialLoop()
{
  myEvent.waitFor();
  Serial.println("Got an Event from myEvent!");
}
Guide Home