mirror of https://github.com/ARMmbed/mbed-os.git
nRF5 - added serial flow control configure API implementation
parent
08ff689afa
commit
fe3a8b04bf
|
@ -116,6 +116,9 @@ typedef struct {
|
|||
|
||||
static uart_ctlblock_t uart_cb[UART_INSTANCE_COUNT];
|
||||
|
||||
static void internal_set_hwfc(FlowControl type,
|
||||
PinName rxflow, PinName txflow);
|
||||
|
||||
|
||||
#if DEVICE_SERIAL_ASYNCH
|
||||
static void end_asynch_rx(void)
|
||||
|
@ -313,9 +316,10 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
nrf_uart_baudrate_set(UART_INSTANCE, UART_CB.baudrate);
|
||||
nrf_uart_configure(UART_INSTANCE, UART_CB.parity, UART_CB.hwfc);
|
||||
if (UART_CB.hwfc == NRF_UART_HWFC_ENABLED) {
|
||||
serial_set_flow_control(obj, FlowControlRTSCTS,
|
||||
internal_set_hwfc(FlowControlRTSCTS,
|
||||
(PinName) UART_CB.pselrts, (PinName) UART_CB.pselcts);
|
||||
}
|
||||
|
||||
nrf_uart_enable(UART_INSTANCE);
|
||||
|
||||
UART_CB.initialized = true;
|
||||
|
@ -524,15 +528,14 @@ void serial_break_clear(serial_t *obj)
|
|||
nrf_uart_task_trigger(UART_INSTANCE, NRF_UART_TASK_STARTTX);
|
||||
}
|
||||
|
||||
void serial_set_flow_control(serial_t *obj, FlowControl type,
|
||||
|
||||
static void internal_set_hwfc(FlowControl type,
|
||||
PinName rxflow, PinName txflow)
|
||||
{
|
||||
(void)obj;
|
||||
|
||||
UART_CB.pselrts =
|
||||
(rxflow == NC) ? NRF_UART_PSEL_DISCONNECTED : (uint32_t)rxflow;
|
||||
((rxflow == NC) || (type == FlowControlCTS)) ? NRF_UART_PSEL_DISCONNECTED : (uint32_t)rxflow;
|
||||
UART_CB.pselcts =
|
||||
(txflow == NC) ? NRF_UART_PSEL_DISCONNECTED : (uint32_t)txflow;
|
||||
((txflow == NC) || (type == FlowControlRTS)) ? NRF_UART_PSEL_DISCONNECTED : (uint32_t)txflow;
|
||||
|
||||
if (UART_CB.pselrts != NRF_UART_PSEL_DISCONNECTED) {
|
||||
nrf_gpio_pin_set(UART_CB.pselrts);
|
||||
|
@ -541,11 +544,24 @@ void serial_set_flow_control(serial_t *obj, FlowControl type,
|
|||
if (UART_CB.pselcts != NRF_UART_PSEL_DISCONNECTED) {
|
||||
nrf_gpio_cfg_input(UART_CB.pselcts, NRF_GPIO_PIN_NOPULL);
|
||||
}
|
||||
nrf_uart_disable(UART_INSTANCE);
|
||||
|
||||
UART_CB.hwfc = (type == FlowControlNone)? NRF_UART_HWFC_DISABLED : UART0_CONFIG_HWFC;
|
||||
|
||||
nrf_uart_configure(UART_INSTANCE, UART_CB.parity, UART_CB.hwfc);
|
||||
nrf_uart_hwfc_pins_set(UART_INSTANCE, UART_CB.pselrts, UART_CB.pselcts);
|
||||
}
|
||||
|
||||
void serial_set_flow_control(serial_t *obj, FlowControl type,
|
||||
PinName rxflow, PinName txflow)
|
||||
{
|
||||
(void)obj;
|
||||
|
||||
nrf_uart_disable(UART_INSTANCE);
|
||||
internal_set_hwfc(type, rxflow, txflow);
|
||||
nrf_uart_enable(UART_INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
void serial_clear(serial_t *obj) {
|
||||
(void)obj;
|
||||
}
|
||||
|
|
|
@ -2005,7 +2005,7 @@
|
|||
"NRF51_DK": {
|
||||
"supported_form_factors": ["ARDUINO"],
|
||||
"inherits": ["MCU_NRF51_32K_UNIFIED"],
|
||||
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"],
|
||||
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"],
|
||||
"release_versions": ["2", "5"],
|
||||
"device_name": "nRF51822_xxAA"
|
||||
},
|
||||
|
@ -2056,7 +2056,7 @@
|
|||
"supported_form_factors": ["ARDUINO"],
|
||||
"inherits": ["MCU_NRF52"],
|
||||
"macros_add": ["BOARD_PCA10040", "NRF52_PAN_12", "NRF52_PAN_15", "NRF52_PAN_58", "NRF52_PAN_55", "NRF52_PAN_54", "NRF52_PAN_31", "NRF52_PAN_30", "NRF52_PAN_51", "NRF52_PAN_36", "NRF52_PAN_53", "S132", "CONFIG_GPIO_AS_PINRESET", "BLE_STACK_SUPPORT_REQD", "SWI_DISABLE0", "NRF52_PAN_20", "NRF52_PAN_64", "NRF52_PAN_62", "NRF52_PAN_63"],
|
||||
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"],
|
||||
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"],
|
||||
"release_versions": ["2", "5"],
|
||||
"device_name": "nRF52832_xxAA"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue