hd44780: fix I2C ifdef macro
This commit is contained in:
parent
3c71b83bb9
commit
ff1b84f505
|
@ -31,7 +31,7 @@
|
||||||
/* own libraries */
|
/* own libraries */
|
||||||
#include "global.h" // common methods
|
#include "global.h" // common methods
|
||||||
#include "lcd_hd44780.h" // own definitions
|
#include "lcd_hd44780.h" // own definitions
|
||||||
#if LCD_HD44780_I2C
|
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||||
#include "i2c_master.h" // I²C utilities
|
#include "i2c_master.h" // I²C utilities
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
* @note this removes the need to call lcd_hd44780_wait_busy but prevents you to do something else meanwhile, particularly when reading is enabled
|
* @note this removes the need to call lcd_hd44780_wait_busy but prevents you to do something else meanwhile, particularly when reading is enabled
|
||||||
* @note because I²C is already slow enough, there is no need to wait further
|
* @note because I²C is already slow enough, there is no need to wait further
|
||||||
*/
|
*/
|
||||||
#if LCD_HD44780_I2C
|
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||||
#define LCD_HD44780_BUSY_WAIT_INCLUDE 1 // lcd_hd44780_wait_busy works, but the I²C bus is often slower
|
#define LCD_HD44780_BUSY_WAIT_INCLUDE 1 // lcd_hd44780_wait_busy works, but the I²C bus is often slower
|
||||||
#else // LCD_HD44780_I2C
|
#else // LCD_HD44780_I2C
|
||||||
#define LCD_HD44780_BUSY_WAIT_INCLUDE 1 // you can change this value
|
#define LCD_HD44780_BUSY_WAIT_INCLUDE 1 // you can change this value
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
#define LCD_HD44780_LED (1 << 11) /**< Backlight Cathode */
|
#define LCD_HD44780_LED (1 << 11) /**< Backlight Cathode */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#if LCD_HD44780_I2C
|
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||||
/* I²C backpack PCF8574 GPIO expander pinout:
|
/* I²C backpack PCF8574 GPIO expander pinout:
|
||||||
* - P0: RS
|
* - P0: RS
|
||||||
* - P1: RnW
|
* - P1: RnW
|
||||||
|
@ -195,7 +195,7 @@ static bool lcd_hd44780_n_2lines = true;
|
||||||
*/
|
*/
|
||||||
static void lcd_hd44780_set_signal(uint16_t signals)
|
static void lcd_hd44780_set_signal(uint16_t signals)
|
||||||
{
|
{
|
||||||
#if LCD_HD44780_I2C
|
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||||
if (signals & LCD_HD44780_RS) {
|
if (signals & LCD_HD44780_RS) {
|
||||||
lcd_hd44780_i2c_output |= LCD_HD44780_I2C_RS;
|
lcd_hd44780_i2c_output |= LCD_HD44780_I2C_RS;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ static void lcd_hd44780_set_signal(uint16_t signals)
|
||||||
*/
|
*/
|
||||||
static void lcd_hd44780_clear_signal(uint16_t signals)
|
static void lcd_hd44780_clear_signal(uint16_t signals)
|
||||||
{
|
{
|
||||||
#if LCD_HD44780_I2C
|
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||||
if (signals & LCD_HD44780_RS) {
|
if (signals & LCD_HD44780_RS) {
|
||||||
lcd_hd44780_i2c_output &= ~LCD_HD44780_I2C_RS;
|
lcd_hd44780_i2c_output &= ~LCD_HD44780_I2C_RS;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ static void lcd_hd44780_clear_signal(uint16_t signals)
|
||||||
*/
|
*/
|
||||||
static void lcd_hd44780_flush_signal(void)
|
static void lcd_hd44780_flush_signal(void)
|
||||||
{
|
{
|
||||||
#if LCD_HD44780_I2C
|
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||||
i2c_master_slave_write(LCD_HD44780_I2C_PERIPH, lcd_hd44780_i2c_addr, false, &lcd_hd44780_i2c_output, 1); // write the set signals
|
i2c_master_slave_write(LCD_HD44780_I2C_PERIPH, lcd_hd44780_i2c_addr, false, &lcd_hd44780_i2c_output, 1); // write the set signals
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,7 @@ static void lcd_hd44780_function_set(bool dl_8bit, bool n_2lines, bool f_5x10)
|
||||||
bool lcd_hd44780_setup(bool n_2lines, bool f_5x10)
|
bool lcd_hd44780_setup(bool n_2lines, bool f_5x10)
|
||||||
{
|
{
|
||||||
sleep_ms(40 + 2); // wait for display to initialise after power on: 15 ms for VCC > 4.5 V, 40 ms for VCC > 2.7 V
|
sleep_ms(40 + 2); // wait for display to initialise after power on: 15 ms for VCC > 4.5 V, 40 ms for VCC > 2.7 V
|
||||||
#ifdef LCD_HD44780_I2C
|
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||||
// configure I²C peripheral
|
// configure I²C peripheral
|
||||||
if (!i2c_master_check_signals(LCD_HD44780_I2C_PERIPH)) { // check if there are pull-ups to operator I²C
|
if (!i2c_master_check_signals(LCD_HD44780_I2C_PERIPH)) { // check if there are pull-ups to operator I²C
|
||||||
return false;
|
return false;
|
||||||
|
@ -694,14 +694,12 @@ bool lcd_hd44780_setup(bool n_2lines, bool f_5x10)
|
||||||
lcd_hd44780_entry_mode_set(true, false); // entry mode set
|
lcd_hd44780_entry_mode_set(true, false); // entry mode set
|
||||||
lcd_hd44780_wait_busy(LCD_HD44780_BUSY_WAIT_SHORT);
|
lcd_hd44780_wait_busy(LCD_HD44780_BUSY_WAIT_SHORT);
|
||||||
|
|
||||||
#if LCD_HD44780_I2C
|
|
||||||
return true; // I²C configuration succeeded
|
return true; // I²C configuration succeeded
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_hd44780_release(void)
|
void lcd_hd44780_release(void)
|
||||||
{
|
{
|
||||||
#if LCD_HD44780_I2C
|
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||||
i2c_master_release(LCD_HD44780_I2C_PERIPH); // release I²C peripheral
|
i2c_master_release(LCD_HD44780_I2C_PERIPH); // release I²C peripheral
|
||||||
#else // LCD_HD44780_I2C
|
#else // LCD_HD44780_I2C
|
||||||
// switch back GPIO back to input
|
// switch back GPIO back to input
|
||||||
|
|
Loading…
Reference in New Issue