Commit Graph

761 Commits (master)

Author SHA1 Message Date
cyliang tw 126d767a59 Avoid USBCDC send_nb break the continuation use case 2023-12-13 13:53:27 +08:00
Chris Liang c30af6a7df To judge send ZLP or not in USBCDC::AsyncWrite 2023-12-08 19:39:16 +08:00
Chris Liang ca616c865a
Move "send ZLP write start" after last alignment packet sent 2023-12-05 19:31:17 +08:00
Chris Liang e2aed1824c
Update USBCDC.cpp to fulfill A style 2023-12-01 20:43:12 +08:00
Chris Liang 1cccc7e14d
Update USBCDC.cpp to support ZLP 2023-12-01 20:22:47 +08:00
Chris Liang 794ee9704f
Update USBCDC.h to support ZLP 2023-12-01 20:17:06 +08:00
George Hilliard 4b07fc63f3 drivers/usb: Add missing dependency on mbed-events
The compiler complained:

    In file included from .../mbed-os/drivers/usb/source/USBCDC_ECM.cpp:19:
    .../mbed-os/drivers/usb/include/usb/USBCDC_ECM.h:27:10: fatal error: events/EventQueue.h: No such file or directory
       27 | #include "events/EventQueue.h"
          |          ^~~~~~~~~~~~~~~~~~~~~
2023-05-01 09:02:50 -05:00
Mingjie Shen 4c3928ecf4 Avoid calling virtual functions from constructors and destructors
Virtual functions are resolved statically (not dynamically) in
constructors and destructors for the same class. The call should be made
explicitly static by qualifying it using the scope resolution operator.
2023-04-18 23:18:27 -04:00
Martin Kojtal 518eb6d1c3 CAN: read only up to 8 bytes
If HAL implementation writes more than 8 bytes of data, error immediately.
CANMessage defines only 8 bytes of data, lenght cannot be > 8.

This fixes https://github.com/ARMmbed/mbed-os/issues/15361

Signed-off-by: Martin Kojtal <martin.kojtal@arm.com>
2023-01-16 15:44:09 +00:00
yutotnh 0992a6cc11
fix: typo in PwmOut.h (pulsewith -> pulsewidth) 2022-06-25 08:21:51 +09:00
yutotnh 236194f7c3
add: PwmOut::read_pulsewitdth_us() for compatibility 2022-06-23 21:59:03 +09:00
yutotnh 6a4ba443ea
rename: read_pulsewitdth_us to read_pulsewidth_us 2022-06-21 23:25:43 +09:00
Hari Limaye f4e5359710 GPIO: Use uintptr_t for gpio_irq_api context
The HAL gpio_irq_api stores object IDs, which serve as a form of context
for the dispatch of the interrupt handler in the drivers level
InterruptIn Class. The way this is achieved is that the InterruptIn
Class casts its address to uint32_t, which is stored as the ID.
This results in compilation failure when the size of an object pointer
is greater than uint32_t, for example when building on a PC for unit
testing.

In order to allow Unit Testing of the InterruptIn Class, we replace the
use of uint32_t with uintptr_t (type capable of holding a pointer),
which allows portability and expresses intentions more clearly.
In aid of this latter goal, we also replace the use of the name "id"
with "context", to improve clarity - these are addresses of the context
related to that callback.
2022-01-26 18:12:52 +00:00
Martin Kojtal 0a3b16868f InterruptIn: add note about enabling interrupts in rise/fall
Fixes #8188
Make it obvious, only calling rise/fall methods, IRQ are active. Nothing more needed.
2021-10-21 14:55:37 +01:00
Hari Limaye b493a15a53 CAN: Use uintptr_t for can_irq_ids
The HAL can_api stores an array of IDs in order to dispatch interrupts
to the correct CAN object. The drivers level CAN Class casts a pointer
to itself to an uint32_t, which is stored as the ID and then cast back
to a CAN * in order to call the correct handler. This results in
compilation failure when the size of an object pointer is greater than
uint32_t, for example when building on a PC for unit testing.

In order to allow Unit Testing of the CAN Class, we replace the use of
uint32_t with uintptr_t (type capable of holding a pointer), which
allows portability and expresses intentions more clearly. In aid of this
latter goal, we also replace the use of the name "id" with "context",
to improve clarity. These are addresses of the context related to that
callback.
2021-09-17 13:36:43 +01:00
Lingkai Dong e04a16fd9f QSPI: Move destructor into source file
This allows the entire QSPI class to be mocked/faked for unit testing
purpose, without dependencies from the real implementation such as
`qspi_free()` from the HAL.
2021-09-10 09:46:02 +01:00
Lingkai Dong 7a8ff5f115 drivers: Add missing OSPI.cpp to CMakeLists.txt 2021-09-10 09:45:11 +01:00
Martin Kojtal acbf352d13
Merge pull request #14993 from hazzlim/unit_test_support
Add boilerplate unit test code to currently untested modules
2021-08-17 10:20:51 +01:00
Hari Limaye c6312a3c70 Unit tests: Add boilerplate code for AnalogIn.cpp
In pursuit of increasing unit test coverage of Mbed OS, we add the
boilerplate code for unit testing of AnalogIn.cpp and an empty test
source file. This serves two purposes - it allows us to report on
currently untested sources in code coverage data, and it makes it a
little easier for developers to write unit tests for these sources.

