Add infrastructure to support RS-485 on the LPC43xx (logic still incomplete)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4958 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
0ba37ba68d
commit
9faa2e9ece
@ -3029,4 +3029,9 @@
|
|||||||
add the ability to run the chip off the internal oscillator. There is no open
|
add the ability to run the chip off the internal oscillator. There is no open
|
||||||
board configuration for this part yet (the STM32VLDiscovery would be a candidate).
|
board configuration for this part yet (the STM32VLDiscovery would be a candidate).
|
||||||
Contributed by Mike Smith.
|
Contributed by Mike Smith.
|
||||||
|
* arch/arm/src/stm32: Fixed typos in conditional compilation in the CAN and DMA
|
||||||
|
and some pin configuration. This would have caused problems for STM32 F107xx.
|
||||||
|
Typos noted by Mike Smith.
|
||||||
|
* arch/arm/src/lpc43xx/lpc43_serial.c: Add support for certain RS-485 features
|
||||||
|
in the serial driver (still a work in progress on initial check-in).
|
||||||
|
|
||||||
|
@ -857,6 +857,50 @@ static int up_interrupt(int irq, void *context)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_set_rs485_mode
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Handle LPC43xx USART0,2,3 RS485 mode set ioctl (TIOCSRS485) to enable
|
||||||
|
* and disable RS-485 mode. This is part of the serial ioctl logic.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_USART_RS485MODE
|
||||||
|
static inline int up_set_rs485_mode(struct up_dev_s *priv,
|
||||||
|
const struct serial_rs485 *mode)
|
||||||
|
{
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
|
DEBUGASSERT(priv && mode);
|
||||||
|
flags = irqsave();
|
||||||
|
#warning "Missing logic"
|
||||||
|
irqrestore(flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_get_rs485_mode
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Handle LPC43xx USART0,2,3 RS485 mode get ioctl (TIOCGRS485) to get the
|
||||||
|
* current RS-485 mode.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_USART_RS485MODE
|
||||||
|
static inline int up_get_rs485_mode(struct up_dev_s *priv,
|
||||||
|
struct serial_rs485 *mode)
|
||||||
|
{
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
|
DEBUGASSERT(priv && mode);
|
||||||
|
flags = irqsave();
|
||||||
|
#warning "Missing logic"
|
||||||
|
irqrestore(flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_ioctl
|
* Name: up_ioctl
|
||||||
*
|
*
|
||||||
@ -906,6 +950,22 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef CONFIG_USART_RS485MODE
|
||||||
|
case TIOCSRS485: /* Set RS485 mode, arg: pointer to struct serial_rs485 */
|
||||||
|
{
|
||||||
|
ret = up_set_rs485_mode(priv,
|
||||||
|
(const struct serial_rs485 *)((uintptr_t)arg));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TIOCGRS485: /* Get RS485 mode, arg: pointer to struct serial_rs485 */
|
||||||
|
{
|
||||||
|
ret = up_get_rs485_mode(priv,
|
||||||
|
(struct serial_rs485 *)((uintptr_t)arg));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
*get_errno_ptr() = ENOTTY;
|
*get_errno_ptr() = ENOTTY;
|
||||||
ret = ERROR;
|
ret = ERROR;
|
||||||
|
@ -716,7 +716,7 @@ LPC4330-Xplorer Configuration Options
|
|||||||
CONFIG_LPC43_USB1_ULPI=y
|
CONFIG_LPC43_USB1_ULPI=y
|
||||||
CONFIG_LPC43_WWDT=y
|
CONFIG_LPC43_WWDT=y
|
||||||
|
|
||||||
LPC43xx specific device driver settings
|
LPC43xx specific U[S]ART device driver settings
|
||||||
|
|
||||||
CONFIG_U[S]ARTn_SERIAL_CONSOLE - selects the UARTn for the
|
CONFIG_U[S]ARTn_SERIAL_CONSOLE - selects the UARTn for the
|
||||||
console and ttys0 (default is the USART0).
|
console and ttys0 (default is the USART0).
|
||||||
@ -729,6 +729,10 @@ LPC4330-Xplorer Configuration Options
|
|||||||
CONFIG_U[S]ARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
|
CONFIG_U[S]ARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
|
||||||
CONFIG_U[S]ARTn_2STOP - Two stop bits
|
CONFIG_U[S]ARTn_2STOP - Two stop bits
|
||||||
|
|
||||||
|
CONFIG_USART_RS485MODE - Support LPC43xx USART0,2,3 RS485 mode
|
||||||
|
ioctls (TIOCSRS485 and TIOCGRS485) to enable and disable
|
||||||
|
RS-485 mode.
|
||||||
|
|
||||||
LPC43xx specific CAN device driver settings. These settings all
|
LPC43xx specific CAN device driver settings. These settings all
|
||||||
require CONFIG_CAN:
|
require CONFIG_CAN:
|
||||||
|
|
||||||
|
@ -227,6 +227,13 @@ CONFIG_UART1_2STOP=0
|
|||||||
CONFIG_USART2_2STOP=0
|
CONFIG_USART2_2STOP=0
|
||||||
CONFIG_USART3_2STOP=0
|
CONFIG_USART3_2STOP=0
|
||||||
|
|
||||||
|
#
|
||||||
|
# CONFIG_USART_RS485MODE - Support LPC43xx USART0,2,3 RS485 mode
|
||||||
|
# ioctls (TIOCSRS485 and TIOCGRS485) to enable and disable
|
||||||
|
# RS-485 mode.
|
||||||
|
#
|
||||||
|
CONFIG_USART_RS485MODE=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# LPC43xx specific PHY/Ethernet device driver settings
|
# LPC43xx specific PHY/Ethernet device driver settings
|
||||||
#
|
#
|
||||||
|
@ -227,6 +227,13 @@ CONFIG_UART1_2STOP=0
|
|||||||
CONFIG_USART2_2STOP=0
|
CONFIG_USART2_2STOP=0
|
||||||
CONFIG_USART3_2STOP=0
|
CONFIG_USART3_2STOP=0
|
||||||
|
|
||||||
|
#
|
||||||
|
# CONFIG_USART_RS485MODE - Support LPC43xx USART0,2,3 RS485 mode
|
||||||
|
# ioctls (TIOCSRS485 and TIOCGRS485) to enable and disable
|
||||||
|
# RS-485 mode.
|
||||||
|
#
|
||||||
|
CONFIG_USART_RS485MODE=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# LPC43xx specific PHY/Ethernet device driver settings
|
# LPC43xx specific PHY/Ethernet device driver settings
|
||||||
#
|
#
|
||||||
|
@ -160,9 +160,21 @@
|
|||||||
#define TIOCMIWAIT _TIOC(0x0028) /* Wait for a change on serial input line(s): void */
|
#define TIOCMIWAIT _TIOC(0x0028) /* Wait for a change on serial input line(s): void */
|
||||||
#define TIOCGICOUNT _TIOC(0x0029) /* Read serial port interrupt count: FAR struct serial_icounter_struct */
|
#define TIOCGICOUNT _TIOC(0x0029) /* Read serial port interrupt count: FAR struct serial_icounter_struct */
|
||||||
|
|
||||||
|
/* RS-485 Support */
|
||||||
|
|
||||||
|
#define TIOCSRS485 _TIOC(0x002a) /* Set RS485 mode, arg: pointer to struct serial_rs485 */
|
||||||
|
#define TIOCGRS485 _TIOC(0x002b) /* Get RS485 mode, arg: pointer to struct serial_rs485 */
|
||||||
|
|
||||||
/* Debugging */
|
/* Debugging */
|
||||||
|
|
||||||
#define TIOCSERGSTRUCT _TIOC(0x002a) /* Get device TTY structure */
|
#define TIOCSERGSTRUCT _TIOC(0x002c) /* Get device TTY structure */
|
||||||
|
|
||||||
|
/* Definitions used in struct serial_rs485 (Linux compatible) */
|
||||||
|
|
||||||
|
#define SER_RS485_ENABLED (1 << 0) /* Enable/disble RS-485 support */
|
||||||
|
#define SER_RS485_RTS_ON_SEND (1 << 1) /* Logic level for RTS pin when sending */
|
||||||
|
#define SER_RS485_RTS_AFTER_SEND (1 << 2) /* Logic level for RTS pin after sent */
|
||||||
|
#define SER_RS485_RX_DURING_TX (1 << 4)
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Type Definitions
|
* Public Type Definitions
|
||||||
@ -178,6 +190,15 @@ struct winsize
|
|||||||
/* uint16_t ws_ypixel; unused */
|
/* uint16_t ws_ypixel; unused */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Structure used with TIOCSRS485 and TIOCGRS485 (Linux compatible) */
|
||||||
|
|
||||||
|
struct serial_rs485
|
||||||
|
{
|
||||||
|
uint32_t flags /* See SER_RS485_* definitions */
|
||||||
|
uint32_t delay_rts_before_send; /* Delay before send (milliseconds) */
|
||||||
|
uint32_t delay_rts_after_send; /* Delay after send (milliseconds) */
|
||||||
|
};
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user