Fixed a display error

display has now a refresh timer to totally refresh the display contents (to prevent EMC issues)

Fixed PCBA names 

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@229 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-04 10:00:15 +00:00
parent c613e64e8a
commit 32be39611e
6 changed files with 103 additions and 43 deletions

View File

@@ -37,26 +37,26 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Constant and macro definitions // Constant and macro definitions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define MAX5715_NUMBER_OF_DACS (4) #define MAX5715_NUMBER_OF_DACS (4)
#define MAX5715_SPI_MAX_CLK_HZ (50000000) #define MAX5715_SPI_MAX_CLK_HZ (50000000)
// SPI settings // SPI settings
#define MAX5715_SPI_Direction (SPI_Direction_1Line_Tx) #define MAX5715_SPI_Direction (SPI_Direction_1Line_Tx)
#define MAX5715_SPI_Mode (SPI_Mode_Master) #define MAX5715_SPI_Mode (SPI_Mode_Master)
#define MAX5715_SPI_DataSize (SPI_DataSize_8b) #define MAX5715_SPI_DataSize (SPI_DataSize_8b)
#define MAX5715_SPI_CPOL (SPI_CPOL_Low) #define MAX5715_SPI_CPOL (SPI_CPOL_Low)
#define MAX5715_SPI_CPHA (SPI_CPHA_1Edge) #define MAX5715_SPI_CPHA (SPI_CPHA_1Edge)
#define MAX5715_SPI_NSS (SPI_NSS_Soft) #define MAX5715_SPI_NSS (SPI_NSS_Soft)
#define MAX5715_SPI_NSS_INTERNAL (SPI_NSSInternalSoft_Reset) #define MAX5715_SPI_NSS_INTERNAL (SPI_NSSInternalSoft_Reset)
#define MAX5715_SPI_FirstBit (SPI_FirstBit_MSB) #define MAX5715_SPI_FirstBit (SPI_FirstBit_MSB)
#define MAX5715_SPI_CRCPolynomial (7) #define MAX5715_SPI_CRCPolynomial (7)
#define MAX5715_SPI_RX_QUEUE (1) #define MAX5715_SPI_RX_QUEUE (1)
#define MAX5715_SPI_TX_QUEUE (32) #define MAX5715_SPI_TX_QUEUE (32)
#define MAX5715_SEL_DACA (0x1) #define MAX5715_SEL_DACA (0x1)
#define MAX5715_SEL_DACB (0x2) #define MAX5715_SEL_DACB (0x2)
#define MAX5715_SEL_DACC (0x4) #define MAX5715_SEL_DACC (0x4)
#define MAX5715_SEL_DACD (0x8) #define MAX5715_SEL_DACD (0x8)
#define MAX5715_CMD_CODEn (0x00) #define MAX5715_CMD_CODEn (0x00)
#define MAX5715_CMD_LOADn (0x10) #define MAX5715_CMD_LOADn (0x10)

View File

@@ -48,10 +48,10 @@ static struct Pcba thisPCBA;
static const char nameArray[4][20] = static const char nameArray[4][20] =
{ {
"Cathode/MCP repair ", "Cathode/MCP repair",
"Tesla repair ", "Tesla repair",
"Anode repair ", "Anode repair",
"UNDEFINED PCBA ", "UNDEFINED PCBA",
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@@ -68,6 +68,9 @@ struct Display
SemaphoreHandle_t displayShadowAccessSemaphore; SemaphoreHandle_t displayShadowAccessSemaphore;
struct DisplayCharacter displayShadow[DISPLAY_MAX_ROWS][DISPLAY_MAX_COLUMNS]; struct DisplayCharacter displayShadow[DISPLAY_MAX_ROWS][DISPLAY_MAX_COLUMNS];
int maxCharactersPerTransmit; int maxCharactersPerTransmit;
int refreshFeedCounter;
int refreshFeedFrequency_ms;
int refreshPeriod_ms;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -94,7 +97,7 @@ struct Display
* @todo * @todo
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
*/ */
extern ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displayDevice, int TaskPriority, uint16_t stackSize, int maxCharactersPerTransmit); extern ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displayDevice, int TaskPriority, uint16_t stackSize, int maxCharactersPerTransmit, int refreshFeedFrequency_ms, int refreshPeriod);
/** ---------------------------------------------------------------------------- /** ----------------------------------------------------------------------------
@@ -197,4 +200,19 @@ extern ErrorStatus Display_setContrast(struct Display* self, size_t contrast);
*/ */
extern ErrorStatus Display_write(struct Display* self, const char* buffer, unsigned int length, size_t row, size_t column); extern ErrorStatus Display_write(struct Display* self, const char* buffer, unsigned int length, size_t row, size_t column);
/** ----------------------------------------------------------------------------
* Display_feedRefreshCounter
* Feeds the refresh counter for display content
* Must be called regulary. Count rhythm and limits are defined in self
*
* @param self The display instance
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void Display_feedRefreshCounter(struct Display* self);
#endif /* DISPLAY_H_ */ #endif /* DISPLAY_H_ */