The 'empty' test file contains a main function that simply returns. This
is required to allow CMake's add_executable() to be used to pull in the
source file for the SUT, which ensures that this source file is built
and therefore instrumented to generate coverage data. The alternative
that was explored was to instead use Google Test's TEST() macro and
prefix the test name with 'DISABLED_' to skip it, but that resulted in
the test being reported as skipped, which was deemed undesireable for
these 'empty' tests.
2021-08-16 10:13:11 +01:00
Ladislas de Toldi e1de484471
Add missing include for PinNames.h 2021-08-13 18:07:13 +02:00
Lingkai Dong d7ef8f857f CMake: greentea: Add skip reason to ticker test 2021-08-11 11:43:17 +01:00
Robert Walton 40154ee2b1 CMake: greentea: Port mbed-drivers-ticker to CTest
Call add_test in mbed_greentea_add_test and specify mbedhtrun as the
command to run.

An MBED_HTRUN_ARGUMENTS variable has been added, which is a semicolon
separated list of arguments to forward to htrun. The user is required to
pass in any arguments mbedhtrun needs to communicate with the device
under test at CMake configuration time.

We automate passing some of the htrun arguments in CMake using data
provided by mbed_config.cmake or gathered from the CMake environment.
The following arguments are passed to htrun from CMake:

* -f/--image-path
* -e/--enum-host-tests
* -m/--micro
* -R/--reset-timeout

--baud-rate is also passed if the MBED_CONF_PLATFORM_STDIO_BAUD_RATE
config parameter is defined.

Temporary checks have been added to mbed_greentea_add_test to keep the
old flow working until we port all of the greentea tests to CTest. These
checks should be removed after we make all greentea tests runnable by
CTest.
2021-08-10 16:54:03 +01:00
Robert Walton 7842320ab7 CMake: Add option to enable greentea tests
Add an option to enable the greentea tests independently from the unit
tests.

We can't just use the typical BUILD_TESTING option to enable greentea
tests. BUILD_TESTING enables unit tests and fetches googletest, which
are compiled for the host. Greentea tests are cross compiled and require
a toolchain file. For this reason we add a new option just to enable
greentea tests, preventing build failures triggered by the unit tests
and googletest.
2021-08-10 16:35:11 +01:00
Lingkai Dong dca2aa79a0 Unit tests: Remove redundant CMake target mbed-headers-base
Individual libraries' `target_h` stub headers have now all been moved
from `mbed-headers-base` to `mbed-headers-<library>`.

Note: Even though headers previously in `target_h` are technically
stubs/fakes too, they are used by not only unit tests but also regular
libraries when compiled for unit tests, because no target-specific HAL
implementation exists in this case. In order for regular library
sources to pick up `target_h` headers, those headers must

* have the same names as regular headers
* appear first in include paths

This is why those headers are part of `mbed-headers-<library>` and not
`mbed-stubs-<library>`. Before this refactoring, `mbed-headers-base`
was the first in unit tests' include paths.
2021-08-02 17:42:43 +01:00
Lingkai Dong e75a45d041 Unit tests: Move drivers target_h stubs 2021-08-02 17:42:43 +01:00
Martin Kojtal 3318720ada
Merge pull request #14941 from hazzlim/update-tests-to-use-chrono
Update references to time values to use chrono
2021-07-30 12:02:10 +01:00
harmut01 86c2d70a5b Greentea: Remove deprecated APIs and use chrono
References to time should do so using std::chrono. We reworked tests in
connectivity and drivers to use std::chrono and new APIs in order to
remove deprecation warnings resulting from deprecated API calls.
This required addition of  a macro for test assertions using std::chrono
values.

As host test "timing_drift_auto" expects time values represented as an
integral number of microseconds, we explicitly provide this in place
using "microseconds{TICKER_TIME}.count()" in the relevant ticker tests.
We recognise this is ugly, but thought it best to descriptively convert
from std::chrono to the host test's required representation.

