- added IODevice support

- fixed some issues with the logger and stack sizes

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@216 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-09-26 11:11:33 +00:00
parent 7bcde7ff5d
commit 1bcb4809db
48 changed files with 1033 additions and 11740 deletions

View File

@@ -11,9 +11,9 @@
// Email: support@microkey.nl
// Web: www.microkey.nl
// -----------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
/// $Revision$
/// $Author$
/// $Date$
// (c) 2017 Micro-Key bv
// -----------------------------------------------------------------------------
@@ -32,12 +32,25 @@
// Include files
// -----------------------------------------------------------------------------
#include "spi.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define NHD0420_SPI_MAX_CLK_HZ (100000)
// SPI settings
#define NHD0420_SPI_Direction (SPI_Direction_1Line_Tx)
#define NHD0420_SPI_Mode (SPI_Mode_Master)
#define NHD0420_SPI_DataSize (SPI_DataSize_8b)
#define NHD0420_SPI_CPOL (SPI_CPOL_High)
#define NHD0420_SPI_CPHA (SPI_CPHA_2Edge)
#define NHD0420_SPI_NSS (SPI_NSS_Soft)
#define NHD0420_SPI_FirstBit (SPI_FirstBit_MSB)
#define NHD0420_SPI_CRCPolynomial (7)
#define NHD0420_SPI_RX_QUEUE (32)
#define NHD0420_SPI_TX_QUEUE (32)
#define NHD0420_NUMBER_OF_ROWS (4)
#define NHD0420_NUMBER_OF_COLUMNS (20)
@@ -109,7 +122,7 @@
/** ----------------------------------------------------------------------------
* NHD0420_Init
* NHD0420_construct
* Initialises the NewHeaven Display 0420
*
* @param interface The interface to use
@@ -123,6 +136,34 @@
extern ErrorStatus NHD0420_construct(void* interface);
/** ----------------------------------------------------------------------------
* NHD0420_destruct
* Destructor for the NHD0420 instance
*
* @param interface The interface to use
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void NHD0420_destruct(void);
/** ----------------------------------------------------------------------------
* NHD0420_getSpiParameters
* Function that assigns the NHD0420 SPI parameters to a spiParameters struct
*
* @param parameters
*
* @return ErrorStatus
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters);
/** ----------------------------------------------------------------------------
* NHD0420_setCursorToPosition
* Sets the cursor of the display to the specified row and column

View File

@@ -11,9 +11,9 @@
// Email: support@microkey.nl
// Web: www.microkey.nl
// -----------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
/// $Revision$
/// $Author$
/// $Date$
// (c) 2017 Micro-Key bv
// -----------------------------------------------------------------------------
@@ -25,7 +25,9 @@
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include <stdio.h>
#include "stm32f10x.h"
#include "nhd0420.h"
@@ -58,6 +60,8 @@ static int nhd0420_cursorRowOffset[NHD0420_NUMBER_OF_ROWS] =
NHD0420_CURSOR_OFFSET_ROW4
};
static bool initialized = false;
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
@@ -72,7 +76,65 @@ static struct SpiDevice* nhd0420Interface;
ErrorStatus NHD0420_construct(void* interface)
{
ErrorStatus returnValue = SUCCESS;
nhd0420Interface = (struct SpiDevice*)interface;
if (!initialized)
{
nhd0420Interface = (struct SpiDevice*)interface;
if (returnValue == SUCCESS)
{
initialized = true;
}
}
return returnValue;
}
void NHD0420_destruct (void)
{
}
ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters)
{
ErrorStatus returnValue = SUCCESS;
if ((configCPU_CLOCK_HZ / 64) < NHD0420_SPI_MAX_CLK_HZ)
{
parameters->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64;
}
else if ((configCPU_CLOCK_HZ / 128) < NHD0420_SPI_MAX_CLK_HZ)
{
parameters->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_128;
}
else if ((configCPU_CLOCK_HZ / 256) < NHD0420_SPI_MAX_CLK_HZ)
{
parameters->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
}
else
{
// The CPU clock is too high. The pre-scaler has a max of 256. A clock higher than 25,6 MHz
// results in a SPI CLK higher than 100 kHz, which is the max of the display
returnValue = ERROR;
}
if (returnValue == SUCCESS)
{
// SPI pre-scaler was no problem - assign the remaining parameters
parameters->SPI_CPHA = NHD0420_SPI_CPHA;
parameters->SPI_CPOL = NHD0420_SPI_CPOL;
parameters->SPI_CRCPolynomial = NHD0420_SPI_CRCPolynomial;
parameters->SPI_DataSize = NHD0420_SPI_DataSize;
parameters->SPI_Direction = NHD0420_SPI_Direction;
parameters->SPI_FirstBit = NHD0420_SPI_FirstBit;
parameters->SPI_Mode = NHD0420_SPI_Mode;
parameters->SPI_NSS = NHD0420_SPI_NSS;
parameters->rxQueueSize = NHD0420_SPI_RX_QUEUE;
parameters->txQueueSize = NHD0420_SPI_TX_QUEUE;
}
return returnValue;
}
@@ -100,7 +162,7 @@ ErrorStatus NHD0420_setCursorToPosition(uint8_t row, uint8_t column)
if (returnValue == SUCCESS)
{
uint8_t address = nhd0420_cursorRowOffset[row] + column;
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CURSOR_SET, address};
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CURSOR_SET, address};
returnValue = NHD0420_sendData(buffer, 3);
}
@@ -126,7 +188,7 @@ ErrorStatus NHD0420_setContrast(uint8_t contrast)
if (returnValue == SUCCESS)
{
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_CONTRAST, contrast};
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_CONTRAST, contrast};
returnValue = NHD0420_sendData(buffer, 3);
}
@@ -152,7 +214,7 @@ ErrorStatus NHD0420_setBacklightBrightness(uint8_t brightness)
if (returnValue == SUCCESS)
{
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_BRIGHTNESS, brightness};
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_BRIGHTNESS, brightness};
returnValue = NHD0420_sendData(buffer, 3);
}
@@ -177,7 +239,7 @@ ErrorStatus NHD0420_setRS232Baudrate(uint8_t baudrate)
if (returnValue == SUCCESS)
{
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_RS232_BR, baudrate};
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_RS232_BR, baudrate};
returnValue = NHD0420_sendData(buffer, 3);
}
return returnValue;
@@ -201,7 +263,7 @@ ErrorStatus NHD0420_setI2CAddress(uint8_t address)
if (returnValue == SUCCESS)
{
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_I2C_ADDRSS, address};
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_I2C_ADDRSS, address};
returnValue = NHD0420_sendData(buffer, 3);
}
return returnValue;