-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hardware sync capability to SerialBase #14600
Closed
Closed
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
8d63828
Add serial_tx_empty API
pennam 069c030
serial_tx_empty TARGET_Ambiq_Micro/TARGET_Apollo3
pennam 970bb55
serial_tx_empty TARGET_Analog_Devices/TARGET_ADUCM302X/
pennam 255b4bc
serial_tx_empty TARGET_Analog_Devices/TARGET_ADUCM4X50
pennam ef1fa49
serial_tx_empty Target_Freescale TARGET_KL25Z
pennam 1bf5396
serial_tx_empty Target_Freescale TARGET_KL46Z
pennam 0b65964
serial_tx_empty TARGET_Freescale TARGET_K66F
pennam 0ac64d3
serial_tx_empty TARGET_Freescale TARGET_K82F
pennam db32e05
serial_tx_empty TARGET_Freescale TARGET_KL43Z
pennam 4a413c2
serial_tx_empty TARGET_Freescale TARGET_KW41Z
pennam 5ae1c35
serial_tx_empty TARGET_Freescale TARGET_MCU_K22F
pennam b669dc9
serial_tx_empty TARGET_Freescale TARGET_MCU_K64F
pennam f67116c
serial_tx_empty TARGET_GigaDevice/TARGET_GD32F30X
pennam 4c9a34b
serial_tx_empty TARGET_GigaDevice/TARGET_GD32F4XX
pennam 2bc6b86
serial_tx_empty TARGET_Maxim/TARGET_MAX32620C
pennam f755ad3
serial_tx_empty TARGET_Maxim/TARGET_MAX32625
pennam 77501b3
serial_tx_empty TARGET_Maxim/TARGET_MAX32630
pennam f0b25da
serial_tx_empty TARGET_NUVOTON/TARGET_M251
pennam ee0945a
serial_tx_empty TARGET_NUVOTON/TARGET_M261
pennam 8a3bb5a
serial_tx_empty TARGET_NUVOTON/TARGET_M451
pennam 004fb7f
serial_tx_empty TARGET_NUVOTON/TARGET_M480
pennam c0a4c66
serial_tx_empty TARGET_NUVOTON/TARGET_NANO100
pennam 9f0ea60
serial_tx_empty TARGET_NUVOTON/TARGET_NUC472
pennam 3593d37
serial_tx_empty TARGET_RENESAS/TARGET_RZ_A1XX
pennam 8d4353a
serial_tx_empty TARGET_RENESAS/TARGET_RZ_A2XX
pennam 7e0a4c7
serial_tx_empty TARGET_NRF5x/TARGET_NRF52
pennam fe43bca
serial_tx_empty TARGET_Cypress/TARGET_PSOC6
pennam db359b6
serial_tx_empty TARGET_STM
pennam c82bbef
serial_tx_empty TARGET_NXP/TARGET_LPC11XX_11CXX
pennam 1da87c2
serial_tx_empty TARGET_NXP/TARGET_LPC176X
pennam 3670bb0
serial_tx_empty TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC
pennam f8da4c6
serial_tx_empty TARGET_Samsung/TARGET_SIDK_S1SBP6A
pennam 465218f
serial_tx_empty TARGET_Silicon_Labs/TARGET_EFM32
pennam f675e51
serial_tx_empty TARGET_TOSHIBA/TARGET_TMPM46B
pennam 4845616
serial_tx_empty TARGET_TOSHIBA/TARGET_TMPM4G9
pennam 08f7853
serial_tx_empty TARGET_ARM_SSG/TARGET_MUSCA_B1
pennam 5245c1c
serial_tx_empty TARGET_ARM_SSG/TARGET_MUSCA_S1
pennam 4c17121
serial_tx_empty TARGET_Samsung/TARGET_SIDK_S5JS100
pennam 2c491f6
UartBase hardware sync
pennam fa10ae3
SerialBase fixes and timeout implementation
pennam 45bac9e
Use sleep_for instead of wait_us
pennam 4e52fb1
Don't use software timeout if _flow_type == CTS or _flow_type == RTSCTS
pennam 84eb205
Fix UART_IS_TX_EMPTY TARGET_NUVOTON/TARGET_M251/
pennam 9d2236e
Fix UART_IS_TX_EMPTY TARGET_NUVOTON/TARGET_M261/
pennam 55243ec
Fix UART_IS_TX_EMPTY TARGET_NUVOTON/TARGET_M451/
pennam 5cd61f2
Fix UART_IS_TX_EMPTY TARGET_NUVOTON/TARGET_M480/
pennam 1c5f33f
Fix UART_IS_TX_EMPTY TARGET_NUVOTON/TARGET_NANO100/
pennam 6cd7063
Fix UART_IS_TX_EMPTY TARGET_NUVOTON/TARGET_NUC472/
pennam 66ecb29
Fix keep char time allowance in Chrono domain
pennam 3b7c94c
serial_tx_empty TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050
pennam 5aece6b
serial_tx_empty TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1170
pennam bdb44e2
Use explicit paths for mbed_chrono and ThisThread
pennam 9141701
Update serial_tx_empty() function description
pennam 6f6b665
Update FileHandle sync() function description
pennam bf8aa3c
Update SerialBase sync() function description
pennam 97994e3
Increase char_time_allowance maximum counter value because CY8CPROTO_…
pennam 2a15da2
Add testcase to check SerialBase sync capability
pennam b063b41
Update uart fpga common tests to check also for serial_tx_empty()
pennam b99ff36
Round up packet transmission time to avoid test failures caused by 1u…
pennam ac2f4ff
Fix build for TARGET_EFM32GG
pennam dfa17d1
Fix build for EV_COG_AD3029LZ
pennam 5f8a564
Fix build for MIMXRT1050_EVK
pennam a566490
Fix build for MIMXRT1170_EVK
pennam b5c1eef
Fix build for S5JS100
pennam 2b00cf6
Add implementation for TARGET_FVP_MPS2, TARGET_CM3DS_MPS2 and TARGET_…
pennam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
drivers/tests/TESTS/mbed_drivers/sync_serial/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) 2020 ARM Limited. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) | ||
|
||
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../.. CACHE INTERNAL "") | ||
set(TEST_TARGET mbed-drivers-sync-serial) | ||
|
||
include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) | ||
|
||
project(${TEST_TARGET}) | ||
|
||
mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright (c) 2019 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. | ||
*/ | ||
#if !DEVICE_SERIAL | ||
#error [NOT_SUPPORTED] serial communication not supported for this target | ||
#else | ||
|
||
#include "mbed.h" | ||
#include "utest/utest.h" | ||
#include "unity/unity.h" | ||
#include "greentea-client/test_env.h" | ||
#include "platform/FileHandle.h" | ||
#include "drivers/BufferedSerial.h" | ||
|
||
|
||
using namespace utest::v1; | ||
|
||
|
||
/** | ||
* Macros for setting console flow control. | ||
*/ | ||
#define CONSOLE_FLOWCONTROL_RTS 1 | ||
#define CONSOLE_FLOWCONTROL_CTS 2 | ||
#define CONSOLE_FLOWCONTROL_RTSCTS 3 | ||
#define mbed_console_concat_(x) CONSOLE_FLOWCONTROL_##x | ||
#define mbed_console_concat(x) mbed_console_concat_(x) | ||
#define CONSOLE_FLOWCONTROL mbed_console_concat(MBED_CONF_TARGET_CONSOLE_UART_FLOW_CONTROL) | ||
|
||
|
||
#define MSG_KEY_SYNC_MESSAGE "sync_message" | ||
#define MSG_VALUE_HELLO_WORLD "Hello, world!" | ||
|
||
|
||
#define EXPECTED_SYNCED_STRING "{{" MSG_KEY_SYNC_MESSAGE ";" MSG_VALUE_HELLO_WORLD "}}" | ||
// The target is expected to transmit Greentea messages with \n (or \r\n) or they are not detected by the host | ||
#define SYNC_STRING_TO_SEND EXPECTED_SYNCED_STRING "\n" | ||
|
||
|
||
static BufferedSerial buffered_serial_obj( | ||
CONSOLE_TX, CONSOLE_RX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE | ||
); | ||
|
||
|
||
FileHandle *mbed::mbed_override_console(int fd) | ||
{ | ||
return &buffered_serial_obj; | ||
} | ||
|
||
|
||
static void test_serial_sync() | ||
{ | ||
char tx_msg[] = SYNC_STRING_TO_SEND; | ||
|
||
TEST_ASSERT_EQUAL_UINT( | ||
strlen(tx_msg) + 1, | ||
buffered_serial_obj.write(tx_msg, strlen(tx_msg) + 1) | ||
); | ||
|
||
// Wait the message is completely sent to the bus | ||
buffered_serial_obj.sync(); | ||
system_reset(); | ||
TEST_ASSERT_MESSAGE(0, "The device did not reset as expected."); | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS | ||
buffered_serial_obj.set_flow_control( | ||
SerialBase::RTS, STDIO_UART_RTS, NC | ||
); | ||
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_CTS | ||
buffered_serial_obj.set_flow_control( | ||
SerialBase::CTS, NC, STDIO_UART_CTS | ||
); | ||
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTSCTS | ||
buffered_serial_obj.set_flow_control( | ||
SerialBase::RTSCTS, STDIO_UART_RTS, STDIO_UART_CTS | ||
); | ||
#endif | ||
GREENTEA_SETUP(12, "serial_comms"); | ||
test_serial_sync(); // The result of this test suite is reported by the host side. | ||
GREENTEA_TESTSUITE_RESULT(0); // Fail on any error. | ||
} | ||
|
||
#endif // !DEVICE_SERIAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call this function
flush
to better explain what it does?A
sync
function could have different meaning, typically ensuring that buffered data is written to the physical device.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case the description is misleading, the goal of this function is to ensure that all data stored in the tx FIFO or TX register is written to the serial bus. I'll update the description to avoid misunderstandings. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The misleading description was inherited from
FileHandle.h
, which uses the same wording. Could you fix that at the same time?The intent is to perform the same function as POSIX
fsync
for files, and we extend that to the serial port. (Apparently POSIX has a separatetcdrain
call which does that, andfsync
doesn't, but we reusefsync
for simplicity,)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updatede the functions description here 6f6b665 and here bf8bf69. i hope i've got the correct one.