Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stm32] i2c irq priority can be set #1143

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/modm/platform/i2c/stm32-extended/i2c_master.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ MODM_ISR(I2C{{ id }}_ER)
// ----------------------------------------------------------------------------

void
modm::platform::I2cMaster{{ id }}::initializeWithPrescaler(uint32_t timingRegisterValue)
modm::platform::I2cMaster{{ id }}::initializeWithPrescaler(uint32_t timingRegisterValue, uint8_t isrPriority)
{
Rcc::enable<Peripheral::I2c{{id}}>();

Expand Down Expand Up @@ -557,19 +557,19 @@ modm::platform::I2cMaster{{ id }}::initializeWithPrescaler(uint32_t timingRegist

%% if shared_irq
// Enable Interrupt
NVIC_SetPriority({{ shared_irq }}_IRQn, 10);
NVIC_SetPriority({{ shared_irq }}_IRQn, isrPriority);
NVIC_EnableIRQ({{ shared_irq }}_IRQn);
%% elif single_interrupt
// Enable Interrupt
NVIC_SetPriority(I2C{{ id }}_IRQn, 10);
NVIC_SetPriority(I2C{{ id }}_IRQn, isrPriority);
NVIC_EnableIRQ(I2C{{ id }}_IRQn);
%% else
// Enable Error Interrupt
NVIC_SetPriority(I2C{{ id }}_ER_IRQn, 10);
NVIC_SetPriority(I2C{{ id }}_ER_IRQn, isrPriority);
NVIC_EnableIRQ(I2C{{ id }}_ER_IRQn);

// Enable Event Interrupt
NVIC_SetPriority(I2C{{ id }}_EV_IRQn, 10);
NVIC_SetPriority(I2C{{ id }}_EV_IRQn, isrPriority);
NVIC_EnableIRQ(I2C{{ id }}_EV_IRQn);
%% endif

Expand Down
6 changes: 3 additions & 3 deletions src/modm/platform/i2c/stm32-extended/i2c_master.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ public:
*/
template<class SystemClock, baudrate_t baudrate=kBd(100), percent_t tolerance=pct(5)>
static void
initialize()
initialize(uint8_t isrPriority = 10u)
{
constexpr std::optional<uint32_t> timingRegisterValue = calculateTimings<SystemClock, baudrate, tolerance>();
static_assert(bool(timingRegisterValue), "Could not find a valid clock configuration for the requested baudrate");

initializeWithPrescaler(timingRegisterValue.value());
initializeWithPrescaler(timingRegisterValue.value(), isrPriority);
}

static bool
Expand All @@ -118,7 +118,7 @@ public:

private:
static void
initializeWithPrescaler(uint32_t timingRegisterValue);
initializeWithPrescaler(uint32_t timingRegisterValue, uint8_t isrPriority = 10u);

%% if shared_irq
friend void ::{{ shared_irq }}_IRQHandler();
Expand Down