Continued work on MAX5715. MACRO functions are done, mostly tested in logic analyzer. SPI unable to work with hardware SS, so software SS is used instead

Added UART3 on PB10/PB11 for terminal (future use)

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@225 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-09-29 14:42:38 +00:00
parent b56bc71f36
commit f44979bf75
15 changed files with 412 additions and 95 deletions

View File

@@ -36,6 +36,7 @@
#include "misc.h"
#include "stm32f10x_rcc.h"
#include "MAX5715.h"
#include "nhd0420.h"
#include "keypadMatrix.h"
@@ -77,6 +78,9 @@ static xTaskHandle initTaskHandle;
static xTaskHandle ledTaskHandle;
static xTaskHandle sysTaskHandle;
static struct NHD0420 nhd0420;
static struct MAX5715 max5715;
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
@@ -153,21 +157,26 @@ static void initTask(void* parameters)
Logger_construct(&uart1->device);
NHD0420_construct(&spiDisplay->device);
NHD0420_construct(&nhd0420, &spiDisplay->device);
NHD0420_turnOffDisplay(&spiDisplay->device);
NHD0420_turnOffDisplay(&nhd0420);
vTaskDelay(1000);
NHD0420_clearScreen(&spiDisplay->device);
NHD0420_clearScreen(&nhd0420);
vTaskDelay(1000);
NHD0420_turnOnDisplay(&spiDisplay->device);
NHD0420_turnOnDisplay(&nhd0420);
vTaskDelay(1000);
NHD0420_setContrast(&spiDisplay->device, 30);
NHD0420_setContrast(&nhd0420, 30);
vTaskDelay(1000);
NHD0420_setBacklightBrightness(&spiDisplay->device, 3);
NHD0420_setBacklightBrightness(&nhd0420, 3);
vTaskDelay(1000);
NHD0420_setCursorToHome(&spiDisplay->device);
NHD0420_setCursorToHome(&nhd0420);
vTaskDelay(1000);
NHD0420_sendData(&spiDisplay->device, "Anode repair A", 20);
NHD0420_sendData(&nhd0420, "Anode repair A", 20);
MAX5715_construct(&max5715, &spiDAC->device);
MAX5715_writeCODEn(&max5715, (MAX5715_SEL_DACA | MAX5715_SEL_DACC), 0x579B);
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 40, &ledTaskArguments, 0, &ledTaskHandle);

View File

@@ -172,6 +172,58 @@ void USART1_IRQHandler(void)
}
/** ----------------------------------------------------------------------------
* @brief Function: USART3_IRQHandler
*
* Dedicated Interrupt Service Routine for USART3
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
void USART3_IRQHandler(void)
{
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
//! Transmission register empty interrupt
if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET)
{
//! Receive element from usart transmission queue
struct usartQueueItem usartTxItem;
xQueueReceiveFromISR(uart3->txQueue, &usartTxItem, &higherPriorityTaskWoken);
//! Write one byte to the transmit data register
USART_SendData(USART3, usartTxItem.byte);
//! check if queue is empty -> all bytes transmit
if(pdTRUE == xQueueIsQueueEmptyFromISR(uart3->txQueue))
{
//! Disable the COMPORT Transmit interrupt and release semaphore
USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
xSemaphoreGiveFromISR(uart3->txSemaphore, &higherPriorityTaskWoken);
}
}
//! Current interrupt is triggered by USART_RXNE (receive register not empty)
if(USART_GetITStatus(USART3, 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(USART3);
//! Add the byte to the bluetooth RX queue
//! In case of a full queue, the data is dumped
(void)xQueueSendFromISR(uart3->rxQueue, &usartRxItem, &higherPriorityTaskWoken);
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
/** ----------------------------------------------------------------------------
* @brief Function: SPI1_IRQHandler
*
@@ -195,15 +247,7 @@ void SPI1_IRQHandler (void)
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))
{