2010-05-13 04:13:15 +02:00
|
|
|
/****************************************************************************
|
2015-03-21 17:58:58 +01:00
|
|
|
* config/lm3s6965-ek/src/lm_oled.c
|
2010-05-13 04:13:15 +02:00
|
|
|
*
|
2015-04-01 00:20:21 +02:00
|
|
|
* Copyright (C) 2010-2011, 2015 Gregory Nutt. All rights reserved.
|
2012-09-13 20:32:24 +02:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2010-05-13 04:13:15 +02:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2015-04-01 00:20:21 +02:00
|
|
|
#include <nuttx/board.h>
|
2013-07-01 16:11:54 +02:00
|
|
|
#include <nuttx/spi/spi.h>
|
2010-12-04 02:56:50 +01:00
|
|
|
#include <nuttx/lcd/lcd.h>
|
|
|
|
#include <nuttx/lcd/p14201.h>
|
2010-05-13 04:13:15 +02:00
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
#include "tiva_gpio.h"
|
2010-05-15 14:40:59 +02:00
|
|
|
#include "lm3s6965ek_internal.h"
|
|
|
|
|
2010-05-13 04:13:15 +02:00
|
|
|
/****************************************************************************
|
2015-03-21 17:58:58 +01:00
|
|
|
* Pre-processor Definitions
|
2010-05-13 04:13:15 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2010-05-16 18:52:04 +02:00
|
|
|
/* Define the CONFIG_LCD_RITDEBUG to enable detailed debug output (stuff you
|
|
|
|
* would never want to see unless you are debugging this file).
|
|
|
|
*
|
|
|
|
* Verbose debug must also be enabled
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONFIG_DEBUG
|
|
|
|
# undef CONFIG_DEBUG_VERBOSE
|
|
|
|
# undef CONFIG_DEBUG_GRAPHICS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_DEBUG_VERBOSE
|
|
|
|
# undef CONFIG_LCD_RITDEBUG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_LCD_RITDEBUG
|
2014-05-22 17:01:51 +02:00
|
|
|
# define ritdbg(format, ...) vdbg(format, ##__VA_ARGS__)
|
|
|
|
# define oleddc_dumpgpio(m) tiva_dumpgpio(OLEDDC_GPIO, m)
|
|
|
|
# define oledcs_dumpgpio(m) tiva_dumpgpio(OLEDCS_GPIO, m)
|
2010-05-16 18:52:04 +02:00
|
|
|
#else
|
|
|
|
# define ritdbg(x...)
|
|
|
|
# define oleddc_dumpgpio(m)
|
|
|
|
# define oledcs_dumpgpio(m)
|
|
|
|
#endif
|
|
|
|
|
2010-05-13 04:13:15 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-05-16 18:52:04 +02:00
|
|
|
/****************************************************************************
|
2015-04-01 00:20:21 +02:00
|
|
|
* Name: board_graphics_setup
|
2010-05-13 04:13:15 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2011-04-17 18:16:28 +02:00
|
|
|
* Called by NX initialization logic to configure the OLED.
|
2010-05-13 04:13:15 +02:00
|
|
|
*
|
2010-05-16 18:52:04 +02:00
|
|
|
****************************************************************************/
|
2010-05-13 04:13:15 +02:00
|
|
|
|
2015-04-01 00:20:21 +02:00
|
|
|
FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno)
|
2010-05-13 04:13:15 +02:00
|
|
|
{
|
|
|
|
FAR struct spi_dev_s *spi;
|
2010-05-15 20:57:24 +02:00
|
|
|
FAR struct lcd_dev_s *dev;
|
2010-05-13 04:13:15 +02:00
|
|
|
|
2010-05-16 18:52:04 +02:00
|
|
|
/* Configure the OLED GPIOs */
|
2010-05-13 04:13:15 +02:00
|
|
|
|
2015-04-01 00:20:21 +02:00
|
|
|
oledcs_dumpgpio("board_graphics_setup: After OLEDCS setup");
|
|
|
|
oleddc_dumpgpio("board_graphics_setup: On entry");
|
2010-05-16 20:02:37 +02:00
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
tiva_configgpio(OLEDDC_GPIO); /* PC7: OLED display data/control select (D/Cn) */
|
|
|
|
tiva_configgpio(OLEDEN_GPIO); /* PC6: Enable +15V needed by OLED (EN+15V) */
|
2010-05-16 20:02:37 +02:00
|
|
|
|
2015-04-01 00:20:21 +02:00
|
|
|
oleddc_dumpgpio("board_graphics_setup: After OLEDDC/EN setup");
|
2010-05-13 04:13:15 +02:00
|
|
|
|
2010-05-16 18:52:04 +02:00
|
|
|
/* Get the SSI port (configure as a Freescale SPI port) */
|
2010-05-13 04:13:15 +02:00
|
|
|
|
|
|
|
spi = up_spiinitialize(0);
|
|
|
|
if (!spi)
|
|
|
|
{
|
2010-05-16 20:02:37 +02:00
|
|
|
glldbg("Failed to initialize SSI port 0\n");
|
2010-05-13 04:13:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-16 18:52:04 +02:00
|
|
|
/* Bind the SSI port to the OLED */
|
2010-05-13 04:13:15 +02:00
|
|
|
|
2010-05-15 20:57:24 +02:00
|
|
|
dev = rit_initialize(spi, devno);
|
|
|
|
if (!dev)
|
2010-05-13 04:13:15 +02:00
|
|
|
{
|
2010-05-16 18:52:04 +02:00
|
|
|
glldbg("Failed to bind SSI port 0 to OLED %d: %d\n", devno);
|
2010-05-13 04:13:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-16 18:52:04 +02:00
|
|
|
gllvdbg("Bound SSI port 0 to OLED %d\n", devno);
|
2010-05-15 22:28:09 +02:00
|
|
|
|
|
|
|
/* And turn the OLED on (CONFIG_LCD_MAXPOWER should be 1) */
|
|
|
|
|
|
|
|
(void)dev->setpower(dev, CONFIG_LCD_MAXPOWER);
|
2010-05-15 20:57:24 +02:00
|
|
|
return dev;
|
2010-05-13 04:13:15 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-01 00:20:21 +02:00
|
|
|
|
2010-05-15 20:57:24 +02:00
|
|
|
return NULL;
|
2010-05-13 04:13:15 +02:00
|
|
|
}
|
|
|
|
|
2015-10-03 15:25:23 +02:00
|
|
|
/****************************************************************************
|
2014-03-08 20:29:09 +01:00
|
|
|
* Name: tiva_spicmddata
|
2010-05-13 04:13:15 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2010-05-16 18:52:04 +02:00
|
|
|
* Set or clear the SD1329 D/Cn bit to select data (true) or command
|
|
|
|
* (false). This function must be provided by platform-specific logic.
|
2010-12-04 02:56:50 +01:00
|
|
|
* This is an implementation of the cmddata method of the SPI
|
2013-07-01 16:11:54 +02:00
|
|
|
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
|
2010-05-13 04:13:15 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
*
|
2010-12-04 02:56:50 +01:00
|
|
|
* spi - SPI device that controls the bus the device that requires the CMD/
|
|
|
|
* DATA selection.
|
|
|
|
* devid - If there are multiple devices on the bus, this selects which one
|
|
|
|
* to select cmd or data. NOTE: This design restricts, for example,
|
|
|
|
* one one SPI display per SPI bus.
|
|
|
|
* cmd - true: select command; false: select data
|
2010-05-13 04:13:15 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
2015-10-03 15:25:23 +02:00
|
|
|
****************************************************************************/
|
2010-05-13 04:13:15 +02:00
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
int tiva_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
2010-05-13 04:13:15 +02:00
|
|
|
{
|
2010-12-04 02:56:50 +01:00
|
|
|
if (devid == SPIDEV_DISPLAY)
|
|
|
|
{
|
|
|
|
/* Set GPIO to 1 for data, 0 for command */
|
2010-05-13 04:13:15 +02:00
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
tiva_gpiowrite(OLEDDC_GPIO, !cmd);
|
2010-12-04 02:56:50 +01:00
|
|
|
return OK;
|
|
|
|
}
|
2014-03-08 20:29:09 +01:00
|
|
|
|
2010-12-04 02:56:50 +01:00
|
|
|
return -ENODEV;
|
2010-05-13 04:13:15 +02:00
|
|
|
}
|