From ace3e75c09eedb4ee7c9e09abec626ff3885c3c3 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 12 Feb 2017 16:23:44 -0300 Subject: [PATCH] Changing interrupt priorities --- IOSTM.cpp | 6 +++--- SerialSTM.cpp | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/IOSTM.cpp b/IOSTM.cpp index 30c80f6..7e8b403 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -135,7 +135,7 @@ void CIO::Init() RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); - NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); + NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); EXTI_InitTypeDef EXTI_InitStructure; @@ -283,8 +283,8 @@ void CIO::startInt() NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; #endif - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 15; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } diff --git a/SerialSTM.cpp b/SerialSTM.cpp index 75f9309..3762f92 100644 --- a/SerialSTM.cpp +++ b/SerialSTM.cpp @@ -174,8 +174,8 @@ void InitUSART1(int speed) // USART IRQ init NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 15; NVIC_Init(&NVIC_InitStructure); // Configure USART as alternate function @@ -238,6 +238,11 @@ void WriteUSART1(const uint8_t* data, uint16_t length) #endif #if defined(SERIAL_REPEATER) + +extern "C" { + void USART2_IRQHandler(); +} + /* ************* USART2 ***************** */ volatile uint32_t intcount2; @@ -312,7 +317,8 @@ uint8_t TXSerialfifoput2(uint8_t next) void USART2_IRQHandler() { uint8_t c; - + io.DEB_pin(HIGH); + if (USART_GetITStatus(USART2, USART_IT_RXNE)) { c = (uint8_t) USART_ReceiveData(USART2); @@ -363,8 +369,8 @@ void InitUSART2(int speed) // USART IRQ init NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 15; NVIC_Init(&NVIC_InitStructure); // Configure USART as alternate function @@ -374,7 +380,7 @@ void InitUSART2(int speed) GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; // Rx GPIO_Init(GPIOA, &GPIO_InitStructure);