BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Functions
sharplcd.h File Reference

Interface for Sharp Memory LCD displays. More...

#include <bsp430/core.h>
#include <bsp430/serial.h>
#include <bsp430/periph/port.h>

Go to the source code of this file.

Data Structures

struct  sBSP430sharplcd
 

Macros

#define configBSP430_PLATFORM_SHARPLCD   0
 
#define BSP430_PLATFORM_SHARPLCD   include <bsp430/platform.h>
 
#define configBSP430_PLATFORM_BOOSTERPACK_SHARP96   0
 
#define BSP430_PLATFORM_BOOSTERPACK_SHARP96   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_ROWS   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_COLUMNS   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_BYTES_PER_LINE   ((7 + BSP430_PLATFORM_SHARPLCD_COLUMNS) / 8)
 
#define BSP430_SHARPLCD_REFRESH_INTERVAL_MS   1000
 
#define BSP430_PLATFORM_SHARPLCD_SPI_BUS_HZ   1000000UL
 
#define BSP430_SHARPLCD_CTL0_INITIALIZER   BSP430_SERIAL_ADJUST_CTL0_INITIALIZER(UCCKPH | UCMSB | UCMST)
 
#define BSP430_PLATFORM_SHARPLCD_CS_PORT_PERIPH_HANDLE   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_CS_PORT_BIT   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_LCD_EN_PORT_PERIPH_HANDLE   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_LCD_EN_PORT_BIT   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_PWR_EN_PORT_PERIPH_HANDLE   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_PWR_EN_PORT_BIT   include <bsp430/platform.h>
 
#define BSP430_PLATFORM_SHARPLCD_SPI_PERIPH_HANDLE   include <bsp430/platform.h>
 
#define BSP430_SHARPLCD_MODE_DYNAMIC   0x80
 
#define BSP430_SHARPLCD_VCOM   0x40
 
#define BSP430_SHARPLCD_CLEAR_ALL   0x20
 
#define BSP430_SHARPLCD_CS_ASSERT(_dev)
 
#define BSP430_SHARPLCD_CS_DEASSERT(_dev)
 

Typedefs

typedef struct sBSP430sharplcd sBSP430sharplcd
 
typedef sBSP430sharplcdhBSP430sharplcd
 

Functions

hBSP430sharplcd hBSP430sharplcdInitializePlatformDevice (hBSP430sharplcd dev)
 
int iBSP430sharplcdSetEnabled_ni (hBSP430sharplcd dev, int enablep)
 
int iBSP430sharplcdClearDisplay_rh (hBSP430sharplcd dev)
 
int iBSP430sharplcdRefreshDisplay_rh (hBSP430sharplcd dev)
 
int iBSP430sharplcdUpdateDisplayLines_rh (hBSP430sharplcd dev, int start_line, int num_lines, const uint8_t *line_data)
 

Detailed Description

Interface for Sharp Memory LCD displays.

This display may be used natively, or in conjunction with configBSP430_UTILITY_U8GLIB.

Homepage
http://github.com/pabigot/bsp430

Macro Definition Documentation

#define BSP430_PLATFORM_BOOSTERPACK_SHARP96   include <bsp430/platform.h>

Indicate that a Sharp Microelectronics LCD display is available on the platform through a 430BOOST-SHARP96 booster pack. The macro is undefined or false if the boosterpack is not requested or its required resources have not been defined for the platform.

C Preprocessor Only:
This macro may have a value that restricts its use to C preprocessor conditional directives.
Dependency:
configBSP430_PLATFORM_BOOSTERPACK_SHARP96
Defaulted:
The value here is superseded by previously encountered definitions.
#define BSP430_PLATFORM_SHARPLCD   include <bsp430/platform.h>

Indicate that a Sharp Microelectronics LCD display is available on the platform. This is set by the platform-specific header when configBSP430_PLATFORM_BOOSTERPACK_SHARP96 is true and the platform has resource mappings for the device, or on platforms that natively contain a Sharp Memory LCD display.

