From 7011d47c70076f995e8470c59eeaa8f3efcc9f05 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Fri, 25 May 2012 17:56:15 -0700 Subject: [PATCH 1/2] Mark reg32 variables as used. So that the compiler does not complain. --- lib/stm32/f1/gpio.c | 3 +++ lib/stm32/f2/gpio.c | 3 +++ lib/stm32/f4/gpio.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/lib/stm32/f1/gpio.c b/lib/stm32/f1/gpio.c index 4f7e663d..9ef60370 100644 --- a/lib/stm32/f1/gpio.c +++ b/lib/stm32/f1/gpio.c @@ -147,5 +147,8 @@ void gpio_port_config_lock(u32 gpioport, u16 gpios) reg32 = GPIO_LCKR(gpioport); /* Read LCKK. */ reg32 = GPIO_LCKR(gpioport); /* Read LCKK again. */ + /* Tell the compiler the variable is actually used. It will get optimized out anyways. */ + reg32 = reg32; + /* If (reg32 & GPIO_LCKK) is true, the lock is now active. */ } diff --git a/lib/stm32/f2/gpio.c b/lib/stm32/f2/gpio.c index 7a381204..fc7a5b69 100644 --- a/lib/stm32/f2/gpio.c +++ b/lib/stm32/f2/gpio.c @@ -135,5 +135,8 @@ void gpio_port_config_lock(u32 gpioport, u16 gpios) reg32 = GPIO_LCKR(gpioport); /* Read LCKK. */ reg32 = GPIO_LCKR(gpioport); /* Read LCKK again. */ + /* Tell the compiler the variable is actually used. It will get optimized out anyways. */ + reg32 = reg32; + /* If (reg32 & GPIO_LCKK) is true, the lock is now active. */ } diff --git a/lib/stm32/f4/gpio.c b/lib/stm32/f4/gpio.c index dea37208..e721f3f6 100644 --- a/lib/stm32/f4/gpio.c +++ b/lib/stm32/f4/gpio.c @@ -135,5 +135,8 @@ void gpio_port_config_lock(u32 gpioport, u16 gpios) reg32 = GPIO_LCKR(gpioport); /* Read LCKK. */ reg32 = GPIO_LCKR(gpioport); /* Read LCKK again. */ + /* Tell the compiler the variable is actually used. It will get optimized out anyways. */ + reg32 = reg32; + /* If (reg32 & GPIO_LCKK) is true, the lock is now active. */ } From 154f67598bb06c0c152bf121979c2292f7f10a84 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Sat, 26 May 2012 20:47:47 +1200 Subject: [PATCH 2/2] Fixed setting of interrupt priorities. --- lib/stm32/nvic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stm32/nvic.c b/lib/stm32/nvic.c index cd823e11..c9cf48bc 100644 --- a/lib/stm32/nvic.c +++ b/lib/stm32/nvic.c @@ -57,7 +57,7 @@ u8 nvic_get_irq_enabled(u8 irqn) void nvic_set_priority(u8 irqn, u8 priority) { - NVIC_IPR(irqn / 4) |= (priority << ((irqn % 4) * 8)); + NVIC_IPR(irqn) = priority; } void nvic_generate_software_interrupt(u8 irqn)