View File

@@ -54,15 +54,14 @@ static void DisplayTask(void* parameters);
inline static void Display_characterUpdate (struct DisplayCharacter* displayCharacter, char character); inline static void Display_characterUpdate (struct DisplayCharacter* displayCharacter, char character);
inline static bool Display_isCharacterUpdated (struct DisplayCharacter* displayCharacter); inline static bool Display_isCharacterUpdated (struct DisplayCharacter* displayCharacter);
inline static char Display_getUpdatedCharacter (struct DisplayCharacter* displayCharacter); inline static char Display_getUpdatedCharacter (struct DisplayCharacter* displayCharacter);
static void Display_characterUpdateAll(struct Display* self);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Function definitions // Function definitions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displayDevice, int TaskPriority, uint16_t stackSize, int maxCharactersPerTransmit) ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displayDevice, int TaskPriority, uint16_t stackSize, int maxCharactersPerTransmit, int refreshFeedFrequency_ms, int refreshPeriod)
{ {
int rowCounter = 0;
int colCounter = 0;
ErrorStatus returnValue = SUCCESS; ErrorStatus returnValue = SUCCESS;
@@ -70,21 +69,27 @@ ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displa
self->TaskPriority = TaskPriority; self->TaskPriority = TaskPriority;
self->stackSize = stackSize; self->stackSize = stackSize;
self->maxCharactersPerTransmit = maxCharactersPerTransmit; self->maxCharactersPerTransmit = maxCharactersPerTransmit;
self->refreshFeedCounter = 0;
self->refreshFeedFrequency_ms = refreshFeedFrequency_ms;
self->refreshPeriod_ms = refreshPeriod;
// Clear the display shadow
for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++)
{
for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++)
{
Display_characterUpdate(&self->displayShadow[rowCounter][colCounter], 0x20);
}
}
if(returnValue == SUCCESS) if(returnValue == SUCCESS)
{ {
// Create a semaphore to sync access to the display shadow // Create a semaphore to sync access to the display shadow
vSemaphoreCreateBinary(self->displayShadowAccessSemaphore); vSemaphoreCreateBinary(self->displayShadowAccessSemaphore);
xSemaphoreGive(self->displayShadowAccessSemaphore); xSemaphoreGive(self->displayShadowAccessSemaphore);
// Clear the display shadow
size_t rowCounter;
size_t colCounter;
for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++)
{
for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++)
{
Display_characterUpdate(&self->displayShadow[rowCounter][colCounter], 0x20);
}
}
} }
self->runTask = true; self->runTask = true;
@@ -186,6 +191,13 @@ ErrorStatus Display_write(struct Display* self, const char* buffer, unsigned int
return returnValue; return returnValue;
} }
void Display_feedRefreshCounter(struct Display* self)
{
self->refreshFeedCounter++;
}
inline static void Display_characterUpdate (struct DisplayCharacter* displayCharacter, char character) inline static void Display_characterUpdate (struct DisplayCharacter* displayCharacter, char character)
{ {
displayCharacter->character = character; displayCharacter->character = character;
@@ -206,6 +218,25 @@ inline static char Display_getUpdatedCharacter (struct DisplayCharacter* display
} }
static void Display_characterUpdateAll(struct Display* self)
{
size_t rowCounter;
size_t colCounter;
// Get the access semaphore to the shadow - wait until the other functions are finished with updating the shadow
xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY);
// Clear the display shadow
for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++)
{
for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++)
{
self->displayShadow[rowCounter][colCounter].isUpdated = true;
}
}
// Give back display memory access semaphore to allow new updates
xSemaphoreGive(self->displayShadowAccessSemaphore);
}
static void DisplayTask(void* parameters) static void DisplayTask(void* parameters)
{ {
struct Display* self = (struct Display*)parameters; struct Display* self = (struct Display*)parameters;
@@ -220,7 +251,7 @@ static void DisplayTask(void* parameters)
size_t columnStart; size_t columnStart;
while (self->runTask) while (self->runTask)
{ {
// Get the access semaphore to the shadow - wait until the write function is finished with updating the shadow // Get the access semaphore to the shadow - wait until the other functions are finished with updating the shadow
xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY); xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY);
leaveLoops = false; leaveLoops = false;
bufferIndex = 0; bufferIndex = 0;
@@ -299,6 +330,14 @@ static void DisplayTask(void* parameters)
rowCounter = 0; rowCounter = 0;
} }
} }
// Check for display refresh timings
if (self->refreshFeedCounter * self->refreshFeedFrequency_ms > self->refreshPeriod_ms)
{
self->refreshFeedCounter = 0;
Display_characterUpdateAll(self);
}
vTaskDelay(10); vTaskDelay(10);
} }

