Skip to content

Commit

Permalink
ADD: priority grouping configuration, interrupts priorities definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
r2axz committed Nov 29, 2020
1 parent ce1031b commit 3a27426
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# General Target Settings
TARGET = bluepill-serial-monster
SRCS = main.c system_clock.c status_led.c usb_core.c usb_descriptors.c\
SRCS = main.c system_clock.c system_interrupts.c status_led.c usb_core.c usb_descriptors.c\
usb_io.c usb_uid.c usb_panic.c usb_cdc.c cdc_shell.c gpio.c device_config.c

# Toolchain & Utils
Expand Down
2 changes: 2 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

#include <stm32f1xx.h>
#include "system_clock.h"
#include "system_interrupts.h"
#include "status_led.h"
#include "device_config.h"
#include "usb.h"


int main() {
system_clock_init();
system_interrupts_init();
device_config_init();
status_led_init();
usb_init();
Expand Down
5 changes: 5 additions & 0 deletions system_interrupts.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "system_interrupts.h"

void system_interrupts_init() {
NVIC_SetPriorityGrouping(SYSTEM_INTERRUPTS_PRIORITY_GROUPING);
}
12 changes: 12 additions & 0 deletions system_interrupts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef SYSTEM_INTERRUPTS_H
#define SYSTEM_INTERRUPTS_H

#include <stm32f1xx.h>

#define SYSTEM_INTERRUPTS_PRIORITY_GROUPING 0x02 /* 2 bits preemption, 2 bits sub-priority */
#define SYSTEM_INTERRUTPS_PRIORITY_CRITICAL (NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0))
#define SYSTEM_INTERRUTPS_PRIORITY_BASE (NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 2, 0))

void system_interrupts_init();

#endif /* SYSTEM_INTERRUPTS_H */

0 comments on commit 3a27426

Please sign in to comment.