BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sharplcd.h
Go to the documentation of this file.
1 /* Copyright 2014, Peter A. Bigot
2  *
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the software nor the names of its contributors may be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef BSP430_UTILITY_SHARPLCD_H
33 #define BSP430_UTILITY_SHARPLCD_H
34 
46 #include <bsp430/core.h>
47 #include <bsp430/serial.h>
48 #include <bsp430/periph/port.h>
49 
58 #ifndef configBSP430_PLATFORM_SHARPLCD
59 #define configBSP430_PLATFORM_SHARPLCD 0
60 #endif /* configBSP430_PLATFORM_SHARPLCD */
61 
77 #if defined(BSP430_DOXYGEN)
78 #define BSP430_PLATFORM_SHARPLCD include <bsp430/platform.h>
79 #endif /* BSP430_DOXYGEN */
80 
90 #ifndef configBSP430_PLATFORM_BOOSTERPACK_SHARP96
91 #define configBSP430_PLATFORM_BOOSTERPACK_SHARP96 0
92 #endif /* configBSP430_PLATFORM_BOOSTERPACK_SHARP96 */
93 
104 #if defined(BSP430_DOXYGEN)
105 #define BSP430_PLATFORM_BOOSTERPACK_SHARP96 include <bsp430/platform.h>
106 #endif /* BSP430_DOXYGEN */
107 
108 #if defined(BSP430_DOXYGEN)
109 
111 #define BSP430_PLATFORM_SHARPLCD_ROWS include <bsp430/platform.h>
112 #endif /* BSP430_PLATFORM_SHARPLCD_ROWS */
113 #if defined(BSP430_DOXYGEN)
114 
116 #define BSP430_PLATFORM_SHARPLCD_COLUMNS include <bsp430/platform.h>
117 #endif /* BSP430_PLATFORM_SHARPLCD_COLUMNS */
118 
119 #define BSP430_PLATFORM_SHARPLCD_BYTES_PER_LINE ((7 + BSP430_PLATFORM_SHARPLCD_COLUMNS) / 8)
120 
121 #if defined(BSP430_DOXYGEN) || !defined(BSP430_SHARPLCD_REFRESH_INTERVAL_MS)
122 
128 #define BSP430_SHARPLCD_REFRESH_INTERVAL_MS 1000
129 #endif /* BSP430_SHARPLCD_REFRESH_INTERVAL_MS */
130 
135 #if defined(BSP430_DOXYGEN) || !defined(BSP430_PLATFORM_SHARPLCD_SPI_BUS_HZ)
136 #define BSP430_PLATFORM_SHARPLCD_SPI_BUS_HZ 1000000UL
137 #endif /* BSP430_SHARPLCD_SPI_BUS_HZ */
138 
140 #define BSP430_SHARPLCD_CTL0_INITIALIZER BSP430_SERIAL_ADJUST_CTL0_INITIALIZER(UCCKPH | UCMSB | UCMST)
141 
142 #if defined(BSP430_DOXYGEN)
143 
146 #define BSP430_PLATFORM_SHARPLCD_CS_PORT_PERIPH_HANDLE include <bsp430/platform.h>
147 
152 #define BSP430_PLATFORM_SHARPLCD_CS_PORT_BIT include <bsp430/platform.h>
153 
156 #define BSP430_PLATFORM_SHARPLCD_LCD_EN_PORT_PERIPH_HANDLE include <bsp430/platform.h>
157 
160 #define BSP430_PLATFORM_SHARPLCD_LCD_EN_PORT_BIT include <bsp430/platform.h>
161 
166 #define BSP430_PLATFORM_SHARPLCD_PWR_EN_PORT_PERIPH_HANDLE include <bsp430/platform.h>
167 
170 #define BSP430_PLATFORM_SHARPLCD_PWR_EN_PORT_BIT include <bsp430/platform.h>
171 
174 #define BSP430_PLATFORM_SHARPLCD_SPI_PERIPH_HANDLE include <bsp430/platform.h>
175 #endif /* BSP430_DOXYGEN */
176 
179 typedef struct sBSP430sharplcd {
180  volatile sBSP430hplPORT * cs;
181  volatile sBSP430hplPORT * lcd_en;
182  volatile sBSP430hplPORT * pwr_en;
184  unsigned int lines;
185  unsigned int columns;
186  unsigned int line_size;
187  uint8_t cs_bit;
188  uint8_t lcd_en_bit;
189  uint8_t pwr_en_bit;
190  uint8_t vcom_state_;
192 
195 
200 #define BSP430_SHARPLCD_MODE_DYNAMIC 0x80
201 
210 #define BSP430_SHARPLCD_VCOM 0x40
211 
215 #define BSP430_SHARPLCD_CLEAR_ALL 0x20
216 
219 #define BSP430_SHARPLCD_CS_ASSERT(_dev) do { \
220  (_dev)->cs->out |= (_dev)->cs_bit; \
221  } while (0)
222 
224 #define BSP430_SHARPLCD_CS_DEASSERT(_dev) do { \
225  (_dev)->cs->out &= ~(_dev)->cs_bit; \
226  } while (0)
227 
243 
255 int iBSP430sharplcdSetEnabled_ni (hBSP430sharplcd dev, int enablep);
256 
263 
274 
290  int start_line,
291  int num_lines,
292  const uint8_t * line_data);
293 
294 #endif /* BSP430_UTILITY_SHARPLCD_H */
volatile sBSP430hplPORT * pwr_en
Definition: sharplcd.h:182
int iBSP430sharplcdClearDisplay_rh(hBSP430sharplcd dev)
uint8_t lcd_en_bit
Definition: sharplcd.h:188
volatile sBSP430hplPORT * cs
Definition: sharplcd.h:180
hBSP430halSERIAL spi
Definition: sharplcd.h:183
Common header included by all BSP430 leaf headers.
unsigned int line_size
Definition: sharplcd.h:186
Definition: serial_.h:193
unsigned int columns
Definition: sharplcd.h:185
unsigned int lines
Definition: sharplcd.h:184
Declarations for abstracted serial interface.
Definition: sharplcd.h:179
volatile sBSP430hplPORT * lcd_en
Definition: sharplcd.h:181
int iBSP430sharplcdRefreshDisplay_rh(hBSP430sharplcd dev)
uint8_t pwr_en_bit
Definition: sharplcd.h:189
Definition: port.h:529
Hardware presentation/abstraction for Digital I/O Port (PORT#/PORT#_R)
uint8_t vcom_state_
Definition: sharplcd.h:190
int iBSP430sharplcdSetEnabled_ni(hBSP430sharplcd dev, int enablep)
struct sBSP430sharplcd sBSP430sharplcd
hBSP430sharplcd hBSP430sharplcdInitializePlatformDevice(hBSP430sharplcd dev)
sBSP430sharplcd * hBSP430sharplcd
Definition: sharplcd.h:194
uint8_t cs_bit
Definition: sharplcd.h:187
int iBSP430sharplcdUpdateDisplayLines_rh(hBSP430sharplcd dev, int start_line, int num_lines, const uint8_t *line_data)