Skip to content

Commit 02475e7

Browse files
committed
cmsis_uart: Merge enhancements from nrf52820 HIC version
1 parent d17e653 commit 02475e7

File tree

1 file changed

+17
-1
lines changed
  • source/hic_hal/cmsis-driver/uart

1 file changed

+17
-1
lines changed

source/hic_hal/cmsis-driver/uart/uart.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file uart.c
3-
* @brief
3+
* @brief UART Function for HIC using CMSIS-Driver
44
*
55
* DAPLink Interface Firmware
66
* Copyright (c) 2020 Arm Limited, All Rights Reserved
@@ -38,6 +38,9 @@ circ_buf_t write_buffer;
3838
uint8_t write_buffer_data[BUFFER_SIZE];
3939
circ_buf_t read_buffer;
4040
uint8_t read_buffer_data[BUFFER_SIZE];
41+
uint16_t cur_line_state;
42+
uint32_t cur_control;
43+
uint32_t cur_baud;
4144

4245
struct {
4346
// Number of bytes pending to be transferred. This is 0 if there is no
@@ -61,6 +64,9 @@ int32_t uart_initialize(void)
6164
cb_buf.tx_size = 0;
6265
CMSIS_UART_INSTANCE.Initialize(uart_handler);
6366
CMSIS_UART_INSTANCE.PowerControl(ARM_POWER_FULL);
67+
cur_line_state = 0;
68+
cur_control = 0;
69+
cur_baud = 0;
6470

6571
return 1;
6672
}
@@ -156,6 +162,12 @@ int32_t uart_set_configuration(UART_Configuration *config)
156162
break;
157163
}
158164

165+
if ((control == cur_control) && (config->Baudrate == cur_baud)) {
166+
return 1;
167+
}
168+
cur_control = control;
169+
cur_baud = config->Baudrate;
170+
159171
NVIC_DisableIRQ(CMSIS_UART_IRQ);
160172
clear_buffers();
161173
if (cb_buf.tx_size != 0) {
@@ -188,6 +200,10 @@ int32_t uart_get_configuration(UART_Configuration *config)
188200

189201
void uart_set_control_line_state(uint16_t ctrl_bmp)
190202
{
203+
if (ctrl_bmp != cur_line_state) {
204+
uart_reset();
205+
cur_line_state = ctrl_bmp;
206+
}
191207
}
192208

193209
int32_t uart_write_free(void)

0 commit comments

Comments
 (0)