C Preprocessor Only:
This macro may have a value that restricts its use to C preprocessor conditional directives.
Dependency:
configBSP430_PLATFORM_SHARPLCD, configBSP430_PLATFORM_BOOSTERPACK_SHARP96
Defaulted:
The value here is superseded by previously encountered definitions.
#define BSP430_PLATFORM_SHARPLCD_BYTES_PER_LINE   ((7 + BSP430_PLATFORM_SHARPLCD_COLUMNS) / 8)

The width of the display in bytes

#define BSP430_PLATFORM_SHARPLCD_COLUMNS   include <bsp430/platform.h>

The width of the display in pixels

Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_PLATFORM_SHARPLCD_CS_PORT_BIT   include <bsp430/platform.h>

Port bit on BSP430_PLATFORM_SHARPLCD_CS_PORT_PERIPH_HANDLE that controls the display chip select.

Note
This signal is active-high.
Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_PLATFORM_SHARPLCD_CS_PORT_PERIPH_HANDLE   include <bsp430/platform.h>

BSP430 peripheral handle for the port that controls the display chip select line.

Note
This signal is active-high unlike most SPI-controlled devices.
Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_PLATFORM_SHARPLCD_LCD_EN_PORT_BIT   include <bsp430/platform.h>

Port bit on BSP430_PLATFORM_SHARPLCD_LCD_EN_PORT_PERIPH_HANDLE that turns the display on or off. The signal is active-high.

Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_PLATFORM_SHARPLCD_LCD_EN_PORT_PERIPH_HANDLE   include <bsp430/platform.h>

BSP430 peripheral handle for the port that controls the display DISP on/off line.

Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_PLATFORM_SHARPLCD_PWR_EN_PORT_BIT   include <bsp430/platform.h>

Port bit on BSP430_PLATFORM_SHARPLCD_PWR_EN_PORT_PERIPH_HANDLE that provides display power. The signal is active-high.

Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_PLATFORM_SHARPLCD_PWR_EN_PORT_PERIPH_HANDLE   include <bsp430/platform.h>

BSP430 peripheral handle for the port that provides display power.

Note
As-delivered the display is powered through BSP430_PLATFORM_SHARPLCD_LCD_EN_PORT_BIT; this GPIO is only necessary when using alternative power configurations.
Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_PLATFORM_SHARPLCD_ROWS   include <bsp430/platform.h>

The height of the display in pixels.

Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_PLATFORM_SHARPLCD_SPI_BUS_HZ   1000000UL

The desired SPI bus speed for the device.

For LS013B4DN04 the maximum value is 1 MHz. For other models it may be up to 2 MHz.

#define BSP430_PLATFORM_SHARPLCD_SPI_PERIPH_HANDLE   include <bsp430/platform.h>

BSP430 peripheral handle for the SPI interface to the device.

Platform-Specific Value:
The value here is an example, and may differ from the actual value used depending on platform information.
#define BSP430_SHARPLCD_CLEAR_ALL   0x20

The command bit pattern to clear all flags in the display.

This may be set in a static mode command to reset the display.

#define BSP430_SHARPLCD_CS_ASSERT (   _dev)
Value:
do { \
(_dev)->cs->out |= (_dev)->cs_bit; \
} while (0)

Assert the CS signal in preparation for interacting with the device.

#define BSP430_SHARPLCD_CS_DEASSERT (   _dev)
Value:
do { \
(_dev)->cs->out &= ~(_dev)->cs_bit; \
} while (0)

De-assert the CS signal after interacting with the device

#define BSP430_SHARPLCD_CTL0_INITIALIZER   BSP430_SERIAL_ADJUST_CTL0_INITIALIZER(UCCKPH | UCMSB | UCMST)

Parameter to pass to hBSP430serialOpenSPI() as the ctl0_byte.

#define BSP430_SHARPLCD_MODE_DYNAMIC   0x80

The command bit pattern set for dynamic mode.

This is what's used to update pixels. Absence of this bit indicates a static mode command.

#define BSP430_SHARPLCD_REFRESH_INTERVAL_MS   1000

