error_t task_yield() { EnterCriticalSection(); if(CurrentRunning == IRQTask) { LeaveCriticalSection(); bufferPrintf("tasks: Can't swap during ISR!\r\n"); return EINVAL; } TaskDescriptor *next = CurrentRunning->taskList.next; if(next != CurrentRunning) { // We have another thread to schedule! -- Ricky26 //bufferPrintf("tasks: Swapping from %s to %s.\n", CurrentRunning->taskName, next->taskName); SwapTask(next); //bufferPrintf("tasks: Swapped from %s to %s.\n", CurrentRunning->taskName, next->taskName); LeaveCriticalSection(); return SUCCESS_VALUE(1); } LeaveCriticalSection(); return SUCCESS_VALUE(0); // didn't yield }
error_t task_wait_timeout(int _ms) { CurrentRunning->wasWoken = 0; task_sleep(_ms); return SUCCESS_VALUE(CurrentRunning->wasWoken); }
static error_t nor_read(mtd_t *_dev, void *_dest, uint32_t _off, int _amt) { uint16_t* alignedBuffer = (uint16_t*)_dest; int len = _amt; for(; len >= 2; len -= 2) { *alignedBuffer = GET_REG16(NOR + _off); _off += 2; alignedBuffer++; } if(len > 0) { uint16_t lastWord = GET_REG16(NOR + _off); uint8_t* unalignedBuffer = (uint8_t*) alignedBuffer; *unalignedBuffer = *((uint8_t*)(&lastWord)); } return SUCCESS_VALUE(_amt); }