Updates on the IODevice structure.
Display and Logger fully functional. Keypad task completed - yet to be tested git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@219 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "IODevice.h"
|
||||
#include "spi.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -133,7 +134,7 @@
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_construct(void* interface);
|
||||
extern ErrorStatus NHD0420_construct(const struct IODevice* const device);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
@@ -177,7 +178,7 @@ extern ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters);
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setCursorToPosition(uint8_t row, uint8_t column);
|
||||
extern ErrorStatus NHD0420_setCursorToPosition(char row, char column);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
@@ -194,7 +195,7 @@ extern ErrorStatus NHD0420_setCursorToPosition(uint8_t row, uint8_t column);
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setContrast(uint8_t contrast);
|
||||
extern ErrorStatus NHD0420_setContrast(char contrast);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
@@ -211,7 +212,7 @@ extern ErrorStatus NHD0420_setContrast(uint8_t contrast);
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setBacklightBrightness(uint8_t brightness);
|
||||
extern ErrorStatus NHD0420_setBacklightBrightness(char brightness);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
@@ -236,7 +237,7 @@ extern ErrorStatus NHD0420_setBacklightBrightness(uint8_t brightness);
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setRS232Baudrate(uint8_t baudrate);
|
||||
extern ErrorStatus NHD0420_setRS232Baudrate(char baudrate);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
@@ -262,7 +263,7 @@ extern ErrorStatus NHD0420_setRS232Baudrate(uint8_t baudrate);
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setI2CAddress(uint8_t address);
|
||||
extern ErrorStatus NHD0420_setI2CAddress(char address);
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* NHD0420_SendCommand
|
||||
@@ -276,8 +277,8 @@ extern ErrorStatus NHD0420_setI2CAddress(uint8_t address);
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_sendCommand(uint8_t command);
|
||||
extern ErrorStatus NHD0420_sendCommand(char command);
|
||||
|
||||
extern ErrorStatus NHD0420_sendData(const uint8_t* buffer, size_t length);
|
||||
extern ErrorStatus NHD0420_sendData(const char* buffer, size_t length);
|
||||
|
||||
#endif /* DISPLAY_INC_NHD0420_H_ */
|
||||
|
||||
@@ -60,7 +60,7 @@ static int nhd0420_cursorRowOffset[NHD0420_NUMBER_OF_ROWS] =
|
||||
NHD0420_CURSOR_OFFSET_ROW4
|
||||
};
|
||||
|
||||
static bool initialized = false;
|
||||
static const struct IODevice* displayDevice = NULL;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
@@ -71,22 +71,20 @@ static bool initialized = false;
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static struct SpiDevice* nhd0420Interface;
|
||||
|
||||
ErrorStatus NHD0420_construct(void* interface)
|
||||
ErrorStatus NHD0420_construct(const struct IODevice* const device)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (!initialized)
|
||||
if (displayDevice == NULL)
|
||||
{
|
||||
nhd0420Interface = (struct SpiDevice*)interface;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
displayDevice = device;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -140,7 +138,7 @@ ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters)
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setCursorToPosition(uint8_t row, uint8_t column)
|
||||
ErrorStatus NHD0420_setCursorToPosition(char row, char column)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
@@ -161,8 +159,8 @@ ErrorStatus NHD0420_setCursorToPosition(uint8_t row, uint8_t column)
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
uint8_t address = nhd0420_cursorRowOffset[row] + column;
|
||||
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CURSOR_SET, address};
|
||||
char address = nhd0420_cursorRowOffset[(int)row] + column;
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CURSOR_SET, address};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
|
||||
@@ -170,7 +168,7 @@ ErrorStatus NHD0420_setCursorToPosition(uint8_t row, uint8_t column)
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setContrast(uint8_t contrast)
|
||||
ErrorStatus NHD0420_setContrast(char contrast)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
@@ -188,7 +186,7 @@ ErrorStatus NHD0420_setContrast(uint8_t contrast)
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_CONTRAST, contrast};
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_CONTRAST, contrast};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
|
||||
@@ -196,7 +194,7 @@ ErrorStatus NHD0420_setContrast(uint8_t contrast)
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setBacklightBrightness(uint8_t brightness)
|
||||
ErrorStatus NHD0420_setBacklightBrightness(char brightness)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
@@ -214,7 +212,7 @@ ErrorStatus NHD0420_setBacklightBrightness(uint8_t brightness)
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_BRIGHTNESS, brightness};
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_BRIGHTNESS, brightness};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
|
||||
@@ -222,7 +220,7 @@ ErrorStatus NHD0420_setBacklightBrightness(uint8_t brightness)
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setRS232Baudrate(uint8_t baudrate)
|
||||
ErrorStatus NHD0420_setRS232Baudrate(char baudrate)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
@@ -239,14 +237,14 @@ ErrorStatus NHD0420_setRS232Baudrate(uint8_t baudrate)
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_RS232_BR, baudrate};
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_RS232_BR, baudrate};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setI2CAddress(uint8_t address)
|
||||
ErrorStatus NHD0420_setI2CAddress(char address)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
@@ -263,7 +261,7 @@ ErrorStatus NHD0420_setI2CAddress(uint8_t address)
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_I2C_ADDRSS, address};
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_I2C_ADDRSS, address};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
return returnValue;
|
||||
@@ -281,23 +279,23 @@ ErrorStatus NHD0420_setI2CAddress(uint8_t address)
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
ErrorStatus NHD0420_sendCommand(uint8_t command)
|
||||
ErrorStatus NHD0420_sendCommand(char command)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
uint8_t buffer[NHD0420_CMD_LENGTH] = {NHD0420_CMD_PREFIX, command};
|
||||
char buffer[NHD0420_CMD_LENGTH] = {NHD0420_CMD_PREFIX, command};
|
||||
|
||||
returnValue = SPI_write(nhd0420Interface, buffer, NHD0420_CMD_LENGTH);
|
||||
returnValue = IODevice_write(displayDevice, buffer, NHD0420_CMD_LENGTH);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_sendData(const uint8_t* buffer, size_t length)
|
||||
ErrorStatus NHD0420_sendData(const char* buffer, size_t length)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
returnValue = SPI_write(nhd0420Interface, buffer, length);
|
||||
returnValue = IODevice_write(displayDevice, buffer, length);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user