Skip to content

Commit dbaeeaf

Browse files
committed
Replace RawSerial instances as it has been deprecated
1 parent de798c4 commit dbaeeaf

File tree

23 files changed

+140
-126
lines changed

23 files changed

+140
-126
lines changed

TESTS/mbed_drivers/flashiap/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#else
2121

2222
#include "utest/utest.h"
23-
#include "utest/utest_serial.h"
23+
#include "utest/utest_print.h"
2424
#include "unity/unity.h"
2525
#include "greentea-client/test_env.h"
2626
#include "FlashIAP.h"

TESTS/mbed_hal/trng/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "base64b.h"
4444
#include "pithy.h"
4545
#include <stdio.h>
46+
#include <string.h>
4647
#include "mbedtls/config.h"
4748
#include "mbedtls/platform.h"
4849

TESTS/psa/entropy_inject/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "entropy.h"
2929
#include "entropy_poll.h"
3030
#include "psa/crypto.h"
31+
#include <string.h>
3132

3233
/* MAX value support macro */
3334
#if !defined(MAX)

TESTS/psa/spm_smoke/COMPONENT_NSPE/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "utest.h"
2828
#include "psa/client.h"
2929
#include "psa_manifest/sid.h"
30+
#include <string.h>
3031

3132
#if defined(TARGET_TFM)
3233
#define PSA_MAX_IOVEC 4

TEST_APPS/device/nanostack_mac_tester/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#endif
4545

4646
extern mac_api_s *mac_interface;
47-
RawSerial pc(USBTX, USBRX);
47+
UnbufferedSerial pc(USBTX, USBRX);
4848
osThreadId_t main_thread;
4949
static CircularBuffer<uint8_t, RX_BUFFER_SIZE> rx_buffer;
5050
static uint8_t ns_heap[HEAP_FOR_MAC_TESTER_SIZE];
@@ -68,7 +68,8 @@ static void app_heap_error_handler(heap_fail_t event)
6868

6969
static void rx_interrupt(void)
7070
{
71-
uint8_t c = pc.getc();
71+
uint8_t c;
72+
pc.read(&c, 1);
7273
rx_buffer.push(c);
7374
if (main_thread != NULL) {
7475
osThreadFlagsSet(main_thread, 1);

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ typedef Port<1, AnalogoutMaps, DefaultFormFactor, TF1> AnalogoutPort;
540540

541541
#if DEVICE_SERIAL
542542
#if DEVICE_SERIAL_FC
543+
#include "hal/serial_api.h"
543544
struct UARTMaps {
544545
static const PinMap *maps[];
545546
static const char *const pin_type_names[];

drivers/RawSerial.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#include <cstdarg>
2828

2929
namespace mbed {
30-
/** \defgroup drivers-public-api-uart UART
31-
* \ingroup drivers-public-api
32-
*/
3330

3431
/**
3532
* \defgroup drivers_RawSerial RawSerial class

drivers/UnbufferedSerial.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131

3232
namespace mbed {
33+
/** \defgroup drivers-public-api-uart UART
34+
* \ingroup drivers-public-api
35+
*/
3336

3437
/**
3538
* \defgroup drivers_UnbufferedSerial UnbufferedSerial class
@@ -152,6 +155,12 @@ class UnbufferedSerial:
152155
*/
153156
virtual short poll(short events) const;
154157

158+
using SerialBase::readable;
159+
using SerialBase::writeable;
160+
using SerialBase::format;
161+
using SerialBase::attach;
162+
using SerialBase::baud;
163+
155164
#if DEVICE_SERIAL_FC
156165
// For now use the base enum - but in future we may have extra options
157166
// such as XON/XOFF or manual GPIO RTSCTS.

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/H4TransportDriver.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ uint16_t H4TransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
5353
while (i < len + 1) {
5454
uint8_t to_write = i == 0 ? type : pData[i - 1];
5555
while (uart.writeable() == 0);
56-
uart.putc(to_write);
56+
uart.write(&to_write, 1);
5757
++i;
5858
}
5959
return len;
@@ -62,8 +62,10 @@ uint16_t H4TransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
6262
void H4TransportDriver::on_controller_irq()
6363
{
6464
while (uart.readable()) {
65-
uint8_t char_received = uart.getc();
66-
on_data_received(&char_received, 1);
65+
uint8_t char_received;
66+
if (uart.read(&char_received, 1)) {
67+
on_data_received(&char_received, 1);
68+
}
6769
}
6870
}
6971

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/H4TransportDriver.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ class H4TransportDriver : public CordioHCITransportDriver {
6969
private:
7070
void on_controller_irq();
7171

72-
// Use RawSerial as opposed to Serial as we don't require the locking primitives
73-
// provided by the Serial class (access to the UART should be exclusive to this driver)
74-
// Furthermore, we access the peripheral in interrupt context which would clash
75-
// with Serial's locking facilities
76-
RawSerial uart;
72+
// Use UnbufferedSerial as we don't require locking primitives.
73+
// We access the peripheral in interrupt context.
74+
UnbufferedSerial uart;
7775
PinName cts;
7876
PinName rts;
7977
};

0 commit comments

Comments
 (0)