Skip to content

Commit 526e731

Browse files
committed
stdio copy in HAL removal
This is not required for each HAL to do, as retarget contains all what is required. It defines serial singleton object, and should be initialized only once.
1 parent 7f80e45 commit 526e731

File tree

44 files changed

+1
-411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1
-411
lines changed

hal/targets/hal/TARGET_ARM_SSG/TARGET_BEETLE/serial_api.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ static const PinMap PinMap_UART_RX[] = {
4646

4747
static uart_irq_handler irq_handler;
4848

49-
int stdio_uart_inited = 0;
50-
serial_t stdio_uart;
51-
5249
struct serial_global_data_s {
5350
uint32_t serial_irq_id;
5451
gpio_t sw_rts, sw_cts;
@@ -113,13 +110,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
113110
uart_data[obj->index].sw_rts.pin = NC;
114111
uart_data[obj->index].sw_cts.pin = NC;
115112
serial_set_flow_control(obj, FlowControlNone, NC, NC);
116-
117-
is_stdio_uart = (uart == STDIO_UART) ? (1) : (0);
118-
119-
if (is_stdio_uart) {
120-
stdio_uart_inited = 1;
121-
memcpy(&stdio_uart, obj, sizeof(serial_t));
122-
}
123113
}
124114

125115
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_ARM_SSG/TARGET_IOTSS/serial_api.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ static const PinMap PinMap_UART_RX[] = {
4949

5050
static uart_irq_handler irq_handler;
5151

52-
int stdio_uart_inited = 0;
53-
serial_t stdio_uart;
54-
5552
struct serial_global_data_s {
5653
uint32_t serial_irq_id;
5754
gpio_t sw_rts, sw_cts;
@@ -156,13 +153,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
156153
uart_data[obj->index].sw_rts.pin = NC;
157154
uart_data[obj->index].sw_cts.pin = NC;
158155
serial_set_flow_control(obj, FlowControlNone, NC, NC);
159-
160-
is_stdio_uart = (uart == STDIO_UART) ? (1) : (0);
161-
162-
if (is_stdio_uart) {
163-
stdio_uart_inited = 1;
164-
memcpy(&stdio_uart, obj, sizeof(serial_t));
165-
}
166156
}
167157

168158
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_ARM_SSG/TARGET_MPS2/serial_api.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ static const PinMap PinMap_UART_RX[] = {
4949

5050
static uart_irq_handler irq_handler;
5151

52-
int stdio_uart_inited = 0;
53-
serial_t stdio_uart;
54-
5552
struct serial_global_data_s {
5653
uint32_t serial_irq_id;
5754
gpio_t sw_rts, sw_cts;
@@ -158,13 +155,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
158155
uart_data[obj->index].sw_rts.pin = NC;
159156
uart_data[obj->index].sw_cts.pin = NC;
160157
serial_set_flow_control(obj, FlowControlNone, NC, NC);
161-
162-
is_stdio_uart = (uart == STDIO_UART) ? (1) : (0);
163-
164-
if (is_stdio_uart) {
165-
stdio_uart_inited = 1;
166-
memcpy(&stdio_uart, obj, sizeof(serial_t));
167-
}
168158
}
169159

170160
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Atmel/TARGET_SAM_CortexM0P/serial_api.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ void uart5_irq(void);
5252
static uint32_t serial_irq_ids[USART_NUM] = {0};
5353
static uart_irq_handler irq_handler;
5454

55-
int stdio_uart_inited = 0;
56-
serial_t stdio_uart;
57-
5855
extern uint8_t g_sys_init;
5956

6057
static inline void usart_syncing(serial_t *obj)
@@ -329,10 +326,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
329326
}
330327
}
331328

332-
if (uart == STDIO_UART) {
333-
stdio_uart_inited = 1;
334-
memcpy(&stdio_uart, obj, sizeof(serial_t));
335-
}
336329
/* Wait until synchronization is complete */
337330
usart_syncing(obj);
338331

hal/targets/hal/TARGET_Atmel/TARGET_SAM_CortexM4/serial_api.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ static void uart5_irq(void);
4848
static void uart6_irq(void);
4949
static void uart7_irq(void);
5050

51-
52-
int stdio_uart_inited = 0;
53-
serial_t stdio_uart;
54-
5551
extern uint8_t g_sys_init;
5652

5753
static int get_usart_clock_id(UARTName peripheral)
@@ -192,11 +188,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
192188
if(rx != NC) {
193189
usart_enable_rx((Usart*)uart);
194190
}
195-
196-
if(uart == STDIO_UART) {
197-
stdio_uart_inited = 1;
198-
memcpy(&stdio_uart, obj, sizeof(serial_t));
199-
}
200191
}
201192

202193
void serial_free(serial_t *obj)
@@ -783,4 +774,4 @@ void serial_rx_abort_asynch(serial_t *obj)
783774
pSERIAL_S(obj)->actrec = false;
784775
}
785776