View File

@@ -85,7 +85,8 @@ static xTaskHandle initTaskHandle;
static xTaskHandle ledTaskHandle; static xTaskHandle ledTaskHandle;
static xTaskHandle sysTaskHandle; static xTaskHandle sysTaskHandle;
static struct Display display; static struct Display _display;
struct Display* display = &_display;
static struct NHD0420 nhd0420; static struct NHD0420 nhd0420;
static struct MAX5715 max5715; static struct MAX5715 max5715;
@@ -136,10 +137,9 @@ static void printSystemInfoTask(void* parameters)
{ {
while (1) while (1)
{ {
uint16_t adcValue = 0;
LOGGER_INFO("---------------------------------------"); LOGGER_INFO("---------------------------------------");
systeminfoCommandHandler(); systeminfoCommandHandler();
vTaskDelay(2000); vTaskDelay(60000);
} }
} }
@@ -159,7 +159,7 @@ static ErrorStatus systeminfoCommandHandler(void)
vTaskDelay(100); vTaskDelay(100);
OS_logTaskInfo(sysTaskHandle); OS_logTaskInfo(sysTaskHandle);
vTaskDelay(100); vTaskDelay(100);
OS_logTaskInfo(display.taskHandle); OS_logTaskInfo(display->taskHandle);
return errorStatus; return errorStatus;
} }
@@ -174,18 +174,18 @@ static void initTask(void* parameters)
NHD0420_construct(&nhd0420, &spiDisplay->device); NHD0420_construct(&nhd0420, &spiDisplay->device);
Display_construct(&display, &nhd0420.displayDevice, 0, 1024, 10); Display_construct(display, &nhd0420.displayDevice, 0, 1024, 10, 1000, 5000);
Display_clearScreen(&display); Display_clearScreen(display);
Display_write(&display, pcba->name, sizeof(pcba->name) / sizeof(pcba->name[0]), 1, 1); Display_write(display, pcba->name, strlen(pcba->name), 1, 1);
char buffer[20]; char buffer[20];
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "SW V. %d.%d.%d.%d", Version_getInstance()->major, snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "SW V. %d.%d.%d.%d", Version_getInstance()->major,
Version_getInstance()->minor, Version_getInstance()->minor,
Version_getInstance()->branch, Version_getInstance()->branch,
Version_getInstance()->patch); Version_getInstance()->patch);
Display_write(&display, buffer, strlen(buffer), 3, 4); Display_write(display, buffer, strlen(buffer), 3, 4);
MAX5715_construct(&max5715, &spiDAC->device); MAX5715_construct(&max5715, &spiDAC->device);

View File

@@ -37,6 +37,7 @@
#include "stm32f10x_spi.h" #include "stm32f10x_spi.h"
#include "stm32f10x_usart.h" #include "stm32f10x_usart.h"
#include "Display.h"
#include "Logger.h" #include "Logger.h"
#include "led.h" #include "led.h"
#include "platform.h" #include "platform.h"
@@ -374,6 +375,7 @@ void EXTI9_5_IRQHandler (void)
} }
extern struct Display* display;
void RTC_IRQHandler(void) void RTC_IRQHandler(void)
{ {
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
@@ -384,6 +386,7 @@ void RTC_IRQHandler(void)
RTC_ClearITPendingBit(RTC_IT_SEC); RTC_ClearITPendingBit(RTC_IT_SEC);
xSemaphoreGiveFromISR(rtc->secondSync, &higherPriorityTaskWoken); xSemaphoreGiveFromISR(rtc->secondSync, &higherPriorityTaskWoken);
Display_feedRefreshCounter(display);
if (ledGreen->status) if (ledGreen->status)
{ {
LED_turnOff(ledGreen); LED_turnOff(ledGreen);