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>
46 #include <cpu/types.h>
48 #include <drv/clock_lm3s.h>
49 #include <drv/ssi_lm3s.h>
50 #include <drv/gpio_lm3s.h>
52 #include <drv/lcd_rit128x96.h>
55 * \name LCD I/O pins/ports
58 /* OLED Data/Command control pin */
59 #define GPIO_OLEDDC_PIN BV(2)
62 #define GPIO_OLEDEN_PIN BV(3)
66 * \name LCD bus control macros
69 /* Enter command mode */
70 #define LCD_SET_COMMAND() \
71 lm3s_gpio_pin_write(GPIO_PORTH_BASE, GPIO_OLEDDC_PIN, 0)
74 #define LCD_SET_DATA() \
75 lm3s_gpio_pin_write(GPIO_PORTH_BASE, GPIO_OLEDDC_PIN, GPIO_OLEDDC_PIN)
77 /* Send data to the display */
78 #define LCD_WRITE(x) lm3s_ssiWriteFrame(SSI0_BASE, x)
80 /* Read data from the display */
84 lm3s_ssiReadFrame(SSI0_BASE, &frame); \
89 INLINE void lcd_bus_init(void)
94 IRQ_SAVE_DISABLE(flags);
96 /* Enable the peripheral clock */
97 SYSCTL_RCGC1_R |= SYSCTL_RCGC1_SSI0;
98 SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOA;
99 SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOH;
102 /* Configure the SSI0CLK and SSIOTX pins for SSI operation. */
103 lm3s_gpio_pin_config(GPIO_PORTA_BASE, BV(2) | BV(3) | BV(5),
104 GPIO_DIR_MODE_HW, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);
106 * Configure the GPIO port pin used as a D/C# signal (data/command
107 * control) for OLED device, and the port pin used to enable power to
110 lm3s_gpio_pin_config(GPIO_PORTH_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN,
111 GPIO_DIR_MODE_OUT, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
112 lm3s_gpio_pin_write(GPIO_PORTH_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN,
113 GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN);
115 /* Configure the SSI0 port for master mode */
116 lm3s_ssiOpen(SSI0_BASE, SSI_FRF_MOTO_MODE_2,
117 SSI_MODE_MASTER, CPU_FREQ / 2, 8);
119 * Configure the GPIO port pin used as a D/Cn signal for OLED device,
120 * and the port pin used to enable power to the OLED panel.
122 lm3s_gpio_pin_config(GPIO_PORTA_BASE, GPIO_OLEDEN_PIN,
123 GPIO_DIR_MODE_HW, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);
125 /* Drain the SSI RX FIFO */
126 while (lm3s_ssiReadFrameNonBlocking(SSI0_BASE, &dummy));
131 #endif /* HW_LCD_H */