786-
#endif
777+
#endif

hal/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/serial_api.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
static uint32_t serial_irq_ids[UART_NUM] = {0};
5454
static uart_irq_handler irq_handler;
5555

56-
int stdio_uart_inited = 0;
57-
serial_t stdio_uart;
58-
5956
void serial_init(serial_t *obj, PinName tx, PinName rx) {
6057
// determine the UART to use
6158
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
@@ -104,11 +101,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
104101
}
105102

106103
obj->uart->C2 |= (UARTLP_C2_RE_MASK | UARTLP_C2_TE_MASK);
107-
108-
if (uart == STDIO_UART) {
109-
stdio_uart_inited = 1;
110-
memcpy(&stdio_uart, obj, sizeof(serial_t));
111-
}
112104
}
113105

114106
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/serial_api.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
static uint32_t serial_irq_ids[UART_NUM] = {0};
5555
static uart_irq_handler irq_handler;
5656

57-
int stdio_uart_inited = 0;
58-
serial_t stdio_uart;
59-
6057
void serial_init(serial_t *obj, PinName tx, PinName rx) {
6158
// determine the UART to use
6259
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
@@ -115,11 +112,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
115112
obj->uart->C2 |= UARTLP_C2_RE_MASK;
116113
pin_mode(rx, PullUp);
117114
}
118-
119-
if (uart == STDIO_UART) {
120-
stdio_uart_inited = 1;
121-
memcpy(&stdio_uart, obj, sizeof(serial_t));
122-
}
123115
}
124116

125117
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL26Z/serial_api.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
static uint32_t serial_irq_ids[UART_NUM] = {0};
5555
static uart_irq_handler irq_handler;
5656

57-
int stdio_uart_inited = 0;
58-
serial_t stdio_uart;
59-
6057
void serial_init(serial_t *obj, PinName tx, PinName rx) {
6158
// determine the UART to use
6259
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
@@ -115,11 +112,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
115112
obj->uart->C2 |= UARTLP_C2_RE_MASK;
116113
pin_mode(rx, PullUp);
117114
}
118-
119-
if (uart == STDIO_UART) {
120-
stdio_uart_inited = 1;
121-
memcpy(&stdio_uart, obj, sizeof(serial_t));
122-
}
123115
}
124116

125117
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL43Z/serial_api.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
static uint32_t serial_irq_ids[UART_NUM] = {0};
3636
static uart_irq_handler irq_handler;
3737

38-
int stdio_uart_inited = 0;
39-
serial_t stdio_uart;
40-
4138
static inline uint32_t serial_get_src_clock(serial_t *obj) {
4239
uint32_t mux, srcclk;
4340

@@ -108,11 +105,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
108105
if (rx != NC) pin_mode(rx, PullUp);
109106

110107
obj->uart->CTRL |= (LPUART_CTRL_RE_MASK | LPUART_CTRL_TE_MASK);
111-
112-
if (uart == STDIO_UART) {
113-
stdio_uart_inited = 1;
114-
memcpy(&stdio_uart, obj, sizeof(serial_t));
115-
}
116108
}
117109

118110
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/serial_api.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
static uint32_t serial_irq_ids[UART_NUM] = {0};
5555
static uart_irq_handler irq_handler;
5656

57-
int stdio_uart_inited = 0;
58-
serial_t stdio_uart;
59-
6057
void serial_init(serial_t *obj, PinName tx, PinName rx) {
6158
// determine the UART to use
6259
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
@@ -115,11 +112,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
115112
obj->uart->C2 |= UARTLP_C2_RE_MASK;
116113
pin_mode(rx, PullUp);
117114
}
118-
119-
if (uart == STDIO_UART) {
120-
stdio_uart_inited = 1;
121-
memcpy(&stdio_uart, obj, sizeof(serial_t));
122-
}
123115
}
124116

125117
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K22F/serial_api.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ static UART_Type *const uart_addrs[] = UART_BASE_PTRS;
3737
/* Array of UART bus clock frequencies */
3838
static clock_name_t const uart_clocks[] = UART_CLOCK_FREQS;
3939

40-
41-
int stdio_uart_inited = 0;
42-
serial_t stdio_uart;
43-
4440
void serial_init(serial_t *obj, PinName tx, PinName rx) {
4541
uint32_t uart_tx = pinmap_peripheral(tx, PinMap_UART_TX);
4642
uint32_t uart_rx = pinmap_peripheral(rx, PinMap_UART_RX);
@@ -71,11 +67,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
7167
UART_EnableRx(uart_addrs[obj->index], true);
7268
pin_mode(rx, PullUp);
7369
}
74-
75-
if (obj->index == STDIO_UART) {
76-
stdio_uart_inited = 1;
77-
memcpy(&stdio_uart, obj, sizeof(serial_t));
78-
}
7970
}
8071

