Updated SSD1306 driver

This commit is contained in:
Alan Carvalho de Assis 2015-07-15 13:28:31 -06:00 committed by Gregory Nutt
parent e832ebdd23
commit d7d15072c4
4 changed files with 18 additions and 13 deletions

View File

@ -235,6 +235,7 @@ struct ssd1306_dev_s
FAR struct spi_dev_s *spi; /* Cached SPI device reference */
#else
FAR struct i2c_dev_s *i2c; /* Cached SPI device reference */
uint8_t addr; /* 7-bit I2C address */
#endif
uint8_t contrast; /* Current contrast setting */
bool on; /* true: display is on */

View File

@ -836,7 +836,10 @@ FAR struct lcd_dev_s *ssd1306_initialize(FAR struct i2c_dev_s *dev, unsigned int
# endif
#else
priv->i2c = dev;
/* Remember the I2C configuration */
priv->i2c = dev;
priv->addr = CONFIG_SSD1306_I2CADDR;
/* Set the I2C address and frequency. REVISIT: This logic would be
* insufficient if we share the I2C bus with any other devices that also

View File

@ -44,11 +44,12 @@
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/i2c.h>
#include <nuttx/lcd/ssd1306.h>
#include "ssd1306.h"
#if defined(CONFIG_LCD_SSD1306) && defined(CONFIG_LCD_UG2864HSWEG01_I2C)
#if defined(CONFIG_LCD_SSD1306) && defined(CONFIG_LCD_SSD1306_I2C)
/****************************************************************************
* Name: ssd1306_sendbyte
@ -81,7 +82,7 @@ void ssd1306_sendbyte(FAR struct ssd1306_dev_s *priv, uint8_t regval)
/* Setup 8-bit SSD1306 address write message */
msg.addr = priv->config->address; /* 7-bit address */
msg.addr = priv->addr; /* 7-bit address */
msg.flags = 0; /* Write transaction, beginning with START */
msg.buffer = txbuffer; /* Transfer from this address */
msg.length = 1; /* Send one byte following the address
@ -116,7 +117,7 @@ void ssd1306_sendblk(FAR struct ssd1306_dev_s *priv, uint8_t *data, uint8_t len)
/* Setup 8-bit SSD1306 address write message */
msg.addr = priv->config->address; /* 7-bit address */
msg.addr = priv->addr; /* 7-bit address */
msg.flags = 0; /* Write transaction, beginning with START */
msg.buffer = data; /* Transfer from this address */
msg.length = len; /* Send one byte following the address
@ -131,4 +132,4 @@ void ssd1306_sendblk(FAR struct ssd1306_dev_s *priv, uint8_t *data, uint8_t len)
}
}
#endif /* CONFIG_LCD_SSD1306 &7 CONFIG_LCD_UG2864HSWEG01_I2C */
#endif /* CONFIG_LCD_SSD1306 &7 CONFIG_LCD_SSD1306_I2C */

View File

@ -48,7 +48,7 @@
#include "ssd1306.h"
#if defined(CONFIG_LCD_UG2864HSWEG01) && defined(CONFIG_LCD_UG2864HSWEG01_SPI)
#if defined(CONFIG_LCD_SSD1306) && defined(CONFIG_LCD_SSD1306_SPI)
/****************************************************************************
* Private Functions
@ -67,7 +67,7 @@ static inline void ssd1306_configspi(FAR struct spi_dev_s *spi)
lcdvdbg("Mode: %d Bits: 8 Frequency: %d\n",
CONFIG_SSD1306_SPIMODE, CONFIG_SSD1306_FREQUENCY);
/* Configure SPI for the UG2864AMBAG01 */
/* Configure SPI for the SSD1306 */
SPI_SETMODE(spi, CONFIG_SSD1306_SPIMODE);
SPI_SETBITS(spi, 8);
@ -83,13 +83,13 @@ static inline void ssd1306_configspi(FAR struct spi_dev_s *spi)
* Name: ssd1306_sendbyte
*
* Description:
* Write a value to an 8-bit value to UG2864AMBAG01
* Write a value to an 8-bit value to SSD1306
*
****************************************************************************/
void ssd1306_sendbyte(FAR struct ssd1306_dev_s *priv, uint8_t regval)
{
#ifdef CONFIG_LCD_UG2864AMBAG01_REGDEBUG
#ifdef CONFIG_LCD_SSD1306_REGDEBUG
lldbg("->0x%02x\n", regval);
#endif
@ -102,7 +102,7 @@ void ssd1306_sendbyte(FAR struct ssd1306_dev_s *priv, uint8_t regval)
* Name: ssd1306_sendblk
*
* Description:
* Write an array of bytes to UG2864AMBAG01
* Write an array of bytes to SSD1306
*
****************************************************************************/
@ -117,7 +117,7 @@ void ssd1306_sendblk(FAR struct ssd1306_dev_s *priv, uint8_t *data, uint8_t len)
* Name: ssd1306_select
*
* Description:
* Enable/Disable UG2864AMBAG01 SPI CS
* Enable/Disable SSD1306 SPI CS
*
****************************************************************************/
@ -155,7 +155,7 @@ void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs)
* Name: ssd1306_cmddata
*
* Description:
* Select Command/Data mode for UG2864AMBAG01
* Select Command/Data mode for SSD1306
*
****************************************************************************/
@ -165,4 +165,4 @@ void ssd1306_cmddata(FAR struct ssd1306_dev_s *priv, bool cmd)
SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY, cmd);
}
#endif /* CONFIG_LCD_UG2864AMBAG01 && CONFIG_LCD_UG2864AMBAG01_SPI */
#endif /* CONFIG_LCD_SSD1306 && CONFIG_LCD_SSD1306_SPI */