8.1.4. How to Use the FTASK Module

8.1.4.1. Adding a Simple Functionality to a Task

This simple example shows how to add a blinking LED every 100ms (assuming the hardware supports this feature) and incrementing a counter from a database variable:

Listing 8.9 Adding functionality to the 100ms User Code Function
 1void FTSK_RunUserCodeCyclic100ms(void) {
 2    /* user code */
 3    static uint32_t ftsk_cyclic_100ms_counter                = 0;
 4    static DATA_BLOCK_EXAMPLE_s ftsk_tableExampleCyclic100ms = {.header.uniqueId = DATA_BLOCK_ID_EXAMPLE};
 5    if ((ftsk_cyclic_100ms_counter % 10u) == 0u) {
 6        gioSetBit(gioPORTB, 6, gioGetBit(gioPORTB, 6) ^ 1);
 7    }
 8
 9    DATA_READ_DATA(&ftsk_tableExampleCyclic100ms);
10    ftsk_tableExampleCyclic100ms.dummyValue++;
11    DATA_WRITE_DATA(&ftsk_tableExampleCyclic100ms);
12    ftsk_cyclic_100ms_counter++;
13}

8.1.4.2. Further Reading

Implementation details of the FTASK module are found in FTASK Module.