I/O Expander: Update skelton file

This commit is contained in:
Gregory Nutt
2016-07-31 14:42:30 -06:00
parent becf7e70c4
commit 99843fe5fe
2 changed files with 17 additions and 77 deletions
+15 -74
View File
@@ -178,80 +178,6 @@ static void skel_lock(FAR struct skel_dev_s *priv)
#define skel_unlock(p) sem_post(&(p)->exclsem) #define skel_unlock(p) sem_post(&(p)->exclsem)
/****************************************************************************
* Name: skel_setbit
*
* Description:
* Write a bit in a register pair
*
****************************************************************************/
static int skel_setbit(FAR struct skel_dev_s *priv, uint8_t pin, int bitval)
{
ioe_pinset_t pinset;
int ret;
if (pin >= CONFIG_IOEXPANDER_NPINS)
{
return -ENXIO;
}
/* Read the pinset from the IO-Expander hardware */
#warning Missing logic
/* Set or clear the pin value */
if (bitval)
{
pinset |= (1 << pin);
}
else
{
pinset &= ~(1 << pin);
}
/* Write the modified value back to the I/O expander */
#warning Missing logic
#ifdef CONFIG_IOEXPANDER_RETRY
if (ret < 0)
{
/* Try again (only once) */
#warning Missing logic
}
#endif
return ret;
}
/****************************************************************************
* Name: skel_getbit
*
* Description:
* Get a bit from a register pair
*
****************************************************************************/
static int skel_getbit(FAR struct skel_dev_s *priv, uint8_t addr,
uint8_t pin, FAR bool *val)
{
ioe_pinset_t pinset;
int ret;
if (pin >= CONFIG_IOEXPANDER_NPINS)
{
return -ENXIO;
}
/* Read the pinset from the IO-Expander hardware */
#warning Missing logic
/* Return true is the corresponding pin is set */
*val = ((pinset & (1 << pin)) != 0);
return OK;
}
/**************************************************************************** /****************************************************************************
* Name: skel_direction * Name: skel_direction
* *
@@ -266,6 +192,13 @@ static int skel_direction(FAR struct ioexpander_dev_s *dev, uint8_t pin,
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
int ret; int ret;
gpioinfo("pin=%u direction=%s\n",
pin, (direction == IOEXPANDER_DIRECTION_IN) ? "IN" : "OUT");
DEBUGASSERT(priv != NULL && pin < CONFIG_IOEXPANDER_NPINS &&
(direction == IOEXPANDER_DIRECTION_IN ||
direction == IOEXPANDER_DIRECTION_IN));
/* Get exclusive access to the I/O Expander */ /* Get exclusive access to the I/O Expander */
skel_lock(priv); skel_lock(priv);
@@ -321,6 +254,10 @@ static int skel_writepin(FAR struct ioexpander_dev_s *dev, uint8_t pin,
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
int ret; int ret;
gpioinfo("pin=%u value=%u\n", pin, value);
DEBUGASSERT(priv != NULL && pin < CONFIG_IOEXPANDER_NPINS);
/* Get exclusive access to the I/O Expander */ /* Get exclusive access to the I/O Expander */
skel_lock(priv); skel_lock(priv);
@@ -346,6 +283,10 @@ static int skel_readpin(FAR struct ioexpander_dev_s *dev, uint8_t pin,
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
int ret; int ret;
gpioinfo("pin=%u\n", priv->addr);
DEBUGASSERT(priv != NULL && pin < CONFIG_IOEXPANDER_NPINS && value != NULL);
/* Get exclusive access to the I/O Expander */ /* Get exclusive access to the I/O Expander */
skel_lock(priv); skel_lock(priv);
+2 -3
View File
@@ -59,7 +59,7 @@
# error No support for devices with more than 64 pins # error No support for devices with more than 64 pins
#endif #endif
/* Pin definiotions *********************************************************/ /* Pin definitions **********************************************************/
#define IOEXPANDER_DIRECTION_IN 0 #define IOEXPANDER_DIRECTION_IN 0
#define IOEXPANDER_DIRECTION_OUT 1 #define IOEXPANDER_DIRECTION_OUT 1
@@ -259,7 +259,6 @@
/* This type represents a bitmap of pins */ /* This type represents a bitmap of pins */
#ifdef CONFIG_IOEXPANDER_INT_ENABLE
#if CONFIG_IOEXPANDER_NPINS <= 8 #if CONFIG_IOEXPANDER_NPINS <= 8
typedef uint8_t ioe_pinset_t; typedef uint8_t ioe_pinset_t;
#elif CONFIG_IOEXPANDER_NPINS <= 16 #elif CONFIG_IOEXPANDER_NPINS <= 16
@@ -268,8 +267,8 @@ typedef uint16_t ioe_pinset_t;
typedef uint32_t ioe_pinset_t; typedef uint32_t ioe_pinset_t;
#else /* if CONFIG_IOEXPANDER_NPINS <= 64 */ #else /* if CONFIG_IOEXPANDER_NPINS <= 64 */
typedef uint64_t ioe_pinset_t; typedef uint64_t ioe_pinset_t;
#endif
#ifdef CONFIG_IOEXPANDER_INT_ENABLE
/* This type represents a pin interrupt callback function */ /* This type represents a pin interrupt callback function */
struct ioexpander_dev_s; struct ioexpander_dev_s;