diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index 2a66ebd..c24efc4 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -128,7 +128,6 @@ ) add_subdirectory(connectivity) -add_subdirectory(drivers) add_subdirectory(events) add_subdirectory(hal) add_subdirectory(platform) diff --git a/UNITTESTS/stubs/drivers/BufferedSerial_stub.cpp b/UNITTESTS/stubs/drivers/BufferedSerial_stub.cpp deleted file mode 100644 index 54d0730..0000000 --- a/UNITTESTS/stubs/drivers/BufferedSerial_stub.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "drivers/BufferedSerial.h" - -namespace mbed { - - -BufferedSerial::BufferedSerial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud) -{ -} - -BufferedSerial::~BufferedSerial() -{ -} - -ssize_t BufferedSerial::read(void *buffer, size_t length) -{ - return 0; -} - -ssize_t BufferedSerial::write(const void *buffer, size_t length) -{ - return 0; -} - -off_t BufferedSerial::seek(off_t offset, int whence) -{ - return -ESPIPE; -} - -int BufferedSerial::close() -{ - return 0; -} - -void BufferedSerial::dcd_irq() -{ -} - -void BufferedSerial::set_baud(int baud) -{ -} - -void BufferedSerial::set_data_carrier_detect(PinName dcd_pin, bool active_high) -{ -} - -void BufferedSerial::set_format(int bits, Parity parity, int stop_bits) -{ -} - -int BufferedSerial::isatty() -{ - return 1; -} - -int BufferedSerial::sync() -{ - return 0; -} - -void BufferedSerial::sigio(Callback func) -{ -} - -ssize_t BufferedSerial::write_unbuffered(const char *buf_ptr, size_t length) -{ - return 0; -} - -bool BufferedSerial::hup() const -{ - return false; -} - -void BufferedSerial::wake() -{ -} - -short BufferedSerial::poll(short events) const -{ - return 0; -} - -void BufferedSerial::api_lock(void) -{ -} - -void BufferedSerial::api_unlock(void) -{ -} - -void BufferedSerial::rx_irq(void) -{ -} - -void BufferedSerial::tx_irq(void) -{ -} - -int BufferedSerial::enable_input(bool enabled) -{ - return 0; -} - -int BufferedSerial::enable_output(bool enabled) -{ - return 0; -} - -#if DEVICE_SERIAL_FC -void BufferedSerial::set_flow_control(mbed::SerialBase::Flow, PinName, PinName) -{ - -} -#endif - -} diff --git a/UNITTESTS/stubs/drivers/CMakeLists.txt b/UNITTESTS/stubs/drivers/CMakeLists.txt deleted file mode 100644 index 139fa28..0000000 --- a/UNITTESTS/stubs/drivers/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2021 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -add_library(mbed-stubs-drivers) - -target_sources(mbed-stubs-drivers - PRIVATE - BufferedSerial_stub.cpp - SerialBase_stub.cpp -) - -target_compile_definitions(mbed-stubs-drivers - PRIVATE - DEVICE_SERIAL=1 - DEVICE_INTERRUPTIN=1 - MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -) - -target_link_libraries(mbed-stubs-drivers - PRIVATE - mbed-headers - mbed-stubs-headers -) diff --git a/UNITTESTS/stubs/drivers/SerialBase_stub.cpp b/UNITTESTS/stubs/drivers/SerialBase_stub.cpp deleted file mode 100644 index 67c31d9..0000000 --- a/UNITTESTS/stubs/drivers/SerialBase_stub.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2017, Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "drivers/SerialBase.h" - -namespace mbed { - -SerialBase::SerialBase(PinName tx, PinName rx, int baud) : - _tx_pin(tx), _rx_pin(rx) -{ -} - -SerialBase::~SerialBase() -{ - -} - -void SerialBase::baud(int baudrate) -{ -} - -void SerialBase::format(int bits, Parity parity, int stop_bits) -{ -} - -int SerialBase::readable() -{ - return 0; -} - - -int SerialBase::writeable() -{ - return 0; -} - -void SerialBase::attach(Callback func, IrqType type) -{ -} - -void SerialBase::_irq_handler(uint32_t id, SerialIrq irq_type) -{ -} - -int SerialBase::_base_getc() -{ - return 0; -} - -int SerialBase::_base_putc(int c) -{ - return 0; -} - -void SerialBase::send_break() -{ -} - -void SerialBase::lock() -{ -} - -void SerialBase:: unlock() -{ -} - -} diff --git a/drivers/tests/UNITTESTS/CMakeLists.txt b/drivers/tests/UNITTESTS/CMakeLists.txt index b04c7f0..f417001 100644 --- a/drivers/tests/UNITTESTS/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright (c) 2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 - +add_subdirectory(doubles) add_subdirectory(PwmOut) add_subdirectory(Watchdog) diff --git a/drivers/tests/UNITTESTS/doubles/BufferedSerial_stub.cpp b/drivers/tests/UNITTESTS/doubles/BufferedSerial_stub.cpp new file mode 100644 index 0000000..54d0730 --- /dev/null +++ b/drivers/tests/UNITTESTS/doubles/BufferedSerial_stub.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2018, Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "drivers/BufferedSerial.h" + +namespace mbed { + + +BufferedSerial::BufferedSerial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud) +{ +} + +BufferedSerial::~BufferedSerial() +{ +} + +ssize_t BufferedSerial::read(void *buffer, size_t length) +{ + return 0; +} + +ssize_t BufferedSerial::write(const void *buffer, size_t length) +{ + return 0; +} + +off_t BufferedSerial::seek(off_t offset, int whence) +{ + return -ESPIPE; +} + +int BufferedSerial::close() +{ + return 0; +} + +void BufferedSerial::dcd_irq() +{ +} + +void BufferedSerial::set_baud(int baud) +{ +} + +void BufferedSerial::set_data_carrier_detect(PinName dcd_pin, bool active_high) +{ +} + +void BufferedSerial::set_format(int bits, Parity parity, int stop_bits) +{ +} + +int BufferedSerial::isatty() +{ + return 1; +} + +int BufferedSerial::sync() +{ + return 0; +} + +void BufferedSerial::sigio(Callback func) +{ +} + +ssize_t BufferedSerial::write_unbuffered(const char *buf_ptr, size_t length) +{ + return 0; +} + +bool BufferedSerial::hup() const +{ + return false; +} + +void BufferedSerial::wake() +{ +} + +short BufferedSerial::poll(short events) const +{ + return 0; +} + +void BufferedSerial::api_lock(void) +{ +} + +void BufferedSerial::api_unlock(void) +{ +} + +void BufferedSerial::rx_irq(void) +{ +} + +void BufferedSerial::tx_irq(void) +{ +} + +int BufferedSerial::enable_input(bool enabled) +{ + return 0; +} + +int BufferedSerial::enable_output(bool enabled) +{ + return 0; +} + +#if DEVICE_SERIAL_FC +void BufferedSerial::set_flow_control(mbed::SerialBase::Flow, PinName, PinName) +{ + +} +#endif + +} diff --git a/drivers/tests/UNITTESTS/doubles/CMakeLists.txt b/drivers/tests/UNITTESTS/doubles/CMakeLists.txt new file mode 100644 index 0000000..139fa28 --- /dev/null +++ b/drivers/tests/UNITTESTS/doubles/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-drivers) + +target_sources(mbed-stubs-drivers + PRIVATE + BufferedSerial_stub.cpp + SerialBase_stub.cpp +) + +target_compile_definitions(mbed-stubs-drivers + PRIVATE + DEVICE_SERIAL=1 + DEVICE_INTERRUPTIN=1 + MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 +) + +target_link_libraries(mbed-stubs-drivers + PRIVATE + mbed-headers + mbed-stubs-headers +) diff --git a/drivers/tests/UNITTESTS/doubles/SerialBase_stub.cpp b/drivers/tests/UNITTESTS/doubles/SerialBase_stub.cpp new file mode 100644 index 0000000..67c31d9 --- /dev/null +++ b/drivers/tests/UNITTESTS/doubles/SerialBase_stub.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2017, Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "drivers/SerialBase.h" + +namespace mbed { + +SerialBase::SerialBase(PinName tx, PinName rx, int baud) : + _tx_pin(tx), _rx_pin(rx) +{ +} + +SerialBase::~SerialBase() +{ + +} + +void SerialBase::baud(int baudrate) +{ +} + +void SerialBase::format(int bits, Parity parity, int stop_bits) +{ +} + +int SerialBase::readable() +{ + return 0; +} + + +int SerialBase::writeable() +{ + return 0; +} + +void SerialBase::attach(Callback func, IrqType type) +{ +} + +void SerialBase::_irq_handler(uint32_t id, SerialIrq irq_type) +{ +} + +int SerialBase::_base_getc() +{ + return 0; +} + +int SerialBase::_base_putc(int c) +{ + return 0; +} + +void SerialBase::send_break() +{ +} + +void SerialBase::lock() +{ +} + +void SerialBase:: unlock() +{ +} + +}