Improvements:
- HAL re-organized - FreeRTOS running stable - UART finished - SPI1 & SPI3 finished and functional - Display driver added (functional) git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@172 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,266 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file stm32f10x_it.c
|
||||
/// @brief Description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file stm32f10x_it.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "misc.h"
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#include "stm32f10x_it.h"
|
||||
|
||||
#include "led.h"
|
||||
#include "platform.h"
|
||||
#include "spi.h"
|
||||
#include "uart.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void IRQ_setInterruptProperties(uint8_t irqChannel, uint8_t preemptionPriority, uint8_t subPriority, FunctionalState command)
|
||||
{
|
||||
NVIC_InitTypeDef NVIC_InitStructure; //! Define empty NVIC structure
|
||||
|
||||
//! Configure the USARTx Interrupt
|
||||
NVIC_InitStructure.NVIC_IRQChannel = irqChannel;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = preemptionPriority;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = subPriority;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = command;
|
||||
//! initialize the interrupts interface will all configured items
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SVCall exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
// void SVC_Handler(void)
|
||||
// {
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief This function handles PendSVC exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
// void PendSV_Handler(void)
|
||||
// {
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief This function handles SysTick Handler.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
// void SysTick_Handler(void)
|
||||
// {
|
||||
// }
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* @brief Function: USART1_IRQHandler
|
||||
*
|
||||
* Dedicated Interrupt Service Routine for USART1
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
|
||||
//! Transmission register empty interrupt
|
||||
if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET)
|
||||
{
|
||||
|
||||
//! Receive element from usart transmission queue
|
||||
|
||||
struct usartQueueItem usartTxItem;
|
||||
|
||||
xQueueReceiveFromISR(uart1->txQueue, &usartTxItem, &higherPriorityTaskWoken);
|
||||
//! Write one byte to the transmit data register
|
||||
USART_SendData(USART1, usartTxItem.byte);
|
||||
//! check if queue is empty -> all bytes transmit
|
||||
if(pdTRUE == xQueueIsQueueEmptyFromISR(uart1->txQueue))
|
||||
{
|
||||
//! Disable the COMPORT Transmit interrupt and release semaphore
|
||||
USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
|
||||
xSemaphoreGiveFromISR(uart1->txSemaphore, &higherPriorityTaskWoken);
|
||||
}
|
||||
}
|
||||
|
||||
//! Current interrupt is triggered by USART_RXNE (receive register not empty)
|
||||
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
|
||||
{
|
||||
//! Read one byte from the receive data register
|
||||
|
||||
struct usartQueueItem usartRxItem;
|
||||
//! Reading from reception register automatically clears the RXNE interrupt
|
||||
usartRxItem.byte = (unsigned char) 0xFF & USART_ReceiveData(USART1);
|
||||
//! Add the byte to the bluetooth RX queue
|
||||
//! In case of a full queue, the data is dumped
|
||||
(void)xQueueSendFromISR(uart1->rxQueue, &usartRxItem, &higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* @brief Function: SPI1_IRQHandler
|
||||
*
|
||||
* Dedicated Interrupt Service Routine for SPI1
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
void SPI1_IRQHandler (void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
//! Transmission register empty interrupt
|
||||
if(SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_TXE) != RESET)
|
||||
{
|
||||
//! Receive element from usart transmission queue
|
||||
|
||||
struct spiQueueItem spiTxItem;
|
||||
|
||||
xQueueReceiveFromISR(spi1->txQueue, &spiTxItem, &higherPriorityTaskWoken);
|
||||
//! Write one byte to the transmit data register
|
||||
if (spi1->SPI_InitStruct.SPI_NSS == SPI_NSS_Soft)
|
||||
{
|
||||
GPIO_ResetBits(spi1->SPI_CE->GPIO_Typedef, spi1->SPI_CE->GPIO_InitStruct.GPIO_Pin);
|
||||
}
|
||||
SPI_I2S_SendData(SPI1, spiTxItem.byte);
|
||||
if (spi1->SPI_InitStruct.SPI_NSS == SPI_NSS_Soft)
|
||||
{
|
||||
GPIO_SetBits(spi1->SPI_CE->GPIO_Typedef, spi1->SPI_CE->GPIO_InitStruct.GPIO_Pin);
|
||||
}
|
||||
//! check if queue is empty -> all bytes transmit
|
||||
if(pdTRUE == xQueueIsQueueEmptyFromISR(spi1->txQueue))
|
||||
{
|
||||
//! Disable the COMPORT Transmit interrupt and release semaphore
|
||||
SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, DISABLE);
|
||||
xSemaphoreGiveFromISR(spi1->txSemaphore, &higherPriorityTaskWoken);
|
||||
}
|
||||
}
|
||||
|
||||
//! Current interrupt is triggered by USART_RXNE (receive register not empty)
|
||||
if(SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_RXNE) != RESET)
|
||||
{
|
||||
//! Read one byte from the receive data register
|
||||
|
||||
struct spiQueueItem spiRxItem;
|
||||
//! Reading from reception register automatically clears the RXNE interrupt
|
||||
spiRxItem.byte = (unsigned char) 0xFF & SPI_I2S_ReceiveData(SPI1);
|
||||
//! Add the byte to the bluetooth RX queue
|
||||
//! In case of a full queue, the data is dumped
|
||||
(void)xQueueSendFromISR(spi1->rxQueue, &spiRxItem, &higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* @brief Function: SPI3_IRQHandler
|
||||
*
|
||||
* Dedicated Interrupt Service Routine for SPI3
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
void SPI3_IRQHandler (void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
//! Transmission register empty interrupt
|
||||
if(SPI_I2S_GetITStatus(SPI3, SPI_I2S_IT_TXE) != RESET)
|
||||
{
|
||||
//! Receive element from usart transmission queue
|
||||
struct spiQueueItem spiTxItem;
|
||||
|
||||
xQueueReceiveFromISR(spi3->txQueue, &spiTxItem, &higherPriorityTaskWoken);
|
||||
//! Write one byte to the transmit data register
|
||||
SPI_I2S_SendData(SPI3, spiTxItem.byte);
|
||||
|
||||
//! check if queue is empty -> all bytes transmit
|
||||
if(pdTRUE == xQueueIsQueueEmptyFromISR(spi3->txQueue))
|
||||
{
|
||||
//! Disable the COMPORT Transmit interrupt and release semaphore
|
||||
SPI_I2S_ITConfig(SPI3, SPI_I2S_IT_TXE, DISABLE);
|
||||
xSemaphoreGiveFromISR(spi3->txSemaphore, &higherPriorityTaskWoken);
|
||||
}
|
||||
}
|
||||
|
||||
//! Current interrupt is triggered by USART_RXNE (receive register not empty)
|
||||
if(SPI_I2S_GetITStatus(SPI3, SPI_I2S_IT_RXNE) != RESET)
|
||||
{
|
||||
//! Read one byte from the receive data register
|
||||
|
||||
struct spiQueueItem spiRxItem;
|
||||
//! Reading from reception register automatically clears the RXNE interrupt
|
||||
spiRxItem.byte = (unsigned char) 0xFF & SPI_I2S_ReceiveData(SPI3);
|
||||
//! Add the byte to the bluetooth RX queue
|
||||
//! In case of a full queue, the data is dumped
|
||||
(void)xQueueSendFromISR(spi3->rxQueue, &spiRxItem, &higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
Reference in New Issue
Block a user