Merged in david_s5/nuttx/px4_firmware_nuttx-8.1+_siglewire (pull request #1070)

single wire Allow selection of pull{up|down|none}

* tioctl:Allow selection of pull{up|down|none}

* stm32:Single Wire add pull{up|down|none} tioctl

* stm32f0l0g0:Single Wire add pull{up|down|none} tioctl

* stm32f7:Single Wire add pull{up|down|none} tioctl

* stm32h7:Single Wire add pull{up|down|none} tioctl

* stm32l4:Single Wire add pull{up|down|none} tioctl

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
David Sidrane 2019-11-10 12:27:47 +00:00 committed by Gregory Nutt
parent 8c85ecf531
commit 19015f7e26
7 changed files with 24 additions and 8 deletions

View File

@ -1965,7 +1965,9 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
#else
if ((arg & SER_SINGLEWIRE_ENABLED) != 0)
{
uint32_t gpio_val = (arg & SER_SINGLEWIRE_PULLUP) ? GPIO_PULLUP : GPIO_OPENDRAIN;
uint32_t gpio_val = GPIO_OPENDRAIN;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLUP ? GPIO_PULLUP : GPIO_FLOAT;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLDOWN ? GPIO_PULLDOWN : GPIO_FLOAT;
stm32_configgpio((priv->tx_gpio & ~(GPIO_PUPD_MASK | GPIO_OPENDRAIN)) | gpio_val);
cr |= USART_CR3_HDSEL;
}

View File

@ -1604,7 +1604,9 @@ static int stm32serial_ioctl(FAR struct file *filep, int cmd,
if ((arg & SER_SINGLEWIRE_ENABLED) != 0)
{
uint32_t gpio_val = (arg & SER_SINGLEWIRE_PULLUP) ? GPIO_PULLUP : GPIO_OPENDRAIN;
uint32_t gpio_val = GPIO_OPENDRAIN;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLUP ? GPIO_PULLUP : GPIO_FLOAT;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLDOWN ? GPIO_PULLDOWN : GPIO_FLOAT;
stm32_configgpio((priv->tx_gpio & ~(GPIO_PUPD_MASK | GPIO_OPENDRAIN)) | gpio_val);
cr |= USART_CR3_HDSEL;
}

View File

@ -1163,7 +1163,9 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
if ((arg & SER_SINGLEWIRE_ENABLED) != 0)
{
uint32_t gpio_val = (arg & SER_SINGLEWIRE_PULLUP) ? GPIO_PULLUP : GPIO_OPENDRAIN;
uint32_t gpio_val = GPIO_OPENDRAIN;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLUP ? GPIO_PULLUP : GPIO_FLOAT;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLDOWN ? GPIO_PULLDOWN : GPIO_FLOAT;
stm32_configgpio((priv->tx_gpio & ~(GPIO_PUPD_MASK | GPIO_OPENDRAIN)) | gpio_val);
cr |= USART_CR3_HDSEL;
}

View File

@ -2127,7 +2127,9 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
if ((arg & SER_SINGLEWIRE_ENABLED) != 0)
{
uint32_t gpio_val = (arg & SER_SINGLEWIRE_PULLUP) ? GPIO_PULLUP : GPIO_OPENDRAIN;
uint32_t gpio_val = GPIO_OPENDRAIN;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLUP ? GPIO_PULLUP : GPIO_FLOAT;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLDOWN ? GPIO_PULLDOWN : GPIO_FLOAT;
stm32_configgpio((priv->tx_gpio & ~(GPIO_PUPD_MASK | GPIO_OPENDRAIN)) | gpio_val);
cr |= USART_CR3_HDSEL;
}

View File

@ -1532,7 +1532,9 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
if ((arg & SER_SINGLEWIRE_ENABLED) != 0)
{
uint32_t gpio_val = (arg & SER_SINGLEWIRE_PULLUP) ? GPIO_PULLUP : GPIO_OPENDRAIN;
uint32_t gpio_val = GPIO_OPENDRAIN;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLUP ? GPIO_PULLUP : GPIO_FLOAT;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLDOWN ? GPIO_PULLDOWN : GPIO_FLOAT;
stm32_configgpio((priv->tx_gpio & ~(GPIO_PUPD_MASK | GPIO_OPENDRAIN)) | gpio_val);
cr |= USART_CR3_HDSEL;
}

View File

@ -1825,7 +1825,9 @@ static int stm32l4serial_ioctl(FAR struct file *filep, int cmd,
if ((arg & SER_SINGLEWIRE_ENABLED) != 0)
{
uint32_t gpio_val = (arg & SER_SINGLEWIRE_PULLUP) ? GPIO_PULLUP : GPIO_OPENDRAIN;
uint32_t gpio_val = GPIO_OPENDRAIN;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLUP ? GPIO_PULLUP : GPIO_FLOAT;
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLDOWN ? GPIO_PULLDOWN : GPIO_FLOAT;
stm32l4_configgpio((priv->tx_gpio & ~(GPIO_PUPD_MASK | GPIO_OPENDRAIN)) | gpio_val);
cr |= USART_CR3_HDSEL;
}

View File

@ -184,8 +184,12 @@
#define TIOCSSINGLEWIRE _TIOC(0x0030) /* Set single-wire mode */
#define TIOCGSINGLEWIRE _TIOC(0x0031) /* Get single-wire mode */
# define SER_SINGLEWIRE_ENABLED (1 << 0) /* Enable/disable single-wire support */
# define SER_SINGLEWIRE_PULLUP (1 << 1) /* Enable Pull-up on TX (Open-Drain otherwise) */
# define SER_SINGLEWIRE_ENABLED (1 << 0) /* Enable/disable single-wire support */
# define SER_SINGLEWIRE_PULL_SHIFT (1) /* RX/TX Line Pullup/down control */
# define SER_SINGLEWIRE_PULL_MASK (3 << SER_SINGLEWIRE_PULL_SHIFT)
# define SER_SINGLEWIRE_PULL_DISABLE (0 << SER_SINGLEWIRE_PULL_SHIFT) /* Float RX/TX Line */
# define SER_SINGLEWIRE_PULLUP (1 << SER_SINGLEWIRE_PULL_SHIFT) /* Enable Pull up the RX/TX Line */
# define SER_SINGLEWIRE_PULLDOWN (2 << SER_SINGLEWIRE_PULL_SHIFT) /* Enable Pull down the RX/TX Line */
/* Debugging */