// returns the timer handle (hTimer) unsigned StartKernelTimer (unsigned nHzDelay, TKernelTimerHandler *pHandler, void *pParam, void *pContext) { if(interrupt->ENABLE_BASIC_IRQ != 1) {initInterrupts(); interruptBasicIRQ();} enableTimeout(40, RPI_ARMTIMER_CTRL_23BIT | RPI_ARMTIMER_CTRL_ENABLE | RPI_ARMTIMER_CTRL_INT_ENABLE | RPI_ARMTIMER_CTRL_PRESCALE_256); pHandler(1, pParam, pContext); return 1; }
void setMD49commands(void) { //set acceleration if command changed since last set of acceleration if (i2cdata[2] NOT currentAcceleration) { setAcceleration(i2cdata[2]); } //set new mode only if changed if (i2cdata[3] NOT currentMode) { setMode(i2cdata[3]); } //set speed continuously, when timeout is enabled if (statusTimeout == 1) { setSpeed1(i2cdata[0]); setSpeed2(i2cdata[1]); } //set speed once changed, when timeout is disabled if (statusTimeout == 0) { if (recentSpeed1 != i2cdata[0]) { setSpeed1(i2cdata[0]); } if (recentSpeed2 != i2cdata[1]) { setSpeed2(i2cdata[1]); } } //reset encoders if byte was checked if (i2cdata[4] == 1) { resetEncoders(); i2cdata[4] = 0; } //set regulator if changed if (i2cdata[5] == 0) { if (statusRegulator NOT i2cdata[5]) { disableRegulator(); } } else if (i2cdata[5] == 1) { if (statusRegulator NOT i2cdata[5]) { enableRegulator(); } } // set timeout if changed if (i2cdata[6] == 0) { if (statusTimeout NOT i2cdata[6]) { disableTimeout(); } } else if (i2cdata[6] == 1) { if (statusTimeout NOT i2cdata[6]) { enableTimeout(); } } }