void Servo::writeMicroseconds(uint16 pulseWidth) { if (!this->attached()) { ASSERT(0); return; } pulseWidth = constrain(pulseWidth, this->minPW, this->maxPW); pwmWrite(this->pin, US_TO_COMPARE(pulseWidth)); }
void Servo::writeMicroseconds(uint16_t pulseWidth) { if (!this->attached()) { // ASSERT(0); return; } TIM_TypeDef *tdev = g_APinDescription[this->pin].ulTimerPeripheral; uint8_t tchan = g_APinDescription[this->pin].ulTimerChannel; pulseWidth = constrain(pulseWidth, this->minPW, this->maxPW); if(tchan == TIM_Channel_1) { TIM_SetCompare1(tdev, US_TO_COMPARE(pulseWidth)); }else if(tchan == TIM_Channel_2) { TIM_SetCompare2(tdev, US_TO_COMPARE(pulseWidth)); }else if(tchan == TIM_Channel_3) { TIM_SetCompare3(tdev, US_TO_COMPARE(pulseWidth)); }else if(tchan == TIM_Channel_4) { TIM_SetCompare4(tdev, US_TO_COMPARE(pulseWidth)); } }