Sha256: ccfda6443fa3c524f00d5810dfa48fa23e12608cf8e6dde46e5bf10293de717c

Contents?: true

Size: 1.1 KB

Versions: 27

Compression:

Stored size: 1.1 KB

Contents

#include "Types.h"
#include "TaskScheduler.h"

typedef struct _Task
{
  bool    doIt;
  uint32  period;
  uint32  startTime;
} Task;

typedef struct _TaskSchedulerInstance
{
  Task usart;
  Task adc;
} TaskSchedulerInstance;

static TaskSchedulerInstance this;

void TaskScheduler_Init(void)
{
  this.usart.doIt = FALSE;
  this.usart.startTime = 0;

  //The correct period
  this.usart.period = 1000;

  this.adc.doIt = FALSE;
  this.adc.startTime = 0;
  this.adc.period = 100;
}

void TaskScheduler_Update(uint32 time)
{
  if ((time - this.usart.startTime) >= this.usart.period)
  {
    this.usart.doIt = TRUE;
    this.usart.startTime = time - (time % this.usart.period);
  }

  if ((time - this.adc.startTime) >= this.adc.period)
  {
    this.adc.doIt = TRUE;
    this.adc.startTime = time - (time % this.adc.period);
  }
}

bool TaskScheduler_DoUsart(void)
{
  bool doIt = FALSE;

  if (this.usart.doIt)
  {
    doIt = TRUE;
    this.usart.doIt = FALSE;
  }

  return doIt;
}

bool TaskScheduler_DoAdc(void)
{
  bool doIt = FALSE;

  if (this.adc.doIt)
  {
    doIt = TRUE;
    this.adc.doIt = FALSE;
  }

  return doIt;
}

Version data entries

27 entries across 14 versions & 1 rubygems

Version Path
ceedling-0.31.1 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.31.1 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.31.0 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.31.0 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.30.0 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.30.0 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.28.3 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.28.3 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.28.2 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.28.2 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.28.1 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.28.1 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.27.0 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.27.0 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.25.0 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.25.0 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.24.0 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c
ceedling-0.24.0 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.22.0 examples/temp_sensor/src/TaskScheduler.c
ceedling-0.22.0 vendor/cmock/examples/temp_sensor/src/TaskScheduler.c