re-organized HAL
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@220 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -1,284 +0,0 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file nhd0420.h
|
||||
/// @brief File 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
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file nhd0420.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
#ifndef DISPLAY_INC_NHD0420_H_
|
||||
#define DISPLAY_INC_NHD0420_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "IODevice.h"
|
||||
#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)
|
||||
|
||||
#define NHD0420_CONTRAST_MIN (1)
|
||||
#define NHD0420_CONTRAST_MAX (50)
|
||||
|
||||
#define NHD0420_BRIGHTNESS_MIN (1)
|
||||
#define NHD0420_BRIGHTNESS_MAX (8)
|
||||
|
||||
#define NHD0420_BAUDRATE_MIN (1)
|
||||
#define NHD0420_BAUDRATE_MAX (8)
|
||||
|
||||
#define NHD0420_CMD_LENGTH (2)
|
||||
|
||||
#define NHD0420_CMD_PREFIX (0xFE)
|
||||
|
||||
#define NHD0420_CMD_DISPLAY_ON (0x41)
|
||||
#define NHD0420_CMD_DISPLAY_OFF (0x42)
|
||||
#define NHD0420_CMD_CURSOR_SET (0x45)
|
||||
#define NHD0420_CMD_CURSOR_HOME (0x46)
|
||||
#define NHD0420_CMD_CURSOR_UL_ON (0x47)
|
||||
#define NHD0420_CMD_CURSOR_UL_OFF (0x48)
|
||||
#define NHD0420_CMD_CURSOR_MV_LEFT (0x49)
|
||||
#define NHD0420_CMD_CURSOR_MV_RIGHT (0x4A)
|
||||
#define NHD0420_CMD_CURSOR_BLK_ON (0x4B)
|
||||
#define NHD0420_CMD_CURSOR_BLK_OFF (0x4C)
|
||||
#define NHD0420_CMD_CURSOR_BACKSPACE (0x4E)
|
||||
#define NHD0420_CMD_CLR_SCREEN (0x51)
|
||||
#define NHD0420_CMD_SET_CONTRAST (0x52)
|
||||
#define NHD0420_CMD_SET_BRIGHTNESS (0x53)
|
||||
#define NHD0420_CMD_LOAD_CSTM_CHAR (0x54)
|
||||
#define NHD0420_CMD_MV_DISPLAY_LEFT (0x55)
|
||||
#define NHD0420_CMD_MV_DISPLAY_RIGHT (0x56)
|
||||
#define NHD0420_CMD_CHANGE_RS232_BR (0x61)
|
||||
#define NHD0420_CMD_CHANGE_I2C_ADDRSS (0x62)
|
||||
#define NHD0420_CMD_SHOW_VERSION (0x70)
|
||||
#define NHD0420_CMD_SHOW_RS232_BR (0x71)
|
||||
#define NHD0420_CMD_SHOW_I2C_ADDRSS (0x72)
|
||||
|
||||
#define NHD0420_turnOnDisplay() NHD0420_sendCommand(NHD0420_CMD_DISPLAY_ON)
|
||||
#define NHD0420_turnOffDisplay() NHD0420_sendCommand(NHD0420_CMD_DISPLAY_OFF)
|
||||
|
||||
#define NHD0420_setCursorToHome() NHD0420_sendCommand(NHD0420_CMD_CURSOR_HOME)
|
||||
#define NHD0420_setUnderlineCursorOn() NHD0420_sendCommand(NHD0420_CMD_CURSOR_UL_ON)
|
||||
#define NHD0420_setUnderlineCursorOff() NHD0420_sendCommand(NHD0420_CMD_CURSOR_UL_OFF)
|
||||
#define NHD0420_moveCursorToLeft() NHD0420_sendCommand(NHD0420_CMD_CURSOR_MV_LEFT)
|
||||
#define NHD0420_moveCursorToRight() NHD0420_sendCommand(NHD0420_CMD_CURSOR_MV_RIGHT)
|
||||
#define NHD0420_turnOnBlinkingCursor() NHD0420_sendCommand(NHD0420_CMD_CURSOR_BLK_ON)
|
||||
#define NHD0420_turnOffBlinkingCursor() NHD0420_sendCommand(NHD0420_CMD_CURSOR_BLK_OFF)
|
||||
#define NHD0420_useBackspace() NHD0420_sendCommand(NHD0420_CMD_CURSOR_BACKSPACE)
|
||||
#define NHD0420_clearScreen() NHD0420_sendCommand(NHD0420_CMD_CLR_SCREEN)
|
||||
|
||||
#define NHD0420_moveDisplayToLeft() NHD0420_sendCommand(NHD0420_CMD_MV_DISPLAY_LEFT)
|
||||
#define NHD0420_moveDisplayToRight() NHD0420_sendCommand(NHD0420_CMD_MV_DISPLAY_RIGHT)
|
||||
|
||||
#define NHD0420_showFirmwareVersion() NHD0420_sendCommand(NHD0420_CMD_SHOW_VERSION)
|
||||
#define NHD0420_showRS232Baudrate() NHD0420_sendCommand(NHD0420_CMD_SHOW_RS232_BR)
|
||||
#define NHD0420_showI2CAddress() NHD0420_sendCommand(NHD0420_CMD_SHOW_I2C_ADDRSS)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* NHD0420_construct
|
||||
* Initialises the NewHeaven Display 0420
|
||||
*
|
||||
* @param interface The interface to use
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_construct(const struct IODevice* const device);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* 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
|
||||
*
|
||||
* @param row The Row to set - between 1 and 4
|
||||
* @param column The column to set - between 1 and 20
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setCursorToPosition(char row, char column);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* NHD0420_setContrast
|
||||
* Sets the contrast of the display
|
||||
*
|
||||
* @param contrast The contrast to set - between 1 and 50.
|
||||
* If passed value is outside the boundaries
|
||||
* this function will return ERROR
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setContrast(char contrast);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* NHD0420_setBacklightBrightness
|
||||
* Sets the backlight brightness of the display
|
||||
*
|
||||
* @param brightness The contrast to set - between 1 and 8
|
||||
* If passed value is outside the boundaries
|
||||
* this function will return ERROR
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setBacklightBrightness(char brightness);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* NHD0420_setRS232Baudrate
|
||||
* Sets the baudrate of the display
|
||||
*
|
||||
* @param baudrate The baudrate to set - between 1 and 8
|
||||
* 1 = 300 baud
|
||||
* 2 = 1200 baud
|
||||
* 3 = 2400 baud
|
||||
* 4 = 9600 baud
|
||||
* 5 = 14400 baud
|
||||
* 6 = 19200 baud
|
||||
* 7 = 57600 baud
|
||||
* 8 = 115200 baud
|
||||
* If passed value is outside the boundaries
|
||||
* this function will return ERROR
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setRS232Baudrate(char baudrate);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* NHD0420_setI2CAddress
|
||||
* Sets the I2C address of the display
|
||||
*
|
||||
* @param address The address to set
|
||||
* This command sets the I2C address. The
|
||||
* address must be an even number (LSB = 0)
|
||||
* and must not be 0xFF.
|
||||
* The address change requires 20 us to
|
||||
* take effect; therefore, the subsequent
|
||||
* input must have an appropriate delay.
|
||||
* The default I2C address can be
|
||||
* restored if SPI or RS-232 is selected as
|
||||
* the communication mode.
|
||||
* Default: 0x50
|
||||
*
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setI2CAddress(char address);
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* NHD0420_SendCommand
|
||||
* Send a command to the display
|
||||
*
|
||||
* @param command
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_sendCommand(char command);
|
||||
|
||||
extern ErrorStatus NHD0420_sendData(const char* buffer, size_t length);
|
||||
|
||||
#endif /* DISPLAY_INC_NHD0420_H_ */
|
||||
@@ -1,301 +0,0 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file nhd0420.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 nhd0420.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "nhd0420.h"
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define NHD0420_CURSOR_OFFSET_ROW1 (0x00)
|
||||
#define NHD0420_CURSOR_OFFSET_ROW2 (0x40)
|
||||
#define NHD0420_CURSOR_OFFSET_ROW3 (0x14)
|
||||
#define NHD0420_CURSOR_OFFSET_ROW4 (0x54)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static int nhd0420_cursorRowOffset[NHD0420_NUMBER_OF_ROWS] =
|
||||
{
|
||||
NHD0420_CURSOR_OFFSET_ROW1,
|
||||
NHD0420_CURSOR_OFFSET_ROW2,
|
||||
NHD0420_CURSOR_OFFSET_ROW3,
|
||||
NHD0420_CURSOR_OFFSET_ROW4
|
||||
};
|
||||
|
||||
static const struct IODevice* displayDevice = NULL;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus NHD0420_construct(const struct IODevice* const device)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (displayDevice == NULL)
|
||||
{
|
||||
displayDevice = device;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setCursorToPosition(char row, char column)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
// Setting cursor requires sending a command sequence with an additional
|
||||
// address parameter representing the line/column
|
||||
|
||||
// Each line has a dedicated offset, the column is simply added to that offset
|
||||
// Make sure to keep within boundaries to avoid glitches
|
||||
|
||||
row = row -1;
|
||||
column = column - 1;
|
||||
|
||||
// Check the coordinates to avoid glitches
|
||||
if ((row >= NHD0420_NUMBER_OF_ROWS) && (column >= NHD0420_NUMBER_OF_COLUMNS))
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
char address = nhd0420_cursorRowOffset[(int)row] + column;
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CURSOR_SET, address};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setContrast(char contrast)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
// Setting contrast requires sending a command sequence with an additional
|
||||
// parameter representing the contrast
|
||||
// Contrast values must be between NHD0420_CONTRAST_MIN and
|
||||
// NHD0420_CONTRAST_MAX. If boundaries are exceeded, this function will be
|
||||
// left with an ERROR
|
||||
|
||||
if ((contrast < NHD0420_CONTRAST_MIN) || (contrast > NHD0420_CONTRAST_MAX))
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_CONTRAST, contrast};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setBacklightBrightness(char brightness)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
// Setting backlight brightness requires sending a command sequence with an
|
||||
// additional parameter representing the brightness
|
||||
// Brightness values must be between NHD0420_BRIGHTNESS_MIN and
|
||||
// NHD0420_BRIGHTNESS_MAX. If boundaries are exceeded, this function will be
|
||||
// left with an ERROR
|
||||
|
||||
if ((brightness < NHD0420_BRIGHTNESS_MIN) || (brightness > NHD0420_BRIGHTNESS_MAX))
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_BRIGHTNESS, brightness};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setRS232Baudrate(char baudrate)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
// Setting baudrate requires sending a command sequence with an
|
||||
// additional parameter representing the baudrate
|
||||
// Baudrate values must be between NHD0420_BAUDRATE_MIN and
|
||||
// NHD0420_BAUDRATE_MAX. If boundaries are exceeded, this function will be
|
||||
// left with an ERROR
|
||||
|
||||
if ((baudrate < NHD0420_BAUDRATE_MIN) || (baudrate > NHD0420_BAUDRATE_MAX))
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_RS232_BR, baudrate};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_setI2CAddress(char address)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
// Setting I2C requires sending a command sequence with an
|
||||
// additional parameter representing the address
|
||||
// Baudrate values must be between NHD0420_BAUDRATE_MIN and
|
||||
// NHD0420_BAUDRATE_MAX. If boundaries are exeeded, this function will be
|
||||
// left with an ERROR
|
||||
|
||||
if ((address | 0xFE) != 0xFE)
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_I2C_ADDRSS, address};
|
||||
returnValue = NHD0420_sendData(buffer, 3);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* NHD0420_SendCommand
|
||||
* Send a command to the display
|
||||
*
|
||||
* @param command
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
ErrorStatus NHD0420_sendCommand(char command)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
char buffer[NHD0420_CMD_LENGTH] = {NHD0420_CMD_PREFIX, command};
|
||||
|
||||
returnValue = IODevice_write(displayDevice, buffer, NHD0420_CMD_LENGTH);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus NHD0420_sendData(const char* buffer, size_t length)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
returnValue = IODevice_write(displayDevice, buffer, length);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
Reference in New Issue
Block a user