} | } | ||||
bool begin(void (*funct)(), float microseconds) { | bool begin(void (*funct)(), float microseconds) { | ||||
if (microseconds <= 0 || microseconds > MAX_PERIOD) return false; | if (microseconds <= 0 || microseconds > MAX_PERIOD) return false; | ||||
uint32_t cycles = (float)(24000000 / 1000000) * microseconds - 0.5; | |||||
uint32_t cycles = (float)(24000000 / 1000000) * microseconds - 0.5f; | |||||
if (cycles < 17) return false; | if (cycles < 17) return false; | ||||
return beginCycles(funct, cycles); | return beginCycles(funct, cycles); | ||||
} | } | ||||
} | } | ||||
void update(float microseconds) { | void update(float microseconds) { | ||||
if (microseconds <= 0 || microseconds > MAX_PERIOD) return; | if (microseconds <= 0 || microseconds > MAX_PERIOD) return; | ||||
uint32_t cycles = (float)(24000000 / 1000000) * microseconds - 0.5; | |||||
uint32_t cycles = (float)(24000000 / 1000000) * microseconds - 0.5f; | |||||
if (cycles < 17) return; | if (cycles < 17) return; | ||||
if (channel) channel->LDVAL = cycles; | if (channel) channel->LDVAL = cycles; | ||||
} | } |
else if(c >= '0' && c <= '9') { // is c a digit? | else if(c >= '0' && c <= '9') { // is c a digit? | ||||
value = value * 10 + c - '0'; | value = value * 10 + c - '0'; | ||||
if(isFraction) | if(isFraction) | ||||
fraction *= 0.1; | |||||
fraction *= 0.1f; | |||||
} | } | ||||
read(); // consume the character we got with peek | read(); // consume the character we got with peek | ||||
c = timedPeek(); | c = timedPeek(); |
// shift decimal point | // shift decimal point | ||||
while (newPrecision > 0) { | while (newPrecision > 0) { | ||||
val *= 10.0; | |||||
val *= 10.0f; | |||||
newPrecision--; | newPrecision--; | ||||
} | } | ||||
{ | { | ||||
uint16_t mask = 1 << submodule; | uint16_t mask = 1 << submodule; | ||||
uint32_t olddiv = p->SM[submodule].VAL1; | uint32_t olddiv = p->SM[submodule].VAL1; | ||||
uint32_t newdiv = (uint32_t)((float)F_BUS_ACTUAL / frequency + 0.5); | |||||
uint32_t newdiv = (uint32_t)((float)F_BUS_ACTUAL / frequency + 0.5f); | |||||
uint32_t prescale = 0; | uint32_t prescale = 0; | ||||
//printf(" div=%lu\n", newdiv); | //printf(" div=%lu\n", newdiv); | ||||
while (newdiv > 65535 && prescale < 7) { | while (newdiv > 65535 && prescale < 7) { | ||||
void quadtimerFrequency(IMXRT_TMR_t *p, unsigned int submodule, float frequency) | void quadtimerFrequency(IMXRT_TMR_t *p, unsigned int submodule, float frequency) | ||||
{ | { | ||||
uint32_t newdiv = (uint32_t)((float)F_BUS_ACTUAL / frequency + 0.5); | |||||
uint32_t newdiv = (uint32_t)((float)F_BUS_ACTUAL / frequency + 0.5f); | |||||
uint32_t prescale = 0; | uint32_t prescale = 0; | ||||
//printf(" div=%lu\n", newdiv); | //printf(" div=%lu\n", newdiv); | ||||
while (newdiv > 65534 && prescale < 7) { | while (newdiv > 65534 && prescale < 7) { |