8172
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_KL27Z/serial_api.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ static LPUART_Type *const uart_addrs[] = LPUART_BASE_PTRS;
3737
/* Array of LPUART bus clock frequencies */
3838
static clock_name_t const uart_clocks[] = LPUART_CLOCK_FREQS;
3939

40-
int stdio_uart_inited = 0;
41-
serial_t stdio_uart;
42-
4340
void serial_init(serial_t *obj, PinName tx, PinName rx) {
4441
uint32_t uart_tx = pinmap_peripheral(tx, PinMap_UART_TX);
4542
uint32_t uart_rx = pinmap_peripheral(rx, PinMap_UART_RX);
@@ -76,11 +73,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
7673
LPUART_EnableRx(uart_addrs[obj->index], true);
7774
pin_mode(rx, PullUp);
7875
}
79-
80-
if (obj->index == STDIO_UART) {
81-
stdio_uart_inited = 1;
82-
memcpy(&stdio_uart, obj, sizeof(serial_t));
83-
}
8476
}
8577

8678
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/serial_api.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ static UART_Type *const uart_addrs[] = UART_BASE_PTRS;
3737
/* Array of UART bus clock frequencies */
3838
static clock_name_t const uart_clocks[] = UART_CLOCK_FREQS;
3939

40-
41-
int stdio_uart_inited = 0;
42-
serial_t stdio_uart;
43-
4440
void serial_init(serial_t *obj, PinName tx, PinName rx) {
4541
uint32_t uart_tx = pinmap_peripheral(tx, PinMap_UART_TX);
4642
uint32_t uart_rx = pinmap_peripheral(rx, PinMap_UART_RX);
@@ -71,11 +67,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
7167
UART_EnableRx(uart_addrs[obj->index], true);
7268
pin_mode(rx, PullUp);
7369
}
74-
75-
if (obj->index == STDIO_UART) {
76-
stdio_uart_inited = 1;
77-
memcpy(&stdio_uart, obj, sizeof(serial_t));
78-
}
7970
}
8071

8172
void serial_free(serial_t *obj) {

hal/targets/hal/TARGET_Maxim/TARGET_MAX32600/serial_api.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
MXC_F_UART_INTFL_RX_PARITY_ERROR | \
5050
MXC_F_UART_INTFL_RX_OVERRUN)
5151

52-
// Variables for managing the stdio UART
53-
int stdio_uart_inited;
54-
serial_t stdio_uart;
55-
5652
// Variables for interrupt driven
5753
static uart_irq_handler irq_handler;
5854
static uint32_t serial_irq_ids[UART_NUM];
@@ -88,12 +84,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
8884
// Configure to default settings
8985
serial_baud(obj, DEFAULT_BAUD);
9086
serial_format(obj, 8, ParityNone, 1);
91-
92-
// Manage stdio UART
93-
if(uart == STDIO_UART) {
94-
stdio_uart_inited = 1;
95-
memcpy(&stdio_uart, obj, sizeof(serial_t));
96-
}
9787
}
9888

9989
//******************************************************************************

hal/targets/hal/TARGET_Maxim/TARGET_MAX32610/serial_api.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
MXC_F_UART_INTFL_RX_PARITY_ERROR | \
5050
MXC_F_UART_INTFL_RX_OVERRUN)
5151

52-
// Variables for managing the stdio UART
53-
int stdio_uart_inited;
54-
serial_t stdio_uart;
55-
5652
// Variables for interrupt driven
5753
static uart_irq_handler irq_handler;
5854
static uint32_t serial_irq_ids[UART_NUM];
@@ -88,12 +84,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
8884
// Configure to default settings
8985
serial_baud(obj, DEFAULT_BAUD);
9086
serial_format(obj, 8, ParityNone, 1);
91-
92-
// Manage stdio UART
93-
if(uart == STDIO_UART) {
94-
stdio_uart_inited = 1;
95-
memcpy(&stdio_uart, obj, sizeof(serial_t));
96-
}
9787
}
9888

9989
//******************************************************************************

hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/serial_api.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ static const int acceptedSpeeds[18][2] = {
5050
{1000000, UART_BAUDRATE_BAUDRATE_Baud1M}
5151
};
5252

53-
int stdio_uart_inited = 0;
54-
serial_t stdio_uart;
55-
56-
5753
void serial_init(serial_t *obj, PinName tx, PinName rx) {
5854
UARTName uart = UART_0;
5955
obj->uart = (NRF_UART_Type *)uart;
@@ -97,11 +93,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
9793
if (rx != NC) {
9894
pin_mode(rx, PullUp);
9995
}
100-
101-
if (uart == STDIO_UART) {
102-
stdio_uart_inited = 1;
103-
memcpy(&stdio_uart, obj, sizeof(serial_t));
104-
}
10596
}
10697

10798
void serial_free(serial_t *obj)

0 commit comments

Comments
 (0)