void setupTransmit(Manchester *man, uint8_t pin, uint8_t SF) { setTxPin(man, pin); man->speedFactor = SF; //we don't use exact calculation of passed time spent outside of transmitter //because of high overhead associated with it, instead we use this //emprirically determined values to compensate for the time loss #if F_CPU == 1000000UL uint16_t compensationFactor = 88; //must be divisible by 8 for workaround #elif F_CPU == 8000000UL uint16_t compensationFactor = 12; #else //16000000Mhz uint16_t compensationFactor = 4; #endif man->delay1 = (HALF_BIT_INTERVAL >> man->speedFactor) - compensationFactor; man->delay2 = (HALF_BIT_INTERVAL >> man->speedFactor) - 2; man->delay3 = (HALF_BIT_INTERVAL >> man->speedFactor) - 2; //man->delay4 = (HALF_BIT_INTERVAL >> man->speedFactor) - 2; //man->delay5 = (HALF_BIT_INTERVAL >> man->speedFactor) - 2; #if F_CPU == 1000000UL man->delay2 -= 44; //22+2 = 24 is divisible by 8 if (man->applyWorkAround1Mhz) { //definition of micro delay is broken for 1MHz speed in tiny cores as of now (May 2013) //this is a workaround that will allow us to transmit on 1Mhz //divide the wait time by 8 man->delay1 >>= 4; man->delay2 >>= 2; man->delay3 <<= 2; man->delay4 = man->delay3 / 3; man->delay5 = man->delay3 / 6; }
Serial::Serial(int rxPin, int txPin) { setRxPin(rxPin); setTxPin(txPin); }
void LocoNetClass::init(uint8_t txPin) { initLnBuf(&LnBuffer) ; setTxPin(txPin); initLocoNetHardware(&LnBuffer); }