ssd1306 update

This commit is contained in:
lilian 2017-08-04 18:38:34 -03:00
parent 2eb50c5f22
commit 92b18cf2fd
4 changed files with 12 additions and 10 deletions

View file

@ -11,9 +11,6 @@
*/
#include "ssd1306.h"
#include <stdio.h>
#if (SSD1306_I2C_SUPPORT)
#include <i2c/i2c.h>
#endif
#if (SSD1306_SPI4_SUPPORT) || (SSD1306_SPI3_SUPPORT)
#include <esp/spi.h>
#endif
@ -92,14 +89,14 @@
#if (SSD1306_I2C_SUPPORT)
static int inline i2c_send(const ssd1306_t *dev, uint8_t reg, uint8_t* data, uint8_t len)
{
return i2c_slave_write(dev->addr, &reg, data, len);
return i2c_slave_write(dev->i2c_dev.bus, dev->i2c_dev.addr , &reg, data, len);
}
#endif
/* Issue a command to SSD1306 device
* I2C proto format:
* |S|Slave Address|W|ACK|0x00|Command|Ack|P|
*
*
* in case of two-bytes command here will be Data byte
* right after the command byte.
*/

View file

@ -19,6 +19,7 @@
// shifted
#if (SSD1306_I2C_SUPPORT)
#include <i2c/i2c.h>
#define SSD1306_I2C_ADDR_0 (0x3C)
#define SSD1306_I2C_ADDR_1 (0x3D)
#endif
@ -67,7 +68,7 @@ typedef struct
ssd1306_screen_t screen ;
union {
#if (SSD1306_I2C_SUPPORT)
uint8_t addr ; //!< I2C address, used by SSD1306_PROTO_I2C
i2c_dev_t i2c_dev; //!< I2C devuce descriptor, used by SSD1306_PROTO_I2C
#endif
uint8_t cs_pin ; //!< Chip Select GPIO pin, used by SSD1306_PROTO_SPI3, SSD1306_PROTO_SPI4
} ;