I2C bus upgrade (#432)

This commit is contained in:
Zaltora 2017-09-01 06:29:32 -03:00 committed by Ruslan V. Uss
parent d100f42b1f
commit b83c2629b9
56 changed files with 909 additions and 804 deletions

View file

@ -60,8 +60,8 @@ static void write_nibble(const hd44780_t *lcd, uint8_t b, bool rs)
| (rs ? 1 << lcd->pins.rs : 0)
| (lcd->backlight ? 1 << lcd->pins.bl : 0);
pcf8574_port_write(lcd->addr, data | (1 << lcd->pins.e));
pcf8574_port_write(lcd->addr, data);
pcf8574_port_write(&lcd->i2c_dev, data | (1 << lcd->pins.e));
pcf8574_port_write(&lcd->i2c_dev, data);
#else
gpio_write(lcd->pins.d7, (b >> 3) & 1);
gpio_write(lcd->pins.d6, (b >> 2) & 1);
@ -164,7 +164,7 @@ void hd44780_set_backlight(hd44780_t *lcd, bool on)
return;
#if (HD44780_I2C)
pcf8574_gpio_write(lcd->addr, lcd->pins.bl, on);
pcf8574_gpio_write(&lcd->i2c_dev, lcd->pins.bl, on);
#else
gpio_write(lcd->pins.bl, on);
#endif

View file

@ -12,7 +12,10 @@
#include <stdbool.h>
#ifndef HD44780_I2C
#define HD44780_I2C 0
#define HD44780_I2C 1
#endif
#if (HD44780_I2C)
#include <i2c/i2c.h>
#endif
#ifdef __cplusplus
@ -36,7 +39,9 @@ typedef enum
*/
typedef struct
{
uint8_t addr; //!< PCF8574 address (0b0100<A2><A1><A0>)
#if (HD44780_I2C)
i2c_dev_t i2c_dev; //!< PCF8574 device settings (0b0100<A2><A1><A0>)
#endif
struct
{
uint8_t rs; //!< gpio/register bit used for RS pin