The interval at which the VCOM signal must be toggled, using iBSP430sharplcdRefreshDisplay_rh(), in order to avoid DC bias build-up. 1 Hz is good; maximum rate is 30 Hz, some devices allow 0.5 Hz.

Defaulted:
The value here is superseded by previously encountered definitions.
#define BSP430_SHARPLCD_VCOM   0x40

The command bit pattern that controls VCOM.

This bit may be combined with BSP430_SHARPLCD_MODE_DYNAMIC or used in static mode. To eliminate DC bias build-up a command should be sent to the display at a minimum frequency of 1Hz (maximum 30 Hz) while the display is active. This bit should alternate in those commands using a 50% duty cycle.

#define configBSP430_PLATFORM_BOOSTERPACK_SHARP96   0

Define to a true value to request that platform enable an interface to the 430BOOST-SHARP96 booster pack.

C Preprocessor Only:
This macro may have a value that restricts its use to C preprocessor conditional directives.
Affects:
BSP430_PLATFORM_SHARPLCD, BSP430_PLATFORM_BOOSTERPACK_SHARP96
Defaulted:
The value here is superseded by previously encountered definitions.
#define configBSP430_PLATFORM_SHARPLCD   0

Define to a true value to request that platform enable its Sharp Microelectronics Memory LCD display.

C Preprocessor Only:
This macro may have a value that restricts its use to C preprocessor conditional directives.
Affects:
BSP430_PLATFORM_SHARPLCD
Defaulted:
The value here is superseded by previously encountered definitions.

Typedef Documentation

Handle for a Sharp Memory LCD device

A structure holding resource references and state required to manipulate a Sharp Memory LCD.

Function Documentation

hBSP430sharplcd hBSP430sharplcdInitializePlatformDevice ( hBSP430sharplcd  dev)

Initialize dev using the platform device constants (viz., BSP430_PLATFORM_SHARPLCD_SPI_PERIPH_HANDLE, BSP430_PLATFORM_SHARPLCD_CS_PORT_PERIPH_HANDLE, BSP430_PLATFORM_SHARPLCD_ROWS, etc.)

This only initializes the device structure and configures the SPI interface. It does not configure any required GPIOs nor does it power-up the device. See iBSP430sharplcdSetEnabled_ni().

Parameters
devpointer to an sBSP430sharplcd structure that will be used to hold the device state.
Returns
dev if successful, a null pointer if a critical resource could not be obtained.
int iBSP430sharplcdClearDisplay_rh ( hBSP430sharplcd  dev)

Issue the command to quickly clear the display.

Parameters
devdevice with display to be cleared
Returns
zero on success, a negative error code on failure.
int iBSP430sharplcdRefreshDisplay_rh ( hBSP430sharplcd  dev)

Issue the command to refresh the display.

This sends a static-mode command that toggles the VCOM signal to the screen, preventing DC bias build-up. It should be invoked once per second while the display is powered.

Parameters
devdevice with display to be refreshed
Returns
zero on success, a negative error code on failure
int iBSP430sharplcdSetEnabled_ni ( hBSP430sharplcd  dev,
int  enablep 
)

Enable or disable the display.

If enablep is true, this enables power to the device and executes its startup sequence. If enablep is false this executes the device shutdown sequence and removes power from it.

Parameters
devdevice to be powered
enablepnonzero to enable device, zero to disable it
Returns
zero on success, a negative error code on failure.
int iBSP430sharplcdUpdateDisplayLines_rh ( hBSP430sharplcd  dev,
int  start_line,
int  num_lines,
const uint8_t *  line_data 
)

Replace lines in the display with new content.

Parameters
devdevice to be updated
start_linethe first line to be updated. Lines are numbered starting with 1; values less than this result in an error return.
num_linesthe number of lines to be updated. A negative value is interpreted to mean all lines starting with start_line.
line_datathe monochrome pixel values to be used. Each line requires dev->line_size bytes.
Returns
zero on success, a negative error code on failure.