mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
drivers/lcd/pcf8574_lcd_backpack.c: Fix nxstyle issues.
This commit is contained in:
@@ -88,12 +88,13 @@
|
|||||||
|
|
||||||
struct pcf8574_lcd_dev_s
|
struct pcf8574_lcd_dev_s
|
||||||
{
|
{
|
||||||
FAR struct i2c_master_s *i2c; /* I2C interface */
|
FAR struct i2c_master_s *i2c; /* I2C interface */
|
||||||
struct pcf8574_lcd_backpack_config_s cfg; /* gpio configuration */
|
struct pcf8574_lcd_backpack_config_s cfg; /* gpio configuration */
|
||||||
uint8_t bl_bit; /* current backlight bit */
|
uint8_t bl_bit; /* current backlight bit */
|
||||||
uint8_t refs; /* Number of references */
|
uint8_t refs; /* Number of references */
|
||||||
uint8_t unlinked; /* We are unlinked, so teardown on last close */
|
uint8_t unlinked; /* We are unlinked, so teardown
|
||||||
sem_t sem_excl; /* mutex */
|
* on last close */
|
||||||
|
sem_t sem_excl; /* mutex */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lcd_instream_s
|
struct lcd_instream_s
|
||||||
@@ -280,8 +281,8 @@ static inline void addr2rc(FAR struct pcf8574_lcd_dev_s *priv, uint8_t addr,
|
|||||||
|
|
||||||
if (*col >= priv->cfg.cols)
|
if (*col >= priv->cfg.cols)
|
||||||
{
|
{
|
||||||
/* 4 line displays have third and fourth lines really as continuation of
|
/* 4 line displays have third and fourth lines really as continuation
|
||||||
* first and second.
|
* of the first and second.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*row += 2;
|
*row += 2;
|
||||||
@@ -554,10 +555,10 @@ static void lcd_init(FAR struct pcf8574_lcd_dev_s *priv)
|
|||||||
|
|
||||||
/* Perform the init sequence. This sequence of commands is constructed so
|
/* Perform the init sequence. This sequence of commands is constructed so
|
||||||
* that it will get the device into nybble mode irrespective of what state
|
* that it will get the device into nybble mode irrespective of what state
|
||||||
* the device is currently in (could be 8 bit, 4 bit nyb 0, 4 bit nyb 1). By
|
* the device is currently in (could be 8 bit, 4 bit nyb 0, 4 bit nyb 1).
|
||||||
* sending the 'set 8-bit mode' three times, we will definitely end up in 8
|
* By sending the 'set 8-bit mode' three times, we will definitely end up
|
||||||
* bit mode, and then we can reliably transition to 4 bit mode for the
|
* in 8 bit mode, and then we can reliably transition to 4 bit mode for
|
||||||
* remainder of operations.
|
* the remainder of operations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Send Command 0x30, set 8-bit mode, and wait > 4.1 ms */
|
/* Send Command 0x30, set 8-bit mode, and wait > 4.1 ms */
|
||||||
@@ -575,8 +576,8 @@ static void lcd_init(FAR struct pcf8574_lcd_dev_s *priv)
|
|||||||
latch_nybble(priv, 0x30 >> 4, false);
|
latch_nybble(priv, 0x30 >> 4, false);
|
||||||
nxsig_usleep(200);
|
nxsig_usleep(200);
|
||||||
|
|
||||||
/* now Function set: Set interface to be 4 bits long (only 1 cycle write for
|
/* now Function set: Set interface to be 4 bits long (only 1 cycle write
|
||||||
* the first time).
|
* for the first time).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
latch_nybble(priv, 0x20 >> 4, false);
|
latch_nybble(priv, 0x20 >> 4, false);
|
||||||
@@ -603,23 +604,23 @@ static void lcd_init(FAR struct pcf8574_lcd_dev_s *priv)
|
|||||||
|
|
||||||
/* Display On, Cursor Off */
|
/* Display On, Cursor Off */
|
||||||
|
|
||||||
lcd_putcmd(priv, 0x0C);
|
lcd_putcmd(priv, 0x0c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: lcd_create_char
|
* Name: lcd_create_char
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This creates a custom character pattern. There can be 8 5x8 patterns.
|
* This creates a custom character pattern. There can be 8 5x8 patterns.
|
||||||
* The bitmap proceeds top to bottom, msb-lsb, and is right justified (i.e.
|
* The bitmap proceeds top to bottom, msb-lsb, and is right justified (i.e.
|
||||||
* only bits 4-0 are used). By convention, you are meant to always leave the
|
* only bits 4-0 are used). By convention, you are meant to always leave
|
||||||
* last line (byte) zero so that the cursor can use this line, but this is
|
* the last line (byte) zero so that the cursor can use this line, but this
|
||||||
* not strictly required.
|
* is not strictly required.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* priv - device instance
|
* priv - device instance
|
||||||
* idxchar - which character is being imaged; 0 - 7
|
* idxchar - which character is being imaged; 0 - 7
|
||||||
* chardata - the character image bitmap; must be 8 bytes always
|
* chardata - the character image bitmap; must be 8 bytes always
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -1020,8 +1021,8 @@ static int lcd_getstream(FAR struct lib_instream_s *instream)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void lcd_fpos_to_curpos(FAR struct pcf8574_lcd_dev_s *priv,
|
static void lcd_fpos_to_curpos(FAR struct pcf8574_lcd_dev_s *priv,
|
||||||
off_t fpos, FAR uint8_t *row, FAR uint8_t *col,
|
off_t fpos, FAR uint8_t *row,
|
||||||
FAR bool *onlf)
|
FAR uint8_t *col, FAR bool *onlf)
|
||||||
{
|
{
|
||||||
int virtcols;
|
int virtcols;
|
||||||
|
|
||||||
@@ -1123,6 +1124,7 @@ static int pcf8574_lcd_close(FAR struct file *filep)
|
|||||||
{
|
{
|
||||||
/* We have no real teardown at present */
|
/* We have no real teardown at present */
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1354,8 +1356,8 @@ static ssize_t pcf8574_lcd_write(FAR struct file *filep,
|
|||||||
{
|
{
|
||||||
lcd_codec_action(priv, (enum slcdcode_e)ch, count);
|
lcd_codec_action(priv, (enum slcdcode_e)ch, count);
|
||||||
|
|
||||||
/* we can't know what happened, so it's easier just to re-inquire as
|
/* we can't know what happened, so it's easier just to re-inquire
|
||||||
* to where we are.
|
* as to where we are.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lcd_get_curpos(priv, &row, &col);
|
lcd_get_curpos(priv, &row, &col);
|
||||||
@@ -1441,6 +1443,7 @@ static off_t pcf8574_lcd_seek(FAR struct file *filep, off_t offset,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
/* Return EINVAL if the whence argument is invalid */
|
/* Return EINVAL if the whence argument is invalid */
|
||||||
|
|
||||||
pos = (off_t) - EINVAL;
|
pos = (off_t) - EINVAL;
|
||||||
@@ -1624,7 +1627,8 @@ static int pcf8574_lcd_unlink(FAR struct inode *inode)
|
|||||||
|
|
||||||
int pcf8574_lcd_backpack_register(FAR const char *devpath,
|
int pcf8574_lcd_backpack_register(FAR const char *devpath,
|
||||||
FAR struct i2c_master_s *i2c,
|
FAR struct i2c_master_s *i2c,
|
||||||
FAR struct pcf8574_lcd_backpack_config_s *cfg)
|
FAR struct pcf8574_lcd_backpack_config_s
|
||||||
|
*cfg)
|
||||||
{
|
{
|
||||||
FAR struct pcf8574_lcd_dev_s *priv;
|
FAR struct pcf8574_lcd_dev_s *priv;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -1637,7 +1641,8 @@ int pcf8574_lcd_backpack_register(FAR const char *devpath,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cfg->cols < 1 || cfg->cols > 64) || (cfg->rows == 4 && cfg->cols > 32))
|
if ((cfg->cols < 1 || cfg->cols > 64) ||
|
||||||
|
(cfg->rows == 4 && cfg->cols > 32))
|
||||||
{
|
{
|
||||||
lcdinfo("Display cols must be 1-64, and may not be part of a 4x40 "
|
lcdinfo("Display cols must be 1-64, and may not be part of a 4x40 "
|
||||||
"configuration\n");
|
"configuration\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user