4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
33 * \brief LM3S1986: OLED-RIT-128x96 (P14201) low-level hardware macros
35 * \author Andrea Righi <arighi@develer.com>
41 #include "cfg/macros.h" /* BV() */
42 #include "cfg/debug.h"
43 #include "cfg/cfg_lcd.h" /* CONFIG_LCD_4BIT */
47 #include <cpu/types.h>
49 #include <drv/clock_lm3s.h>
50 #include <drv/ssi_lm3s.h>
51 #include <drv/gpio_lm3s.h>
53 #include <drv/lcd_rit128x96.h>
56 * \name LCD I/O pins/ports
59 /* OLED Data/Command control pin */
60 #define GPIO_OLEDDC_PIN BV(2)
63 #define GPIO_OLEDEN_PIN BV(3)
67 * \name LCD bus control macros
70 /* Enter command mode */
71 #define LCD_SET_COMMAND() \
72 lm3s_gpio_pin_write(GPIO_PORTH_BASE, GPIO_OLEDDC_PIN, 0)
75 #define LCD_SET_DATA() \
76 lm3s_gpio_pin_write(GPIO_PORTH_BASE, GPIO_OLEDDC_PIN, GPIO_OLEDDC_PIN)
78 /* Send data to the display */
79 #define LCD_WRITE(x) lm3s_ssiWriteFrame(SSI0_BASE, x)
81 /* Read data from the display */
85 lm3s_ssiReadFrame(SSI0_BASE, &frame); \
90 INLINE void lcd_bus_init(void)
95 IRQ_SAVE_DISABLE(flags);
97 /* Enable the peripheral clock */
98 SYSCTL_RCGC1_R |= SYSCTL_RCGC1_SSI0;
99 SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOA;
100 SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOH;
103 /* Configure the SSI0CLK and SSIOTX pins for SSI operation. */
104 lm3s_gpio_pin_config(GPIO_PORTA_BASE, BV(2) | BV(3) | BV(5),
105 GPIO_DIR_MODE_HW, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);
107 * Configure the GPIO port pin used as a D/C# signal (data/command
108 * control) for OLED device, and the port pin used to enable power to
111 lm3s_gpio_pin_config(GPIO_PORTH_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN,
112 GPIO_DIR_MODE_OUT, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
113 lm3s_gpio_pin_write(GPIO_PORTH_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN,
114 GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN);
116 /* Configure the SSI0 port for master mode */
117 lm3s_ssiOpen(SSI0_BASE, SSI_FRF_MOTO_MODE_2,
118 SSI_MODE_MASTER, CPU_FREQ / 2, 8);
120 * Configure the GPIO port pin used as a D/Cn signal for OLED device,
121 * and the port pin used to enable power to the OLED panel.
123 lm3s_gpio_pin_config(GPIO_PORTA_BASE, GPIO_OLEDEN_PIN,
124 GPIO_DIR_MODE_HW, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);
126 /* Drain the SSI RX FIFO */
127 while (lm3s_ssiReadFrameNonBlocking(SSI0_BASE, &dummy));
132 #endif /* HW_LCD_H */