H7 working

This commit is contained in:
Luca Lizaranzu
2026-04-01 14:11:41 -07:00
parent 1b29371fff
commit 36f5b37b5a
9 changed files with 539 additions and 295 deletions

View File

@@ -18,42 +18,42 @@ SHAL_GPIO::SHAL_GPIO(GPIO_Key key) : m_GPIO_KEY(key) {
SHAL_set_register_value(GPIORCCEnable.reg,GPIORCCEnable.mask);
}
void SHAL_GPIO::setLow() {
void SHAL_GPIO::setLow() const {
auto outputDataReg = getGPIOOutputDataRegister(m_GPIO_KEY);
SHAL_set_bits(outputDataReg.reg,1,0,outputDataReg.offset);
}
void SHAL_GPIO::setHigh() {
void SHAL_GPIO::setHigh() const {
auto outputDataReg = getGPIOOutputDataRegister(m_GPIO_KEY);
SHAL_set_bits(outputDataReg.reg,1,1,outputDataReg.offset);
}
void SHAL_GPIO::toggle() volatile {
void SHAL_GPIO::toggle() const volatile {
auto outputDataReg = getGPIOOutputDataRegister(m_GPIO_KEY);
SHAL_flip_bits(outputDataReg.reg,1,outputDataReg.offset);
}
void SHAL_GPIO::setOutputType(PinType type) volatile {
void SHAL_GPIO::setOutputType(PinType type) const volatile {
auto outputTypeReg = getGPIOOutputTypeRegister(m_GPIO_KEY);
SHAL_set_bits(outputTypeReg.reg,2,static_cast<uint8_t>(type),outputTypeReg.offset);
}
void SHAL_GPIO::setOutputSpeed(OutputSpeed speed) volatile {
void SHAL_GPIO::setOutputSpeed(OutputSpeed speed) const volatile {
auto outputSpeedReg = getGPIOOutputSpeedRegister(m_GPIO_KEY);
SHAL_set_bits(outputSpeedReg.reg,2,static_cast<uint8_t>(speed),outputSpeedReg.offset);
}
void SHAL_GPIO::setInternalResistor(InternalResistorType type) volatile {
void SHAL_GPIO::setInternalResistor(InternalResistorType type) const volatile {
auto pupdreg = getGPIOPUPDRegister(m_GPIO_KEY);
SHAL_set_bits(pupdreg.reg,2,static_cast<uint8_t>(type),pupdreg.offset);
}
void SHAL_GPIO::setAlternateFunction(GPIO_Alternate_Function AF) volatile {
void SHAL_GPIO::setAlternateFunction(GPIO_Alternate_Function AF) const volatile {
auto alternateFunctionReg = getGPIOAlternateFunctionRegister(m_GPIO_KEY);
SHAL_set_bits(alternateFunctionReg.reg,4,static_cast<uint8_t>(AF),alternateFunctionReg.offset);
}
SHAL_Result SHAL_GPIO::setPinMode(PinMode mode) volatile {
SHAL_Result SHAL_GPIO::setPinMode(PinMode mode) const volatile {
auto pinModeReg = getGPIOModeRegister(m_GPIO_KEY);
/*

View File

@@ -34,19 +34,19 @@ void Timer::start() {
enableInterrupt();
}
void Timer::stop() {
void Timer::stop() const {
auto rcc_reg = getTimerRCC(m_key);
SHAL_clear_bitmask(rcc_reg.reg,rcc_reg.enable_mask);
}
void Timer::setPrescaler(const uint16_t presc) const {
void Timer::setPrescaler(const uint32_t presc) const {
auto prescalerReg = getTimerPrescalerRegister(m_key);
SHAL_set_bits(prescalerReg.reg,16,presc,0);
}
void Timer::setARR(const uint16_t arr) const {
void Timer::setARR(const uint32_t arr) const {
auto autoReloadReg = getTimerAutoReloadRegister(m_key);
SHAL_set_bits(autoReloadReg.reg,16,arr,0);}
@@ -56,7 +56,7 @@ void Timer::enableInterrupt() {
NVIC_EnableIRQ(getIRQn(m_key));
}
void Timer::init(uint16_t prescaler, uint16_t autoReload) {
void Timer::init(uint32_t prescaler, uint32_t autoReload) {
SHAL_TIM_RCC_Register rcc = getTimerRCC(m_key);
SHAL_apply_bitmask(rcc.reg,rcc.enable_mask);
@@ -65,7 +65,7 @@ void Timer::init(uint16_t prescaler, uint16_t autoReload) {
setARR(autoReload);
}
void Timer::configurePWM(SHAL_Timer_Channel channel, uint16_t prescaler, uint16_t autoReload, uint16_t captureCompareThreshold) {
void Timer::configurePWM(SHAL_Timer_Channel channel, uint32_t prescaler, uint32_t autoReload, uint32_t captureCompareThreshold) {
setPrescaler(prescaler);
setARR(autoReload);
@@ -76,7 +76,7 @@ void Timer::configurePWM(SHAL_Timer_Channel channel, uint16_t prescaler, uint16_
setCaptureCompareValue(channel, captureCompareThreshold);
}
void Timer::configureOneshot(SHAL_Timer_Channel channel, uint16_t prescaler, uint16_t autoReload, uint16_t captureCompareThreshold) {
void Timer::configureOneshot(SHAL_Timer_Channel channel, uint32_t prescaler, uint32_t autoReload, uint32_t captureCompareThreshold) {
setPrescaler(prescaler);
setARR(autoReload);
@@ -87,7 +87,7 @@ void Timer::configureOneshot(SHAL_Timer_Channel channel, uint16_t prescaler, uin
setCaptureCompareValue(channel, captureCompareThreshold);
}
void Timer::setOutputCompareMode(SHAL_Timer_Channel channel, SHAL_TIM_Output_Compare_Mode outputCompareMode) {
void Timer::setOutputCompareMode(SHAL_Timer_Channel channel, SHAL_TIM_Output_Compare_Mode outputCompareMode) const {
auto channelNum = static_cast<uint8_t>(channel);
@@ -114,7 +114,7 @@ void Timer::enableChannel(SHAL_Timer_Channel channel, SHAL_Timer_Channel_Main_Ou
SHAL_set_bits(captureCompareEnableReg.reg,16,setValue,0);
}
void Timer::setCaptureCompareValue(SHAL_Timer_Channel channel, uint16_t value) {
void Timer::setCaptureCompareValue(SHAL_Timer_Channel channel, uint32_t value) const {
auto captureCompareReg = getTimerCaptureCompareRegister(m_key,channel);
SHAL_set_bits(captureCompareReg.reg,16,value,0);