Co-authored-by: Hari Limaye <hari.limaye@arm.com>
2021-07-29 14:06:27 +01:00
Robert Walton a09d08917b CMake: unittests: Show all tests in CTest report
Previously a test executable was recognised as a single test by CTest.
However, test executables usually contain multiple test cases, the
results of the test cases should be individually reported. With our
previous setup we could miss test case failures that didn't cause the
executable to return an error code.

This commit uses gtest_discover_test to discover all test cases in a
test executable. This enables CTest to match test passes and failures
from the googletest binary output.
2021-07-27 21:09:39 +01:00
Robert Walton 1e48a61d89 CMake: unittests: Remove trailing whitespace 2021-07-27 21:09:38 +01:00
Hari Limaye bfe24ce64d Greentea: Remove unused variable from ticker test
Ticker test contains definition of variable total_ticks, which is unused
in the file since removal of function wait_and_print() in commit
aaa15bcf58
2021-07-21 12:21:58 +01:00
Martin Kojtal a07ec0bfeb
Merge pull request #14805 from rkotan/I2C_Multiple_Buses_fix
i2c: fix issue #14735 with multiple buses
2021-07-20 09:44:59 +02:00
Martin Kojtal 7095dc79fa
Merge pull request #14688 from MubeenHCLite/CAN_rxinterrupt_fix
Solution for mutex problem in CAN read ISR
2021-07-12 17:21:56 +02:00
Mohammed Mubeen d477efe780 Corrected the conditional compilation of RawCAN. 2021-07-09 11:34:25 +05:30
Martin Kojtal e145ae3acd
Merge pull request #14881 from jeromecoutant/PR_LED1
Standard Pin Name: LED1 issue for targets without LED
2021-07-07 17:53:44 +02:00
Mohammed Mubeen 27df8c74d3 Indentation set for the comments 2021-07-07 10:32:09 +05:30
Lingkai Dong 9b8acca136 Remove `#ifdef UNITTEST` from MbedCRC.h
Production code should not contain any test-specific checks. Rather
than checking `UNITTEST`, MbedCRC.h can simply include in all cases
<mstd_type_traits> whose unit test stub exists.

Also remove the `UNITTEST` macro from CMake definitions of kvstore
unit tests which depend on MbedCRC.h.
2021-07-06 17:29:15 +01:00
jeromecoutant d9204d06eb generic_tests update for targets without LED1 2021-07-06 17:13:45 +02:00
Mohammed Mubeen 65a72c29c8 Added documentation for the implementation 2021-07-06 20:12:12 +05:30
Mohammed Mubeen ff01046385 Spell check corrected 2021-07-03 15:10:10 +05:30
Mohammed Mubeen 8622f66b46 Resolved review comments 2021-07-03 13:22:25 +05:30
Mohammed Mubeen d4eba5c0a7 Resolving the astyle error 2021-06-30 18:01:04 +05:30
Mohammed Mubeen debfda67f2 Updated the Licenses for RawCAN and aligned indentation 2021-06-30 17:40:32 +05:30
Mohammed Mubeen 7a4a4ea30d Added a newline at the end of RawCAN.cpp 2021-06-30 10:33:24 +05:30
Mohammed Mubeen 3565ae3b3b Removed the new line at the end of file. 2021-06-30 07:37:08 +05:30
Jaeden Amero 472c688a83
Merge pull request #14828 from hazzlim/add-cmake-supports-psa-tests
CMake: Add CMake to mbed-psa greentea tests
2021-06-29 15:17:01 +01:00
Mohammed Mubeen 5d861f895d
Merge branch 'master' into CAN_rxinterrupt_fix 2021-06-29 18:32:48 +05:30
Hari Limaye f95052cf6f CMake: Require TEST_SOURCES in greentea CMake file
Assumption that greentea test file is always named main.cpp is
incorrect. Updated mbed_greentea_add_test() macro to make TEST_SOURCES
parameter compulsory, which is used to specify greentea test
file(s). This allows tests to use C, or have a different name.
Therefore also updated all pre-existing greentea test CMake files to
explicity add main.cpp to TEST_SOURCES.
2021-06-29 13:33:42 +01:00
Mohammed Mubeen 1a2d624828 Added Raw CAN (unlocked can read api) and updated the code for the
rxInterrupt to work for all CAN instances
2021-06-29 12:46:21 +05:30
Martin Kojtal 9244625508
Merge pull request #14786 from ARMmbed/move_drivers_stub
Move mbed-stubs-drivers to the drivers directory
2021-06-24 15:43:37 +02:00
Rajkumar Kanagaraj e64d1c7605 CMake: unit-tests: Make drivers stub only depend on headers it uses
Previously the drivers stub library depended on `mbed-headers`, which
is a collection of all available headers in mbed-os. To make it easier
to separate the library, only depend on the headers we're using.
2021-06-22 04:32:17 -07:00