Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/TaskBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,31 @@ class TaskBlock {
private:
TimerTask tasks[DEFAULT_TASK_SIZE];
const taskid_t first;
const taskid_t arraySize;
const taskid_t tasksSize;
public:
explicit TaskBlock(taskid_t first_) : first(first_), arraySize(DEFAULT_TASK_SIZE) {}
explicit TaskBlock(taskid_t first_) : first(first_), tasksSize(DEFAULT_TASK_SIZE) {}

/**
* Checks if taskId is contained within this block
* @param task the task ID to check
* @return true if contained, otherwise false
*/
bool isTaskContained(taskid_t task) const {
return task >= first && task < (first + arraySize);
return task >= first && task < (first + tasksSize);
};

TimerTask* getContainedTask(taskid_t task) {
return isTaskContained(task) ? &tasks[task - first] : nullptr;
}

void clearAll() {
for(taskid_t i=0; i<arraySize;i++) {
for(taskid_t i=0; i<tasksSize;i++) {
tasks[i].clear();
}
}

taskid_t allocateTask() {
for(taskid_t i=0; i<arraySize; i++) {
for(taskid_t i=0; i<tasksSize; i++) {
if(tasks[i].allocateIfPossible()) {
return i + first;
}
Expand All @@ -61,7 +61,7 @@ class TaskBlock {
}

taskid_t lastSlot() const {
return first + arraySize - 1;
return first + tasksSize - 1;
}

taskid_t firstSlot() const {
Expand Down
8 changes: 7 additions & 1 deletion src/TaskManagerIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "TaskTypes.h"
#include "TaskBlock.h"

#ifdef PARTICLE
enum InterruptMode;
#endif // PARTICLE

/**
* @file TaskManagerIO.h
*
Expand Down Expand Up @@ -74,8 +78,10 @@ class InterruptAbstraction {
*/
class BasicArduinoInterruptAbstraction : public InterruptAbstraction {
void attachInterrupt(pintype_t pin, RawIntHandler fn, uint8_t mode) override {
#ifdef ARDUINO_MBED_MODE
#if defined(ARDUINO_MBED_MODE)
::attachInterrupt(pin, fn, (PinStatus)mode);
#elif defined(PARTICLE)
::attachInterrupt(pin, fn, (InterruptMode)mode);
#else
::attachInterrupt(pin, fn, mode);
#endif // ARDUINO_MBED_MODE
Expand Down