aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-04-12 00:43:12 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-04-12 00:43:12 -0400
commitee1d13d27d6e6be7f9babce655f697fe7f224c77 (patch)
treeae4a706753869229808ae652f29dbada3012eb50 /libmaple
parent7b14b950363f707c40732b4387f2f50711907673 (diff)
downloadlibrambutan-ee1d13d27d6e6be7f9babce655f697fe7f224c77.tar.gz
librambutan-ee1d13d27d6e6be7f9babce655f697fe7f224c77.zip
Adding guards for negative nvic_irq_num enumerators.
nvic_irq_enable() and nvic_irq_disable() previously didn't protect against negative arguments.
Diffstat (limited to 'libmaple')
-rw-r--r--libmaple/nvic.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/libmaple/nvic.h b/libmaple/nvic.h
index 2e98c9f..496c41b 100644
--- a/libmaple/nvic.h
+++ b/libmaple/nvic.h
@@ -160,6 +160,9 @@ static inline void nvic_globalirq_disable() {
* @param irq_num Interrupt to enable
*/
static inline void nvic_irq_enable(nvic_irq_num irq_num) {
+ if (irq_num < 0) {
+ return;
+ }
NVIC_BASE->ISER[irq_num / 32] = BIT(irq_num % 32);
}
@@ -168,6 +171,9 @@ static inline void nvic_irq_enable(nvic_irq_num irq_num) {
* @param irq_num Interrupt to disable
*/
static inline void nvic_irq_disable(nvic_irq_num irq_num) {
+ if (irq_num < 0) {
+ return;
+ }
NVIC_BASE->ICER[irq_num / 32] = BIT(irq_num % 32);
}