Abstracted registers for PWM and other timer modes
This commit is contained in:
@@ -109,6 +109,12 @@ uint16_t SHAL_GPIO::analogRead(SHAL_ADC_SampleTime sampleTime) {
|
||||
return GPIOManager::getGPIOADC().singleConvertSingle(channel,sampleTime);
|
||||
}
|
||||
|
||||
void SHAL_GPIO::setAlternateFunction(GPIO_Alternate_Function_Mapping AF) volatile {
|
||||
setPinMode(PinMode::ALTERNATE_FUNCTION_MODE);
|
||||
auto alternateFunctionReg = getGPIOAlternateFunctionRegister(m_GPIO_KEY);
|
||||
SHAL_set_bits(alternateFunctionReg.reg,4,static_cast<uint8_t>(AF),alternateFunctionReg.offset);
|
||||
}
|
||||
|
||||
|
||||
SHAL_GPIO& GPIOManager::get(GPIO_Key key) {
|
||||
|
||||
|
||||
@@ -54,6 +54,21 @@ void Timer::init(uint32_t prescaler, uint32_t autoReload) {
|
||||
setARR(autoReload);
|
||||
}
|
||||
|
||||
void Timer::setPWMMode(SHAL_Timer_Channel channel, SHAL_Timer_Channel_Main_Output_Mode mainOutputMode,
|
||||
SHAL_Timer_Channel_Complimentary_Output_Mode complimentaryOutputMode) {
|
||||
|
||||
uint8_t fullModeMask = static_cast<uint8_t>(mainOutputMode) | (static_cast<uint8_t>(complimentaryOutputMode) << 2);
|
||||
uint32_t offset = static_cast<uint8_t>(channel) * 4;
|
||||
|
||||
auto ccer = getTimerCaptureCompareEnableRegister(m_key);
|
||||
|
||||
if(static_cast<uint8_t>(m_key) > 3){
|
||||
fullModeMask &= (0b0011); //Clear bits for complimentary output since channels 4,5,6 don't support it
|
||||
}
|
||||
|
||||
SHAL_set_bits(ccer.reg,4,fullModeMask,offset);
|
||||
}
|
||||
|
||||
|
||||
Timer &TimerManager::get(Timer_Key timer_key) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user