From f4b986dc1bcba6e738f7a35961b2cb2938ef6e3e Mon Sep 17 00:00:00 2001 From: Evelyne Donnaes Date: Wed, 19 Jun 2019 11:26:07 +0100 Subject: [PATCH 01/35] RTOS public apis (#1) * Moved source files and internal headers to internal/ * Added doxygen commands --- .../source/NanostackRfPhyAtmel.cpp | 1 + .../source/NanostackRfPhyMcr20a.cpp | 1 + .../source/NanostackRfPhys2lp.cpp | 1 + rtos/ConditionVariable.h | 13 ++++--- rtos/EventFlags.h | 3 +- rtos/Kernel.h | 6 ++-- rtos/Mail.h | 4 +-- rtos/MemoryPool.h | 6 +++- rtos/Mutex.h | 3 +- rtos/Queue.h | 5 +-- rtos/RtosTimer.h | 3 +- rtos/Semaphore.h | 3 +- rtos/TARGET_CORTEX/SysTimer.h | 10 +++--- rtos/TARGET_CORTEX/mbed_boot.h | 5 +++ rtos/TARGET_CORTEX/mbed_rtos_storage.h | 35 +++++++++++++------ rtos/TARGET_CORTEX/mbed_rtx_handlers.c | 4 +-- rtos/TARGET_CORTEX/mbed_rtx_idle.cpp | 2 +- rtos/ThisThread.h | 11 ++---- rtos/Thread.h | 3 +- rtos/{ => internal}/ConditionVariable.cpp | 4 +-- rtos/{ => internal}/EventFlags.cpp | 4 +-- rtos/{ => internal}/Kernel.cpp | 4 +-- rtos/{ => internal}/Mutex.cpp | 4 +-- rtos/{ => internal}/RtosTimer.cpp | 0 rtos/{ => internal}/Semaphore.cpp | 0 rtos/{ => internal}/ThisThread.cpp | 2 +- rtos/{ => internal}/Thread.cpp | 4 +-- rtos/{ => internal}/rtos_handlers.h | 11 +++--- rtos/{ => internal}/rtos_idle.h | 13 ++++--- rtos/rtos.h | 3 -- 30 files changed, 97 insertions(+), 71 deletions(-) rename rtos/{ => internal}/ConditionVariable.cpp (98%) rename rtos/{ => internal}/EventFlags.cpp (97%) rename rtos/{ => internal}/Kernel.cpp (98%) rename rtos/{ => internal}/Mutex.cpp (98%) rename rtos/{ => internal}/RtosTimer.cpp (100%) rename rtos/{ => internal}/Semaphore.cpp (100%) rename rtos/{ => internal}/ThisThread.cpp (99%) rename rtos/{ => internal}/Thread.cpp (99%) rename rtos/{ => internal}/rtos_handlers.h (95%) rename rtos/{ => internal}/rtos_idle.h (96%) diff --git a/components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp b/components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp index ff6bc0cc108..9dfdf579ed0 100644 --- a/components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp +++ b/components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp @@ -32,6 +32,7 @@ #include "SPI.h" #include "inttypes.h" #include "Timeout.h" +#include "platform/mbed_error.h" #define TRACE_GROUP "AtRF" diff --git a/components/802.15.4_RF/mcr20a-rf-driver/source/NanostackRfPhyMcr20a.cpp b/components/802.15.4_RF/mcr20a-rf-driver/source/NanostackRfPhyMcr20a.cpp index 18801a8ba25..2f70302ce70 100644 --- a/components/802.15.4_RF/mcr20a-rf-driver/source/NanostackRfPhyMcr20a.cpp +++ b/components/802.15.4_RF/mcr20a-rf-driver/source/NanostackRfPhyMcr20a.cpp @@ -23,6 +23,7 @@ #include #include "rtos.h" #include "mbed_interface.h" +#include "platform/mbed_error.h" using namespace mbed; using namespace rtos; diff --git a/components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp b/components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp index 1d88ba052ce..f1e1a4a635e 100644 --- a/components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp +++ b/components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp @@ -29,6 +29,7 @@ #include "Timeout.h" #include "Thread.h" #include "mbed_wait_api.h" +#include "platform/mbed_error.h" using namespace mbed; using namespace rtos; diff --git a/rtos/ConditionVariable.h b/rtos/ConditionVariable.h index 543efc7eb34..ca87123ddef 100644 --- a/rtos/ConditionVariable.h +++ b/rtos/ConditionVariable.h @@ -30,10 +30,15 @@ #include "platform/NonCopyable.h" namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api Public API */ /** @{*/ struct Waiter; +/** + * \defgroup rtos_ConditionVariable ConditionVariable class + * @{ + */ /** The ConditionVariable class is a synchronization primitive that allows * threads to wait until a particular condition occurs. @@ -325,7 +330,7 @@ class ConditionVariable : private mbed::NonCopyable { #endif // !defined(DOXYGEN_ONLY) }; -} -#endif - /** @}*/ +/** @}*/ +} // namespace rtos +#endif diff --git a/rtos/EventFlags.h b/rtos/EventFlags.h index bac58ea5889..bf81d614995 100644 --- a/rtos/EventFlags.h +++ b/rtos/EventFlags.h @@ -30,7 +30,8 @@ #include "platform/NonCopyable.h" namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** * \defgroup rtos_EventFlags EventFlags class diff --git a/rtos/Kernel.h b/rtos/Kernel.h index 851dfb688ed..258896045f3 100644 --- a/rtos/Kernel.h +++ b/rtos/Kernel.h @@ -26,7 +26,8 @@ #include "cmsis_os2.h" namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** Functions in the Kernel namespace control RTOS kernel information. */ @@ -60,7 +61,6 @@ void attach_thread_terminate_hook(void (*fptr)(osThreadId_t id)); } // namespace Kernel +/** @}*/ } // namespace rtos #endif - -/** @}*/ diff --git a/rtos/Mail.h b/rtos/Mail.h index dd105096816..0efa86da4b5 100644 --- a/rtos/Mail.h +++ b/rtos/Mail.h @@ -28,7 +28,6 @@ #include "Queue.h" #include "MemoryPool.h" #include "cmsis_os2.h" -#include "mbed_rtos_storage.h" #include "mbed_rtos1_types.h" #include "platform/mbed_toolchain.h" @@ -39,7 +38,8 @@ using namespace rtos; #endif namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** * \defgroup rtos_Mail Mail class diff --git a/rtos/MemoryPool.h b/rtos/MemoryPool.h index 431b5d6894c..3b55d7c128a 100644 --- a/rtos/MemoryPool.h +++ b/rtos/MemoryPool.h @@ -29,9 +29,13 @@ #include "mbed_rtos1_types.h" #include "mbed_rtos_storage.h" #include "platform/NonCopyable.h" +#include "platform/mbed_assert.h" +#include "Kernel.h" + namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** * \defgroup rtos_MemoryPool MemoryPool class diff --git a/rtos/Mutex.h b/rtos/Mutex.h index a4955a54c66..71d9d9557f0 100644 --- a/rtos/Mutex.h +++ b/rtos/Mutex.h @@ -32,7 +32,8 @@ #include "platform/mbed_toolchain.h" namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ class Mutex; diff --git a/rtos/Queue.h b/rtos/Queue.h index e31fb619d66..408923b1385 100644 --- a/rtos/Queue.h +++ b/rtos/Queue.h @@ -25,11 +25,12 @@ #include "cmsis_os2.h" #include "mbed_rtos1_types.h" #include "mbed_rtos_storage.h" -#include "platform/mbed_error.h" +#include "platform/mbed_assert.h" #include "platform/NonCopyable.h" namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** * \defgroup rtos_Queue Queue class diff --git a/rtos/RtosTimer.h b/rtos/RtosTimer.h index eb976cd0bd4..cc631d8972f 100644 --- a/rtos/RtosTimer.h +++ b/rtos/RtosTimer.h @@ -31,7 +31,8 @@ #include "mbed_rtos1_types.h" namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** * \defgroup rtos_RtosTimer RtosTimer class diff --git a/rtos/Semaphore.h b/rtos/Semaphore.h index 9eaa116d054..c08e2cb20fc 100644 --- a/rtos/Semaphore.h +++ b/rtos/Semaphore.h @@ -30,7 +30,8 @@ #include "platform/NonCopyable.h" namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** * \defgroup rtos_Semaphore Semaphore class diff --git a/rtos/TARGET_CORTEX/SysTimer.h b/rtos/TARGET_CORTEX/SysTimer.h index 653ffbe895a..6561e647010 100644 --- a/rtos/TARGET_CORTEX/SysTimer.h +++ b/rtos/TARGET_CORTEX/SysTimer.h @@ -30,12 +30,11 @@ namespace rtos { namespace internal { +/** \ingroup rtos */ +/** \addtogroup mbed-os-internal */ +/** @{*/ + /** - * @cond RTOS_INTERNAL - * - * @addtogroup rtos - * @{ - * * @defgroup rtos_SysTimer SysTimer class * @{ */ @@ -126,7 +125,6 @@ class SysTimer: private mbed::TimerEvent, private mbed::NonCopyable { /** * @} * @} - * @endcond */ } diff --git a/rtos/TARGET_CORTEX/mbed_boot.h b/rtos/TARGET_CORTEX/mbed_boot.h index 65f7af6fcbe..7ad6e63435a 100644 --- a/rtos/TARGET_CORTEX/mbed_boot.h +++ b/rtos/TARGET_CORTEX/mbed_boot.h @@ -25,6 +25,10 @@ extern "C" { #include "mbed_rtx.h" +/** \ingroup rtos */ +/** \addtogroup mbed-os-internal */ +/** @{*/ + /** * \defgroup boot Boot sequence * Boot sequence overview @@ -158,6 +162,7 @@ void mbed_sdk_init(void); */ void mbed_main(void); +/**@}*/ /**@}*/ #ifdef __cplusplus diff --git a/rtos/TARGET_CORTEX/mbed_rtos_storage.h b/rtos/TARGET_CORTEX/mbed_rtos_storage.h index 2a0338baedf..bc0344585a6 100644 --- a/rtos/TARGET_CORTEX/mbed_rtos_storage.h +++ b/rtos/TARGET_CORTEX/mbed_rtos_storage.h @@ -26,31 +26,48 @@ extern "C" { #endif -/** \addtogroup rtos */ -/** @{*/ +#include "rtx_os.h" +#include "mbed_rtx_conf.h" -/** @brief RTOS primitives storage types for RTX +/** \ingroup rtos */ +/** \addtogroup mbed-os-internal */ +/** @{*/ +/** \defgroup rtos_storage RTOS primitives storage types for RTX Types defined in this file should be utilized, when the direct RTOS C API usage is required, to provide backing memory for internal RTX data. Allocated object should be wrapped in attribute struct and passed to os*New call, for details see CMSIS-RTOS2 documentation. - @note This file breaks abstraction layers and uses RTX internal types, but it limits the contamination to single, RTOS implementation specific, header file, therefore limiting scope of possible changes. - */ - -#include "rtx_os.h" -#include "mbed_rtx_conf.h" + @{ +*/ +/** RTX Mutex storage */ typedef osRtxMutex_t mbed_rtos_storage_mutex_t; + +/** RTX Semaphore storage */ typedef osRtxSemaphore_t mbed_rtos_storage_semaphore_t; + +/** RTX Thread storage */ typedef osRtxThread_t mbed_rtos_storage_thread_t; + +/** RTX Memory Pool storage */ typedef osRtxMemoryPool_t mbed_rtos_storage_mem_pool_t; + +/** RTX Message Queue storage */ typedef osRtxMessageQueue_t mbed_rtos_storage_msg_queue_t; + +/** RTX Event Flags storage */ typedef osRtxEventFlags_t mbed_rtos_storage_event_flags_t; + +/** RTX Message storage */ typedef osRtxMessage_t mbed_rtos_storage_message_t; + +/** RTX Timer storage */ typedef osRtxTimer_t mbed_rtos_storage_timer_t; +/** @}*/ +/** @}*/ #define MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(block_count, block_size) \ osRtxMemoryPoolMemSize(block_count, block_size) @@ -60,5 +77,3 @@ typedef osRtxTimer_t mbed_rtos_storage_timer_t; #endif #endif - -/** @}*/ diff --git a/rtos/TARGET_CORTEX/mbed_rtx_handlers.c b/rtos/TARGET_CORTEX/mbed_rtx_handlers.c index 31ce7f81d70..63b0031d7c2 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_handlers.c +++ b/rtos/TARGET_CORTEX/mbed_rtx_handlers.c @@ -22,8 +22,8 @@ #include "mbed_error.h" #include "mbed_interface.h" #include "RTX_Config.h" -#include "rtos/rtos_handlers.h" -#include "rtos/rtos_idle.h" +#include "rtos/internal/rtos_handlers.h" +#include "rtos/internal/rtos_idle.h" #ifdef RTE_Compiler_EventRecorder #include "EventRecorder.h" // Keil::Compiler:Event Recorder diff --git a/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp b/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp index 7504ac71b95..d0fa77af2be 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp +++ b/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp @@ -20,7 +20,7 @@ * SOFTWARE. */ -#include "rtos/rtos_idle.h" +#include "rtos/internal/rtos_idle.h" #include "platform/mbed_power_mgmt.h" #include "TimerEvent.h" #include "lp_ticker_api.h" diff --git a/rtos/ThisThread.h b/rtos/ThisThread.h index d566fb5397d..f2d5972fbf0 100644 --- a/rtos/ThisThread.h +++ b/rtos/ThisThread.h @@ -24,16 +24,11 @@ #include #include "cmsis_os2.h" -#include "mbed_rtos1_types.h" -#include "mbed_rtos_storage.h" -#include "platform/Callback.h" -#include "platform/mbed_toolchain.h" -#include "platform/NonCopyable.h" -#include "rtos/Semaphore.h" -#include "rtos/Mutex.h" + namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** * \defgroup rtos_ThisThread ThisThread namespace diff --git a/rtos/Thread.h b/rtos/Thread.h index 34da08aa244..eb34f5c5e3f 100644 --- a/rtos/Thread.h +++ b/rtos/Thread.h @@ -33,7 +33,8 @@ #include "rtos/Mutex.h" namespace rtos { -/** \addtogroup rtos */ +/** \ingroup rtos */ +/** \addtogroup mbed-os-api */ /** @{*/ /** * \defgroup rtos_Thread Thread class diff --git a/rtos/ConditionVariable.cpp b/rtos/internal/ConditionVariable.cpp similarity index 98% rename from rtos/ConditionVariable.cpp rename to rtos/internal/ConditionVariable.cpp index cb3bf805a06..dfcf1ce561a 100644 --- a/rtos/ConditionVariable.cpp +++ b/rtos/internal/ConditionVariable.cpp @@ -23,8 +23,8 @@ #include "rtos/Kernel.h" #include "rtos/ThisThread.h" -#include "mbed_error.h" -#include "mbed_assert.h" +#include "platform/mbed_error.h" +#include "platform/mbed_assert.h" namespace rtos { diff --git a/rtos/EventFlags.cpp b/rtos/internal/EventFlags.cpp similarity index 97% rename from rtos/EventFlags.cpp rename to rtos/internal/EventFlags.cpp index 1167d764ac5..128cb6d2ff7 100644 --- a/rtos/EventFlags.cpp +++ b/rtos/internal/EventFlags.cpp @@ -21,8 +21,8 @@ */ #include "rtos/EventFlags.h" #include -#include "mbed_error.h" -#include "mbed_assert.h" +#include "platform/mbed_error.h" +#include "platform/mbed_assert.h" namespace rtos { diff --git a/rtos/Kernel.cpp b/rtos/internal/Kernel.cpp similarity index 98% rename from rtos/Kernel.cpp rename to rtos/internal/Kernel.cpp index a620c0cf1fc..21de1b30b33 100644 --- a/rtos/Kernel.cpp +++ b/rtos/internal/Kernel.cpp @@ -22,8 +22,8 @@ #include "cmsis_os2.h" #include "rtos/Kernel.h" -#include "rtos/rtos_idle.h" -#include "rtos/rtos_handlers.h" +#include "rtos_idle.h" +#include "rtos_handlers.h" #include "platform/mbed_critical.h" namespace rtos { diff --git a/rtos/Mutex.cpp b/rtos/internal/Mutex.cpp similarity index 98% rename from rtos/Mutex.cpp rename to rtos/internal/Mutex.cpp index 24f3085cb9b..83edcb9d3eb 100644 --- a/rtos/Mutex.cpp +++ b/rtos/internal/Mutex.cpp @@ -23,8 +23,8 @@ #include "rtos/Kernel.h" #include -#include "mbed_error.h" -#include "mbed_assert.h" +#include "platform/mbed_error.h" +#include "platform/mbed_assert.h" namespace rtos { diff --git a/rtos/RtosTimer.cpp b/rtos/internal/RtosTimer.cpp similarity index 100% rename from rtos/RtosTimer.cpp rename to rtos/internal/RtosTimer.cpp diff --git a/rtos/Semaphore.cpp b/rtos/internal/Semaphore.cpp similarity index 100% rename from rtos/Semaphore.cpp rename to rtos/internal/Semaphore.cpp diff --git a/rtos/ThisThread.cpp b/rtos/internal/ThisThread.cpp similarity index 99% rename from rtos/ThisThread.cpp rename to rtos/internal/ThisThread.cpp index 0e3b89d4310..23675c5ce23 100644 --- a/rtos/ThisThread.cpp +++ b/rtos/internal/ThisThread.cpp @@ -24,7 +24,7 @@ #include "rtos/ThisThread.h" #include "rtos/Kernel.h" -#include "rtos/rtos_idle.h" +#include "rtos_idle.h" #include "platform/mbed_assert.h" namespace rtos { diff --git a/rtos/Thread.cpp b/rtos/internal/Thread.cpp similarity index 99% rename from rtos/Thread.cpp rename to rtos/internal/Thread.cpp index 40154afe00e..678375a7687 100644 --- a/rtos/Thread.cpp +++ b/rtos/internal/Thread.cpp @@ -21,8 +21,8 @@ */ #include "rtos/Thread.h" #include "rtos/ThisThread.h" -#include "rtos/rtos_idle.h" -#include "rtos/rtos_handlers.h" +#include "rtos_idle.h" +#include "rtos_handlers.h" #include "platform/mbed_assert.h" #include "platform/mbed_error.h" diff --git a/rtos/rtos_handlers.h b/rtos/internal/rtos_handlers.h similarity index 95% rename from rtos/rtos_handlers.h rename to rtos/internal/rtos_handlers.h index e3d474300f3..2a4755d88a7 100644 --- a/rtos/rtos_handlers.h +++ b/rtos/internal/rtos_handlers.h @@ -1,6 +1,3 @@ - -/** \addtogroup rtos */ -/** @{*/ /* mbed Microcontroller Library * Copyright (c) 2006-2012 ARM Limited * @@ -31,6 +28,10 @@ extern "C" { #endif +/** \ingroup rtos */ +/** \addtogroup mbed-os-internal Internal API */ +/** @{*/ + /** * \defgroup rtos_handlers RTOS hook functions * @{ @@ -42,12 +43,10 @@ extern "C" { */ void rtos_attach_thread_terminate_hook(void (*fptr)(osThreadId_t id)); /** @}*/ +/** @}*/ #ifdef __cplusplus } #endif #endif - -/** @}*/ - diff --git a/rtos/rtos_idle.h b/rtos/internal/rtos_idle.h similarity index 96% rename from rtos/rtos_idle.h rename to rtos/internal/rtos_idle.h index f1f5d6fc3dc..d32b29b9bc7 100644 --- a/rtos/rtos_idle.h +++ b/rtos/internal/rtos_idle.h @@ -1,6 +1,3 @@ - -/** \addtogroup rtos */ -/** @{*/ /* mbed Microcontroller Library * Copyright (c) 2006-2012 ARM Limited * @@ -26,12 +23,16 @@ #define RTOS_IDLE_H #include "mbed_toolchain.h" -#include #ifdef __cplusplus extern "C" { #endif + +/** \ingroup rtos */ +/** \addtogroup mbed-os-internal */ +/** @{*/ + /** * \defgroup rtos_Idle Idle hook function * @{ @@ -46,6 +47,7 @@ void rtos_attach_idle_hook(void (*fptr)(void)); /** @private */ MBED_NORETURN void rtos_idle_loop(void); +/** @}*/ /** @}*/ #ifdef __cplusplus @@ -53,6 +55,3 @@ MBED_NORETURN void rtos_idle_loop(void); #endif #endif - -/** @}*/ - diff --git a/rtos/rtos.h b/rtos/rtos.h index c2d4ad5a98b..3324c68e6e0 100644 --- a/rtos/rtos.h +++ b/rtos/rtos.h @@ -25,7 +25,6 @@ #ifndef RTOS_H #define RTOS_H -#include "mbed_rtos_storage.h" #include "rtos/Kernel.h" #include "rtos/Thread.h" #include "rtos/ThisThread.h" @@ -42,8 +41,6 @@ using namespace rtos; #endif -#include "platform/mbed_version.h" - #endif /** @}*/ From 6a5d04e552b394823b52853ca0fb3d73c5b18977 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 25 Jun 2019 15:13:28 +0100 Subject: [PATCH 02/35] Drivers: Sanity cleanup for coherence and reducing size (#2) * Move implementations from headers to sources in order to remove header file inclusions that do not need to be there. * Move one-line methods that do not call other modules methods to the header files. * Replace implicit inclusion of header files by explicit inclusions of the header files needed. * Explicitly include header files in other modules that relied on implicit inclusion of said header files. * Update the year in the Copyright notice of modules modified. --- drivers/AnalogIn.cpp | 27 ++++++- drivers/AnalogIn.h | 26 ++----- drivers/AnalogOut.cpp | 62 ++++++++++++++++ drivers/AnalogOut.h | 39 ++-------- drivers/CAN.cpp | 48 ++++++++++--- drivers/CAN.h | 49 ++++--------- drivers/DigitalIn.cpp | 31 ++++++++ drivers/DigitalIn.h | 11 +-- drivers/DigitalInOut.cpp | 60 ++++++++++++++++ drivers/DigitalInOut.h | 39 ++-------- drivers/DigitalOut.cpp | 39 ++++++++++ drivers/DigitalOut.h | 18 +---- drivers/FlashIAP.cpp | 39 +--------- drivers/FlashIAP.h | 36 ++++++++-- drivers/I2C.cpp | 12 +--- drivers/I2C.h | 14 ++-- drivers/I2CSlave.cpp | 39 +--------- drivers/I2CSlave.h | 35 +++++++-- drivers/InterruptIn.cpp | 28 +------- drivers/InterruptIn.h | 23 ++++-- drivers/InterruptManager.cpp | 32 --------- drivers/InterruptManager.h | 35 +++++++-- drivers/MbedCRC.cpp | 1 - drivers/PortIn.cpp | 43 +++++++++++ drivers/PortIn.h | 17 +---- drivers/PortInOut.cpp | 72 +++++++++++++++++++ drivers/PortInOut.h | 43 ++--------- drivers/PortOut.cpp | 51 ++++++++++++++ drivers/PortOut.h | 22 ++---- drivers/PwmOut.cpp | 133 +++++++++++++++++++++++++++++++++++ drivers/PwmOut.h | 107 ++++------------------------ drivers/QSPI.cpp | 10 --- drivers/QSPI.h | 10 ++- drivers/RawSerial.cpp | 23 +----- drivers/RawSerial.h | 18 +++-- drivers/SPI.cpp | 51 +------------- drivers/SPI.h | 60 +++++++++++++--- drivers/SPISlave.cpp | 15 ---- drivers/SPISlave.h | 15 +++- drivers/Serial.cpp | 33 +-------- drivers/Serial.h | 34 ++++++--- drivers/SerialBase.cpp | 19 ----- drivers/SerialBase.h | 17 ++++- drivers/SerialWireOutput.cpp | 41 +++++++++++ drivers/SerialWireOutput.h | 18 ++--- drivers/Ticker.cpp | 12 +++- drivers/Ticker.h | 12 +--- drivers/Timeout.h | 3 +- drivers/Timer.cpp | 16 +---- drivers/Timer.h | 13 ++-- drivers/TimerEvent.cpp | 29 +------- drivers/TimerEvent.h | 30 ++++++-- drivers/UARTSerial.cpp | 68 +----------------- drivers/UARTSerial.h | 59 ++++++++++++---- hal/LowPowerTickerWrapper.h | 4 +- 55 files changed, 1016 insertions(+), 825 deletions(-) create mode 100644 drivers/AnalogOut.cpp create mode 100644 drivers/DigitalIn.cpp create mode 100644 drivers/DigitalInOut.cpp create mode 100644 drivers/DigitalOut.cpp create mode 100644 drivers/PortIn.cpp create mode 100644 drivers/PortInOut.cpp create mode 100644 drivers/PortOut.cpp create mode 100644 drivers/PwmOut.cpp create mode 100644 drivers/SerialWireOutput.cpp diff --git a/drivers/AnalogIn.cpp b/drivers/AnalogIn.cpp index dd9d22f306f..97b1b8e1386 100644 --- a/drivers/AnalogIn.cpp +++ b/drivers/AnalogIn.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,6 +23,29 @@ namespace mbed { SingletonPtr AnalogIn::_mutex; -}; +AnalogIn::AnalogIn(PinName pin) +{ + lock(); + analogin_init(&_adc, pin); + unlock(); +} + +float AnalogIn::read() +{ + lock(); + float ret = analogin_read(&_adc); + unlock(); + return ret; +} + +unsigned short AnalogIn::read_u16() +{ + lock(); + unsigned short ret = analogin_read_u16(&_adc); + unlock(); + return ret; +} + +} // namespace mbed #endif diff --git a/drivers/AnalogIn.h b/drivers/AnalogIn.h index 8f247e5975b..633b3b0b4e3 100644 --- a/drivers/AnalogIn.h +++ b/drivers/AnalogIn.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -58,37 +58,20 @@ class AnalogIn { * * @param pin AnalogIn pin to connect to */ - AnalogIn(PinName pin) - { - lock(); - analogin_init(&_adc, pin); - unlock(); - } + AnalogIn(PinName pin); /** Read the input voltage, represented as a float in the range [0.0, 1.0] * * @returns A floating-point value representing the current input voltage, measured as a percentage */ - float read() - { - lock(); - float ret = analogin_read(&_adc); - unlock(); - return ret; - } + float read(); /** Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF] * * @returns * 16-bit unsigned short representing the current input voltage, normalized to a 16-bit value */ - unsigned short read_u16() - { - lock(); - unsigned short ret = analogin_read_u16(&_adc); - unlock(); - return ret; - } + unsigned short read_u16(); /** An operator shorthand for read() * @@ -120,7 +103,6 @@ class AnalogIn { { _mutex->lock(); } - virtual void unlock() { _mutex->unlock(); diff --git a/drivers/AnalogOut.cpp b/drivers/AnalogOut.cpp new file mode 100644 index 00000000000..0ca51c0f710 --- /dev/null +++ b/drivers/AnalogOut.cpp @@ -0,0 +1,62 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * 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/AnalogOut.h" + +#if DEVICE_ANALOGOUT + +namespace mbed { + +void AnalogOut::write(float value) +{ + lock(); + analogout_write(&_dac, value); + unlock(); +} + +void AnalogOut::write_u16(unsigned short value) +{ + lock(); + analogout_write_u16(&_dac, value); + unlock(); +} + +float AnalogOut::read() +{ + lock(); + float ret = analogout_read(&_dac); + unlock(); + return ret; +} + +AnalogOut &AnalogOut::operator= (float percent) +{ + // Underlying write call is thread safe + write(percent); + return *this; +} + +AnalogOut &AnalogOut::operator= (AnalogOut &rhs) +{ + // Underlying write call is thread safe + write(rhs.read()); + return *this; +} + +} // namespace mbed + +#endif // DEVICE_ANALOGOUT diff --git a/drivers/AnalogOut.h b/drivers/AnalogOut.h index d12cbafcc4d..ec75c7a333b 100644 --- a/drivers/AnalogOut.h +++ b/drivers/AnalogOut.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -70,24 +70,14 @@ class AnalogOut { * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%). * Values outside this range will be saturated to 0.0f or 1.0f. */ - void write(float value) - { - lock(); - analogout_write(&_dac, value); - unlock(); - } + void write(float value); /** Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF] * * @param value 16-bit unsigned short representing the output voltage, * normalized to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v) */ - void write_u16(unsigned short value) - { - lock(); - analogout_write_u16(&_dac, value); - unlock(); - } + void write_u16(unsigned short value); /** Return the current output voltage setting, measured as a percentage (float) * @@ -99,33 +89,17 @@ class AnalogOut { * @note * This value may not match exactly the value set by a previous write(). */ - float read() - { - lock(); - float ret = analogout_read(&_dac); - unlock(); - return ret; - } + float read(); /** An operator shorthand for write() * \sa AnalogOut::write() */ - AnalogOut &operator= (float percent) - { - // Underlying write call is thread safe - write(percent); - return *this; - } + AnalogOut &operator= (float percent); /** An operator shorthand for write() * \sa AnalogOut::write() */ - AnalogOut &operator= (AnalogOut &rhs) - { - // Underlying write call is thread safe - write(rhs.read()); - return *this; - } + AnalogOut &operator= (AnalogOut &rhs); /** An operator shorthand for read() * \sa AnalogOut::read() @@ -147,7 +121,6 @@ class AnalogOut { { _mutex.lock(); } - virtual void unlock() { _mutex.unlock(); diff --git a/drivers/CAN.cpp b/drivers/CAN.cpp index a3699e3919d..78b6762f343 100644 --- a/drivers/CAN.cpp +++ b/drivers/CAN.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,6 +22,42 @@ namespace mbed { +CANMessage::CANMessage() : CAN_Message() +{ + len = 8U; + type = CANData; + format = CANStandard; + id = 0U; + memset(data, 0, 8); +} + +CANMessage::CANMessage(unsigned int _id, const unsigned char *_data, unsigned char _len, CANType _type, CANFormat _format) +{ + len = _len & 0xF; + type = _type; + format = _format; + id = _id; + memcpy(data, _data, _len); +} + +CANMessage::CANMessage(unsigned int _id, const char *_data, unsigned char _len, CANType _type, CANFormat _format) +{ + len = _len & 0xF; + type = _type; + format = _format; + id = _id; + memcpy(data, _data, _len); +} + +CANMessage::CANMessage(unsigned int _id, CANFormat _format) +{ + len = 0; + type = CANRemote; + format = _format; + id = _id; + memset(data, 0, 8); +} + CAN::CAN(PinName rd, PinName td) : _can(), _irq() { // No lock needed in constructor @@ -157,16 +193,6 @@ void CAN::_irq_handler(uint32_t id, CanIrqType type) } } -void CAN::lock() -{ - _mutex.lock(); -} - -void CAN::unlock() -{ - _mutex.unlock(); -} - } // namespace mbed #endif diff --git a/drivers/CAN.h b/drivers/CAN.h index 665677efc0f..05cb1ec2529 100644 --- a/drivers/CAN.h +++ b/drivers/CAN.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,14 +39,7 @@ class CANMessage : public CAN_Message { public: /** Creates empty CAN message. */ - CANMessage() : CAN_Message() - { - len = 8U; - type = CANData; - format = CANStandard; - id = 0U; - memset(data, 0, 8); - } + CANMessage(); /** Creates CAN message with specific content. * @@ -56,14 +49,7 @@ class CANMessage : public CAN_Message { * @param _type Type of Data: Use enum CANType for valid parameter values * @param _format Data Format: Use enum CANFormat for valid parameter values */ - CANMessage(unsigned int _id, const unsigned char *_data, unsigned char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard) - { - len = _len & 0xF; - type = _type; - format = _format; - id = _id; - memcpy(data, _data, _len); - } + CANMessage(unsigned int _id, const unsigned char *_data, unsigned char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard); /** Creates CAN message with specific content. @@ -74,28 +60,14 @@ class CANMessage : public CAN_Message { * @param _type Type of Data: Use enum CANType for valid parameter values * @param _format Data Format: Use enum CANFormat for valid parameter values */ - CANMessage(unsigned int _id, const char *_data, unsigned char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard) - { - len = _len & 0xF; - type = _type; - format = _format; - id = _id; - memcpy(data, _data, _len); - } + CANMessage(unsigned int _id, const char *_data, unsigned char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard); /** Creates CAN remote message. * * @param _id Message ID * @param _format Data Format: Use enum CANType for valid parameter values */ - CANMessage(unsigned int _id, CANFormat _format = CANStandard) - { - len = 0; - type = CANRemote; - format = _format; - id = _id; - memset(data, 0, 8); - } + CANMessage(unsigned int _id, CANFormat _format = CANStandard); }; /** A can bus client, used for communicating with can devices @@ -313,8 +285,15 @@ class CAN : private NonCopyable { #if !defined(DOXYGEN_ONLY) protected: - virtual void lock(); - virtual void unlock(); + virtual void lock() + { + _mutex.lock(); + } + virtual void unlock() + { + _mutex.unlock(); + } + can_t _can; Callback _irq[IrqCnt]; PlatformMutex _mutex; diff --git a/drivers/DigitalIn.cpp b/drivers/DigitalIn.cpp new file mode 100644 index 00000000000..064503eee49 --- /dev/null +++ b/drivers/DigitalIn.cpp @@ -0,0 +1,31 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * 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/DigitalIn.h" + +#include "platform/mbed_critical.h" + +namespace mbed { + +void DigitalIn::mode(PinMode pull) +{ + core_util_critical_section_enter(); + gpio_mode(&gpio, pull); + core_util_critical_section_exit(); +} + +} // namespace mbed diff --git a/drivers/DigitalIn.h b/drivers/DigitalIn.h index 348a87bf33a..b2406ea8e78 100644 --- a/drivers/DigitalIn.h +++ b/drivers/DigitalIn.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,6 @@ #include "platform/platform.h" #include "hal/gpio_api.h" -#include "platform/mbed_critical.h" namespace mbed { /** \addtogroup drivers */ @@ -72,6 +71,7 @@ class DigitalIn { // No lock needed in the constructor gpio_init_in_ex(&gpio, pin, mode); } + /** Read the input, represented as 0 or 1 (int) * * @returns @@ -88,12 +88,7 @@ class DigitalIn { * * @param pull PullUp, PullDown, PullNone, OpenDrain */ - void mode(PinMode pull) - { - core_util_critical_section_enter(); - gpio_mode(&gpio, pull); - core_util_critical_section_exit(); - } + void mode(PinMode pull); /** Return the output setting, represented as 0 or 1 (int) * diff --git a/drivers/DigitalInOut.cpp b/drivers/DigitalInOut.cpp new file mode 100644 index 00000000000..7a9cfef8246 --- /dev/null +++ b/drivers/DigitalInOut.cpp @@ -0,0 +1,60 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * 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/DigitalInOut.h" + +#include "platform/mbed_critical.h" + +namespace mbed { + +void DigitalInOut::output() +{ + core_util_critical_section_enter(); + gpio_dir(&gpio, PIN_OUTPUT); + core_util_critical_section_exit(); +} + +void DigitalInOut::input() +{ + core_util_critical_section_enter(); + gpio_dir(&gpio, PIN_INPUT); + core_util_critical_section_exit(); +} + +void DigitalInOut::mode(PinMode pull) +{ + core_util_critical_section_enter(); + gpio_mode(&gpio, pull); + core_util_critical_section_exit(); +} + +DigitalInOut &DigitalInOut::operator= (int value) +{ + // Underlying write is thread safe + write(value); + return *this; +} + +DigitalInOut &DigitalInOut::operator= (DigitalInOut &rhs) +{ + core_util_critical_section_enter(); + write(rhs.read()); + core_util_critical_section_exit(); + return *this; +} + +} // namespace mbed diff --git a/drivers/DigitalInOut.h b/drivers/DigitalInOut.h index 9ceb025aee8..c21253bf89f 100644 --- a/drivers/DigitalInOut.h +++ b/drivers/DigitalInOut.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,6 @@ #include "platform/platform.h" #include "hal/gpio_api.h" -#include "platform/mbed_critical.h" namespace mbed { /** \addtogroup drivers */ @@ -81,32 +80,17 @@ class DigitalInOut { /** Set as an output */ - void output() - { - core_util_critical_section_enter(); - gpio_dir(&gpio, PIN_OUTPUT); - core_util_critical_section_exit(); - } + void output(); /** Set as an input */ - void input() - { - core_util_critical_section_enter(); - gpio_dir(&gpio, PIN_INPUT); - core_util_critical_section_exit(); - } + void input(); /** Set the input pin mode * * @param pull PullUp, PullDown, PullNone, OpenDrain */ - void mode(PinMode pull) - { - core_util_critical_section_enter(); - gpio_mode(&gpio, pull); - core_util_critical_section_exit(); - } + void mode(PinMode pull); /** Return the output setting, represented as 0 or 1 (int) * @@ -130,24 +114,13 @@ class DigitalInOut { * inout = button; // Equivalent to inout.write(button.read()) * @endcode */ - DigitalInOut &operator= (int value) - { - // Underlying write is thread safe - write(value); - return *this; - } + DigitalInOut &operator= (int value); /**A shorthand for write() using the assignment operator which copies the * state from the DigitalInOut argument. * \sa DigitalInOut::write() */ - DigitalInOut &operator= (DigitalInOut &rhs) - { - core_util_critical_section_enter(); - write(rhs.read()); - core_util_critical_section_exit(); - return *this; - } + DigitalInOut &operator= (DigitalInOut &rhs); /** A shorthand for read() * \sa DigitalInOut::read() diff --git a/drivers/DigitalOut.cpp b/drivers/DigitalOut.cpp new file mode 100644 index 00000000000..20ec03bac79 --- /dev/null +++ b/drivers/DigitalOut.cpp @@ -0,0 +1,39 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * 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/DigitalOut.h" + +#include "platform/mbed_critical.h" + +namespace mbed { + +DigitalOut &DigitalOut::operator= (int value) +{ + // Underlying write is thread safe + write(value); + return *this; +} + +DigitalOut &DigitalOut::operator= (DigitalOut &rhs) +{ + core_util_critical_section_enter(); + write(rhs.read()); + core_util_critical_section_exit(); + return *this; +} + +} // namespace mbed diff --git a/drivers/DigitalOut.h b/drivers/DigitalOut.h index b9fe1f2d3ec..41ba5c5460e 100644 --- a/drivers/DigitalOut.h +++ b/drivers/DigitalOut.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +19,6 @@ #include "platform/platform.h" #include "hal/gpio_api.h" -#include "platform/mbed_critical.h" namespace mbed { /** \addtogroup drivers */ @@ -111,24 +110,13 @@ class DigitalOut { * led = button; // Equivalent to led.write(button.read()) * @endcode */ - DigitalOut &operator= (int value) - { - // Underlying write is thread safe - write(value); - return *this; - } + DigitalOut &operator= (int value); /** A shorthand for write() using the assignment operator which copies the * state from the DigitalOut argument. * \sa DigitalOut::write() */ - DigitalOut &operator= (DigitalOut &rhs) - { - core_util_critical_section_enter(); - write(rhs.read()); - core_util_critical_section_exit(); - return *this; - } + DigitalOut &operator= (DigitalOut &rhs); /** A shorthand for read() * \sa DigitalOut::read() diff --git a/drivers/FlashIAP.cpp b/drivers/FlashIAP.cpp index ff015092593..45031ce6450 100644 --- a/drivers/FlashIAP.cpp +++ b/drivers/FlashIAP.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited + * Copyright (c) 2017-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -46,16 +46,6 @@ static inline bool is_aligned(uint32_t number, uint32_t alignment) } } -FlashIAP::FlashIAP() -{ - -} - -FlashIAP::~FlashIAP() -{ - -} - int FlashIAP::init() { int ret = 0; @@ -216,31 +206,6 @@ int FlashIAP::erase(uint32_t addr, uint32_t size) return ret; } -uint32_t FlashIAP::get_page_size() const -{ - return flash_get_page_size(&_flash); -} - -uint32_t FlashIAP::get_sector_size(uint32_t addr) const -{ - return flash_get_sector_size(&_flash, addr); -} - -uint32_t FlashIAP::get_flash_start() const -{ - return flash_get_start_address(&_flash); -} - -uint32_t FlashIAP::get_flash_size() const -{ - return flash_get_size(&_flash); -} - -uint8_t FlashIAP::get_erase_value() const -{ - return flash_get_erase_value(&_flash); -} - -} +} // namespace mbed #endif diff --git a/drivers/FlashIAP.h b/drivers/FlashIAP.h index 0c3c8e10495..47c9fc6939a 100644 --- a/drivers/FlashIAP.h +++ b/drivers/FlashIAP.h @@ -58,8 +58,15 @@ namespace mbed { */ class FlashIAP : private NonCopyable { public: - FlashIAP(); - ~FlashIAP(); + FlashIAP() + { + + } + + ~FlashIAP() + { + + } /** Initialize a flash IAP device * @@ -114,33 +121,48 @@ class FlashIAP : private NonCopyable { * @param addr Address of or inside the sector to query * @return Size of a sector in bytes or MBED_FLASH_INVALID_SIZE if not mapped */ - uint32_t get_sector_size(uint32_t addr) const; + uint32_t get_sector_size(uint32_t addr) const + { + return flash_get_sector_size(&_flash, addr); + } /** Get the flash start address * * @return Flash start address */ - uint32_t get_flash_start() const; + uint32_t get_flash_start() const + { + return flash_get_start_address(&_flash); + } /** Get the flash size * * @return Flash size */ - uint32_t get_flash_size() const; + uint32_t get_flash_size() const + { + return flash_get_size(&_flash); + } /** Get the program page size * * The page size defines the writable page size * @return Size of a program page in bytes */ - uint32_t get_page_size() const; + uint32_t get_page_size() const + { + return flash_get_page_size(&_flash); + } /** Get the flash erase value * * Get the value we read after erase operation * @return flash erase value */ - uint8_t get_erase_value() const; + uint8_t get_erase_value() const + { + return flash_get_erase_value(&_flash); + } #if !defined(DOXYGEN_ONLY) private: diff --git a/drivers/I2C.cpp b/drivers/I2C.cpp index 3e06825c17d..8221f46ad9e 100644 --- a/drivers/I2C.cpp +++ b/drivers/I2C.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2015 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -131,16 +131,6 @@ void I2C::stop(void) unlock(); } -void I2C::lock() -{ - _mutex->lock(); -} - -void I2C::unlock() -{ - _mutex->unlock(); -} - int I2C::recover(PinName sda, PinName scl) { DigitalInOut pin_sda(sda, PIN_INPUT, PullNone, 1); diff --git a/drivers/I2C.h b/drivers/I2C.h index 9a19bd12474..97ca24536bd 100644 --- a/drivers/I2C.h +++ b/drivers/I2C.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2015 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +30,7 @@ #if DEVICE_I2C_ASYNCH #include "platform/CThunk.h" #include "hal/dma_api.h" -#include "platform/FunctionPointer.h" +#include "platform/Callback.h" #endif namespace mbed { @@ -164,11 +164,17 @@ class I2C : private NonCopyable { /** Acquire exclusive access to this I2C bus */ - virtual void lock(void); + virtual void lock(void) + { + _mutex->lock(); + } /** Release exclusive access to this I2C bus */ - virtual void unlock(void); + virtual void unlock(void) + { + _mutex->unlock(); + } virtual ~I2C() { diff --git a/drivers/I2CSlave.cpp b/drivers/I2CSlave.cpp index f0697460be6..cb37e88ef5f 100644 --- a/drivers/I2CSlave.cpp +++ b/drivers/I2CSlave.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,47 +27,12 @@ I2CSlave::I2CSlave(PinName sda, PinName scl) : _i2c() i2c_slave_mode(&_i2c, 1); } -void I2CSlave::frequency(int hz) -{ - i2c_frequency(&_i2c, hz); -} - void I2CSlave::address(int address) { int addr = (address & 0xFF) | 1; i2c_slave_address(&_i2c, 0, addr, 0); } -int I2CSlave::receive(void) -{ - return i2c_slave_receive(&_i2c); -} - -int I2CSlave::read(char *data, int length) -{ - return i2c_slave_read(&_i2c, data, length) != length; -} - -int I2CSlave::read(void) -{ - return i2c_byte_read(&_i2c, 0); -} - -int I2CSlave::write(const char *data, int length) -{ - return i2c_slave_write(&_i2c, data, length) != length; -} - -int I2CSlave::write(int data) -{ - return i2c_byte_write(&_i2c, data); -} - -void I2CSlave::stop(void) -{ - i2c_stop(&_i2c); -} - -} +} // namespace mbed #endif diff --git a/drivers/I2CSlave.h b/drivers/I2CSlave.h index 78715ba9345..529b5bc433f 100644 --- a/drivers/I2CSlave.h +++ b/drivers/I2CSlave.h @@ -87,7 +87,10 @@ class I2CSlave { * * @param hz The bus frequency in Hertz. */ - void frequency(int hz); + void frequency(int hz) + { + i2c_frequency(&_i2c, hz); + } /** Check if this I2C Slave has been addressed. * @@ -97,7 +100,10 @@ class I2CSlave { * @retval WriteAddressed The master is writing to this slave. * @retval WriteGeneral The master is writing to all slave. */ - int receive(void); + int receive(void) + { + return i2c_slave_receive(&_i2c); + } /** Read specified number of bytes from an I2C master. * @@ -108,13 +114,19 @@ class I2CSlave { * @retval 0 If the number of bytes read is equal to length requested. * @retval nonzero On error or if the number of bytes read is less than requested. */ - int read(char *data, int length); + int read(char *data, int length) + { + return i2c_slave_read(&_i2c, data, length) != length; + } /** Read a single byte from an I2C master. * * @return The byte read. */ - int read(void); + int read(void) + { + return i2c_byte_read(&_i2c, 0); + } /** Write to an I2C master. * @@ -125,7 +137,10 @@ class I2CSlave { * @retval 0 If written all bytes successfully. * @retval nonzero On error or if the number of bytes written is less than requested. */ - int write(const char *data, int length); + int write(const char *data, int length) + { + return i2c_slave_write(&_i2c, data, length) != length; + } /** Write a single byte to an I2C master. * @@ -136,7 +151,10 @@ class I2CSlave { * @retval 1 If an ACK is received. * @retval 2 On timeout. */ - int write(int data); + int write(int data) + { + return i2c_byte_write(&_i2c, data); + } /** Set the I2C slave address. * @@ -149,7 +167,10 @@ class I2CSlave { /** Reset the I2C slave back into the known ready receiving state. */ - void stop(void); + void stop(void) + { + i2c_stop(&_i2c); + } #if !defined(DOXYGEN_ONLY) diff --git a/drivers/InterruptIn.cpp b/drivers/InterruptIn.cpp index a4ab5f0135a..fef25f99907 100644 --- a/drivers/InterruptIn.cpp +++ b/drivers/InterruptIn.cpp @@ -24,10 +24,7 @@ namespace mbed { // compatibility. // If not for that, we could simplify by having only the 2-param // constructor, with a default value for the PinMode. -InterruptIn::InterruptIn(PinName pin) : gpio(), - gpio_irq(), - _rise(NULL), - _fall(NULL) +InterruptIn::InterruptIn(PinName pin) : gpio(), gpio_irq(), _rise(NULL), _fall(NULL) { // No lock needed in the constructor irq_init(pin); @@ -45,23 +42,6 @@ InterruptIn::InterruptIn(PinName pin, PinMode mode) : gpio_init_in_ex(&gpio, pin, mode); } -void InterruptIn::irq_init(PinName pin) -{ - gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this); -} - -InterruptIn::~InterruptIn() -{ - // No lock needed in the destructor - gpio_irq_free(&gpio_irq); -} - -int InterruptIn::read() -{ - // Read only - return gpio_read(&gpio); -} - void InterruptIn::mode(PinMode pull) { core_util_critical_section_enter(); @@ -128,12 +108,6 @@ void InterruptIn::disable_irq() core_util_critical_section_exit(); } -InterruptIn::operator int() -{ - // Underlying call is atomic - return read(); -} - } // namespace mbed #endif diff --git a/drivers/InterruptIn.h b/drivers/InterruptIn.h index 32cc6619eec..991cc0b811b 100644 --- a/drivers/InterruptIn.h +++ b/drivers/InterruptIn.h @@ -80,7 +80,11 @@ class InterruptIn : private NonCopyable { */ InterruptIn(PinName pin, PinMode mode); - virtual ~InterruptIn(); + virtual ~InterruptIn() + { + // No lock needed in the destructor + gpio_irq_free(&gpio_irq); + } /** Read the input, represented as 0 or 1 (int) * @@ -88,11 +92,19 @@ class InterruptIn : private NonCopyable { * An integer representing the state of the input pin, * 0 for logical 0, 1 for logical 1 */ - int read(); + int read() + { + // Read only + return gpio_read(&gpio); + } /** An operator shorthand for read() */ - operator int(); + operator int() + { + // Underlying call is atomic + return read(); + } /** Attach a function to call when a rising edge occurs on the input @@ -171,7 +183,10 @@ class InterruptIn : private NonCopyable { Callback _rise; Callback _fall; - void irq_init(PinName pin); + void irq_init(PinName pin) + { + gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this); + } #endif }; diff --git a/drivers/InterruptManager.cpp b/drivers/InterruptManager.cpp index 179731b4199..465b8c13c14 100644 --- a/drivers/InterruptManager.cpp +++ b/drivers/InterruptManager.cpp @@ -57,12 +57,6 @@ InterruptManager *InterruptManager::get() return _instance; } -InterruptManager::InterruptManager() -{ - // No mutex needed in constructor - memset(_chains, 0, NVIC_NUM_VECTORS * sizeof(CallChain *)); -} - void InterruptManager::destroy() { // Not a good idea to call this unless NO interrupt at all @@ -127,32 +121,6 @@ bool InterruptManager::remove_handler(pFunctionPointer_t handler, IRQn_Type irq) return ret; } -void InterruptManager::irq_helper() -{ - _chains[__get_IPSR()]->call(); -} - -int InterruptManager::get_irq_index(IRQn_Type irq) -{ - // Pure function - no lock needed - return (int)irq + NVIC_USER_IRQ_OFFSET; -} - -void InterruptManager::static_irq_helper() -{ - InterruptManager::get()->irq_helper(); -} - -void InterruptManager::lock() -{ - _mutex.lock(); -} - -void InterruptManager::unlock() -{ - _mutex.unlock(); -} - } // namespace mbed #endif diff --git a/drivers/InterruptManager.h b/drivers/InterruptManager.h index 8b207f0c5ea..85463aad9d2 100644 --- a/drivers/InterruptManager.h +++ b/drivers/InterruptManager.h @@ -169,11 +169,23 @@ class InterruptManager : private NonCopyable { #if !defined(DOXYGEN_ONLY) private: - InterruptManager(); + InterruptManager() + { + // No mutex needed in constructor + memset(_chains, 0, NVIC_NUM_VECTORS * sizeof(CallChain *)); + } + ~InterruptManager(); - void lock(); - void unlock(); + void lock() + { + _mutex.lock(); + } + + void unlock() + { + _mutex.unlock(); + } template pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front = false) @@ -192,10 +204,21 @@ class InterruptManager : private NonCopyable { pFunctionPointer_t add_common(void (*function)(void), IRQn_Type irq, bool front = false); bool must_replace_vector(IRQn_Type irq); - int get_irq_index(IRQn_Type irq); - void irq_helper(); + int get_irq_index(IRQn_Type irq) + { + // Pure function - no lock needed + return (int)irq + NVIC_USER_IRQ_OFFSET; + } + + void irq_helper() + { + _chains[__get_IPSR()]->call(); + } void add_helper(void (*function)(void), IRQn_Type irq, bool front = false); - static void static_irq_helper(); + static void static_irq_helper() + { + InterruptManager::get()->irq_helper(); + } CallChain *_chains[NVIC_NUM_VECTORS]; static InterruptManager *_instance; diff --git a/drivers/MbedCRC.cpp b/drivers/MbedCRC.cpp index 6353e052c3f..4115da01ccf 100644 --- a/drivers/MbedCRC.cpp +++ b/drivers/MbedCRC.cpp @@ -16,7 +16,6 @@ */ #include -#include "drivers/TableCRC.h" #include "drivers/MbedCRC.h" namespace mbed { diff --git a/drivers/PortIn.cpp b/drivers/PortIn.cpp new file mode 100644 index 00000000000..fc8577b8486 --- /dev/null +++ b/drivers/PortIn.cpp @@ -0,0 +1,43 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * 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/PortIn.h" + + +#if DEVICE_PORTIN + +#include "platform/mbed_critical.h" + +namespace mbed { + +PortIn::PortIn(PortName port, int mask) +{ + core_util_critical_section_enter(); + port_init(&_port, port, mask, PIN_INPUT); + core_util_critical_section_exit(); +} + +void PortIn::mode(PinMode mode) +{ + core_util_critical_section_enter(); + port_mode(&_port, mode); + core_util_critical_section_exit(); +} + +} // namespace mbed + +#endif // #if DEVICE_PORTIN diff --git a/drivers/PortIn.h b/drivers/PortIn.h index f3ae250e98d..d3fb7192429 100644 --- a/drivers/PortIn.h +++ b/drivers/PortIn.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ #if DEVICE_PORTIN || defined(DOXYGEN_ONLY) #include "hal/port_api.h" -#include "platform/mbed_critical.h" namespace mbed { /** \addtogroup drivers */ @@ -61,12 +60,7 @@ class PortIn { * @param port Port to connect to (as defined in target's PortNames.h) * @param mask Bitmask defines which port pins should be an input (0 - ignore, 1 - include) */ - PortIn(PortName port, int mask = 0xFFFFFFFF) - { - core_util_critical_section_enter(); - port_init(&_port, port, mask, PIN_INPUT); - core_util_critical_section_exit(); - } + PortIn(PortName port, int mask = 0xFFFFFFFF); /** Read the value input to the port * @@ -82,12 +76,7 @@ class PortIn { * * @param mode PullUp, PullDown, PullNone, OpenDrain */ - void mode(PinMode mode) - { - core_util_critical_section_enter(); - port_mode(&_port, mode); - core_util_critical_section_exit(); - } + void mode(PinMode mode); /** A shorthand for read() */ diff --git a/drivers/PortInOut.cpp b/drivers/PortInOut.cpp new file mode 100644 index 00000000000..3b9671ad965 --- /dev/null +++ b/drivers/PortInOut.cpp @@ -0,0 +1,72 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * 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/PortInOut.h" + + +#if DEVICE_PORTINOUT + +#include "platform/mbed_critical.h" + +namespace mbed { + +PortInOut::PortInOut(PortName port, int mask) +{ + core_util_critical_section_enter(); + port_init(&_port, port, mask, PIN_INPUT); + core_util_critical_section_exit(); +} + +void PortInOut::output() +{ + core_util_critical_section_enter(); + port_dir(&_port, PIN_OUTPUT); + core_util_critical_section_exit(); +} + +void PortInOut::input() +{ + core_util_critical_section_enter(); + port_dir(&_port, PIN_INPUT); + core_util_critical_section_exit(); +} + +void PortInOut::mode(PinMode mode) +{ + core_util_critical_section_enter(); + port_mode(&_port, mode); + core_util_critical_section_exit(); +} + +PortInOut &PortInOut::operator= (int value) +{ + write(value); + return *this; +} + +/** A shorthand for write() + * \sa PortInOut::write() + */ +PortInOut &PortInOut::operator= (PortInOut &rhs) +{ + write(rhs.read()); + return *this; +} + +} // namespace mbed + +#endif // #if DEVICE_PORTINOUT diff --git a/drivers/PortInOut.h b/drivers/PortInOut.h index 2036eba2520..e725fa003f8 100644 --- a/drivers/PortInOut.h +++ b/drivers/PortInOut.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ #if DEVICE_PORTINOUT || defined(DOXYGEN_ONLY) #include "hal/port_api.h" -#include "platform/mbed_critical.h" namespace mbed { /** \addtogroup drivers */ @@ -40,12 +39,7 @@ class PortInOut { * @param port Port to connect to (Port0-Port5) * @param mask A bitmask to identify which bits in the port should be included (0 - ignore) */ - PortInOut(PortName port, int mask = 0xFFFFFFFF) - { - core_util_critical_section_enter(); - port_init(&_port, port, mask, PIN_INPUT); - core_util_critical_section_exit(); - } + PortInOut(PortName port, int mask = 0xFFFFFFFF); /** Write the value to the output port * @@ -68,50 +62,27 @@ class PortInOut { /** Set as an output */ - void output() - { - core_util_critical_section_enter(); - port_dir(&_port, PIN_OUTPUT); - core_util_critical_section_exit(); - } + void output(); /** Set as an input */ - void input() - { - core_util_critical_section_enter(); - port_dir(&_port, PIN_INPUT); - core_util_critical_section_exit(); - } + void input(); /** Set the input pin mode * * @param mode PullUp, PullDown, PullNone, OpenDrain */ - void mode(PinMode mode) - { - core_util_critical_section_enter(); - port_mode(&_port, mode); - core_util_critical_section_exit(); - } + void mode(PinMode mode); /** A shorthand for write() * \sa PortInOut::write() */ - PortInOut &operator= (int value) - { - write(value); - return *this; - } + PortInOut &operator= (int value); /** A shorthand for write() * \sa PortInOut::write() */ - PortInOut &operator= (PortInOut &rhs) - { - write(rhs.read()); - return *this; - } + PortInOut &operator= (PortInOut &rhs); /** A shorthand for read() * \sa PortInOut::read() diff --git a/drivers/PortOut.cpp b/drivers/PortOut.cpp new file mode 100644 index 00000000000..62fd3a26482 --- /dev/null +++ b/drivers/PortOut.cpp @@ -0,0 +1,51 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * 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/PortOut.h" + + +#if DEVICE_PORTOUT + +#include "platform/mbed_critical.h" + +namespace mbed { + +PortOut::PortOut(PortName port, int mask) +{ + core_util_critical_section_enter(); + port_init(&_port, port, mask, PIN_OUTPUT); + core_util_critical_section_exit(); +} + +PortOut &PortOut::operator= (int value) +{ + write(value); + return *this; +} + +/** A shorthand for write() + * \sa PortOut::write() + */ +PortOut &PortOut::operator= (PortOut &rhs) +{ + write(rhs.read()); + return *this; +} + +} // namespace mbed + +#endif // #if DEVICE_PORTOUT diff --git a/drivers/PortOut.h b/drivers/PortOut.h index 18a0bcd3c5d..609c229e0de 100644 --- a/drivers/PortOut.h +++ b/drivers/PortOut.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ #if DEVICE_PORTOUT || defined(DOXYGEN_ONLY) #include "hal/port_api.h" -#include "platform/mbed_critical.h" namespace mbed { /** \addtogroup drivers */ @@ -60,12 +59,7 @@ class PortOut { * @param port Port to connect to (as defined in target's PortNames.h) * @param mask Bitmask defines which port pins are an output (0 - ignore, 1 - include) */ - PortOut(PortName port, int mask = 0xFFFFFFFF) - { - core_util_critical_section_enter(); - port_init(&_port, port, mask, PIN_OUTPUT); - core_util_critical_section_exit(); - } + PortOut(PortName port, int mask = 0xFFFFFFFF); /** Write the value to the output port * @@ -89,20 +83,12 @@ class PortOut { /** A shorthand for write() * \sa PortOut::write() */ - PortOut &operator= (int value) - { - write(value); - return *this; - } + PortOut &operator= (int value); /** A shorthand for read() * \sa PortOut::read() */ - PortOut &operator= (PortOut &rhs) - { - write(rhs.read()); - return *this; - } + PortOut &operator= (PortOut &rhs); /** A shorthand for read() * \sa PortOut::read() diff --git a/drivers/PwmOut.cpp b/drivers/PwmOut.cpp new file mode 100644 index 00000000000..12711658828 --- /dev/null +++ b/drivers/PwmOut.cpp @@ -0,0 +1,133 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * 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/PwmOut.h" + + +#if DEVICE_PWMOUT + +#include "platform/mbed_critical.h" +#include "platform/mbed_power_mgmt.h" + +namespace mbed { + +PwmOut::PwmOut(PinName pin) : _deep_sleep_locked(false) +{ + core_util_critical_section_enter(); + pwmout_init(&_pwm, pin); + core_util_critical_section_exit(); +} + +PwmOut::~PwmOut() +{ + core_util_critical_section_enter(); + pwmout_free(&_pwm); + unlock_deep_sleep(); + core_util_critical_section_exit(); +} + +void PwmOut::write(float value) +{ + core_util_critical_section_enter(); + lock_deep_sleep(); + pwmout_write(&_pwm, value); + core_util_critical_section_exit(); +} + +float PwmOut::read() +{ + core_util_critical_section_enter(); + float val = pwmout_read(&_pwm); + core_util_critical_section_exit(); + return val; +} + +void PwmOut::period(float seconds) +{ + core_util_critical_section_enter(); + pwmout_period(&_pwm, seconds); + core_util_critical_section_exit(); +} + +void PwmOut::period_ms(int ms) +{ + core_util_critical_section_enter(); + pwmout_period_ms(&_pwm, ms); + core_util_critical_section_exit(); +} + +void PwmOut::period_us(int us) +{ + core_util_critical_section_enter(); + pwmout_period_us(&_pwm, us); + core_util_critical_section_exit(); +} + +void PwmOut::pulsewidth(float seconds) +{ + core_util_critical_section_enter(); + pwmout_pulsewidth(&_pwm, seconds); + core_util_critical_section_exit(); +} + +void PwmOut::pulsewidth_ms(int ms) +{ + core_util_critical_section_enter(); + pwmout_pulsewidth_ms(&_pwm, ms); + core_util_critical_section_exit(); +} + +void PwmOut::pulsewidth_us(int us) +{ + core_util_critical_section_enter(); + pwmout_pulsewidth_us(&_pwm, us); + core_util_critical_section_exit(); +} + +PwmOut &PwmOut::operator= (float value) +{ + // Underlying call is thread safe + write(value); + return *this; +} + +PwmOut &PwmOut::operator= (PwmOut &rhs) +{ + // Underlying call is thread safe + write(rhs.read()); + return *this; +} + +void PwmOut::lock_deep_sleep() +{ + if (_deep_sleep_locked == false) { + sleep_manager_lock_deep_sleep(); + _deep_sleep_locked = true; + } +} + +void PwmOut::unlock_deep_sleep() +{ + if (_deep_sleep_locked == true) { + sleep_manager_unlock_deep_sleep(); + _deep_sleep_locked = false; + } +} + +} // namespace mbed + +#endif // #if DEVICE_PWMOUT diff --git a/drivers/PwmOut.h b/drivers/PwmOut.h index ed8765594a9..7803eda61f9 100644 --- a/drivers/PwmOut.h +++ b/drivers/PwmOut.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,6 @@ #if DEVICE_PWMOUT || defined(DOXYGEN_ONLY) #include "hal/pwmout_api.h" -#include "platform/mbed_critical.h" -#include "platform/mbed_power_mgmt.h" namespace mbed { /** \addtogroup drivers */ @@ -58,20 +56,9 @@ class PwmOut { * * @param pin PwmOut pin to connect to */ - PwmOut(PinName pin) : _deep_sleep_locked(false) - { - core_util_critical_section_enter(); - pwmout_init(&_pwm, pin); - core_util_critical_section_exit(); - } + PwmOut(PinName pin); - ~PwmOut() - { - core_util_critical_section_enter(); - pwmout_free(&_pwm); - unlock_deep_sleep(); - core_util_critical_section_exit(); - } + ~PwmOut(); /** Set the output duty-cycle, specified as a percentage (float) * @@ -80,13 +67,7 @@ class PwmOut { * 0.0f (representing on 0%) and 1.0f (representing on 100%). * Values outside this range will be saturated to 0.0f or 1.0f. */ - void write(float value) - { - core_util_critical_section_enter(); - lock_deep_sleep(); - pwmout_write(&_pwm, value); - core_util_critical_section_exit(); - } + void write(float value); /** Return the current output duty-cycle setting, measured as a percentage (float) * @@ -98,13 +79,7 @@ class PwmOut { * @note * This value may not match exactly the value set by a previous write(). */ - float read() - { - core_util_critical_section_enter(); - float val = pwmout_read(&_pwm); - core_util_critical_section_exit(); - return val; - } + float read(); /** Set the PWM period, specified in seconds (float), keeping the duty cycle the same. * @@ -113,82 +88,42 @@ class PwmOut { * The resolution is currently in microseconds; periods smaller than this * will be set to zero. */ - void period(float seconds) - { - core_util_critical_section_enter(); - pwmout_period(&_pwm, seconds); - core_util_critical_section_exit(); - } + void period(float seconds); /** Set the PWM period, specified in milliseconds (int), keeping the duty cycle the same. * @param ms Change the period of a PWM signal in milliseconds without modifying the duty cycle */ - void period_ms(int ms) - { - core_util_critical_section_enter(); - pwmout_period_ms(&_pwm, ms); - core_util_critical_section_exit(); - } + void period_ms(int ms); /** Set the PWM period, specified in microseconds (int), keeping the duty cycle the same. * @param us Change the period of a PWM signal in microseconds without modifying the duty cycle */ - void period_us(int us) - { - core_util_critical_section_enter(); - pwmout_period_us(&_pwm, us); - core_util_critical_section_exit(); - } + void period_us(int us); /** Set the PWM pulsewidth, specified in seconds (float), keeping the period the same. * @param seconds Change the pulse width of a PWM signal specified in seconds (float) */ - void pulsewidth(float seconds) - { - core_util_critical_section_enter(); - pwmout_pulsewidth(&_pwm, seconds); - core_util_critical_section_exit(); - } + void pulsewidth(float seconds); /** Set the PWM pulsewidth, specified in milliseconds (int), keeping the period the same. * @param ms Change the pulse width of a PWM signal specified in milliseconds */ - void pulsewidth_ms(int ms) - { - core_util_critical_section_enter(); - pwmout_pulsewidth_ms(&_pwm, ms); - core_util_critical_section_exit(); - } + void pulsewidth_ms(int ms); /** Set the PWM pulsewidth, specified in microseconds (int), keeping the period the same. * @param us Change the pulse width of a PWM signal specified in microseconds */ - void pulsewidth_us(int us) - { - core_util_critical_section_enter(); - pwmout_pulsewidth_us(&_pwm, us); - core_util_critical_section_exit(); - } + void pulsewidth_us(int us); /** A operator shorthand for write() * \sa PwmOut::write() */ - PwmOut &operator= (float value) - { - // Underlying call is thread safe - write(value); - return *this; - } + PwmOut &operator= (float value); /** A operator shorthand for write() * \sa PwmOut::write() */ - PwmOut &operator= (PwmOut &rhs) - { - // Underlying call is thread safe - write(rhs.read()); - return *this; - } + PwmOut &operator= (PwmOut &rhs); /** An operator shorthand for read() * \sa PwmOut::read() @@ -202,22 +137,10 @@ class PwmOut { #if !(DOXYGEN_ONLY) protected: /** Lock deep sleep only if it is not yet locked */ - void lock_deep_sleep() - { - if (_deep_sleep_locked == false) { - sleep_manager_lock_deep_sleep(); - _deep_sleep_locked = true; - } - } + void lock_deep_sleep(); /** Unlock deep sleep in case it is locked */ - void unlock_deep_sleep() - { - if (_deep_sleep_locked == true) { - sleep_manager_unlock_deep_sleep(); - _deep_sleep_locked = false; - } - } + void unlock_deep_sleep(); pwmout_t _pwm; bool _deep_sleep_locked; diff --git a/drivers/QSPI.cpp b/drivers/QSPI.cpp index c79c949e3b3..49246fdedd5 100644 --- a/drivers/QSPI.cpp +++ b/drivers/QSPI.cpp @@ -206,16 +206,6 @@ qspi_status_t QSPI::command_transfer(int instruction, int address, const char *t return ret_status; } -void QSPI::lock() -{ - _mutex->lock(); -} - -void QSPI::unlock() -{ - _mutex->unlock(); -} - // Note: Private helper function to initialize qspi HAL bool QSPI::_initialize() { diff --git a/drivers/QSPI.h b/drivers/QSPI.h index e247e8f6515..1c6b7e743d6 100644 --- a/drivers/QSPI.h +++ b/drivers/QSPI.h @@ -187,11 +187,17 @@ class QSPI : private NonCopyable { protected: /** Acquire exclusive access to this SPI bus */ - virtual void lock(void); + virtual void lock(void) + { + _mutex->lock(); + } /** Release exclusive access to this SPI bus */ - virtual void unlock(void); + virtual void unlock(void) + { + _mutex->unlock(); + } qspi_t _qspi; diff --git a/drivers/RawSerial.cpp b/drivers/RawSerial.cpp index 1424c6c9afb..8c289999e78 100644 --- a/drivers/RawSerial.cpp +++ b/drivers/RawSerial.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,9 +15,7 @@ * limitations under the License. */ #include "drivers/RawSerial.h" -#include "platform/mbed_wait_api.h" #include -#include #if DEVICE_SERIAL @@ -26,11 +24,6 @@ namespace mbed { -RawSerial::RawSerial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud) -{ - // No lock needed in the constructor -} - int RawSerial::getc() { lock(); @@ -91,20 +84,6 @@ int RawSerial::vprintf(const char *format, std::va_list arg) return len; } -/** Acquire exclusive access to this serial port - */ -void RawSerial::lock() -{ - // No lock used - external synchronization required -} - -/** Release exclusive access to this serial port - */ -void RawSerial::unlock() -{ - // No lock used - external synchronization required -} - } // namespace mbed #endif diff --git a/drivers/RawSerial.h b/drivers/RawSerial.h index 0e6c9c7c8ff..215c271388c 100644 --- a/drivers/RawSerial.h +++ b/drivers/RawSerial.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,6 @@ #include "mbed_toolchain.h" #include "drivers/SerialBase.h" -#include "hal/serial_api.h" #include "platform/NonCopyable.h" #include @@ -65,7 +64,10 @@ class RawSerial: public SerialBase, private NonCopyable { * @note * Either tx or rx may be specified as NC if unused */ - RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); + RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) : SerialBase(tx, rx, baud) + { + // No lock needed in the constructor + } /** Write a char to the serial port * @@ -97,11 +99,17 @@ class RawSerial: public SerialBase, private NonCopyable { /* Acquire exclusive access to this serial port */ - virtual void lock(void); + virtual void lock(void) + { + // No lock used - external synchronization required + } /* Release exclusive access to this serial port */ - virtual void unlock(void); + virtual void unlock(void) + { + // No lock used - external synchronization required + } #endif }; diff --git a/drivers/SPI.cpp b/drivers/SPI.cpp index ffe696bd6db..66c3b3ef41d 100644 --- a/drivers/SPI.cpp +++ b/drivers/SPI.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,32 +28,6 @@ namespace mbed { SPI::spi_peripheral_s SPI::_peripherals[SPI_PERIPHERALS_USED]; int SPI::_peripherals_used; -SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel) : -#if DEVICE_SPI_ASYNCH - _irq(this), -#endif - _mosi(mosi), - _miso(miso), - _sclk(sclk), - _hw_ssel(ssel), - _sw_ssel(NC) -{ - _do_construct(); -} - -SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel, use_gpio_ssel_t) : -#if DEVICE_SPI_ASYNCH - _irq(this), -#endif - _mosi(mosi), - _miso(miso), - _sclk(sclk), - _hw_ssel(NC), - _sw_ssel(ssel, 1) -{ - _do_construct(); -} - void SPI::_do_construct() { // No lock needed in the constructor @@ -188,11 +162,6 @@ void SPI::_set_ssel(int val) } } -void SPI::lock() -{ - _peripheral->mutex->lock(); -} - void SPI::select() { lock(); @@ -202,11 +171,6 @@ void SPI::select() } } -void SPI::unlock() -{ - _peripheral->mutex->unlock(); -} - void SPI::deselect() { if (--_select_count == 0) { @@ -243,14 +207,6 @@ void SPI::abort_transfer() #endif } - -void SPI::clear_transfer_buffer() -{ -#if TRANSACTION_QUEUE_SIZE_SPI - _peripheral->transaction_buffer->reset(); -#endif -} - void SPI::abort_all_transfers() { clear_transfer_buffer(); @@ -323,11 +279,6 @@ void SPI::unlock_deep_sleep() #if TRANSACTION_QUEUE_SIZE_SPI -void SPI::start_transaction(transaction_t *data) -{ - start_transfer(data->tx_buffer, data->tx_length, data->rx_buffer, data->rx_length, data->width, data->callback, data->event); -} - void SPI::dequeue_transaction() { Transaction t; diff --git a/drivers/SPI.h b/drivers/SPI.h index 6b647a3adca..ebb95f46098 100644 --- a/drivers/SPI.h +++ b/drivers/SPI.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2015 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -40,7 +40,7 @@ #include "platform/CThunk.h" #include "hal/dma_api.h" #include "platform/CircularBuffer.h" -#include "platform/FunctionPointer.h" +#include "platform/Callback.h" #include "platform/Transaction.h" #endif @@ -110,7 +110,18 @@ class SPI : private NonCopyable { * @param sclk SPI Clock pin. * @param ssel SPI Chip Select pin. */ - SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel = NC); + SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel = NC) : +#if DEVICE_SPI_ASYNCH + _irq(this), +#endif + _mosi(mosi), + _miso(miso), + _sclk(sclk), + _hw_ssel(ssel), + _sw_ssel(NC) + { + _do_construct(); + } /** Create a SPI master connected to the specified pins. * @@ -126,7 +137,18 @@ class SPI : private NonCopyable { * @param sclk SPI Clock pin. * @param ssel SPI Chip Select pin. */ - SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel, use_gpio_ssel_t); + SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel, use_gpio_ssel_t) : +#if DEVICE_SPI_ASYNCH + _irq(this), +#endif + _mosi(mosi), + _miso(miso), + _sclk(sclk), + _hw_ssel(NC), + _sw_ssel(ssel, 1) + { + _do_construct(); + } virtual ~SPI(); @@ -178,11 +200,17 @@ class SPI : private NonCopyable { /** Acquire exclusive access to this SPI bus. */ - virtual void lock(void); + virtual void lock(void) + { + _peripheral->mutex->lock(); + } /** Release exclusive access to this SPI bus. */ - virtual void unlock(void); + virtual void unlock(void) + { + _peripheral->mutex->unlock(); + } /** Assert the Slave Select line, acquiring exclusive access to this SPI bus. * @@ -239,7 +267,12 @@ class SPI : private NonCopyable { /** Clear the queue of transfers. */ - void clear_transfer_buffer(); + void clear_transfer_buffer() + { + #if TRANSACTION_QUEUE_SIZE_SPI + _peripheral->transaction_buffer->reset(); + #endif + } /** Clear the queue of transfers and abort the on-going transfer. */ @@ -325,7 +358,18 @@ class SPI : private NonCopyable { * * @param data Transaction data. */ - void start_transaction(transaction_t *data); + void start_transaction(transaction_t *data) + { + start_transfer( + data->tx_buffer, + data->tx_length, + data->rx_buffer, + data->rx_length, + data->width, + data->callback, + data->event + ); + } /** Dequeue a transaction and start the transfer if there was one pending. */ diff --git a/drivers/SPISlave.cpp b/drivers/SPISlave.cpp index db870cdea2a..02127e6c899 100644 --- a/drivers/SPISlave.cpp +++ b/drivers/SPISlave.cpp @@ -44,21 +44,6 @@ void SPISlave::frequency(int hz) spi_frequency(&_spi, _hz); } -int SPISlave::receive(void) -{ - return (spi_slave_receive(&_spi)); -} - -int SPISlave::read(void) -{ - return (spi_slave_read(&_spi)); -} - -void SPISlave::reply(int value) -{ - spi_slave_write(&_spi, value); -} - } // namespace mbed #endif diff --git a/drivers/SPISlave.h b/drivers/SPISlave.h index 878bc8d6721..72ebf0dcdd9 100644 --- a/drivers/SPISlave.h +++ b/drivers/SPISlave.h @@ -96,20 +96,29 @@ class SPISlave : private NonCopyable { * @retval 0 No data waiting. * @retval 1 Data waiting. */ - int receive(void); + int receive(void) + { + return (spi_slave_receive(&_spi)); + } /** Retrieve data from receive buffer as slave. * * @return The data in the receive buffer. */ - int read(void); + int read(void) + { + return (spi_slave_read(&_spi)); + } /** Fill the transmission buffer with the value to be written out * as slave on the next received message from the master. * * @param value The data to be transmitted next. */ - void reply(int value); + void reply(int value) + { + spi_slave_write(&_spi, value); + } #if !defined(DOXYGEN_ONLY) diff --git a/drivers/Serial.cpp b/drivers/Serial.cpp index d0f87263b67..e3dccd0d955 100644 --- a/drivers/Serial.cpp +++ b/drivers/Serial.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,42 +15,11 @@ * limitations under the License. */ #include "drivers/Serial.h" -#include "platform/mbed_wait_api.h" #if DEVICE_SERIAL namespace mbed { -Serial::Serial(PinName tx, PinName rx, const char *name, int baud) : SerialBase(tx, rx, baud), Stream(name) -{ -} - -Serial::Serial(PinName tx, PinName rx, int baud): SerialBase(tx, rx, baud), Stream(NULL) -{ -} - -int Serial::_getc() -{ - // Mutex is already held - return _base_getc(); -} - -int Serial::_putc(int c) -{ - // Mutex is already held - return _base_putc(c); -} - -void Serial::lock() -{ - _mutex.lock(); -} - -void Serial::unlock() -{ - _mutex.unlock(); -} - } // namespace mbed #endif diff --git a/drivers/Serial.h b/drivers/Serial.h index d19010808d5..b6cf4d4b17e 100644 --- a/drivers/Serial.h +++ b/drivers/Serial.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,6 @@ #include "platform/Stream.h" #include "SerialBase.h" #include "platform/PlatformMutex.h" -#include "hal/serial_api.h" #include "platform/NonCopyable.h" namespace mbed { @@ -69,7 +68,9 @@ class Serial : public SerialBase, public Stream, private NonCopyable { * @note * Either tx or rx may be specified as NC (Not Connected) if unused */ - Serial(PinName tx, PinName rx, const char *name = NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); + Serial(PinName tx, PinName rx, const char *name = NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) : SerialBase(tx, rx, baud), Stream(name) + { + } /** Create a Serial port, connected to the specified transmit and receive pins, with the specified baud @@ -81,7 +82,9 @@ class Serial : public SerialBase, public Stream, private NonCopyable { * @note * Either tx or rx may be specified as NC (Not Connected) if unused */ - Serial(PinName tx, PinName rx, int baud); + Serial(PinName tx, PinName rx,int baud) : SerialBase(tx, rx, baud), Stream(NULL) + { + } /* Stream gives us a FileHandle with non-functional poll()/readable()/writable. Pass through * the calls from the SerialBase instead for backwards compatibility. This problem is @@ -102,10 +105,25 @@ class Serial : public SerialBase, public Stream, private NonCopyable { #if !(DOXYGEN_ONLY) protected: - virtual int _getc(); - virtual int _putc(int c); - virtual void lock(); - virtual void unlock(); + virtual int _getc() + { + // Mutex is already held + return _base_getc(); + } + virtual int _putc(int c) + { + // Mutex is already held + return _base_putc(c); + } + virtual void lock() + { + _mutex.lock(); + } + virtual void unlock() + { + _mutex.unlock(); + } + PlatformMutex _mutex; #endif diff --git a/drivers/SerialBase.cpp b/drivers/SerialBase.cpp index 856944fd347..09372d71dc0 100644 --- a/drivers/SerialBase.cpp +++ b/drivers/SerialBase.cpp @@ -66,7 +66,6 @@ int SerialBase::readable() return ret; } - int SerialBase::writeable() { lock(); @@ -107,12 +106,6 @@ void SerialBase::_irq_handler(uint32_t id, SerialIrq irq_type) } } -int SerialBase::_base_getc() -{ - // Mutex is already held - return serial_getc(&_serial); -} - int SerialBase::_base_putc(int c) { // Mutex is already held @@ -151,16 +144,6 @@ void SerialBase::send_break() unlock(); } -void SerialBase::lock() -{ - // Stub -} - -void SerialBase:: unlock() -{ - // Stub -} - SerialBase::~SerialBase() { // No lock needed in destructor @@ -294,7 +277,6 @@ int SerialBase::read(uint8_t *buffer, int length, const event_callback_t &callba return result; } - int SerialBase::read(uint16_t *buffer, int length, const event_callback_t &callback, int event, unsigned char char_match) { int result = 0; @@ -308,7 +290,6 @@ int SerialBase::read(uint16_t *buffer, int length, const event_callback_t &callb return result; } - void SerialBase::start_read(void *buffer, int buffer_size, char buffer_width, const event_callback_t &callback, int event, unsigned char char_match) { _rx_asynch_set = true; diff --git a/drivers/SerialBase.h b/drivers/SerialBase.h index 99da7a9b45d..5d081d680ea 100644 --- a/drivers/SerialBase.h +++ b/drivers/SerialBase.h @@ -157,11 +157,17 @@ class SerialBase : private NonCopyable { /** Acquire exclusive access to this serial port */ - virtual void lock(void); + virtual void lock(void) + { + // Stub + } /** Release exclusive access to this serial port */ - virtual void unlock(void); + virtual void unlock(void) + { + // Stub + } #endif public: @@ -288,7 +294,12 @@ class SerialBase : private NonCopyable { SerialBase(PinName tx, PinName rx, int baud); virtual ~SerialBase(); - int _base_getc(); + int _base_getc() + { + // Mutex is already held + return serial_getc(&_serial); + } + int _base_putc(int c); #if DEVICE_SERIAL_ASYNCH diff --git a/drivers/SerialWireOutput.cpp b/drivers/SerialWireOutput.cpp new file mode 100644 index 00000000000..92d6bd3c016 --- /dev/null +++ b/drivers/SerialWireOutput.cpp @@ -0,0 +1,41 @@ +/* mbed Microcontroller Library + * Copyright (c) 2017-2019 ARM Limited + * 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/SerialWireOutput.h" + +#if defined(DEVICE_ITM) + +#include "hal/itm_api.h" + +namespace mbed { + +SerialWireOutput::SerialWireOutput(void) +{ + /* Initialize ITM using internal init function. */ + mbed_itm_init(); +} + +ssize_t SerialWireOutput::write(const void *buffer, size_t size) +{ + mbed_itm_send_block(ITM_PORT_SWO, buffer, size); + + return size; +} + +} // namespace mbed + +#endif // DEVICE_ITM diff --git a/drivers/SerialWireOutput.h b/drivers/SerialWireOutput.h index 0379687c9ba..b9dfae79dfd 100644 --- a/drivers/SerialWireOutput.h +++ b/drivers/SerialWireOutput.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited + * Copyright (c) 2017-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,10 @@ #ifndef MBED_SERIALWIREOUTPUT_H #define MBED_SERIALWIREOUTPUT_H +#include "platform/platform.h" + #if defined(DEVICE_ITM) -#include "hal/itm_api.h" #include "platform/FileHandle.h" namespace mbed { @@ -29,18 +30,9 @@ class SerialWireOutput : public FileHandle { public: - SerialWireOutput(void) - { - /* Initialize ITM using internal init function. */ - mbed_itm_init(); - } - - virtual ssize_t write(const void *buffer, size_t size) - { - mbed_itm_send_block(ITM_PORT_SWO, buffer, size); + SerialWireOutput(void); - return size; - } + virtual ssize_t write(const void *buffer, size_t size); virtual ssize_t read(void *buffer, size_t size) { diff --git a/drivers/Ticker.cpp b/drivers/Ticker.cpp index b9540ec0fdd..fada56cf646 100644 --- a/drivers/Ticker.cpp +++ b/drivers/Ticker.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,9 +20,19 @@ #include "platform/FunctionPointer.h" #include "hal/ticker_api.h" #include "platform/mbed_critical.h" +#include "platform/mbed_power_mgmt.h" namespace mbed { +Ticker::Ticker() : TimerEvent(), _function(0), _lock_deepsleep(true) +{ +} + +// When low power ticker is in use, then do not disable deep sleep. +Ticker::Ticker(const ticker_data_t *data) : TimerEvent(data), _function(0), _lock_deepsleep(!data->interface->runs_in_deep_sleep) +{ +} + void Ticker::detach() { core_util_critical_section_enter(); diff --git a/drivers/Ticker.h b/drivers/Ticker.h index 8a68b4a00f6..87053b9ee88 100644 --- a/drivers/Ticker.h +++ b/drivers/Ticker.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,9 +21,7 @@ #include "platform/Callback.h" #include "platform/mbed_toolchain.h" #include "platform/NonCopyable.h" -#include "platform/mbed_power_mgmt.h" #include "hal/lp_ticker_api.h" -#include "platform/mbed_critical.h" namespace mbed { /** \addtogroup drivers */ @@ -67,14 +65,10 @@ namespace mbed { class Ticker : public TimerEvent, private NonCopyable { public: - Ticker() : TimerEvent(), _function(0), _lock_deepsleep(true) - { - } + Ticker(); // When low power ticker is in use, then do not disable deep sleep. - Ticker(const ticker_data_t *data) : TimerEvent(data), _function(0), _lock_deepsleep(!data->interface->runs_in_deep_sleep) - { - } + Ticker(const ticker_data_t *data); /** Attach a function to be called by the Ticker, specifying the interval in seconds * diff --git a/drivers/Timeout.h b/drivers/Timeout.h index c155c9bcecf..d86708cc3d7 100644 --- a/drivers/Timeout.h +++ b/drivers/Timeout.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +19,6 @@ #include "drivers/Ticker.h" #include "platform/NonCopyable.h" -#include "platform/mbed_power_mgmt.h" namespace mbed { /** \addtogroup drivers */ diff --git a/drivers/Timer.cpp b/drivers/Timer.cpp index 072581087ae..18120edd626 100644 --- a/drivers/Timer.cpp +++ b/drivers/Timer.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,6 +18,7 @@ #include "hal/ticker_api.h" #include "hal/us_ticker_api.h" #include "platform/mbed_critical.h" +#include "platform/mbed_power_mgmt.h" namespace mbed { @@ -26,8 +27,7 @@ Timer::Timer() : _running(), _start(), _time(), _ticker_data(get_us_ticker_data( reset(); } -Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker_data(data), - _lock_deepsleep(!data->interface->runs_in_deep_sleep) +Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker_data(data), _lock_deepsleep(!data->interface->runs_in_deep_sleep) { reset(); } @@ -70,11 +70,6 @@ void Timer::stop() core_util_critical_section_exit(); } -int Timer::read_us() -{ - return read_high_resolution_us(); -} - float Timer::read() { return (float)read_high_resolution_us() / 1000000.0f; @@ -112,9 +107,4 @@ void Timer::reset() core_util_critical_section_exit(); } -Timer::operator float() -{ - return read(); -} - } // namespace mbed diff --git a/drivers/Timer.h b/drivers/Timer.h index 010f6019b5f..d32b84a2089 100644 --- a/drivers/Timer.h +++ b/drivers/Timer.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,6 @@ #include "platform/platform.h" #include "hal/ticker_api.h" #include "platform/NonCopyable.h" -#include "platform/mbed_power_mgmt.h" namespace mbed { /** \addtogroup drivers */ @@ -86,11 +85,17 @@ class Timer : private NonCopyable { * * @returns Time passed in microseconds */ - int read_us(); + int read_us() + { + return read_high_resolution_us(); + } /** An operator shorthand for read() */ - operator float(); + operator float() + { + return read(); + } /** Get in a high resolution type the time passed in microseconds. * Returns a 64 bit integer. diff --git a/drivers/TimerEvent.cpp b/drivers/TimerEvent.cpp index 9c77eb86f58..a225d1fd1b1 100644 --- a/drivers/TimerEvent.cpp +++ b/drivers/TimerEvent.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +17,6 @@ #include "drivers/TimerEvent.h" #include -#include "hal/ticker_api.h" #include "hal/us_ticker_api.h" namespace mbed { @@ -27,36 +26,10 @@ TimerEvent::TimerEvent() : event(), _ticker_data(get_us_ticker_data()) ticker_set_handler(_ticker_data, (&TimerEvent::irq)); } -TimerEvent::TimerEvent(const ticker_data_t *data) : event(), _ticker_data(data) -{ - ticker_set_handler(_ticker_data, (&TimerEvent::irq)); -} - void TimerEvent::irq(uint32_t id) { TimerEvent *timer_event = (TimerEvent *)id; timer_event->handler(); } -TimerEvent::~TimerEvent() -{ - remove(); -} - -// insert in to linked list -void TimerEvent::insert(timestamp_t timestamp) -{ - ticker_insert_event(_ticker_data, &event, timestamp, (uint32_t)this); -} - -void TimerEvent::insert_absolute(us_timestamp_t timestamp) -{ - ticker_insert_event_us(_ticker_data, &event, timestamp, (uint32_t)this); -} - -void TimerEvent::remove() -{ - ticker_remove_event(_ticker_data, &event); -} - } // namespace mbed diff --git a/drivers/TimerEvent.h b/drivers/TimerEvent.h index 88f4c3b750d..0102e528911 100644 --- a/drivers/TimerEvent.h +++ b/drivers/TimerEvent.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,6 @@ #define MBED_TIMEREVENT_H #include "hal/ticker_api.h" -#include "hal/us_ticker_api.h" #include "platform/NonCopyable.h" namespace mbed { @@ -32,7 +31,12 @@ namespace mbed { class TimerEvent : private NonCopyable { public: TimerEvent(); - TimerEvent(const ticker_data_t *data); + + TimerEvent(const ticker_data_t *data) + : event(), _ticker_data(data) + { + ticker_set_handler(_ticker_data, (&TimerEvent::irq)); + } /** The handler registered with the underlying timer interrupt * @@ -42,7 +46,10 @@ class TimerEvent : private NonCopyable { /** Destruction removes it... */ - virtual ~TimerEvent(); + virtual ~TimerEvent() + { + remove(); + } #if !defined(DOXYGEN_ONLY) protected: @@ -61,7 +68,10 @@ class TimerEvent : private NonCopyable { * from the past the event is scheduled after ticker's overflow. * For reference @see convert_timestamp */ - void insert(timestamp_t timestamp); + void insert(timestamp_t timestamp) + { + ticker_insert_event(_ticker_data, &event, timestamp, (uint32_t)this); + } /** Set absolute timestamp of the internal event. * @param timestamp event's us timestamp @@ -70,11 +80,17 @@ class TimerEvent : private NonCopyable { * Do not insert more than one timestamp. * The same @a event object is used for every @a insert/insert_absolute call. */ - void insert_absolute(us_timestamp_t timestamp); + void insert_absolute(us_timestamp_t timestamp) + { + ticker_insert_event_us(_ticker_data, &event, timestamp, (uint32_t)this); + } /** Remove timestamp. */ - void remove(); + void remove() + { + ticker_remove_event(_ticker_data, &event); + } ticker_event_t event; diff --git a/drivers/UARTSerial.cpp b/drivers/UARTSerial.cpp index e9213555d76..628bc62da0a 100644 --- a/drivers/UARTSerial.cpp +++ b/drivers/UARTSerial.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2017 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,34 +28,12 @@ namespace mbed { -UARTSerial::UARTSerial(PinName tx, PinName rx, int baud) : - SerialBase(tx, rx, baud), - _blocking(true), - _tx_irq_enabled(false), - _rx_irq_enabled(false), - _tx_enabled(true), - _rx_enabled(true), - _dcd_irq(NULL) +UARTSerial::UARTSerial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud), _blocking(true), _tx_irq_enabled(false), _rx_irq_enabled(false), _tx_enabled(true), _rx_enabled(true), _dcd_irq(NULL) { /* Attatch IRQ routines to the serial device. */ enable_rx_irq(); } -UARTSerial::~UARTSerial() -{ - delete _dcd_irq; -} - -void UARTSerial::dcd_irq() -{ - wake(); -} - -void UARTSerial::set_baud(int baud) -{ - SerialBase::baud(baud); -} - void UARTSerial::set_data_carrier_detect(PinName dcd_pin, bool active_high) { delete _dcd_irq; @@ -87,26 +65,6 @@ void UARTSerial::set_flow_control(Flow type, PinName flow1, PinName flow2) } #endif -int UARTSerial::close() -{ - /* Does not let us pass a file descriptor. So how to close ? - * Also, does it make sense to close a device type file descriptor*/ - return 0; -} - -int UARTSerial::isatty() -{ - return 1; - -} - -off_t UARTSerial::seek(off_t offset, int whence) -{ - /*XXX lseek can be done theoratically, but is it sane to mark positions on a dynamically growing/shrinking - * buffer system (from an interrupt context) */ - return -ESPIPE; -} - int UARTSerial::sync() { api_lock(); @@ -279,28 +237,6 @@ short UARTSerial::poll(short events) const return revents; } -void UARTSerial::lock() -{ - // This is the override for SerialBase. - // No lock required as we only use SerialBase from interrupt or from - // inside our own critical section. -} - -void UARTSerial::unlock() -{ - // This is the override for SerialBase. -} - -void UARTSerial::api_lock(void) -{ - _mutex.lock(); -} - -void UARTSerial::api_unlock(void) -{ - _mutex.unlock(); -} - void UARTSerial::rx_irq(void) { bool was_empty = _rxbuf.empty(); diff --git a/drivers/UARTSerial.h b/drivers/UARTSerial.h index 2959ce77e2c..23cb869ca85 100644 --- a/drivers/UARTSerial.h +++ b/drivers/UARTSerial.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2017 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,6 @@ #include "SerialBase.h" #include "InterruptIn.h" #include "platform/PlatformMutex.h" -#include "hal/serial_api.h" #include "platform/CircularBuffer.h" #include "platform/NonCopyable.h" @@ -57,7 +56,10 @@ class UARTSerial : private SerialBase, public FileHandle, private NonCopyable Date: Wed, 26 Jun 2019 09:48:47 +0100 Subject: [PATCH 03/35] Deprecate `drivers/Ethernet` and `hal/ethernet_api` (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/Ethernet, and anything Ethernet-related in the “HAL” region has never been used in Mbed OS 5. Ethernet is not provided like other core things such as serial. So drivers/Ethernet.h, drivers/Ethernet.cpp and hal/ethernet_api.h, and anything referring to them is obsolete. From 5.0-5.8, Ethernet drivers were written natively as lwIP or Nanostack drivers, and attached via their native APIs. No Mbed OS APIs were involved for driver attachment. Since 5.9, Ethernet drivers are provided by a class derived from `EMAC`, and is attached to lwIP or Nanostack. The above assume Ethernet drivers that send and receive Ethernet frames, in other words it assumes it uses an on-board IP stack. If the interface has an off-board IP stack, then a custom driver needs to derive from `EthInterface` or `WifiInterface` and implement the complete socket API for them. Applications can use various degrees of abstraction by designating particular classes: * NetworkInterface - any interface type * EthInterface/WifiInterface/MeshInterface/CellularInterface – specific interface type, no particular implementation * EthernetInterface – Ethernet using on-board stack, default EMAC * EthernetInterface - Ethernet using on-board stack and particular EMAC ESP8266Interface/BG96CellularModem – Particular network interface The top couple have static “get_default_instance()” methods to locate an appropriate interface for the current target. Or applications can nominate their driver specifically using the lower forms. “EthernetInterface” is a concrete implementation of the abstract “EthInterface”, it means “Use default onboard stack with default EMAC driver, defaults selected by get_default_instance”. That’s only half an abstraction – really portable apps should be saying “EthInterface::get_default_instance” (not caring about onboard or offboard), or “NetworkInterface::get_default_instance” (not caring about Wifi or Ethernet). --- drivers/Ethernet.h | 5 +++++ hal/ethernet_api.h | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/Ethernet.h b/drivers/Ethernet.h index 30618806e52..4f23c093cb1 100644 --- a/drivers/Ethernet.h +++ b/drivers/Ethernet.h @@ -56,6 +56,11 @@ namespace mbed { * @endcode * @ingroup drivers */ +MBED_DEPRECATED( + "EthInterface is now the preferred way to get an Ethernet object.", + "Alternatively, use NetworkInterface to get an instance of an appropriate network" + "interface (WiFi or Ethernet)." +) class Ethernet : private NonCopyable { public: diff --git a/hal/ethernet_api.h b/hal/ethernet_api.h index 1a14fda06e7..442f1ea47eb 100644 --- a/hal/ethernet_api.h +++ b/hal/ethernet_api.h @@ -29,32 +29,67 @@ extern "C" { #endif // Connection constants - +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) int ethernet_init(void); +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) void ethernet_free(void); // write size bytes from data to ethernet buffer // return num bytes written // or -1 if size is too big +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) int ethernet_write(const char *data, int size); // send ethernet write buffer, returning the packet size sent +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) int ethernet_send(void); // receive from ethernet buffer, returning packet size, or 0 if no packet +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) int ethernet_receive(void); // read size bytes in to data, return actual num bytes read (0..size) // if data == NULL, throw the bytes away +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) int ethernet_read(char *data, int size); // get the ethernet address +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) void ethernet_address(char *mac); // see if the link is up +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) int ethernet_link(void); // force link settings +MBED_DEPRECATED( + "Ethernet drivers are provided by a class derived from `EMAC` attached to" + " either lwIP or Nanostack." +) void ethernet_set_link(int speed, int duplex); #ifdef __cplusplus From b15930c86d2b451b5b324b79170b25b92f26e6a6 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Thu, 27 Jun 2019 12:00:36 +0100 Subject: [PATCH 04/35] Separate drivers internal APIs from public APIs (#5) * Move source files and internal headers to `internal` dir * Amend test files and other modules include paths for internal headers * Add Doxygen comments for documenting internal and public drivers APIs * Remove incorrectly grouped Devicekey from the drivers Doxygen group and add to the newly created `Device Key` group. --- TESTS/mbed_drivers/timerevent/main.cpp | 2 +- UNITTESTS/stubs/SerialBase_stub.cpp | 2 +- drivers/AnalogIn.h | 13 +++++++++++-- drivers/AnalogOut.h | 12 ++++++++++-- drivers/BusIn.h | 12 ++++++++++-- drivers/BusInOut.h | 12 ++++++++++-- drivers/BusOut.h | 12 ++++++++++-- drivers/CAN.h | 20 +++++++++++++++++--- drivers/DigitalIn.h | 12 ++++++++++-- drivers/DigitalInOut.h | 12 ++++++++++-- drivers/DigitalOut.h | 12 ++++++++++-- drivers/Ethernet.h | 12 ++++++++++-- drivers/FlashIAP.h | 12 ++++++++++-- drivers/I2C.h | 12 ++++++++++-- drivers/I2CSlave.h | 12 ++++++++++-- drivers/InterruptIn.h | 12 ++++++++++-- drivers/InterruptManager.h | 12 ++++++++++-- drivers/LowPowerTicker.h | 12 ++++++++++-- drivers/LowPowerTimeout.h | 14 +++++++++++--- drivers/LowPowerTimer.h | 12 ++++++++++-- drivers/MbedCRC.h | 12 +++++++++--- drivers/PortIn.h | 12 ++++++++++-- drivers/PortInOut.h | 12 ++++++++++-- drivers/PortOut.h | 12 ++++++++++-- drivers/PwmOut.h | 12 ++++++++++-- drivers/QSPI.h | 12 ++++++++++-- drivers/RawSerial.h | 14 +++++++++++--- drivers/SPI.h | 12 ++++++++++-- drivers/SPISlave.h | 12 ++++++++++-- drivers/Serial.h | 14 +++++++++++--- drivers/SerialWireOutput.h | 10 ++++++++++ drivers/Ticker.h | 14 +++++++++++--- drivers/Timeout.h | 12 ++++++++++-- drivers/Timer.h | 12 ++++++++++-- drivers/UARTSerial.h | 15 ++++++++++++--- drivers/{ => internal}/AnalogIn.cpp | 0 drivers/{ => internal}/AnalogOut.cpp | 0 drivers/{ => internal}/BusIn.cpp | 0 drivers/{ => internal}/BusInOut.cpp | 0 drivers/{ => internal}/BusOut.cpp | 0 drivers/{ => internal}/CAN.cpp | 0 drivers/{ => internal}/DigitalIn.cpp | 0 drivers/{ => internal}/DigitalInOut.cpp | 0 drivers/{ => internal}/DigitalOut.cpp | 0 drivers/{ => internal}/Ethernet.cpp | 0 drivers/{ => internal}/FlashIAP.cpp | 0 drivers/{ => internal}/I2C.cpp | 0 drivers/{ => internal}/I2CSlave.cpp | 0 drivers/{ => internal}/InterruptIn.cpp | 0 drivers/{ => internal}/InterruptManager.cpp | 0 drivers/{ => internal}/MbedCRC.cpp | 4 ---- drivers/{ => internal}/PortIn.cpp | 0 drivers/{ => internal}/PortInOut.cpp | 0 drivers/{ => internal}/PortOut.cpp | 0 drivers/{ => internal}/PwmOut.cpp | 0 drivers/{ => internal}/QSPI.cpp | 0 drivers/{ => internal}/RawSerial.cpp | 0 drivers/{ => internal}/SPI.cpp | 0 drivers/{ => internal}/SPISlave.cpp | 0 drivers/{ => internal}/Serial.cpp | 0 drivers/{ => internal}/SerialBase.cpp | 2 +- drivers/{ => internal}/SerialBase.h | 13 +++++++++++-- drivers/{ => internal}/SerialWireOutput.cpp | 0 drivers/{ => internal}/TableCRC.cpp | 6 +----- drivers/{ => internal}/TableCRC.h | 4 +++- drivers/{ => internal}/Ticker.cpp | 2 +- drivers/{ => internal}/Timeout.cpp | 0 drivers/{ => internal}/Timer.cpp | 0 drivers/{ => internal}/TimerEvent.cpp | 2 +- drivers/{ => internal}/TimerEvent.h | 12 ++++++++++-- drivers/{ => internal}/UARTSerial.cpp | 0 features/device_key/source/DeviceKey.h | 4 ++-- rtos/TARGET_CORTEX/SysTimer.h | 4 ++-- rtos/TARGET_CORTEX/mbed_rtx_idle.cpp | 4 ++-- 74 files changed, 379 insertions(+), 96 deletions(-) rename drivers/{ => internal}/AnalogIn.cpp (100%) rename drivers/{ => internal}/AnalogOut.cpp (100%) rename drivers/{ => internal}/BusIn.cpp (100%) rename drivers/{ => internal}/BusInOut.cpp (100%) rename drivers/{ => internal}/BusOut.cpp (100%) rename drivers/{ => internal}/CAN.cpp (100%) rename drivers/{ => internal}/DigitalIn.cpp (100%) rename drivers/{ => internal}/DigitalInOut.cpp (100%) rename drivers/{ => internal}/DigitalOut.cpp (100%) rename drivers/{ => internal}/Ethernet.cpp (100%) rename drivers/{ => internal}/FlashIAP.cpp (100%) rename drivers/{ => internal}/I2C.cpp (100%) rename drivers/{ => internal}/I2CSlave.cpp (100%) rename drivers/{ => internal}/InterruptIn.cpp (100%) rename drivers/{ => internal}/InterruptManager.cpp (100%) rename drivers/{ => internal}/MbedCRC.cpp (97%) rename drivers/{ => internal}/PortIn.cpp (100%) rename drivers/{ => internal}/PortInOut.cpp (100%) rename drivers/{ => internal}/PortOut.cpp (100%) rename drivers/{ => internal}/PwmOut.cpp (100%) rename drivers/{ => internal}/QSPI.cpp (100%) rename drivers/{ => internal}/RawSerial.cpp (100%) rename drivers/{ => internal}/SPI.cpp (100%) rename drivers/{ => internal}/SPISlave.cpp (100%) rename drivers/{ => internal}/Serial.cpp (100%) rename drivers/{ => internal}/SerialBase.cpp (99%) rename drivers/{ => internal}/SerialBase.h (98%) rename drivers/{ => internal}/SerialWireOutput.cpp (100%) rename drivers/{ => internal}/TableCRC.cpp (99%) rename drivers/{ => internal}/TableCRC.h (94%) rename drivers/{ => internal}/Ticker.cpp (98%) rename drivers/{ => internal}/Timeout.cpp (100%) rename drivers/{ => internal}/Timer.cpp (100%) rename drivers/{ => internal}/TimerEvent.cpp (96%) rename drivers/{ => internal}/TimerEvent.h (94%) rename drivers/{ => internal}/UARTSerial.cpp (100%) diff --git a/TESTS/mbed_drivers/timerevent/main.cpp b/TESTS/mbed_drivers/timerevent/main.cpp index 7228b8bb16e..b02a441db79 100644 --- a/TESTS/mbed_drivers/timerevent/main.cpp +++ b/TESTS/mbed_drivers/timerevent/main.cpp @@ -21,7 +21,7 @@ #include "greentea-client/test_env.h" #include "unity.h" #include "utest.h" -#include "drivers/TimerEvent.h" +#include "drivers/internal/TimerEvent.h" #include "hal/ticker_api.h" #include "rtos.h" diff --git a/UNITTESTS/stubs/SerialBase_stub.cpp b/UNITTESTS/stubs/SerialBase_stub.cpp index e156d8f4802..740972e101f 100644 --- a/UNITTESTS/stubs/SerialBase_stub.cpp +++ b/UNITTESTS/stubs/SerialBase_stub.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "SerialBase.h" +#include "drivers/internal/SerialBase.h" namespace mbed { diff --git a/drivers/AnalogIn.h b/drivers/AnalogIn.h index 633b3b0b4e3..8b217bb4d1a 100644 --- a/drivers/AnalogIn.h +++ b/drivers/AnalogIn.h @@ -26,7 +26,13 @@ #include "platform/PlatformMutex.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api Public API */ +/** @{*/ +/** + * \defgroup drivers_AnalogIn AnalogIn class + * @{ + */ /** An analog input, used for reading the voltage on a pin * @@ -48,7 +54,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class AnalogIn { @@ -111,8 +116,12 @@ class AnalogIn { analogin_t _adc; static SingletonPtr _mutex; #endif //!defined(DOXYGEN_ONLY) + }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/AnalogOut.h b/drivers/AnalogOut.h index ec75c7a333b..15aa3791c13 100644 --- a/drivers/AnalogOut.h +++ b/drivers/AnalogOut.h @@ -25,7 +25,13 @@ #include "platform/PlatformMutex.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_AnalogOut AnalogOut class + * @{ + */ /** An analog output, used for setting the voltage on a pin * @@ -48,7 +54,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class AnalogOut { @@ -131,6 +136,9 @@ class AnalogOut { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/BusIn.h b/drivers/BusIn.h index 61bf7b536e3..85d9c9256da 100644 --- a/drivers/BusIn.h +++ b/drivers/BusIn.h @@ -23,12 +23,17 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_BusIn BusIn class + * @{ + */ /** A digital input bus, used for reading the state of a collection of pins * * @note Synchronization level: Thread safe - * @ingroup drivers */ class BusIn : private NonCopyable { @@ -125,6 +130,9 @@ class BusIn : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/BusInOut.h b/drivers/BusInOut.h index 618f9b8cf3b..d2470874e29 100644 --- a/drivers/BusInOut.h +++ b/drivers/BusInOut.h @@ -22,7 +22,13 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_BusInOut BusInOut class + * @{ + */ /** A digital input output bus, used for setting the state of a collection of pins. * Implemented as an array of DigitalInOut pins, the bus can be constructed by any @@ -30,7 +36,6 @@ namespace mbed { * capabilities * * @note Synchronization level: Thread safe - * @ingroup drivers */ class BusInOut : private NonCopyable { @@ -147,6 +152,9 @@ class BusInOut : private NonCopyable { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/BusOut.h b/drivers/BusOut.h index ca83d00a17a..cbd58ed1983 100644 --- a/drivers/BusOut.h +++ b/drivers/BusOut.h @@ -22,10 +22,15 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_BusOut BusOut class + * @{ + */ /** A digital output bus, used for setting the state of a collection of pins - * @ingroup drivers */ class BusOut : private NonCopyable { @@ -125,6 +130,9 @@ class BusOut : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/CAN.h b/drivers/CAN.h index 05cb1ec2529..8e9cc11ed34 100644 --- a/drivers/CAN.h +++ b/drivers/CAN.h @@ -27,12 +27,17 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_CANMessage CANMessage class + * @{ + */ /** CANMessage class * * @note Synchronization level: Thread safe - * @ingroup drivers */ class CANMessage : public CAN_Message { @@ -70,8 +75,14 @@ class CANMessage : public CAN_Message { CANMessage(unsigned int _id, CANFormat _format = CANStandard); }; +/** @}*/ + +/** + * \defgroup drivers_CAN CAN class + * @{ + */ + /** A can bus client, used for communicating with can devices - * @ingroup drivers */ class CAN : private NonCopyable { @@ -300,6 +311,9 @@ class CAN : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/DigitalIn.h b/drivers/DigitalIn.h index b2406ea8e78..ae2bf52df46 100644 --- a/drivers/DigitalIn.h +++ b/drivers/DigitalIn.h @@ -22,7 +22,13 @@ #include "hal/gpio_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_DigitalIn DigitalIn class + * @{ + */ /** A digital input, used for reading the state of a pin * @@ -46,7 +52,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class DigitalIn { @@ -122,6 +127,9 @@ class DigitalIn { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/DigitalInOut.h b/drivers/DigitalInOut.h index c21253bf89f..6897768704f 100644 --- a/drivers/DigitalInOut.h +++ b/drivers/DigitalInOut.h @@ -22,12 +22,17 @@ #include "hal/gpio_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_DigitalInOut DigitalInOut class + * @{ + */ /** A digital input/output, used for setting or reading a bi-directional pin * * @note Synchronization level: Interrupt safe - * @ingroup drivers */ class DigitalInOut { @@ -144,6 +149,9 @@ class DigitalInOut { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/DigitalOut.h b/drivers/DigitalOut.h index 41ba5c5460e..bc1c44de947 100644 --- a/drivers/DigitalOut.h +++ b/drivers/DigitalOut.h @@ -21,7 +21,13 @@ #include "hal/gpio_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_DigitalOut DigitalOut class + * @{ + */ /** A digital output, used for setting the state of a pin * @@ -41,7 +47,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class DigitalOut { @@ -138,6 +143,9 @@ class DigitalOut { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/Ethernet.h b/drivers/Ethernet.h index 4f23c093cb1..6bc85e9c242 100644 --- a/drivers/Ethernet.h +++ b/drivers/Ethernet.h @@ -23,7 +23,13 @@ #if DEVICE_ETHERNET || defined(DOXYGEN_ONLY) namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_Ethernet Ethernet class + * @{ + */ /** An ethernet interface, to use with the ethernet pins. * @@ -54,7 +60,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ MBED_DEPRECATED( "EthInterface is now the preferred way to get an Ethernet object.", @@ -175,6 +180,9 @@ class Ethernet : private NonCopyable { void set_link(Mode mode); }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/FlashIAP.h b/drivers/FlashIAP.h index 47c9fc6939a..f2ab7f1dc6f 100644 --- a/drivers/FlashIAP.h +++ b/drivers/FlashIAP.h @@ -49,12 +49,17 @@ extern uint32_t Load$$LR$$LR_IROM1$$Limit[]; namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_FlashIAP FlashIAP class + * @{ + */ /** Flash IAP driver. It invokes flash HAL functions. * * @note Synchronization level: Thread safe - * @ingroup drivers */ class FlashIAP : private NonCopyable { public: @@ -181,6 +186,9 @@ class FlashIAP : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } /* namespace mbed */ #endif /* DEVICE_FLASH */ diff --git a/drivers/I2C.h b/drivers/I2C.h index 97ca24536bd..1aa2d894c37 100644 --- a/drivers/I2C.h +++ b/drivers/I2C.h @@ -34,7 +34,13 @@ #endif namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_I2C I2C class + * @{ + */ /** An I2C Master, used for communicating with I2C slave devices * @@ -70,7 +76,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class I2C : private NonCopyable { @@ -248,6 +253,9 @@ class I2C : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/I2CSlave.h b/drivers/I2CSlave.h index 529b5bc433f..e270e3a342d 100644 --- a/drivers/I2CSlave.h +++ b/drivers/I2CSlave.h @@ -24,7 +24,13 @@ #include "hal/i2c_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_I2CSlave I2CSlave class + * @{ + */ /** An I2C Slave, used for communicating with an I2C Master device. * @@ -64,7 +70,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class I2CSlave { @@ -181,6 +186,9 @@ class I2CSlave { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/InterruptIn.h b/drivers/InterruptIn.h index 991cc0b811b..4b9a4dbdc11 100644 --- a/drivers/InterruptIn.h +++ b/drivers/InterruptIn.h @@ -29,7 +29,13 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_InterruptIn InterruptIn class + * @{ + */ /** A digital interrupt input, used to call a function on a rising or falling edge * @@ -57,7 +63,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class InterruptIn : private NonCopyable { @@ -190,6 +195,9 @@ class InterruptIn : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/InterruptManager.h b/drivers/InterruptManager.h index 85463aad9d2..612c5980d67 100644 --- a/drivers/InterruptManager.h +++ b/drivers/InterruptManager.h @@ -24,7 +24,13 @@ #include namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_InterruptManager InterruptManager class + * @{ + */ /** Use this singleton if you need to chain interrupt handlers. * @deprecated Do not use this class. This class is not part of the public API of mbed-os and is being removed in the future. @@ -54,7 +60,6 @@ namespace mbed { * InterruptManager::get()->add_handler(handler, TIMER3_IRQn); * } * @endcode - * @ingroup drivers */ class InterruptManager : private NonCopyable { public: @@ -226,6 +231,9 @@ class InterruptManager : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/LowPowerTicker.h b/drivers/LowPowerTicker.h index a6f9fa94011..1c616a457b3 100644 --- a/drivers/LowPowerTicker.h +++ b/drivers/LowPowerTicker.h @@ -26,12 +26,17 @@ #include "hal/lp_ticker_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_LowPowerTicker LowPowerTicker class + * @{ + */ /** Low Power Ticker * * @note Synchronization level: Interrupt safe - * @ingroup drivers */ class LowPowerTicker : public Ticker, private NonCopyable { @@ -45,6 +50,9 @@ class LowPowerTicker : public Ticker, private NonCopyable { } }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/LowPowerTimeout.h b/drivers/LowPowerTimeout.h index 7198d7dc64c..e678809c0f4 100644 --- a/drivers/LowPowerTimeout.h +++ b/drivers/LowPowerTimeout.h @@ -26,12 +26,17 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_LowPowerTimeout LowPowerTimeout class + * @{ + */ /** Low Power Timout * * @note Synchronization level: Interrupt safe - * @ingroup drivers */ class LowPowerTimeout : public LowPowerTicker, private NonCopyable { #if !defined(DOXYGEN_ONLY) @@ -43,7 +48,10 @@ class LowPowerTimeout : public LowPowerTicker, private NonCopyable { @@ -42,6 +47,9 @@ class LowPowerTimer : public Timer, private NonCopyable { }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/MbedCRC.h b/drivers/MbedCRC.h index c0726a92b9f..1d666da445d 100644 --- a/drivers/MbedCRC.h +++ b/drivers/MbedCRC.h @@ -17,7 +17,7 @@ #ifndef MBED_CRC_API_H #define MBED_CRC_API_H -#include "drivers/TableCRC.h" +#include "drivers/internal/TableCRC.h" #include "hal/crc_api.h" #include "platform/mbed_assert.h" #include "platform/SingletonPtr.h" @@ -40,8 +40,13 @@ but we check for ( width < 8) before performing shift, so it should not be an is #endif namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ /** @{*/ +/** + * \defgroup drivers_MbedCRC MbedCRC class + * @{ + */ extern SingletonPtr mbed_crc_mutex; @@ -101,7 +106,6 @@ extern SingletonPtr mbed_crc_mutex; * return 0; * } * @endcode - * @ingroup drivers */ template class MbedCRC { @@ -565,6 +569,8 @@ class MbedCRC { #endif /** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/PortIn.h b/drivers/PortIn.h index d3fb7192429..bf77d70e3f5 100644 --- a/drivers/PortIn.h +++ b/drivers/PortIn.h @@ -24,7 +24,13 @@ #include "hal/port_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_PortIn PortIn class + * @{ + */ /** A multiple pin digital input * @@ -50,7 +56,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class PortIn { public: @@ -89,6 +94,9 @@ class PortIn { port_t _port; }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/PortInOut.h b/drivers/PortInOut.h index e725fa003f8..f17a6e55614 100644 --- a/drivers/PortInOut.h +++ b/drivers/PortInOut.h @@ -24,12 +24,17 @@ #include "hal/port_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_PortInOut PortInOut class + * @{ + */ /** A multiple pin digital in/out used to set/read multiple bi-directional pins * * @note Synchronization level: Interrupt safe - * @ingroup drivers */ class PortInOut { public: @@ -96,6 +101,9 @@ class PortInOut { port_t _port; }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/PortOut.h b/drivers/PortOut.h index 609c229e0de..1ce20e7424e 100644 --- a/drivers/PortOut.h +++ b/drivers/PortOut.h @@ -24,7 +24,13 @@ #include "hal/port_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_PortOut PortOut class + * @{ + */ /** A multiple pin digital output * * @note Synchronization level: Interrupt safe @@ -49,7 +55,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class PortOut { public: @@ -102,6 +107,9 @@ class PortOut { port_t _port; }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/PwmOut.h b/drivers/PwmOut.h index 7803eda61f9..d1221fb67c4 100644 --- a/drivers/PwmOut.h +++ b/drivers/PwmOut.h @@ -23,7 +23,13 @@ #include "hal/pwmout_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_PwmOut PwmOut class + * @{ + */ /** A pulse-width modulation digital output * @@ -46,7 +52,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class PwmOut { @@ -147,6 +152,9 @@ class PwmOut { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/QSPI.h b/drivers/QSPI.h index 1c6b7e743d6..42fcfa9b8b7 100644 --- a/drivers/QSPI.h +++ b/drivers/QSPI.h @@ -30,7 +30,13 @@ namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_QSPI QSPI class + * @{ + */ /** A QSPI Driver, used for communicating with QSPI slave devices * @@ -69,7 +75,6 @@ namespace mbed { * * } * @endcode - * @ingroup drivers */ class QSPI : private NonCopyable { @@ -231,6 +236,9 @@ class QSPI : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/RawSerial.h b/drivers/RawSerial.h index 215c271388c..d1100887de8 100644 --- a/drivers/RawSerial.h +++ b/drivers/RawSerial.h @@ -22,12 +22,18 @@ #if DEVICE_SERIAL || defined(DOXYGEN_ONLY) #include "mbed_toolchain.h" -#include "drivers/SerialBase.h" +#include "drivers/internal/SerialBase.h" #include "platform/NonCopyable.h" #include namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_RawSerial RawSerial class + * @{ + */ /** A serial port (UART) for communication with other serial devices * This is a variation of the Serial class that doesn't use streams, @@ -50,7 +56,6 @@ namespace mbed { * pc.putc('A'); * } * @endcode - * @ingroup drivers */ class RawSerial: public SerialBase, private NonCopyable { @@ -113,6 +118,9 @@ class RawSerial: public SerialBase, private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/SPI.h b/drivers/SPI.h index ebb95f46098..7ac4a44ae2e 100644 --- a/drivers/SPI.h +++ b/drivers/SPI.h @@ -45,7 +45,13 @@ #endif namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_SPI SPI class + * @{ + */ struct use_gpio_ssel_t { }; const use_gpio_ssel_t use_gpio_ssel; @@ -90,7 +96,6 @@ const use_gpio_ssel_t use_gpio_ssel; * device.unlock(); * } * @endcode - * @ingroup drivers */ class SPI : private NonCopyable { @@ -463,6 +468,9 @@ class SPI : private NonCopyable { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif // DEVICE_SPI || DOXYGEN_ONLY diff --git a/drivers/SPISlave.h b/drivers/SPISlave.h index 72ebf0dcdd9..411e2b380fd 100644 --- a/drivers/SPISlave.h +++ b/drivers/SPISlave.h @@ -25,7 +25,13 @@ #include "hal/spi_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_SPISlave SPISlave class + * @{ + */ /** A SPI slave, used for communicating with a SPI master device. * @@ -51,7 +57,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class SPISlave : private NonCopyable { @@ -136,6 +141,9 @@ class SPISlave : private NonCopyable { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/Serial.h b/drivers/Serial.h index b6cf4d4b17e..e5d272ec8b0 100644 --- a/drivers/Serial.h +++ b/drivers/Serial.h @@ -22,12 +22,18 @@ #if DEVICE_SERIAL || defined(DOXYGEN_ONLY) #include "platform/Stream.h" -#include "SerialBase.h" +#include "drivers/internal/SerialBase.h" #include "platform/PlatformMutex.h" #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_Serial Serial class + * @{ + */ /** A serial port (UART) for communication with other serial devices * @@ -48,7 +54,6 @@ namespace mbed { * pc.printf("Hello World\n"); * } * @endcode - * @ingroup drivers */ class Serial : public SerialBase, public Stream, private NonCopyable { @@ -129,6 +134,9 @@ class Serial : public SerialBase, public Stream, private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/SerialWireOutput.h b/drivers/SerialWireOutput.h index b9dfae79dfd..a446e37ff2d 100644 --- a/drivers/SerialWireOutput.h +++ b/drivers/SerialWireOutput.h @@ -25,6 +25,13 @@ #include "platform/FileHandle.h" namespace mbed { +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_SerialWireOutput SerialWireOutput class + * @{ + */ class SerialWireOutput : public FileHandle { @@ -64,6 +71,9 @@ class SerialWireOutput : public FileHandle { } }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif // DEVICE_ITM diff --git a/drivers/Ticker.h b/drivers/Ticker.h index 87053b9ee88..395e0cf2e6b 100644 --- a/drivers/Ticker.h +++ b/drivers/Ticker.h @@ -17,14 +17,20 @@ #ifndef MBED_TICKER_H #define MBED_TICKER_H -#include "drivers/TimerEvent.h" +#include "drivers/internal/TimerEvent.h" #include "platform/Callback.h" #include "platform/mbed_toolchain.h" #include "platform/NonCopyable.h" #include "hal/lp_ticker_api.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_Ticker Ticker class + * @{ + */ /** A Ticker is used to call a function at a recurring interval * @@ -60,7 +66,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class Ticker : public TimerEvent, private NonCopyable { @@ -149,6 +154,9 @@ class Ticker : public TimerEvent, private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/Timeout.h b/drivers/Timeout.h index d86708cc3d7..673554f2341 100644 --- a/drivers/Timeout.h +++ b/drivers/Timeout.h @@ -21,7 +21,13 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_Timeout Timeout class + * @{ + */ /** A Timeout is used to call a function at a point in the future * @@ -52,7 +58,6 @@ namespace mbed { * } * } * @endcode - * @ingroup drivers */ class Timeout : public Ticker, private NonCopyable { @@ -62,6 +67,9 @@ class Timeout : public Ticker, private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/Timer.h b/drivers/Timer.h index d32b84a2089..4fd2007dccc 100644 --- a/drivers/Timer.h +++ b/drivers/Timer.h @@ -22,7 +22,13 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_Timer Timer class + * @{ + */ /** A general purpose timer * @@ -46,7 +52,6 @@ namespace mbed { * printf("Toggle the led takes %d us", end - begin); * } * @endcode - * @ingroup drivers */ class Timer : private NonCopyable { @@ -113,6 +118,9 @@ class Timer : private NonCopyable { }; #endif +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/UARTSerial.h b/drivers/UARTSerial.h index 23cb869ca85..e9bbb418b25 100644 --- a/drivers/UARTSerial.h +++ b/drivers/UARTSerial.h @@ -23,7 +23,7 @@ #if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #include "platform/FileHandle.h" -#include "SerialBase.h" +#include "drivers/internal/SerialBase.h" #include "InterruptIn.h" #include "platform/PlatformMutex.h" #include "platform/CircularBuffer.h" @@ -39,11 +39,16 @@ namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ +/** + * \defgroup drivers_UARTSerial UARTSerial class + * @{ + */ /** Class providing buffered UART communication functionality using separate circular buffer for send and receive channels * - * @ingroup drivers */ class UARTSerial : private SerialBase, public FileHandle, private NonCopyable { @@ -349,6 +354,10 @@ class UARTSerial : private SerialBase, public FileHandle, private NonCopyable mbed_crc_mutex; @@ -74,6 +72,4 @@ MbedCRC::MbedCRC(): mbed_crc_ctor(); } -/** @}*/ } // namespace mbed - diff --git a/drivers/PortIn.cpp b/drivers/internal/PortIn.cpp similarity index 100% rename from drivers/PortIn.cpp rename to drivers/internal/PortIn.cpp diff --git a/drivers/PortInOut.cpp b/drivers/internal/PortInOut.cpp similarity index 100% rename from drivers/PortInOut.cpp rename to drivers/internal/PortInOut.cpp diff --git a/drivers/PortOut.cpp b/drivers/internal/PortOut.cpp similarity index 100% rename from drivers/PortOut.cpp rename to drivers/internal/PortOut.cpp diff --git a/drivers/PwmOut.cpp b/drivers/internal/PwmOut.cpp similarity index 100% rename from drivers/PwmOut.cpp rename to drivers/internal/PwmOut.cpp diff --git a/drivers/QSPI.cpp b/drivers/internal/QSPI.cpp similarity index 100% rename from drivers/QSPI.cpp rename to drivers/internal/QSPI.cpp diff --git a/drivers/RawSerial.cpp b/drivers/internal/RawSerial.cpp similarity index 100% rename from drivers/RawSerial.cpp rename to drivers/internal/RawSerial.cpp diff --git a/drivers/SPI.cpp b/drivers/internal/SPI.cpp similarity index 100% rename from drivers/SPI.cpp rename to drivers/internal/SPI.cpp diff --git a/drivers/SPISlave.cpp b/drivers/internal/SPISlave.cpp similarity index 100% rename from drivers/SPISlave.cpp rename to drivers/internal/SPISlave.cpp diff --git a/drivers/Serial.cpp b/drivers/internal/Serial.cpp similarity index 100% rename from drivers/Serial.cpp rename to drivers/internal/Serial.cpp diff --git a/drivers/SerialBase.cpp b/drivers/internal/SerialBase.cpp similarity index 99% rename from drivers/SerialBase.cpp rename to drivers/internal/SerialBase.cpp index 09372d71dc0..ddf13bc292e 100644 --- a/drivers/SerialBase.cpp +++ b/drivers/internal/SerialBase.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "drivers/SerialBase.h" +#include "drivers/internal/SerialBase.h" #include "platform/mbed_wait_api.h" #include "platform/mbed_critical.h" #include "platform/mbed_power_mgmt.h" diff --git a/drivers/SerialBase.h b/drivers/internal/SerialBase.h similarity index 98% rename from drivers/SerialBase.h rename to drivers/internal/SerialBase.h index 5d081d680ea..a8af60a9bf9 100644 --- a/drivers/SerialBase.h +++ b/drivers/internal/SerialBase.h @@ -32,13 +32,19 @@ #endif namespace mbed { -/** \addtogroup drivers */ +/** \defgroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-internal-api Internal API */ +/** @{*/ +/** + * \defgroup drivers_SerialBase SerialBase class + * @{ + */ /** A base class for serial port implementations * Can't be instantiated directly (use Serial or RawSerial) * * @note Synchronization level: Set by subclass - * @ingroup drivers */ class SerialBase : private NonCopyable { @@ -318,6 +324,9 @@ class SerialBase : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/SerialWireOutput.cpp b/drivers/internal/SerialWireOutput.cpp similarity index 100% rename from drivers/SerialWireOutput.cpp rename to drivers/internal/SerialWireOutput.cpp diff --git a/drivers/TableCRC.cpp b/drivers/internal/TableCRC.cpp similarity index 99% rename from drivers/TableCRC.cpp rename to drivers/internal/TableCRC.cpp index b0d316e4719..6cea67d94a3 100644 --- a/drivers/TableCRC.cpp +++ b/drivers/internal/TableCRC.cpp @@ -16,11 +16,9 @@ */ #include -#include "drivers/TableCRC.h" +#include "drivers/internal/TableCRC.h" namespace mbed { -/** \addtogroup drivers */ -/** @{*/ extern const uint8_t Table_CRC_7Bit_SD[MBED_CRC_TABLE_SIZE] = { 0x0, 0x12, 0x24, 0x36, 0x48, 0x5a, 0x6c, 0x7e, 0x90, 0x82, 0xb4, 0xa6, 0xd8, 0xca, 0xfc, 0xee, @@ -151,6 +149,4 @@ extern const uint32_t Table_CRC_32bit_Rev_ANSI[MBED_OPTIMIZED_CRC_TABLE_SIZE] = 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c }; - -/** @}*/ } // namespace mbed diff --git a/drivers/TableCRC.h b/drivers/internal/TableCRC.h similarity index 94% rename from drivers/TableCRC.h rename to drivers/internal/TableCRC.h index 1ab5bf83656..15e460cb616 100644 --- a/drivers/TableCRC.h +++ b/drivers/internal/TableCRC.h @@ -21,7 +21,8 @@ #include namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-internal-api Internal API */ /** @{*/ #define MBED_CRC_TABLE_SIZE 256 @@ -35,6 +36,7 @@ extern const uint32_t Table_CRC_32bit_ANSI[MBED_CRC_TABLE_SIZE]; extern const uint32_t Table_CRC_32bit_Rev_ANSI[MBED_OPTIMIZED_CRC_TABLE_SIZE]; /** @}*/ + } // namespace mbed #endif diff --git a/drivers/Ticker.cpp b/drivers/internal/Ticker.cpp similarity index 98% rename from drivers/Ticker.cpp rename to drivers/internal/Ticker.cpp index fada56cf646..15098f9c96d 100644 --- a/drivers/Ticker.cpp +++ b/drivers/internal/Ticker.cpp @@ -16,7 +16,7 @@ */ #include "drivers/Ticker.h" -#include "drivers/TimerEvent.h" +#include "drivers/internal/TimerEvent.h" #include "platform/FunctionPointer.h" #include "hal/ticker_api.h" #include "platform/mbed_critical.h" diff --git a/drivers/Timeout.cpp b/drivers/internal/Timeout.cpp similarity index 100% rename from drivers/Timeout.cpp rename to drivers/internal/Timeout.cpp diff --git a/drivers/Timer.cpp b/drivers/internal/Timer.cpp similarity index 100% rename from drivers/Timer.cpp rename to drivers/internal/Timer.cpp diff --git a/drivers/TimerEvent.cpp b/drivers/internal/TimerEvent.cpp similarity index 96% rename from drivers/TimerEvent.cpp rename to drivers/internal/TimerEvent.cpp index a225d1fd1b1..d93e74790b7 100644 --- a/drivers/TimerEvent.cpp +++ b/drivers/internal/TimerEvent.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "drivers/TimerEvent.h" +#include "drivers/internal/TimerEvent.h" #include #include "hal/us_ticker_api.h" diff --git a/drivers/TimerEvent.h b/drivers/internal/TimerEvent.h similarity index 94% rename from drivers/TimerEvent.h rename to drivers/internal/TimerEvent.h index 0102e528911..df0056a0c06 100644 --- a/drivers/TimerEvent.h +++ b/drivers/internal/TimerEvent.h @@ -21,12 +21,17 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-internal-api Internal API */ +/** @{*/ +/** + * \defgroup drivers_TimerEvent TimerEvent class + * @{ + */ /** Base abstraction for timer interrupts * * @note Synchronization level: Interrupt safe - * @ingroup drivers */ class TimerEvent : private NonCopyable { public: @@ -98,6 +103,9 @@ class TimerEvent : private NonCopyable { #endif }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif diff --git a/drivers/UARTSerial.cpp b/drivers/internal/UARTSerial.cpp similarity index 100% rename from drivers/UARTSerial.cpp rename to drivers/internal/UARTSerial.cpp diff --git a/features/device_key/source/DeviceKey.h b/features/device_key/source/DeviceKey.h index 6ca024127e6..861d1592a0c 100644 --- a/features/device_key/source/DeviceKey.h +++ b/features/device_key/source/DeviceKey.h @@ -32,7 +32,7 @@ #if (DEVICEKEY_ENABLED) || defined(DOXYGEN_ONLY) namespace mbed { -/** \addtogroup drivers */ +/** \addtogroup device-key Device Key */ #define DEVICE_KEY_16BYTE 16 #define DEVICE_KEY_32BYTE 32 @@ -56,7 +56,7 @@ enum DeviceKeyStatus { /** Use this singleton if you need to derive a new key from the device root of trust. * * @note Synchronization level: Thread safe - * @ingroup drivers + * @ingroup device-key */ class DeviceKey : private mbed::NonCopyable { diff --git a/rtos/TARGET_CORTEX/SysTimer.h b/rtos/TARGET_CORTEX/SysTimer.h index 6561e647010..223bf7efc9e 100644 --- a/rtos/TARGET_CORTEX/SysTimer.h +++ b/rtos/TARGET_CORTEX/SysTimer.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ #if MBED_TICKLESS || defined(DOXYGEN_ONLY) #include "platform/NonCopyable.h" -#include "drivers/TimerEvent.h" +#include "drivers/internal/TimerEvent.h" namespace rtos { namespace internal { diff --git a/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp b/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp index d0fa77af2be..f6d0a1e8bf7 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp +++ b/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ #include "rtos/internal/rtos_idle.h" #include "platform/mbed_power_mgmt.h" -#include "TimerEvent.h" +#include "drivers/internal/TimerEvent.h" #include "lp_ticker_api.h" #include "us_ticker_api.h" #include "mbed_critical.h" From 82ae01aeb4f31322f7fbe8d1a6dd2c57caa4e85e Mon Sep 17 00:00:00 2001 From: George Psimenos Date: Mon, 1 Jul 2019 15:30:07 +0100 Subject: [PATCH 05/35] Clean up events (#3) * Move private stuff into internal dir * Fix relative paths * Add Doxygen * Update copyright --- events/Event.h | 68 ++++++++++++++----- events/EventQueue.h | 19 ++++-- events/{equeue => internal}/.mbedignore | 0 events/{ => internal}/EventQueue.cpp | 0 events/{equeue => internal}/Makefile | 0 events/{equeue => internal}/README.md | 1 - events/{equeue => internal}/equeue.c | 4 +- events/{equeue => internal}/equeue.h | 12 ++-- events/{equeue => internal}/equeue_mbed.cpp | 4 +- events/{equeue => internal}/equeue_platform.h | 12 ++-- events/{equeue => internal}/equeue_posix.c | 4 +- events/{ => internal}/mbed_shared_queues.cpp | 0 events/{equeue => internal}/tests/prof.c | 0 events/{equeue => internal}/tests/tests.c | 0 events/mbed_events.h | 8 +-- events/mbed_shared_queues.h | 16 ++--- rtos/ConditionVariable.h | 4 +- rtos/EventFlags.h | 5 +- rtos/Kernel.h | 4 +- rtos/Mail.h | 7 +- rtos/MemoryPool.h | 4 +- rtos/Mutex.h | 6 +- rtos/Queue.h | 4 +- rtos/RtosTimer.h | 6 +- rtos/Semaphore.h | 6 +- rtos/TARGET_CORTEX/mbed_boot.h | 2 +- rtos/TARGET_CORTEX/mbed_rtx_handlers.c | 2 +- rtos/ThisThread.h | 6 +- rtos/Thread.h | 6 +- rtos/internal/rtos_handlers.h | 2 +- rtos/rtos.h | 2 +- usb/device/utilities/events/PolledQueue.h | 9 +-- usb/device/utilities/events/Task.h | 9 +-- usb/device/utilities/events/TaskBase.h | 9 +-- usb/device/utilities/events/TaskQueue.h | 8 ++- 35 files changed, 138 insertions(+), 111 deletions(-) rename events/{equeue => internal}/.mbedignore (100%) rename events/{ => internal}/EventQueue.cpp (100%) rename events/{equeue => internal}/Makefile (100%) rename events/{equeue => internal}/README.md (99%) rename events/{equeue => internal}/equeue.c (99%) rename events/{equeue => internal}/equeue.h (97%) rename events/{equeue => internal}/equeue_mbed.cpp (98%) rename events/{equeue => internal}/equeue_platform.h (97%) rename events/{equeue => internal}/equeue_posix.c (96%) rename events/{ => internal}/mbed_shared_queues.cpp (100%) rename events/{equeue => internal}/tests/prof.c (100%) rename events/{equeue => internal}/tests/tests.c (100%) diff --git a/events/Event.h b/events/Event.h index a8a2ff62348..0f8300c3c3c 100644 --- a/events/Event.h +++ b/events/Event.h @@ -1,5 +1,5 @@ -/* events - * Copyright (c) 2016 ARM Limited +/* + * Copyright (c) 2016-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,20 +21,25 @@ #include "platform/mbed_assert.h" namespace events { -/** \addtogroup events */ +/** \ingroup events */ +/** \addtogroup events-public-api Public API */ +/** @{*/ /** Event * * Representation of an event for fine-grain dispatch control - * @ingroup events */ template class Event; +/** + * \defgroup events_Event Event class + * @{ + */ + /** Event * * Representation of an event for fine-grain dispatch control - * @ingroup events */ template <> class Event { @@ -483,10 +488,16 @@ class Event { } }; +/** @}*/ + +/** + * \defgroup events_EventA0 Event class + * @{ + */ + /** Event * * Representation of an event for fine-grain dispatch control - * @ingroup events */ template class Event { @@ -939,10 +950,16 @@ class Event { } }; +/** @}*/ + +/** + * \defgroup events_EventA0A1 Event class + * @{ + */ + /** Event * * Representation of an event for fine-grain dispatch control - * @ingroup events */ template class Event { @@ -1395,10 +1412,16 @@ class Event { } }; +/** @}*/ + +/** + * \defgroup events_EventA0A1A2 Event class + * @{ + */ + /** Event * * Representation of an event for fine-grain dispatch control - * @ingroup events */ template class Event { @@ -1851,10 +1874,16 @@ class Event { } }; +/** @}*/ + +/** + * \defgroup events_EventA0A1A2A3 Event class + * @{ + */ + /** Event * * Representation of an event for fine-grain dispatch control - * @ingroup events */ template class Event { @@ -2306,12 +2335,20 @@ class Event { { new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4); } +#endif // DOXYGEN_ONLY }; +/** @}*/ + + +/** + * \defgroup events_EventA0A1A2A3A4 Event class + * @{ + */ + /** Event * * Representation of an event for fine-grain dispatch control - * @ingroup events */ template class Event { @@ -2764,12 +2801,11 @@ class Event { } }; - -/** \addtogroup events */ -/** @{ */ +/** @}*/ // Convenience functions declared here to avoid cyclic // dependency between Event and EventQueue +#if !defined(DOXYGEN_ONLY) template Event EventQueue::event(R(*func)()) { @@ -4065,9 +4101,9 @@ Event EventQueue::event(mbed::Callback(this, cb, c0, c1, c2, c3, c4); } -#endif +#endif // DOXYGEN_ONLY + +/** @}*/ } #endif - -/** @}*/ diff --git a/events/EventQueue.h b/events/EventQueue.h index 2b6b200a779..a3e879620a1 100644 --- a/events/EventQueue.h +++ b/events/EventQueue.h @@ -1,5 +1,5 @@ -/* events - * Copyright (c) 2016 ARM Limited +/* + * Copyright (c) 2016-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,14 +18,16 @@ #ifndef EVENT_QUEUE_H #define EVENT_QUEUE_H -#include "equeue/equeue.h" +#include "events/internal/equeue.h" #include "platform/Callback.h" #include "platform/NonCopyable.h" #include #include namespace events { -/** \addtogroup events */ +/** \ingroup events */ +/** \addtogroup events-public-api */ +/** @{*/ /** EVENTS_EVENT_SIZE * Minimum size of an event @@ -43,11 +45,14 @@ namespace events { template class Event; +/** + * \defgroup events_EventQueue EventQueue class + * @{ + */ /** EventQueue * * Flexible event queue for dispatching events - * @ingroup events */ class EventQueue : private mbed::NonCopyable { public: @@ -3402,7 +3407,9 @@ class EventQueue : private mbed::NonCopyable { #endif //!defined(DOXYGEN_ONLY) }; +/** @}*/ +/** @}*/ + } #endif - diff --git a/events/equeue/.mbedignore b/events/internal/.mbedignore similarity index 100% rename from events/equeue/.mbedignore rename to events/internal/.mbedignore diff --git a/events/EventQueue.cpp b/events/internal/EventQueue.cpp similarity index 100% rename from events/EventQueue.cpp rename to events/internal/EventQueue.cpp diff --git a/events/equeue/Makefile b/events/internal/Makefile similarity index 100% rename from events/equeue/Makefile rename to events/internal/Makefile diff --git a/events/equeue/README.md b/events/internal/README.md similarity index 99% rename from events/equeue/README.md rename to events/internal/README.md index 10f500c56f8..625c355571d 100644 --- a/events/equeue/README.md +++ b/events/internal/README.md @@ -207,4 +207,3 @@ comparison with previous runs: make prof | tee results.txt cat results.txt | make prof ``` - diff --git a/events/equeue/equeue.c b/events/internal/equeue.c similarity index 99% rename from events/equeue/equeue.c rename to events/internal/equeue.c index 3d55f3a0509..769be33d1e2 100644 --- a/events/equeue/equeue.c +++ b/events/internal/equeue.c @@ -1,7 +1,7 @@ /* * Flexible event queue for dispatching events * - * Copyright (c) 2016 Christopher Haster + * Copyright (c) 2016-2019 Christopher Haster * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "equeue/equeue.h" +#include "events/internal/equeue.h" #include #include diff --git a/events/equeue/equeue.h b/events/internal/equeue.h similarity index 97% rename from events/equeue/equeue.h rename to events/internal/equeue.h index a2c56e3fc82..e2600af7778 100644 --- a/events/equeue/equeue.h +++ b/events/internal/equeue.h @@ -1,10 +1,8 @@ -/** \addtogroup events */ -/** @{*/ /* * Flexible event queue for dispatching events * - * Copyright (c) 2016 Christopher Haster + * Copyright (c) 2016-2019 Christopher Haster * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +24,14 @@ extern "C" { #endif // Platform specific files -#include "equeue/equeue_platform.h" +#include "events/internal/equeue_platform.h" #include #include +/** \ingroup events */ +/** \addtogroup events-internal-api Internal API */ +/** @{*/ // The minimum size of an event // This size is guaranteed to fit events created by event_call @@ -225,11 +226,10 @@ void equeue_background(equeue_t *queue, // platform-specific error code. int equeue_chain(equeue_t *queue, equeue_t *target); +/** @}*/ #ifdef __cplusplus } #endif #endif - -/** @}*/ diff --git a/events/equeue/equeue_mbed.cpp b/events/internal/equeue_mbed.cpp similarity index 98% rename from events/equeue/equeue_mbed.cpp rename to events/internal/equeue_mbed.cpp index ca337df21f4..ce397b935c9 100644 --- a/events/equeue/equeue_mbed.cpp +++ b/events/internal/equeue_mbed.cpp @@ -2,7 +2,7 @@ * Implementation for the mbed library * https://github.com/mbedmicro/mbed * - * Copyright (c) 2016 Christopher Haster + * Copyright (c) 2016-2019 Christopher Haster * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "equeue/equeue_platform.h" +#include "events/internal/equeue_platform.h" #if defined(EQUEUE_PLATFORM_MBED) diff --git a/events/equeue/equeue_platform.h b/events/internal/equeue_platform.h similarity index 97% rename from events/equeue/equeue_platform.h rename to events/internal/equeue_platform.h index a63243ed9fc..a2add1e05b3 100644 --- a/events/equeue/equeue_platform.h +++ b/events/internal/equeue_platform.h @@ -1,10 +1,7 @@ - -/** \addtogroup events */ -/** @{*/ /* * System specific implementation * - * Copyright (c) 2016 Christopher Haster + * Copyright (c) 2016-2019 Christopher Haster * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +24,10 @@ extern "C" { #include +/** \ingroup events */ +/** \addtogroup events-internal-api */ +/** @{*/ + // Currently supported platforms // // Uncomment to select a supported platform or reimplement this file @@ -142,11 +143,10 @@ void equeue_sema_destroy(equeue_sema_t *sema); void equeue_sema_signal(equeue_sema_t *sema); bool equeue_sema_wait(equeue_sema_t *sema, int ms); +/** @}*/ #ifdef __cplusplus } #endif #endif - -/** @}*/ diff --git a/events/equeue/equeue_posix.c b/events/internal/equeue_posix.c similarity index 96% rename from events/equeue/equeue_posix.c rename to events/internal/equeue_posix.c index 02ebad794b8..64c113cac13 100644 --- a/events/equeue/equeue_posix.c +++ b/events/internal/equeue_posix.c @@ -1,7 +1,7 @@ /* * Implementation for Posix compliant platforms * - * Copyright (c) 2016 Christopher Haster + * Copyright (c) 2016-2019 Christopher Haster * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "equeue/equeue_platform.h" +#include "events/internal/equeue_platform.h" #if defined(EQUEUE_PLATFORM_POSIX) diff --git a/events/mbed_shared_queues.cpp b/events/internal/mbed_shared_queues.cpp similarity index 100% rename from events/mbed_shared_queues.cpp rename to events/internal/mbed_shared_queues.cpp diff --git a/events/equeue/tests/prof.c b/events/internal/tests/prof.c similarity index 100% rename from events/equeue/tests/prof.c rename to events/internal/tests/prof.c diff --git a/events/equeue/tests/tests.c b/events/internal/tests/tests.c similarity index 100% rename from events/equeue/tests/tests.c rename to events/internal/tests/tests.c diff --git a/events/mbed_events.h b/events/mbed_events.h index 466b82bb17b..39e4695edd0 100644 --- a/events/mbed_events.h +++ b/events/mbed_events.h @@ -1,8 +1,6 @@ - /** \addtogroup events */ /** @{*/ -/* events - * Copyright (c) 2016 ARM Limited +/* Copyright (c) 2016-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,10 +18,6 @@ #ifndef MBED_EVENTS_H #define MBED_EVENTS_H - -#include "equeue/equeue.h" - - #ifdef __cplusplus #include "events/EventQueue.h" diff --git a/events/mbed_shared_queues.h b/events/mbed_shared_queues.h index eb8d91e7910..741bddbe5f4 100644 --- a/events/mbed_shared_queues.h +++ b/events/mbed_shared_queues.h @@ -1,8 +1,5 @@ - -/** \addtogroup events */ -/** @{*/ -/* events - * Copyright (c) 2017 ARM Limited +/* + * Copyright (c) 2016-2019 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +19,9 @@ #include "events/EventQueue.h" namespace mbed { +/** \ingroup events */ +/** \addtogroup events-public-api */ +/** @{*/ /** * Return a pointer to an EventQueue, on which normal tasks can be queued. @@ -85,8 +85,8 @@ events::EventQueue *mbed_highprio_event_queue(); #endif // MBED_CONF_RTOS_PRESENT -}; +/** @}*/ -#endif +} -/** @}*/ +#endif diff --git a/rtos/ConditionVariable.h b/rtos/ConditionVariable.h index ca87123ddef..31596e726eb 100644 --- a/rtos/ConditionVariable.h +++ b/rtos/ConditionVariable.h @@ -1,5 +1,5 @@ /* Mbed Microcontroller Library - * Copyright (c) 2017-2018 ARM Limited + * Copyright (c) 2017-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api Public API */ +/** \addtogroup rtos-public-api RTOS Public API */ /** @{*/ struct Waiter; diff --git a/rtos/EventFlags.h b/rtos/EventFlags.h index bf81d614995..f115f813299 100644 --- a/rtos/EventFlags.h +++ b/rtos/EventFlags.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2017 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** * \defgroup rtos_EventFlags EventFlags class @@ -124,4 +124,3 @@ class EventFlags : private mbed::NonCopyable { } #endif - diff --git a/rtos/Kernel.h b/rtos/Kernel.h index 258896045f3..e643ba61761 100644 --- a/rtos/Kernel.h +++ b/rtos/Kernel.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited + * Copyright (c) 2017-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** Functions in the Kernel namespace control RTOS kernel information. */ diff --git a/rtos/Mail.h b/rtos/Mail.h index 0efa86da4b5..2a208e5bda9 100644 --- a/rtos/Mail.h +++ b/rtos/Mail.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2017 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,7 +39,7 @@ using namespace rtos; namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** * \defgroup rtos_Mail Mail class @@ -237,6 +237,3 @@ class Mail : private mbed::NonCopyable > { } #endif - - - diff --git a/rtos/MemoryPool.h b/rtos/MemoryPool.h index 3b55d7c128a..c6fe947f106 100644 --- a/rtos/MemoryPool.h +++ b/rtos/MemoryPool.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -35,7 +35,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** * \defgroup rtos_MemoryPool MemoryPool class diff --git a/rtos/Mutex.h b/rtos/Mutex.h index 71d9d9557f0..9bcc63ed852 100644 --- a/rtos/Mutex.h +++ b/rtos/Mutex.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,7 +33,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ class Mutex; @@ -178,5 +178,3 @@ class Mutex : private mbed::NonCopyable { /** @}*/ } #endif - - diff --git a/rtos/Queue.h b/rtos/Queue.h index 408923b1385..0cdc5a49133 100644 --- a/rtos/Queue.h +++ b/rtos/Queue.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** * \defgroup rtos_Queue Queue class diff --git a/rtos/RtosTimer.h b/rtos/RtosTimer.h index cc631d8972f..2c3ed4d828d 100644 --- a/rtos/RtosTimer.h +++ b/rtos/RtosTimer.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,7 +32,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** * \defgroup rtos_RtosTimer RtosTimer class @@ -188,5 +188,3 @@ class RtosTimer : private mbed::NonCopyable { } #endif - - diff --git a/rtos/Semaphore.h b/rtos/Semaphore.h index c08e2cb20fc..afafafbb535 100644 --- a/rtos/Semaphore.h +++ b/rtos/Semaphore.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** * \defgroup rtos_Semaphore Semaphore class @@ -151,5 +151,3 @@ class Semaphore : private mbed::NonCopyable { /** @}*/ } #endif - - diff --git a/rtos/TARGET_CORTEX/mbed_boot.h b/rtos/TARGET_CORTEX/mbed_boot.h index 7ad6e63435a..98229b39295 100644 --- a/rtos/TARGET_CORTEX/mbed_boot.h +++ b/rtos/TARGET_CORTEX/mbed_boot.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2018-2018 ARM Limited + * Copyright (c) 2018-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/rtos/TARGET_CORTEX/mbed_rtx_handlers.c b/rtos/TARGET_CORTEX/mbed_rtx_handlers.c index 63b0031d7c2..86739e73996 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_handlers.c +++ b/rtos/TARGET_CORTEX/mbed_rtx_handlers.c @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2016 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/rtos/ThisThread.h b/rtos/ThisThread.h index f2d5972fbf0..3124f318b73 100644 --- a/rtos/ThisThread.h +++ b/rtos/ThisThread.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2018 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +28,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** * \defgroup rtos_ThisThread ThisThread namespace @@ -185,5 +185,3 @@ const char *get_name(); /** @}*/ } #endif - - diff --git a/rtos/Thread.h b/rtos/Thread.h index eb34f5c5e3f..00e189b160b 100644 --- a/rtos/Thread.h +++ b/rtos/Thread.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -34,7 +34,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup mbed-os-api */ +/** \addtogroup rtos-public-api */ /** @{*/ /** * \defgroup rtos_Thread Thread class @@ -545,5 +545,3 @@ class Thread : private mbed::NonCopyable { /** @}*/ } #endif - - diff --git a/rtos/internal/rtos_handlers.h b/rtos/internal/rtos_handlers.h index 2a4755d88a7..d5e256cae25 100644 --- a/rtos/internal/rtos_handlers.h +++ b/rtos/internal/rtos_handlers.h @@ -29,7 +29,7 @@ extern "C" { #endif /** \ingroup rtos */ -/** \addtogroup mbed-os-internal Internal API */ +/** \addtogroup rtos-internal-api Internal API */ /** @{*/ /** diff --git a/rtos/rtos.h b/rtos/rtos.h index 3324c68e6e0..42e4d8c1d45 100644 --- a/rtos/rtos.h +++ b/rtos/rtos.h @@ -2,7 +2,7 @@ /** \addtogroup rtos */ /** @{*/ /* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/usb/device/utilities/events/PolledQueue.h b/usb/device/utilities/events/PolledQueue.h index 61492b727d7..a2bfc0ac78c 100644 --- a/usb/device/utilities/events/PolledQueue.h +++ b/usb/device/utilities/events/PolledQueue.h @@ -22,14 +22,14 @@ #include "platform/Callback.h" #include "LinkedList.h" namespace events { -/** \addtogroup events */ - +/** \ingroup events */ +/** \addtogroup events-internal-api */ +/** @{*/ /** PolledQueue * * This class is an implementation of TaskQueue which is * processed synchronously by calls to dispatch. - * @ingroup events */ class PolledQueue: public TaskQueue { public: @@ -67,6 +67,7 @@ class PolledQueue: public TaskQueue { }; +/** @}*/ + } #endif - diff --git a/usb/device/utilities/events/Task.h b/usb/device/utilities/events/Task.h index 966db971527..b1e2a517fa1 100644 --- a/usb/device/utilities/events/Task.h +++ b/usb/device/utilities/events/Task.h @@ -24,7 +24,9 @@ #include "platform/Callback.h" namespace events { -/** \addtogroup events */ +/** \ingroup events */ +/** \addtogroup events-internal-api */ +/** @{*/ template @@ -583,7 +585,6 @@ class Task: public TaskBase { /** Task * * Representation of a postable task - * @ingroup events */ template class Task: public TaskBase { @@ -647,8 +648,8 @@ class Task: public TaskBase { All _args; }; -} - /** @}*/ +} + #endif diff --git a/usb/device/utilities/events/TaskBase.h b/usb/device/utilities/events/TaskBase.h index b88e4d43366..8aceba6b5ee 100644 --- a/usb/device/utilities/events/TaskBase.h +++ b/usb/device/utilities/events/TaskBase.h @@ -27,7 +27,9 @@ class Semaphore; } namespace events { -/** \addtogroup events */ +/** \ingroup events */ +/** \addtogroup events-internal-api */ +/** @{*/ class TaskQueue; @@ -35,7 +37,6 @@ class TaskQueue; /** TaskBase * * Representation of a caller allocated task - * @ingroup events */ class TaskBase : public LinkEntry { public: @@ -158,8 +159,8 @@ class TaskBase : public LinkEntry { void _wake_check(); }; +/** @}*/ + } #endif - -/** @}*/ diff --git a/usb/device/utilities/events/TaskQueue.h b/usb/device/utilities/events/TaskQueue.h index 5623fd65e0f..8fae4e676bf 100644 --- a/usb/device/utilities/events/TaskQueue.h +++ b/usb/device/utilities/events/TaskQueue.h @@ -25,14 +25,15 @@ #define MBED_MAX_TASK_SIZE 32 namespace events { -/** \addtogroup events */ +/** \ingroup events */ +/** \addtogroup events-internal-api */ +/** @{*/ /** TaskQueue * * Flexible task queue for dispatching tasks - * @ingroup events */ class TaskQueue { public: @@ -134,6 +135,7 @@ class TaskQueue { } }; +/** @}*/ + } #endif - From 3456f5fb565ec9284b81043a337994911f25cd81 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 2 Jul 2019 05:07:29 +0100 Subject: [PATCH 06/35] FiX build when Ethernet is included (#6) The macro `MBED_DEPRECATED` only takes one argument. Also move it to ensure the class is marked deprecated correctly. --- drivers/Ethernet.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/Ethernet.h b/drivers/Ethernet.h index 6bc85e9c242..b845603f53b 100644 --- a/drivers/Ethernet.h +++ b/drivers/Ethernet.h @@ -61,12 +61,12 @@ namespace mbed { * } * @endcode */ +class MBED_DEPRECATED( - "EthInterface is now the preferred way to get an Ethernet object.", - "Alternatively, use NetworkInterface to get an instance of an appropriate network" + "EthInterface is now the preferred way to get an Ethernet object. " + "Alternatively, use NetworkInterface to get an instance of an appropriate network " "interface (WiFi or Ethernet)." -) -class Ethernet : private NonCopyable { +) Ethernet : private NonCopyable { public: From 11003eaed9ba5f23077cd9fcad15f7671a578a58 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 3 Jul 2019 10:00:01 +0100 Subject: [PATCH 07/35] Fix the incorrect Doxygen group alias for RTOS public API documentation (#8) --- rtos/ConditionVariable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtos/ConditionVariable.h b/rtos/ConditionVariable.h index 31596e726eb..3c2de71d861 100644 --- a/rtos/ConditionVariable.h +++ b/rtos/ConditionVariable.h @@ -31,7 +31,7 @@ namespace rtos { /** \ingroup rtos */ -/** \addtogroup rtos-public-api RTOS Public API */ +/** \addtogroup rtos-public-api Public API */ /** @{*/ struct Waiter; From fc48e434e2f40a0750c413d50aaa89f9be6665e0 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 3 Jul 2019 10:00:32 +0100 Subject: [PATCH 08/35] Fix RTOS internal API Doxygen documentation (#7) --- rtos/internal/rtos_idle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtos/internal/rtos_idle.h b/rtos/internal/rtos_idle.h index d32b29b9bc7..b6b28500780 100644 --- a/rtos/internal/rtos_idle.h +++ b/rtos/internal/rtos_idle.h @@ -30,7 +30,7 @@ extern "C" { /** \ingroup rtos */ -/** \addtogroup mbed-os-internal */ +/** \addtogroup rtos-internal-api Internal API */ /** @{*/ /** From 052c46d314a0ea1788c9f5253a17a4c323551042 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Fri, 5 Jul 2019 11:59:42 +0100 Subject: [PATCH 09/35] Fix code style errors. --- drivers/Ethernet.h | 10 +++++----- drivers/SPI.h | 6 +++--- drivers/Serial.h | 2 +- drivers/internal/TimerEvent.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/Ethernet.h b/drivers/Ethernet.h index b845603f53b..f070bd524a3 100644 --- a/drivers/Ethernet.h +++ b/drivers/Ethernet.h @@ -62,11 +62,11 @@ namespace mbed { * @endcode */ class -MBED_DEPRECATED( - "EthInterface is now the preferred way to get an Ethernet object. " - "Alternatively, use NetworkInterface to get an instance of an appropriate network " - "interface (WiFi or Ethernet)." -) Ethernet : private NonCopyable { + MBED_DEPRECATED( + "EthInterface is now the preferred way to get an Ethernet object. " + "Alternatively, use NetworkInterface to get an instance of an appropriate network " + "interface (WiFi or Ethernet)." + ) Ethernet : private NonCopyable { public: diff --git a/drivers/SPI.h b/drivers/SPI.h index 7ac4a44ae2e..b3f57723198 100644 --- a/drivers/SPI.h +++ b/drivers/SPI.h @@ -117,7 +117,7 @@ class SPI : private NonCopyable { */ SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel = NC) : #if DEVICE_SPI_ASYNCH - _irq(this), + _irq(this), #endif _mosi(mosi), _miso(miso), @@ -274,9 +274,9 @@ class SPI : private NonCopyable { */ void clear_transfer_buffer() { - #if TRANSACTION_QUEUE_SIZE_SPI +#if TRANSACTION_QUEUE_SIZE_SPI _peripheral->transaction_buffer->reset(); - #endif +#endif } /** Clear the queue of transfers and abort the on-going transfer. diff --git a/drivers/Serial.h b/drivers/Serial.h index e5d272ec8b0..bb0caa001e9 100644 --- a/drivers/Serial.h +++ b/drivers/Serial.h @@ -87,7 +87,7 @@ class Serial : public SerialBase, public Stream, private NonCopyable { * @note * Either tx or rx may be specified as NC (Not Connected) if unused */ - Serial(PinName tx, PinName rx,int baud) : SerialBase(tx, rx, baud), Stream(NULL) + Serial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud), Stream(NULL) { } diff --git a/drivers/internal/TimerEvent.h b/drivers/internal/TimerEvent.h index df0056a0c06..88703c8c2cb 100644 --- a/drivers/internal/TimerEvent.h +++ b/drivers/internal/TimerEvent.h @@ -38,7 +38,7 @@ class TimerEvent : private NonCopyable { TimerEvent(); TimerEvent(const ticker_data_t *data) - : event(), _ticker_data(data) + : event(), _ticker_data(data) { ticker_set_handler(_ticker_data, (&TimerEvent::irq)); } From bee7ae4f6eba8bea0802348032c8722afa69c00d Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Fri, 5 Jul 2019 13:45:44 +0100 Subject: [PATCH 10/35] Add Doxygen `ingroup` command as a recognised token in CI spellchecker --- tools/test/travis-ci/doxy-spellchecker/spell.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/test/travis-ci/doxy-spellchecker/spell.sh b/tools/test/travis-ci/doxy-spellchecker/spell.sh index e56c33e646b..9574e69eb6a 100755 --- a/tools/test/travis-ci/doxy-spellchecker/spell.sh +++ b/tools/test/travis-ci/doxy-spellchecker/spell.sh @@ -20,6 +20,7 @@ while read file; do # matched. start_tokens=( "/@code" "/addtogroup" + "ingroup" "defgroup" "<" "()" @@ -28,6 +29,7 @@ while read file; do formats=( 'strip_between' 'strip_between' 'strip_line' + 'strip_line' 'strip_between_sameline' 'strip_token' ) @@ -35,6 +37,7 @@ while read file; do end_tokens=( "/@endcode" "/\*" "" + "" ">" "" ) From 71137a4fca58aa02fd966644a39383b583dd1cb9 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Fri, 5 Jul 2019 14:24:09 +0100 Subject: [PATCH 11/35] Classify public base classes as public APIs --- drivers/{internal => }/SerialBase.h | 2 +- drivers/SerialWireOutput.h | 2 +- drivers/{internal => }/TimerEvent.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename drivers/{internal => }/SerialBase.h (99%) rename drivers/{internal => }/TimerEvent.h (98%) diff --git a/drivers/internal/SerialBase.h b/drivers/SerialBase.h similarity index 99% rename from drivers/internal/SerialBase.h rename to drivers/SerialBase.h index a8af60a9bf9..d3cdb4a7733 100644 --- a/drivers/internal/SerialBase.h +++ b/drivers/SerialBase.h @@ -34,7 +34,7 @@ namespace mbed { /** \defgroup drivers */ /** \ingroup drivers */ -/** \addtogroup drivers-internal-api Internal API */ +/** \addtogroup drivers-public-api */ /** @{*/ /** * \defgroup drivers_SerialBase SerialBase class diff --git a/drivers/SerialWireOutput.h b/drivers/SerialWireOutput.h index a446e37ff2d..a2db35d93e9 100644 --- a/drivers/SerialWireOutput.h +++ b/drivers/SerialWireOutput.h @@ -26,7 +26,7 @@ namespace mbed { /** \ingroup drivers */ -/** \addtogroup drivers-public-api */ +/** \addtogroup drivers-public-api Internal API */ /** @{*/ /** * \defgroup drivers_SerialWireOutput SerialWireOutput class diff --git a/drivers/internal/TimerEvent.h b/drivers/TimerEvent.h similarity index 98% rename from drivers/internal/TimerEvent.h rename to drivers/TimerEvent.h index 88703c8c2cb..ef02df81830 100644 --- a/drivers/internal/TimerEvent.h +++ b/drivers/TimerEvent.h @@ -22,7 +22,7 @@ namespace mbed { /** \ingroup drivers */ -/** \addtogroup drivers-internal-api Internal API */ +/** \addtogroup drivers-public-api */ /** @{*/ /** * \defgroup drivers_TimerEvent TimerEvent class From d04b0a3cb454d0ae33c88e2ccac5e7fac46b541c Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Fri, 5 Jul 2019 14:51:22 +0100 Subject: [PATCH 12/35] Rename newly created `internal` subdir to `source` dir This avoids the overlap in meaning with a strong `internal` dir which would allow shipping the public header without the content of the internal dir. The subirs `source` instead contain classes and APIs that users should not use and are subject to change. --- TESTS/mbed_drivers/timerevent/main.cpp | 2 +- UNITTESTS/stubs/SerialBase_stub.cpp | 2 +- drivers/MbedCRC.h | 2 +- drivers/RawSerial.h | 2 +- drivers/Serial.h | 2 +- drivers/Ticker.h | 2 +- drivers/UARTSerial.h | 2 +- drivers/{internal => source}/AnalogIn.cpp | 0 drivers/{internal => source}/AnalogOut.cpp | 0 drivers/{internal => source}/BusIn.cpp | 0 drivers/{internal => source}/BusInOut.cpp | 0 drivers/{internal => source}/BusOut.cpp | 0 drivers/{internal => source}/CAN.cpp | 0 drivers/{internal => source}/DigitalIn.cpp | 0 drivers/{internal => source}/DigitalInOut.cpp | 0 drivers/{internal => source}/DigitalOut.cpp | 0 drivers/{internal => source}/Ethernet.cpp | 0 drivers/{internal => source}/FlashIAP.cpp | 0 drivers/{internal => source}/I2C.cpp | 0 drivers/{internal => source}/I2CSlave.cpp | 0 drivers/{internal => source}/InterruptIn.cpp | 0 drivers/{internal => source}/InterruptManager.cpp | 0 drivers/{internal => source}/MbedCRC.cpp | 0 drivers/{internal => source}/PortIn.cpp | 0 drivers/{internal => source}/PortInOut.cpp | 0 drivers/{internal => source}/PortOut.cpp | 0 drivers/{internal => source}/PwmOut.cpp | 0 drivers/{internal => source}/QSPI.cpp | 0 drivers/{internal => source}/RawSerial.cpp | 0 drivers/{internal => source}/SPI.cpp | 0 drivers/{internal => source}/SPISlave.cpp | 0 drivers/{internal => source}/Serial.cpp | 0 drivers/{internal => source}/SerialBase.cpp | 2 +- drivers/{internal => source}/SerialWireOutput.cpp | 0 drivers/{internal => source}/TableCRC.cpp | 2 +- drivers/{internal => source}/TableCRC.h | 0 drivers/{internal => source}/Ticker.cpp | 2 +- drivers/{internal => source}/Timeout.cpp | 0 drivers/{internal => source}/Timer.cpp | 0 drivers/{internal => source}/TimerEvent.cpp | 2 +- drivers/{internal => source}/UARTSerial.cpp | 0 events/EventQueue.h | 2 +- events/{internal => source}/.mbedignore | 0 events/{internal => source}/EventQueue.cpp | 0 events/{internal => source}/Makefile | 0 events/{internal => source}/README.md | 0 events/{internal => source}/equeue.c | 2 +- events/{internal => source}/equeue.h | 2 +- events/{internal => source}/equeue_mbed.cpp | 2 +- events/{internal => source}/equeue_platform.h | 0 events/{internal => source}/equeue_posix.c | 2 +- events/{internal => source}/mbed_shared_queues.cpp | 0 events/{internal => source}/tests/prof.c | 0 events/{internal => source}/tests/tests.c | 0 rtos/TARGET_CORTEX/SysTimer.h | 2 +- rtos/TARGET_CORTEX/mbed_rtx_handlers.c | 4 ++-- rtos/TARGET_CORTEX/mbed_rtx_idle.cpp | 4 ++-- rtos/{internal => source}/ConditionVariable.cpp | 0 rtos/{internal => source}/EventFlags.cpp | 0 rtos/{internal => source}/Kernel.cpp | 0 rtos/{internal => source}/Mutex.cpp | 0 rtos/{internal => source}/RtosTimer.cpp | 0 rtos/{internal => source}/Semaphore.cpp | 0 rtos/{internal => source}/ThisThread.cpp | 0 rtos/{internal => source}/Thread.cpp | 0 rtos/{internal => source}/rtos_handlers.h | 0 rtos/{internal => source}/rtos_idle.h | 0 67 files changed, 21 insertions(+), 21 deletions(-) rename drivers/{internal => source}/AnalogIn.cpp (100%) rename drivers/{internal => source}/AnalogOut.cpp (100%) rename drivers/{internal => source}/BusIn.cpp (100%) rename drivers/{internal => source}/BusInOut.cpp (100%) rename drivers/{internal => source}/BusOut.cpp (100%) rename drivers/{internal => source}/CAN.cpp (100%) rename drivers/{internal => source}/DigitalIn.cpp (100%) rename drivers/{internal => source}/DigitalInOut.cpp (100%) rename drivers/{internal => source}/DigitalOut.cpp (100%) rename drivers/{internal => source}/Ethernet.cpp (100%) rename drivers/{internal => source}/FlashIAP.cpp (100%) rename drivers/{internal => source}/I2C.cpp (100%) rename drivers/{internal => source}/I2CSlave.cpp (100%) rename drivers/{internal => source}/InterruptIn.cpp (100%) rename drivers/{internal => source}/InterruptManager.cpp (100%) rename drivers/{internal => source}/MbedCRC.cpp (100%) rename drivers/{internal => source}/PortIn.cpp (100%) rename drivers/{internal => source}/PortInOut.cpp (100%) rename drivers/{internal => source}/PortOut.cpp (100%) rename drivers/{internal => source}/PwmOut.cpp (100%) rename drivers/{internal => source}/QSPI.cpp (100%) rename drivers/{internal => source}/RawSerial.cpp (100%) rename drivers/{internal => source}/SPI.cpp (100%) rename drivers/{internal => source}/SPISlave.cpp (100%) rename drivers/{internal => source}/Serial.cpp (100%) rename drivers/{internal => source}/SerialBase.cpp (99%) rename drivers/{internal => source}/SerialWireOutput.cpp (100%) rename drivers/{internal => source}/TableCRC.cpp (99%) rename drivers/{internal => source}/TableCRC.h (100%) rename drivers/{internal => source}/Ticker.cpp (98%) rename drivers/{internal => source}/Timeout.cpp (100%) rename drivers/{internal => source}/Timer.cpp (100%) rename drivers/{internal => source}/TimerEvent.cpp (96%) rename drivers/{internal => source}/UARTSerial.cpp (100%) rename events/{internal => source}/.mbedignore (100%) rename events/{internal => source}/EventQueue.cpp (100%) rename events/{internal => source}/Makefile (100%) rename events/{internal => source}/README.md (100%) rename events/{internal => source}/equeue.c (99%) rename events/{internal => source}/equeue.h (99%) rename events/{internal => source}/equeue_mbed.cpp (99%) rename events/{internal => source}/equeue_platform.h (100%) rename events/{internal => source}/equeue_posix.c (98%) rename events/{internal => source}/mbed_shared_queues.cpp (100%) rename events/{internal => source}/tests/prof.c (100%) rename events/{internal => source}/tests/tests.c (100%) rename rtos/{internal => source}/ConditionVariable.cpp (100%) rename rtos/{internal => source}/EventFlags.cpp (100%) rename rtos/{internal => source}/Kernel.cpp (100%) rename rtos/{internal => source}/Mutex.cpp (100%) rename rtos/{internal => source}/RtosTimer.cpp (100%) rename rtos/{internal => source}/Semaphore.cpp (100%) rename rtos/{internal => source}/ThisThread.cpp (100%) rename rtos/{internal => source}/Thread.cpp (100%) rename rtos/{internal => source}/rtos_handlers.h (100%) rename rtos/{internal => source}/rtos_idle.h (100%) diff --git a/TESTS/mbed_drivers/timerevent/main.cpp b/TESTS/mbed_drivers/timerevent/main.cpp index b02a441db79..c1d318310d0 100644 --- a/TESTS/mbed_drivers/timerevent/main.cpp +++ b/TESTS/mbed_drivers/timerevent/main.cpp @@ -21,7 +21,7 @@ #include "greentea-client/test_env.h" #include "unity.h" #include "utest.h" -#include "drivers/internal/TimerEvent.h" +#include "drivers/source/TimerEvent.h" #include "hal/ticker_api.h" #include "rtos.h" diff --git a/UNITTESTS/stubs/SerialBase_stub.cpp b/UNITTESTS/stubs/SerialBase_stub.cpp index 740972e101f..048cd565a1c 100644 --- a/UNITTESTS/stubs/SerialBase_stub.cpp +++ b/UNITTESTS/stubs/SerialBase_stub.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "drivers/internal/SerialBase.h" +#include "drivers/source/SerialBase.h" namespace mbed { diff --git a/drivers/MbedCRC.h b/drivers/MbedCRC.h index 1d666da445d..d56fae76268 100644 --- a/drivers/MbedCRC.h +++ b/drivers/MbedCRC.h @@ -17,7 +17,7 @@ #ifndef MBED_CRC_API_H #define MBED_CRC_API_H -#include "drivers/internal/TableCRC.h" +#include "drivers/source/TableCRC.h" #include "hal/crc_api.h" #include "platform/mbed_assert.h" #include "platform/SingletonPtr.h" diff --git a/drivers/RawSerial.h b/drivers/RawSerial.h index d1100887de8..ec83a36a47e 100644 --- a/drivers/RawSerial.h +++ b/drivers/RawSerial.h @@ -22,7 +22,7 @@ #if DEVICE_SERIAL || defined(DOXYGEN_ONLY) #include "mbed_toolchain.h" -#include "drivers/internal/SerialBase.h" +#include "drivers/source/SerialBase.h" #include "platform/NonCopyable.h" #include diff --git a/drivers/Serial.h b/drivers/Serial.h index bb0caa001e9..4ab43d93ec8 100644 --- a/drivers/Serial.h +++ b/drivers/Serial.h @@ -22,7 +22,7 @@ #if DEVICE_SERIAL || defined(DOXYGEN_ONLY) #include "platform/Stream.h" -#include "drivers/internal/SerialBase.h" +#include "drivers/source/SerialBase.h" #include "platform/PlatformMutex.h" #include "platform/NonCopyable.h" diff --git a/drivers/Ticker.h b/drivers/Ticker.h index 395e0cf2e6b..540c6be603d 100644 --- a/drivers/Ticker.h +++ b/drivers/Ticker.h @@ -17,7 +17,7 @@ #ifndef MBED_TICKER_H #define MBED_TICKER_H -#include "drivers/internal/TimerEvent.h" +#include "drivers/source/TimerEvent.h" #include "platform/Callback.h" #include "platform/mbed_toolchain.h" #include "platform/NonCopyable.h" diff --git a/drivers/UARTSerial.h b/drivers/UARTSerial.h index e9bbb418b25..b02d61ace37 100644 --- a/drivers/UARTSerial.h +++ b/drivers/UARTSerial.h @@ -23,7 +23,7 @@ #if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #include "platform/FileHandle.h" -#include "drivers/internal/SerialBase.h" +#include "drivers/source/SerialBase.h" #include "InterruptIn.h" #include "platform/PlatformMutex.h" #include "platform/CircularBuffer.h" diff --git a/drivers/internal/AnalogIn.cpp b/drivers/source/AnalogIn.cpp similarity index 100% rename from drivers/internal/AnalogIn.cpp rename to drivers/source/AnalogIn.cpp diff --git a/drivers/internal/AnalogOut.cpp b/drivers/source/AnalogOut.cpp similarity index 100% rename from drivers/internal/AnalogOut.cpp rename to drivers/source/AnalogOut.cpp diff --git a/drivers/internal/BusIn.cpp b/drivers/source/BusIn.cpp similarity index 100% rename from drivers/internal/BusIn.cpp rename to drivers/source/BusIn.cpp diff --git a/drivers/internal/BusInOut.cpp b/drivers/source/BusInOut.cpp similarity index 100% rename from drivers/internal/BusInOut.cpp rename to drivers/source/BusInOut.cpp diff --git a/drivers/internal/BusOut.cpp b/drivers/source/BusOut.cpp similarity index 100% rename from drivers/internal/BusOut.cpp rename to drivers/source/BusOut.cpp diff --git a/drivers/internal/CAN.cpp b/drivers/source/CAN.cpp similarity index 100% rename from drivers/internal/CAN.cpp rename to drivers/source/CAN.cpp diff --git a/drivers/internal/DigitalIn.cpp b/drivers/source/DigitalIn.cpp similarity index 100% rename from drivers/internal/DigitalIn.cpp rename to drivers/source/DigitalIn.cpp diff --git a/drivers/internal/DigitalInOut.cpp b/drivers/source/DigitalInOut.cpp similarity index 100% rename from drivers/internal/DigitalInOut.cpp rename to drivers/source/DigitalInOut.cpp diff --git a/drivers/internal/DigitalOut.cpp b/drivers/source/DigitalOut.cpp similarity index 100% rename from drivers/internal/DigitalOut.cpp rename to drivers/source/DigitalOut.cpp diff --git a/drivers/internal/Ethernet.cpp b/drivers/source/Ethernet.cpp similarity index 100% rename from drivers/internal/Ethernet.cpp rename to drivers/source/Ethernet.cpp diff --git a/drivers/internal/FlashIAP.cpp b/drivers/source/FlashIAP.cpp similarity index 100% rename from drivers/internal/FlashIAP.cpp rename to drivers/source/FlashIAP.cpp diff --git a/drivers/internal/I2C.cpp b/drivers/source/I2C.cpp similarity index 100% rename from drivers/internal/I2C.cpp rename to drivers/source/I2C.cpp diff --git a/drivers/internal/I2CSlave.cpp b/drivers/source/I2CSlave.cpp similarity index 100% rename from drivers/internal/I2CSlave.cpp rename to drivers/source/I2CSlave.cpp diff --git a/drivers/internal/InterruptIn.cpp b/drivers/source/InterruptIn.cpp similarity index 100% rename from drivers/internal/InterruptIn.cpp rename to drivers/source/InterruptIn.cpp diff --git a/drivers/internal/InterruptManager.cpp b/drivers/source/InterruptManager.cpp similarity index 100% rename from drivers/internal/InterruptManager.cpp rename to drivers/source/InterruptManager.cpp diff --git a/drivers/internal/MbedCRC.cpp b/drivers/source/MbedCRC.cpp similarity index 100% rename from drivers/internal/MbedCRC.cpp rename to drivers/source/MbedCRC.cpp diff --git a/drivers/internal/PortIn.cpp b/drivers/source/PortIn.cpp similarity index 100% rename from drivers/internal/PortIn.cpp rename to drivers/source/PortIn.cpp diff --git a/drivers/internal/PortInOut.cpp b/drivers/source/PortInOut.cpp similarity index 100% rename from drivers/internal/PortInOut.cpp rename to drivers/source/PortInOut.cpp diff --git a/drivers/internal/PortOut.cpp b/drivers/source/PortOut.cpp similarity index 100% rename from drivers/internal/PortOut.cpp rename to drivers/source/PortOut.cpp diff --git a/drivers/internal/PwmOut.cpp b/drivers/source/PwmOut.cpp similarity index 100% rename from drivers/internal/PwmOut.cpp rename to drivers/source/PwmOut.cpp diff --git a/drivers/internal/QSPI.cpp b/drivers/source/QSPI.cpp similarity index 100% rename from drivers/internal/QSPI.cpp rename to drivers/source/QSPI.cpp diff --git a/drivers/internal/RawSerial.cpp b/drivers/source/RawSerial.cpp similarity index 100% rename from drivers/internal/RawSerial.cpp rename to drivers/source/RawSerial.cpp diff --git a/drivers/internal/SPI.cpp b/drivers/source/SPI.cpp similarity index 100% rename from drivers/internal/SPI.cpp rename to drivers/source/SPI.cpp diff --git a/drivers/internal/SPISlave.cpp b/drivers/source/SPISlave.cpp similarity index 100% rename from drivers/internal/SPISlave.cpp rename to drivers/source/SPISlave.cpp diff --git a/drivers/internal/Serial.cpp b/drivers/source/Serial.cpp similarity index 100% rename from drivers/internal/Serial.cpp rename to drivers/source/Serial.cpp diff --git a/drivers/internal/SerialBase.cpp b/drivers/source/SerialBase.cpp similarity index 99% rename from drivers/internal/SerialBase.cpp rename to drivers/source/SerialBase.cpp index ddf13bc292e..8dc3a611f2c 100644 --- a/drivers/internal/SerialBase.cpp +++ b/drivers/source/SerialBase.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "drivers/internal/SerialBase.h" +#include "drivers/source/SerialBase.h" #include "platform/mbed_wait_api.h" #include "platform/mbed_critical.h" #include "platform/mbed_power_mgmt.h" diff --git a/drivers/internal/SerialWireOutput.cpp b/drivers/source/SerialWireOutput.cpp similarity index 100% rename from drivers/internal/SerialWireOutput.cpp rename to drivers/source/SerialWireOutput.cpp diff --git a/drivers/internal/TableCRC.cpp b/drivers/source/TableCRC.cpp similarity index 99% rename from drivers/internal/TableCRC.cpp rename to drivers/source/TableCRC.cpp index 6cea67d94a3..1ba6f4f5ec8 100644 --- a/drivers/internal/TableCRC.cpp +++ b/drivers/source/TableCRC.cpp @@ -16,7 +16,7 @@ */ #include -#include "drivers/internal/TableCRC.h" +#include "drivers/source/TableCRC.h" namespace mbed { diff --git a/drivers/internal/TableCRC.h b/drivers/source/TableCRC.h similarity index 100% rename from drivers/internal/TableCRC.h rename to drivers/source/TableCRC.h diff --git a/drivers/internal/Ticker.cpp b/drivers/source/Ticker.cpp similarity index 98% rename from drivers/internal/Ticker.cpp rename to drivers/source/Ticker.cpp index 15098f9c96d..f243faa0eb0 100644 --- a/drivers/internal/Ticker.cpp +++ b/drivers/source/Ticker.cpp @@ -16,7 +16,7 @@ */ #include "drivers/Ticker.h" -#include "drivers/internal/TimerEvent.h" +#include "drivers/source/TimerEvent.h" #include "platform/FunctionPointer.h" #include "hal/ticker_api.h" #include "platform/mbed_critical.h" diff --git a/drivers/internal/Timeout.cpp b/drivers/source/Timeout.cpp similarity index 100% rename from drivers/internal/Timeout.cpp rename to drivers/source/Timeout.cpp diff --git a/drivers/internal/Timer.cpp b/drivers/source/Timer.cpp similarity index 100% rename from drivers/internal/Timer.cpp rename to drivers/source/Timer.cpp diff --git a/drivers/internal/TimerEvent.cpp b/drivers/source/TimerEvent.cpp similarity index 96% rename from drivers/internal/TimerEvent.cpp rename to drivers/source/TimerEvent.cpp index d93e74790b7..3ea092b9075 100644 --- a/drivers/internal/TimerEvent.cpp +++ b/drivers/source/TimerEvent.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "drivers/internal/TimerEvent.h" +#include "drivers/source/TimerEvent.h" #include #include "hal/us_ticker_api.h" diff --git a/drivers/internal/UARTSerial.cpp b/drivers/source/UARTSerial.cpp similarity index 100% rename from drivers/internal/UARTSerial.cpp rename to drivers/source/UARTSerial.cpp diff --git a/events/EventQueue.h b/events/EventQueue.h index a3e879620a1..f624798bafc 100644 --- a/events/EventQueue.h +++ b/events/EventQueue.h @@ -18,7 +18,7 @@ #ifndef EVENT_QUEUE_H #define EVENT_QUEUE_H -#include "events/internal/equeue.h" +#include "events/source/equeue.h" #include "platform/Callback.h" #include "platform/NonCopyable.h" #include diff --git a/events/internal/.mbedignore b/events/source/.mbedignore similarity index 100% rename from events/internal/.mbedignore rename to events/source/.mbedignore diff --git a/events/internal/EventQueue.cpp b/events/source/EventQueue.cpp similarity index 100% rename from events/internal/EventQueue.cpp rename to events/source/EventQueue.cpp diff --git a/events/internal/Makefile b/events/source/Makefile similarity index 100% rename from events/internal/Makefile rename to events/source/Makefile diff --git a/events/internal/README.md b/events/source/README.md similarity index 100% rename from events/internal/README.md rename to events/source/README.md diff --git a/events/internal/equeue.c b/events/source/equeue.c similarity index 99% rename from events/internal/equeue.c rename to events/source/equeue.c index 769be33d1e2..8f23688d0dd 100644 --- a/events/internal/equeue.c +++ b/events/source/equeue.c @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "events/internal/equeue.h" +#include "events/source/equeue.h" #include #include diff --git a/events/internal/equeue.h b/events/source/equeue.h similarity index 99% rename from events/internal/equeue.h rename to events/source/equeue.h index e2600af7778..b08097cd3ca 100644 --- a/events/internal/equeue.h +++ b/events/source/equeue.h @@ -24,7 +24,7 @@ extern "C" { #endif // Platform specific files -#include "events/internal/equeue_platform.h" +#include "events/source/equeue_platform.h" #include #include diff --git a/events/internal/equeue_mbed.cpp b/events/source/equeue_mbed.cpp similarity index 99% rename from events/internal/equeue_mbed.cpp rename to events/source/equeue_mbed.cpp index ce397b935c9..d58b828781d 100644 --- a/events/internal/equeue_mbed.cpp +++ b/events/source/equeue_mbed.cpp @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "events/internal/equeue_platform.h" +#include "events/source/equeue_platform.h" #if defined(EQUEUE_PLATFORM_MBED) diff --git a/events/internal/equeue_platform.h b/events/source/equeue_platform.h similarity index 100% rename from events/internal/equeue_platform.h rename to events/source/equeue_platform.h diff --git a/events/internal/equeue_posix.c b/events/source/equeue_posix.c similarity index 98% rename from events/internal/equeue_posix.c rename to events/source/equeue_posix.c index 64c113cac13..f22cededc35 100644 --- a/events/internal/equeue_posix.c +++ b/events/source/equeue_posix.c @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "events/internal/equeue_platform.h" +#include "events/source/equeue_platform.h" #if defined(EQUEUE_PLATFORM_POSIX) diff --git a/events/internal/mbed_shared_queues.cpp b/events/source/mbed_shared_queues.cpp similarity index 100% rename from events/internal/mbed_shared_queues.cpp rename to events/source/mbed_shared_queues.cpp diff --git a/events/internal/tests/prof.c b/events/source/tests/prof.c similarity index 100% rename from events/internal/tests/prof.c rename to events/source/tests/prof.c diff --git a/events/internal/tests/tests.c b/events/source/tests/tests.c similarity index 100% rename from events/internal/tests/tests.c rename to events/source/tests/tests.c diff --git a/rtos/TARGET_CORTEX/SysTimer.h b/rtos/TARGET_CORTEX/SysTimer.h index 223bf7efc9e..0ad2d6c81b6 100644 --- a/rtos/TARGET_CORTEX/SysTimer.h +++ b/rtos/TARGET_CORTEX/SysTimer.h @@ -25,7 +25,7 @@ #if MBED_TICKLESS || defined(DOXYGEN_ONLY) #include "platform/NonCopyable.h" -#include "drivers/internal/TimerEvent.h" +#include "drivers/source/TimerEvent.h" namespace rtos { namespace internal { diff --git a/rtos/TARGET_CORTEX/mbed_rtx_handlers.c b/rtos/TARGET_CORTEX/mbed_rtx_handlers.c index 86739e73996..b5e46f812e8 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_handlers.c +++ b/rtos/TARGET_CORTEX/mbed_rtx_handlers.c @@ -22,8 +22,8 @@ #include "mbed_error.h" #include "mbed_interface.h" #include "RTX_Config.h" -#include "rtos/internal/rtos_handlers.h" -#include "rtos/internal/rtos_idle.h" +#include "rtos/source/rtos_handlers.h" +#include "rtos/source/rtos_idle.h" #ifdef RTE_Compiler_EventRecorder #include "EventRecorder.h" // Keil::Compiler:Event Recorder diff --git a/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp b/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp index f6d0a1e8bf7..88114cef40c 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp +++ b/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp @@ -20,9 +20,9 @@ * SOFTWARE. */ -#include "rtos/internal/rtos_idle.h" +#include "rtos/source/rtos_idle.h" #include "platform/mbed_power_mgmt.h" -#include "drivers/internal/TimerEvent.h" +#include "drivers/source/TimerEvent.h" #include "lp_ticker_api.h" #include "us_ticker_api.h" #include "mbed_critical.h" diff --git a/rtos/internal/ConditionVariable.cpp b/rtos/source/ConditionVariable.cpp similarity index 100% rename from rtos/internal/ConditionVariable.cpp rename to rtos/source/ConditionVariable.cpp diff --git a/rtos/internal/EventFlags.cpp b/rtos/source/EventFlags.cpp similarity index 100% rename from rtos/internal/EventFlags.cpp rename to rtos/source/EventFlags.cpp diff --git a/rtos/internal/Kernel.cpp b/rtos/source/Kernel.cpp similarity index 100% rename from rtos/internal/Kernel.cpp rename to rtos/source/Kernel.cpp diff --git a/rtos/internal/Mutex.cpp b/rtos/source/Mutex.cpp similarity index 100% rename from rtos/internal/Mutex.cpp rename to rtos/source/Mutex.cpp diff --git a/rtos/internal/RtosTimer.cpp b/rtos/source/RtosTimer.cpp similarity index 100% rename from rtos/internal/RtosTimer.cpp rename to rtos/source/RtosTimer.cpp diff --git a/rtos/internal/Semaphore.cpp b/rtos/source/Semaphore.cpp similarity index 100% rename from rtos/internal/Semaphore.cpp rename to rtos/source/Semaphore.cpp diff --git a/rtos/internal/ThisThread.cpp b/rtos/source/ThisThread.cpp similarity index 100% rename from rtos/internal/ThisThread.cpp rename to rtos/source/ThisThread.cpp diff --git a/rtos/internal/Thread.cpp b/rtos/source/Thread.cpp similarity index 100% rename from rtos/internal/Thread.cpp rename to rtos/source/Thread.cpp diff --git a/rtos/internal/rtos_handlers.h b/rtos/source/rtos_handlers.h similarity index 100% rename from rtos/internal/rtos_handlers.h rename to rtos/source/rtos_handlers.h diff --git a/rtos/internal/rtos_idle.h b/rtos/source/rtos_idle.h similarity index 100% rename from rtos/internal/rtos_idle.h rename to rtos/source/rtos_idle.h From 2443b48eced8e3b940b11b177ec2458da240002b Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 07:54:38 +0100 Subject: [PATCH 13/35] Fix path to TimerEvent.h header file --- TESTS/mbed_drivers/timerevent/main.cpp | 2 +- drivers/Ticker.h | 2 +- drivers/source/Ticker.cpp | 2 +- drivers/source/TimerEvent.cpp | 2 +- rtos/TARGET_CORTEX/SysTimer.h | 2 +- rtos/TARGET_CORTEX/mbed_rtx_idle.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TESTS/mbed_drivers/timerevent/main.cpp b/TESTS/mbed_drivers/timerevent/main.cpp index c1d318310d0..7228b8bb16e 100644 --- a/TESTS/mbed_drivers/timerevent/main.cpp +++ b/TESTS/mbed_drivers/timerevent/main.cpp @@ -21,7 +21,7 @@ #include "greentea-client/test_env.h" #include "unity.h" #include "utest.h" -#include "drivers/source/TimerEvent.h" +#include "drivers/TimerEvent.h" #include "hal/ticker_api.h" #include "rtos.h" diff --git a/drivers/Ticker.h b/drivers/Ticker.h index 540c6be603d..455283718e1 100644 --- a/drivers/Ticker.h +++ b/drivers/Ticker.h @@ -17,7 +17,7 @@ #ifndef MBED_TICKER_H #define MBED_TICKER_H -#include "drivers/source/TimerEvent.h" +#include "drivers/TimerEvent.h" #include "platform/Callback.h" #include "platform/mbed_toolchain.h" #include "platform/NonCopyable.h" diff --git a/drivers/source/Ticker.cpp b/drivers/source/Ticker.cpp index f243faa0eb0..fada56cf646 100644 --- a/drivers/source/Ticker.cpp +++ b/drivers/source/Ticker.cpp @@ -16,7 +16,7 @@ */ #include "drivers/Ticker.h" -#include "drivers/source/TimerEvent.h" +#include "drivers/TimerEvent.h" #include "platform/FunctionPointer.h" #include "hal/ticker_api.h" #include "platform/mbed_critical.h" diff --git a/drivers/source/TimerEvent.cpp b/drivers/source/TimerEvent.cpp index 3ea092b9075..a225d1fd1b1 100644 --- a/drivers/source/TimerEvent.cpp +++ b/drivers/source/TimerEvent.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "drivers/source/TimerEvent.h" +#include "drivers/TimerEvent.h" #include #include "hal/us_ticker_api.h" diff --git a/rtos/TARGET_CORTEX/SysTimer.h b/rtos/TARGET_CORTEX/SysTimer.h index 0ad2d6c81b6..ff52348cded 100644 --- a/rtos/TARGET_CORTEX/SysTimer.h +++ b/rtos/TARGET_CORTEX/SysTimer.h @@ -25,7 +25,7 @@ #if MBED_TICKLESS || defined(DOXYGEN_ONLY) #include "platform/NonCopyable.h" -#include "drivers/source/TimerEvent.h" +#include "drivers/TimerEvent.h" namespace rtos { namespace internal { diff --git a/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp b/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp index 88114cef40c..bd74ddc9069 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp +++ b/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp @@ -22,7 +22,7 @@ #include "rtos/source/rtos_idle.h" #include "platform/mbed_power_mgmt.h" -#include "drivers/source/TimerEvent.h" +#include "drivers/TimerEvent.h" #include "lp_ticker_api.h" #include "us_ticker_api.h" #include "mbed_critical.h" From 693f7be1964c3f8fb4e7827a8b1b28844f2131f5 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 07:57:02 +0100 Subject: [PATCH 14/35] Fix path to SerialBase.h header file --- UNITTESTS/stubs/SerialBase_stub.cpp | 2 +- drivers/RawSerial.h | 2 +- drivers/Serial.h | 2 +- drivers/UARTSerial.h | 2 +- drivers/source/SerialBase.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/UNITTESTS/stubs/SerialBase_stub.cpp b/UNITTESTS/stubs/SerialBase_stub.cpp index 048cd565a1c..c0a19d3f54c 100644 --- a/UNITTESTS/stubs/SerialBase_stub.cpp +++ b/UNITTESTS/stubs/SerialBase_stub.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "drivers/source/SerialBase.h" +#include "drivers/SerialBase.h" namespace mbed { diff --git a/drivers/RawSerial.h b/drivers/RawSerial.h index ec83a36a47e..71c5a49bd4f 100644 --- a/drivers/RawSerial.h +++ b/drivers/RawSerial.h @@ -22,7 +22,7 @@ #if DEVICE_SERIAL || defined(DOXYGEN_ONLY) #include "mbed_toolchain.h" -#include "drivers/source/SerialBase.h" +#include "drivers/SerialBase.h" #include "platform/NonCopyable.h" #include diff --git a/drivers/Serial.h b/drivers/Serial.h index 4ab43d93ec8..c3fa6f12ae6 100644 --- a/drivers/Serial.h +++ b/drivers/Serial.h @@ -22,7 +22,7 @@ #if DEVICE_SERIAL || defined(DOXYGEN_ONLY) #include "platform/Stream.h" -#include "drivers/source/SerialBase.h" +#include "drivers/SerialBase.h" #include "platform/PlatformMutex.h" #include "platform/NonCopyable.h" diff --git a/drivers/UARTSerial.h b/drivers/UARTSerial.h index b02d61ace37..13366a5e12a 100644 --- a/drivers/UARTSerial.h +++ b/drivers/UARTSerial.h @@ -23,7 +23,7 @@ #if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #include "platform/FileHandle.h" -#include "drivers/source/SerialBase.h" +#include "drivers/SerialBase.h" #include "InterruptIn.h" #include "platform/PlatformMutex.h" #include "platform/CircularBuffer.h" diff --git a/drivers/source/SerialBase.cpp b/drivers/source/SerialBase.cpp index 8dc3a611f2c..09372d71dc0 100644 --- a/drivers/source/SerialBase.cpp +++ b/drivers/source/SerialBase.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "drivers/source/SerialBase.h" +#include "drivers/SerialBase.h" #include "platform/mbed_wait_api.h" #include "platform/mbed_critical.h" #include "platform/mbed_power_mgmt.h" From 00c30158598c5cf2bc13819877d7f4ec384ace0b Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 08:02:37 +0100 Subject: [PATCH 15/35] Fix events dir path in UNITTESTS makefile --- UNITTESTS/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 95806c5b7c5..1b18700defb 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -101,7 +101,7 @@ set(unittest-includes-base "${PROJECT_SOURCE_DIR}/../drivers" "${PROJECT_SOURCE_DIR}/../hal" "${PROJECT_SOURCE_DIR}/../events" - "${PROJECT_SOURCE_DIR}/../events/equeue" + "${PROJECT_SOURCE_DIR}/../events/source" "${PROJECT_SOURCE_DIR}/../rtos" "${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX" "${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX/rtx5/Include" From a79f23e3e656ff3ab608a332fd66ddc0cce68cd9 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 08:42:35 +0100 Subject: [PATCH 16/35] Fix path to equeue and profiling events tests in travis script --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 19d3a75a4d4..31b754d8cbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -227,9 +227,9 @@ matrix: features/frameworks/utest features/frameworks/unity components BUILD - python tools/make.py -t GCC_ARM -m DISCO_F401VC --source=. --build=BUILD/DISCO_F401VC/GCC_ARM -j0 # Run local equeue tests - - make -C ${EVENTS}/equeue test + - make -C ${EVENTS}/source test # Run profiling tests - - make -C ${EVENTS}/equeue prof | tee prof + - make -C ${EVENTS}/source prof | tee prof after_success: # Update status, comparing with master if possible. - | From 2fccd99801455dee6f610a9d1f262cdff30059f8 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 09:06:15 +0100 Subject: [PATCH 17/35] Fix include path to find `source` folder from relative path in travis test --- events/source/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/source/Makefile b/events/source/Makefile index 1323c96bf00..6e636bc87b1 100644 --- a/events/source/Makefile +++ b/events/source/Makefile @@ -17,7 +17,7 @@ endif ifdef WORD CFLAGS += -m$(WORD) endif -CFLAGS += -I. -I.. +CFLAGS += -I. -I.. -I../.. CFLAGS += -std=c99 CFLAGS += -Wall CFLAGS += -D_XOPEN_SOURCE=600 From ef074e76ab1f502a7b5e3dfe966baddbe4e717fb Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 09:30:25 +0100 Subject: [PATCH 18/35] Fix missing declaration of `sleep` symbol by including header file. --- events/source/equeue_mbed.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/events/source/equeue_mbed.cpp b/events/source/equeue_mbed.cpp index d58b828781d..41f0ac7a1dd 100644 --- a/events/source/equeue_mbed.cpp +++ b/events/source/equeue_mbed.cpp @@ -23,6 +23,7 @@ #include #include #include "platform/mbed_critical.h" +#include "platform/mbed_power_mgmt.h" #include "drivers/Timer.h" #include "drivers/Ticker.h" #include "drivers/Timeout.h" From 429caa69a1dc787a06c0f4de0cdad277a91098bb Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 13:55:14 +0100 Subject: [PATCH 19/35] Inline low footprint methods for code size and speed --- drivers/CAN.h | 36 +++++++++++++++++++++++++---- drivers/DigitalInOut.h | 7 +++++- drivers/DigitalOut.h | 7 +++++- drivers/PortInOut.h | 12 ++++++++-- drivers/PortOut.h | 12 ++++++++-- drivers/PwmOut.h | 14 +++++++++-- drivers/source/CAN.cpp | 36 ----------------------------- drivers/source/DigitalInOut.cpp | 7 ------ drivers/source/DigitalOut.cpp | 7 ------ drivers/source/PortInOut.cpp | 15 ------------ drivers/source/PortOut.cpp | 15 ------------ drivers/source/PwmOut.cpp | 14 ----------- drivers/source/SerialWireOutput.cpp | 4 ++-- drivers/source/Ticker.cpp | 4 ++-- 14 files changed, 80 insertions(+), 110 deletions(-) diff --git a/drivers/CAN.h b/drivers/CAN.h index 8e9cc11ed34..d88a7a54083 100644 --- a/drivers/CAN.h +++ b/drivers/CAN.h @@ -44,7 +44,14 @@ class CANMessage : public CAN_Message { public: /** Creates empty CAN message. */ - CANMessage(); + CANMessage() : CAN_Message() + { + len = 8U; + type = CANData; + format = CANStandard; + id = 0U; + memset(data, 0, 8); + } /** Creates CAN message with specific content. * @@ -54,7 +61,14 @@ class CANMessage : public CAN_Message { * @param _type Type of Data: Use enum CANType for valid parameter values * @param _format Data Format: Use enum CANFormat for valid parameter values */ - CANMessage(unsigned int _id, const unsigned char *_data, unsigned char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard); + CANMessage(unsigned int _id, const unsigned char *_data, unsigned char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard) + { + len = _len & 0xF; + type = _type; + format = _format; + id = _id; + memcpy(data, _data, _len); + } /** Creates CAN message with specific content. @@ -65,14 +79,28 @@ class CANMessage : public CAN_Message { * @param _type Type of Data: Use enum CANType for valid parameter values * @param _format Data Format: Use enum CANFormat for valid parameter values */ - CANMessage(unsigned int _id, const char *_data, unsigned char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard); + CANMessage(unsigned int _id, const char *_data, unsigned char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard) + { + len = _len & 0xF; + type = _type; + format = _format; + id = _id; + memcpy(data, _data, _len); + } /** Creates CAN remote message. * * @param _id Message ID * @param _format Data Format: Use enum CANType for valid parameter values */ - CANMessage(unsigned int _id, CANFormat _format = CANStandard); + CANMessage(unsigned int _id, CANFormat _format = CANStandard) + { + len = 0; + type = CANRemote; + format = _format; + id = _id; + memset(data, 0, 8); + } }; /** @}*/ diff --git a/drivers/DigitalInOut.h b/drivers/DigitalInOut.h index 6897768704f..ccae13e997c 100644 --- a/drivers/DigitalInOut.h +++ b/drivers/DigitalInOut.h @@ -119,7 +119,12 @@ class DigitalInOut { * inout = button; // Equivalent to inout.write(button.read()) * @endcode */ - DigitalInOut &operator= (int value); + DigitalInOut &operator= (int value) + { + // Underlying write is thread safe + write(value); + return *this; + } /**A shorthand for write() using the assignment operator which copies the * state from the DigitalInOut argument. diff --git a/drivers/DigitalOut.h b/drivers/DigitalOut.h index bc1c44de947..87387d98d89 100644 --- a/drivers/DigitalOut.h +++ b/drivers/DigitalOut.h @@ -115,7 +115,12 @@ class DigitalOut { * led = button; // Equivalent to led.write(button.read()) * @endcode */ - DigitalOut &operator= (int value); + DigitalOut &operator= (int value) + { + // Underlying write is thread safe + write(value); + return *this; + } /** A shorthand for write() using the assignment operator which copies the * state from the DigitalOut argument. diff --git a/drivers/PortInOut.h b/drivers/PortInOut.h index f17a6e55614..839d26651b1 100644 --- a/drivers/PortInOut.h +++ b/drivers/PortInOut.h @@ -82,12 +82,20 @@ class PortInOut { /** A shorthand for write() * \sa PortInOut::write() */ - PortInOut &operator= (int value); + PortInOut &operator= (int value) + { + write(value); + return *this; + } /** A shorthand for write() * \sa PortInOut::write() */ - PortInOut &operator= (PortInOut &rhs); + PortInOut &operator= (PortInOut &rhs) + { + write(rhs.read()); + return *this; + } /** A shorthand for read() * \sa PortInOut::read() diff --git a/drivers/PortOut.h b/drivers/PortOut.h index 1ce20e7424e..3b3c3ec6a04 100644 --- a/drivers/PortOut.h +++ b/drivers/PortOut.h @@ -88,12 +88,20 @@ class PortOut { /** A shorthand for write() * \sa PortOut::write() */ - PortOut &operator= (int value); + PortOut &operator= (int value) + { + write(value); + return *this; + } /** A shorthand for read() * \sa PortOut::read() */ - PortOut &operator= (PortOut &rhs); + PortOut &operator= (PortOut &rhs) + { + write(rhs.read()); + return *this; + } /** A shorthand for read() * \sa PortOut::read() diff --git a/drivers/PwmOut.h b/drivers/PwmOut.h index d1221fb67c4..d1516297744 100644 --- a/drivers/PwmOut.h +++ b/drivers/PwmOut.h @@ -123,12 +123,22 @@ class PwmOut { /** A operator shorthand for write() * \sa PwmOut::write() */ - PwmOut &operator= (float value); + PwmOut &operator= (float value) + { + // Underlying call is thread safe + write(value); + return *this; + } /** A operator shorthand for write() * \sa PwmOut::write() */ - PwmOut &operator= (PwmOut &rhs); + PwmOut &operator= (PwmOut &rhs) + { + // Underlying call is thread safe + write(rhs.read()); + return *this; + } /** An operator shorthand for read() * \sa PwmOut::read() diff --git a/drivers/source/CAN.cpp b/drivers/source/CAN.cpp index 78b6762f343..9b665271db4 100644 --- a/drivers/source/CAN.cpp +++ b/drivers/source/CAN.cpp @@ -22,42 +22,6 @@ namespace mbed { -CANMessage::CANMessage() : CAN_Message() -{ - len = 8U; - type = CANData; - format = CANStandard; - id = 0U; - memset(data, 0, 8); -} - -CANMessage::CANMessage(unsigned int _id, const unsigned char *_data, unsigned char _len, CANType _type, CANFormat _format) -{ - len = _len & 0xF; - type = _type; - format = _format; - id = _id; - memcpy(data, _data, _len); -} - -CANMessage::CANMessage(unsigned int _id, const char *_data, unsigned char _len, CANType _type, CANFormat _format) -{ - len = _len & 0xF; - type = _type; - format = _format; - id = _id; - memcpy(data, _data, _len); -} - -CANMessage::CANMessage(unsigned int _id, CANFormat _format) -{ - len = 0; - type = CANRemote; - format = _format; - id = _id; - memset(data, 0, 8); -} - CAN::CAN(PinName rd, PinName td) : _can(), _irq() { // No lock needed in constructor diff --git a/drivers/source/DigitalInOut.cpp b/drivers/source/DigitalInOut.cpp index 7a9cfef8246..418491e1650 100644 --- a/drivers/source/DigitalInOut.cpp +++ b/drivers/source/DigitalInOut.cpp @@ -42,13 +42,6 @@ void DigitalInOut::mode(PinMode pull) core_util_critical_section_exit(); } -DigitalInOut &DigitalInOut::operator= (int value) -{ - // Underlying write is thread safe - write(value); - return *this; -} - DigitalInOut &DigitalInOut::operator= (DigitalInOut &rhs) { core_util_critical_section_enter(); diff --git a/drivers/source/DigitalOut.cpp b/drivers/source/DigitalOut.cpp index 20ec03bac79..1d1855a9efc 100644 --- a/drivers/source/DigitalOut.cpp +++ b/drivers/source/DigitalOut.cpp @@ -21,13 +21,6 @@ namespace mbed { -DigitalOut &DigitalOut::operator= (int value) -{ - // Underlying write is thread safe - write(value); - return *this; -} - DigitalOut &DigitalOut::operator= (DigitalOut &rhs) { core_util_critical_section_enter(); diff --git a/drivers/source/PortInOut.cpp b/drivers/source/PortInOut.cpp index 3b9671ad965..bb496720317 100644 --- a/drivers/source/PortInOut.cpp +++ b/drivers/source/PortInOut.cpp @@ -52,21 +52,6 @@ void PortInOut::mode(PinMode mode) core_util_critical_section_exit(); } -PortInOut &PortInOut::operator= (int value) -{ - write(value); - return *this; -} - -/** A shorthand for write() - * \sa PortInOut::write() - */ -PortInOut &PortInOut::operator= (PortInOut &rhs) -{ - write(rhs.read()); - return *this; -} - } // namespace mbed #endif // #if DEVICE_PORTINOUT diff --git a/drivers/source/PortOut.cpp b/drivers/source/PortOut.cpp index 62fd3a26482..12a23d00ecc 100644 --- a/drivers/source/PortOut.cpp +++ b/drivers/source/PortOut.cpp @@ -31,21 +31,6 @@ PortOut::PortOut(PortName port, int mask) core_util_critical_section_exit(); } -PortOut &PortOut::operator= (int value) -{ - write(value); - return *this; -} - -/** A shorthand for write() - * \sa PortOut::write() - */ -PortOut &PortOut::operator= (PortOut &rhs) -{ - write(rhs.read()); - return *this; -} - } // namespace mbed #endif // #if DEVICE_PORTOUT diff --git a/drivers/source/PwmOut.cpp b/drivers/source/PwmOut.cpp index 12711658828..67e5f36b341 100644 --- a/drivers/source/PwmOut.cpp +++ b/drivers/source/PwmOut.cpp @@ -98,20 +98,6 @@ void PwmOut::pulsewidth_us(int us) core_util_critical_section_exit(); } -PwmOut &PwmOut::operator= (float value) -{ - // Underlying call is thread safe - write(value); - return *this; -} - -PwmOut &PwmOut::operator= (PwmOut &rhs) -{ - // Underlying call is thread safe - write(rhs.read()); - return *this; -} - void PwmOut::lock_deep_sleep() { if (_deep_sleep_locked == false) { diff --git a/drivers/source/SerialWireOutput.cpp b/drivers/source/SerialWireOutput.cpp index 92d6bd3c016..1cb171c9d3e 100644 --- a/drivers/source/SerialWireOutput.cpp +++ b/drivers/source/SerialWireOutput.cpp @@ -23,13 +23,13 @@ namespace mbed { -SerialWireOutput::SerialWireOutput(void) +inline SerialWireOutput::SerialWireOutput(void) { /* Initialize ITM using internal init function. */ mbed_itm_init(); } -ssize_t SerialWireOutput::write(const void *buffer, size_t size) +inline ssize_t SerialWireOutput::write(const void *buffer, size_t size) { mbed_itm_send_block(ITM_PORT_SWO, buffer, size); diff --git a/drivers/source/Ticker.cpp b/drivers/source/Ticker.cpp index fada56cf646..2f5566b8236 100644 --- a/drivers/source/Ticker.cpp +++ b/drivers/source/Ticker.cpp @@ -24,12 +24,12 @@ namespace mbed { -Ticker::Ticker() : TimerEvent(), _function(0), _lock_deepsleep(true) +inline Ticker::Ticker() : TimerEvent(), _function(0), _lock_deepsleep(true) { } // When low power ticker is in use, then do not disable deep sleep. -Ticker::Ticker(const ticker_data_t *data) : TimerEvent(data), _function(0), _lock_deepsleep(!data->interface->runs_in_deep_sleep) +inline Ticker::Ticker(const ticker_data_t *data) : TimerEvent(data), _function(0), _lock_deepsleep(!data->interface->runs_in_deep_sleep) { } From 92ded3a0579c9d2f4b9caed85e6e6945f54ccd34 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 13:55:53 +0100 Subject: [PATCH 20/35] Correct copyright owner in copyright notice --- events/source/equeue.c | 2 +- events/source/equeue.h | 2 +- events/source/equeue_mbed.cpp | 2 +- events/source/equeue_platform.h | 2 +- events/source/equeue_posix.c | 2 +- events/source/tests/prof.c | 2 +- events/source/tests/tests.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/events/source/equeue.c b/events/source/equeue.c index 8f23688d0dd..91e79407732 100644 --- a/events/source/equeue.c +++ b/events/source/equeue.c @@ -1,7 +1,7 @@ /* * Flexible event queue for dispatching events * - * Copyright (c) 2016-2019 Christopher Haster + * Copyright (c) 2016-2019 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/events/source/equeue.h b/events/source/equeue.h index b08097cd3ca..45f407c3692 100644 --- a/events/source/equeue.h +++ b/events/source/equeue.h @@ -2,7 +2,7 @@ /* * Flexible event queue for dispatching events * - * Copyright (c) 2016-2019 Christopher Haster + * Copyright (c) 2016-2019 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/events/source/equeue_mbed.cpp b/events/source/equeue_mbed.cpp index 41f0ac7a1dd..48d38eb3be9 100644 --- a/events/source/equeue_mbed.cpp +++ b/events/source/equeue_mbed.cpp @@ -2,7 +2,7 @@ * Implementation for the mbed library * https://github.com/mbedmicro/mbed * - * Copyright (c) 2016-2019 Christopher Haster + * Copyright (c) 2016-2019 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/events/source/equeue_platform.h b/events/source/equeue_platform.h index a2add1e05b3..e3a5c0d635f 100644 --- a/events/source/equeue_platform.h +++ b/events/source/equeue_platform.h @@ -1,7 +1,7 @@ /* * System specific implementation * - * Copyright (c) 2016-2019 Christopher Haster + * Copyright (c) 2016-2019 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/events/source/equeue_posix.c b/events/source/equeue_posix.c index f22cededc35..4e47f807603 100644 --- a/events/source/equeue_posix.c +++ b/events/source/equeue_posix.c @@ -1,7 +1,7 @@ /* * Implementation for Posix compliant platforms * - * Copyright (c) 2016-2019 Christopher Haster + * Copyright (c) 2016-2019 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/events/source/tests/prof.c b/events/source/tests/prof.c index 82b5c93e0c1..1a3996fef1d 100644 --- a/events/source/tests/prof.c +++ b/events/source/tests/prof.c @@ -1,7 +1,7 @@ /* * Profiling framework for the events library * - * Copyright (c) 2016 Christopher Haster + * Copyright (c) 2016 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/events/source/tests/tests.c b/events/source/tests/tests.c index 96f18429623..b0309f69491 100644 --- a/events/source/tests/tests.c +++ b/events/source/tests/tests.c @@ -1,7 +1,7 @@ /* * Testing framework for the events library * - * Copyright (c) 2016 Christopher Haster + * Copyright (c) 2016 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 31e51deaa048247389f3f83bd00b6c3a4733dbd4 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 8 Jul 2019 13:57:55 +0100 Subject: [PATCH 21/35] Slightly improve readability and consistence --- drivers/AnalogIn.h | 1 + drivers/AnalogOut.h | 1 + drivers/UARTSerial.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/AnalogIn.h b/drivers/AnalogIn.h index 8b217bb4d1a..172a2e5cfdd 100644 --- a/drivers/AnalogIn.h +++ b/drivers/AnalogIn.h @@ -108,6 +108,7 @@ class AnalogIn { { _mutex->lock(); } + virtual void unlock() { _mutex->unlock(); diff --git a/drivers/AnalogOut.h b/drivers/AnalogOut.h index 15aa3791c13..6e1bc7db6fb 100644 --- a/drivers/AnalogOut.h +++ b/drivers/AnalogOut.h @@ -126,6 +126,7 @@ class AnalogOut { { _mutex.lock(); } + virtual void unlock() { _mutex.unlock(); diff --git a/drivers/UARTSerial.h b/drivers/UARTSerial.h index 13366a5e12a..77454a014bb 100644 --- a/drivers/UARTSerial.h +++ b/drivers/UARTSerial.h @@ -24,7 +24,7 @@ #include "platform/FileHandle.h" #include "drivers/SerialBase.h" -#include "InterruptIn.h" +#include "drivers/InterruptIn.h" #include "platform/PlatformMutex.h" #include "platform/CircularBuffer.h" #include "platform/NonCopyable.h" From 52d53d0d6e7d57eaeadaec354f705ec4792d6806 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 9 Jul 2019 14:21:27 +0100 Subject: [PATCH 22/35] Fix inline usage by moving it to method declarations --- drivers/SerialWireOutput.h | 4 ++-- drivers/Ticker.h | 4 ++-- drivers/source/SerialWireOutput.cpp | 4 ++-- drivers/source/Ticker.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/SerialWireOutput.h b/drivers/SerialWireOutput.h index a2db35d93e9..2fad1a2bf89 100644 --- a/drivers/SerialWireOutput.h +++ b/drivers/SerialWireOutput.h @@ -37,9 +37,9 @@ class SerialWireOutput : public FileHandle { public: - SerialWireOutput(void); + inline SerialWireOutput(void); - virtual ssize_t write(const void *buffer, size_t size); + inline virtual ssize_t write(const void *buffer, size_t size); virtual ssize_t read(void *buffer, size_t size) { diff --git a/drivers/Ticker.h b/drivers/Ticker.h index 455283718e1..f5ddb81fbe5 100644 --- a/drivers/Ticker.h +++ b/drivers/Ticker.h @@ -70,10 +70,10 @@ namespace mbed { class Ticker : public TimerEvent, private NonCopyable { public: - Ticker(); + inline Ticker(); // When low power ticker is in use, then do not disable deep sleep. - Ticker(const ticker_data_t *data); + inline Ticker(const ticker_data_t *data); /** Attach a function to be called by the Ticker, specifying the interval in seconds * diff --git a/drivers/source/SerialWireOutput.cpp b/drivers/source/SerialWireOutput.cpp index 1cb171c9d3e..92d6bd3c016 100644 --- a/drivers/source/SerialWireOutput.cpp +++ b/drivers/source/SerialWireOutput.cpp @@ -23,13 +23,13 @@ namespace mbed { -inline SerialWireOutput::SerialWireOutput(void) +SerialWireOutput::SerialWireOutput(void) { /* Initialize ITM using internal init function. */ mbed_itm_init(); } -inline ssize_t SerialWireOutput::write(const void *buffer, size_t size) +ssize_t SerialWireOutput::write(const void *buffer, size_t size) { mbed_itm_send_block(ITM_PORT_SWO, buffer, size); diff --git a/drivers/source/Ticker.cpp b/drivers/source/Ticker.cpp index 2f5566b8236..fada56cf646 100644 --- a/drivers/source/Ticker.cpp +++ b/drivers/source/Ticker.cpp @@ -24,12 +24,12 @@ namespace mbed { -inline Ticker::Ticker() : TimerEvent(), _function(0), _lock_deepsleep(true) +Ticker::Ticker() : TimerEvent(), _function(0), _lock_deepsleep(true) { } // When low power ticker is in use, then do not disable deep sleep. -inline Ticker::Ticker(const ticker_data_t *data) : TimerEvent(data), _function(0), _lock_deepsleep(!data->interface->runs_in_deep_sleep) +Ticker::Ticker(const ticker_data_t *data) : TimerEvent(data), _function(0), _lock_deepsleep(!data->interface->runs_in_deep_sleep) { } From 35ce062a83800a6fdd40887650b22f9a2887d36d Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 9 Jul 2019 15:02:46 +0100 Subject: [PATCH 23/35] Fix remove inline specifier as the definition of an inline function must be present in the translation unit where it is accessed --- drivers/SerialWireOutput.h | 4 ++-- drivers/Ticker.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/SerialWireOutput.h b/drivers/SerialWireOutput.h index 2fad1a2bf89..a2db35d93e9 100644 --- a/drivers/SerialWireOutput.h +++ b/drivers/SerialWireOutput.h @@ -37,9 +37,9 @@ class SerialWireOutput : public FileHandle { public: - inline SerialWireOutput(void); + SerialWireOutput(void); - inline virtual ssize_t write(const void *buffer, size_t size); + virtual ssize_t write(const void *buffer, size_t size); virtual ssize_t read(void *buffer, size_t size) { diff --git a/drivers/Ticker.h b/drivers/Ticker.h index f5ddb81fbe5..455283718e1 100644 --- a/drivers/Ticker.h +++ b/drivers/Ticker.h @@ -70,10 +70,10 @@ namespace mbed { class Ticker : public TimerEvent, private NonCopyable { public: - inline Ticker(); + Ticker(); // When low power ticker is in use, then do not disable deep sleep. - inline Ticker(const ticker_data_t *data); + Ticker(const ticker_data_t *data); /** Attach a function to be called by the Ticker, specifying the interval in seconds * From 9b592cdf452445068bf752f2b9ab375e693e4751 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 08:11:12 +0100 Subject: [PATCH 24/35] Fix SerialWireOutput API Doxygen classification --- drivers/SerialWireOutput.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/SerialWireOutput.h b/drivers/SerialWireOutput.h index a2db35d93e9..52f5416c54b 100644 --- a/drivers/SerialWireOutput.h +++ b/drivers/SerialWireOutput.h @@ -26,7 +26,7 @@ namespace mbed { /** \ingroup drivers */ -/** \addtogroup drivers-public-api Internal API */ +/** \addtogroup drivers-public-api Public API */ /** @{*/ /** * \defgroup drivers_SerialWireOutput SerialWireOutput class From 91ef36dd789e1bb98cee6d918aeadc80203c338f Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 08:20:05 +0100 Subject: [PATCH 25/35] Create `internal` dir in `events` and `drivers` --- drivers/MbedCRC.h | 2 +- drivers/{source => internal}/TableCRC.cpp | 2 +- drivers/{source => internal}/TableCRC.h | 0 events/EventQueue.h | 2 +- events/{source => internal}/equeue.c | 2 +- events/{source => internal}/equeue.h | 2 +- events/{source => internal}/equeue_platform.h | 0 events/source/equeue_mbed.cpp | 2 +- events/source/equeue_posix.c | 2 +- 9 files changed, 7 insertions(+), 7 deletions(-) rename drivers/{source => internal}/TableCRC.cpp (99%) rename drivers/{source => internal}/TableCRC.h (100%) rename events/{source => internal}/equeue.c (99%) rename events/{source => internal}/equeue.h (99%) rename events/{source => internal}/equeue_platform.h (100%) diff --git a/drivers/MbedCRC.h b/drivers/MbedCRC.h index d56fae76268..1d666da445d 100644 --- a/drivers/MbedCRC.h +++ b/drivers/MbedCRC.h @@ -17,7 +17,7 @@ #ifndef MBED_CRC_API_H #define MBED_CRC_API_H -#include "drivers/source/TableCRC.h" +#include "drivers/internal/TableCRC.h" #include "hal/crc_api.h" #include "platform/mbed_assert.h" #include "platform/SingletonPtr.h" diff --git a/drivers/source/TableCRC.cpp b/drivers/internal/TableCRC.cpp similarity index 99% rename from drivers/source/TableCRC.cpp rename to drivers/internal/TableCRC.cpp index 1ba6f4f5ec8..6cea67d94a3 100644 --- a/drivers/source/TableCRC.cpp +++ b/drivers/internal/TableCRC.cpp @@ -16,7 +16,7 @@ */ #include -#include "drivers/source/TableCRC.h" +#include "drivers/internal/TableCRC.h" namespace mbed { diff --git a/drivers/source/TableCRC.h b/drivers/internal/TableCRC.h similarity index 100% rename from drivers/source/TableCRC.h rename to drivers/internal/TableCRC.h diff --git a/events/EventQueue.h b/events/EventQueue.h index f624798bafc..a3e879620a1 100644 --- a/events/EventQueue.h +++ b/events/EventQueue.h @@ -18,7 +18,7 @@ #ifndef EVENT_QUEUE_H #define EVENT_QUEUE_H -#include "events/source/equeue.h" +#include "events/internal/equeue.h" #include "platform/Callback.h" #include "platform/NonCopyable.h" #include diff --git a/events/source/equeue.c b/events/internal/equeue.c similarity index 99% rename from events/source/equeue.c rename to events/internal/equeue.c index 91e79407732..4cab29b1a32 100644 --- a/events/source/equeue.c +++ b/events/internal/equeue.c @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "events/source/equeue.h" +#include "events/internal/equeue.h" #include #include diff --git a/events/source/equeue.h b/events/internal/equeue.h similarity index 99% rename from events/source/equeue.h rename to events/internal/equeue.h index 45f407c3692..d167fe48c84 100644 --- a/events/source/equeue.h +++ b/events/internal/equeue.h @@ -24,7 +24,7 @@ extern "C" { #endif // Platform specific files -#include "events/source/equeue_platform.h" +#include "events/internal/equeue_platform.h" #include #include diff --git a/events/source/equeue_platform.h b/events/internal/equeue_platform.h similarity index 100% rename from events/source/equeue_platform.h rename to events/internal/equeue_platform.h diff --git a/events/source/equeue_mbed.cpp b/events/source/equeue_mbed.cpp index 48d38eb3be9..62bd101098c 100644 --- a/events/source/equeue_mbed.cpp +++ b/events/source/equeue_mbed.cpp @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "events/source/equeue_platform.h" +#include "events/internal/equeue_platform.h" #if defined(EQUEUE_PLATFORM_MBED) diff --git a/events/source/equeue_posix.c b/events/source/equeue_posix.c index 4e47f807603..9663865a97b 100644 --- a/events/source/equeue_posix.c +++ b/events/source/equeue_posix.c @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "events/source/equeue_platform.h" +#include "events/internal/equeue_platform.h" #if defined(EQUEUE_PLATFORM_POSIX) From 7d3d9442e65fc04f229cb70597e13d9c71241767 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 09:56:57 +0100 Subject: [PATCH 26/35] Fix events tests paths to internal headers --- UNITTESTS/CMakeLists.txt | 1 + events/source/tests/prof.c | 2 +- events/source/tests/tests.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 1b18700defb..b3897f40fe7 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -102,6 +102,7 @@ set(unittest-includes-base "${PROJECT_SOURCE_DIR}/../hal" "${PROJECT_SOURCE_DIR}/../events" "${PROJECT_SOURCE_DIR}/../events/source" + "${PROJECT_SOURCE_DIR}/../events/internal" "${PROJECT_SOURCE_DIR}/../rtos" "${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX" "${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX/rtx5/Include" diff --git a/events/source/tests/prof.c b/events/source/tests/prof.c index 1a3996fef1d..6f535aacb76 100644 --- a/events/source/tests/prof.c +++ b/events/source/tests/prof.c @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "equeue.h" +#include "events/internal/equeue.h" #include #include #include diff --git a/events/source/tests/tests.c b/events/source/tests/tests.c index b0309f69491..5950cd5e829 100644 --- a/events/source/tests/tests.c +++ b/events/source/tests/tests.c @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "equeue.h" +#include "events/internal/equeue.h" #include #include #include From 893b930bc8b1e97c6a20a917469dd9c7bd672674 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 11:47:36 +0100 Subject: [PATCH 27/35] Restore methods made inline in header files --- drivers/CAN.h | 10 +---- drivers/FlashIAP.h | 36 +++------------- drivers/I2C.h | 10 +---- drivers/I2CSlave.h | 37 ++++------------ drivers/InterruptIn.h | 23 ++-------- drivers/InterruptManager.h | 34 +++------------ drivers/QSPI.h | 10 +---- drivers/RawSerial.h | 15 ++----- drivers/SPI.h | 56 +++--------------------- drivers/SPISlave.h | 15 ++----- drivers/Serial.h | 31 +++----------- drivers/SerialBase.h | 16 ++----- drivers/Timer.h | 10 +---- drivers/TimerEvent.h | 27 +++--------- drivers/UARTSerial.h | 56 +++++------------------- drivers/source/CAN.cpp | 10 +++++ drivers/source/FlashIAP.cpp | 37 +++++++++++++++- drivers/source/I2C.cpp | 10 +++++ drivers/source/I2CSlave.cpp | 37 +++++++++++++++- drivers/source/InterruptIn.cpp | 28 +++++++++++- drivers/source/InterruptManager.cpp | 32 ++++++++++++++ drivers/source/QSPI.cpp | 10 +++++ drivers/source/RawSerial.cpp | 19 +++++++++ drivers/source/SPI.cpp | 48 +++++++++++++++++++++ drivers/source/SPISlave.cpp | 15 +++++++ drivers/source/Serial.cpp | 30 +++++++++++++ drivers/source/SerialBase.cpp | 19 +++++++++ drivers/source/Timer.cpp | 13 +++++- drivers/source/TimerEvent.cpp | 26 ++++++++++++ drivers/source/UARTSerial.cpp | 66 ++++++++++++++++++++++++++++- 30 files changed, 464 insertions(+), 322 deletions(-) diff --git a/drivers/CAN.h b/drivers/CAN.h index d88a7a54083..2de35c8ffde 100644 --- a/drivers/CAN.h +++ b/drivers/CAN.h @@ -324,14 +324,8 @@ class CAN : private NonCopyable { #if !defined(DOXYGEN_ONLY) protected: - virtual void lock() - { - _mutex.lock(); - } - virtual void unlock() - { - _mutex.unlock(); - } + virtual void lock(); + virtual void unlock(); can_t _can; Callback _irq[IrqCnt]; diff --git a/drivers/FlashIAP.h b/drivers/FlashIAP.h index f2ab7f1dc6f..f0397eb68c3 100644 --- a/drivers/FlashIAP.h +++ b/drivers/FlashIAP.h @@ -63,15 +63,8 @@ namespace mbed { */ class FlashIAP : private NonCopyable { public: - FlashIAP() - { - - } - - ~FlashIAP() - { - - } + FlashIAP(); + ~FlashIAP(); /** Initialize a flash IAP device * @@ -126,48 +119,33 @@ class FlashIAP : private NonCopyable { * @param addr Address of or inside the sector to query * @return Size of a sector in bytes or MBED_FLASH_INVALID_SIZE if not mapped */ - uint32_t get_sector_size(uint32_t addr) const - { - return flash_get_sector_size(&_flash, addr); - } + uint32_t get_sector_size(uint32_t addr) const; /** Get the flash start address * * @return Flash start address */ - uint32_t get_flash_start() const - { - return flash_get_start_address(&_flash); - } + uint32_t get_flash_start() const; /** Get the flash size * * @return Flash size */ - uint32_t get_flash_size() const - { - return flash_get_size(&_flash); - } + uint32_t get_flash_size() const; /** Get the program page size * * The page size defines the writable page size * @return Size of a program page in bytes */ - uint32_t get_page_size() const - { - return flash_get_page_size(&_flash); - } + uint32_t get_page_size() const; /** Get the flash erase value * * Get the value we read after erase operation * @return flash erase value */ - uint8_t get_erase_value() const - { - return flash_get_erase_value(&_flash); - } + uint8_t get_erase_value() const; #if !defined(DOXYGEN_ONLY) private: diff --git a/drivers/I2C.h b/drivers/I2C.h index 1aa2d894c37..ffcbe1ae273 100644 --- a/drivers/I2C.h +++ b/drivers/I2C.h @@ -169,17 +169,11 @@ class I2C : private NonCopyable { /** Acquire exclusive access to this I2C bus */ - virtual void lock(void) - { - _mutex->lock(); - } + virtual void lock(void); /** Release exclusive access to this I2C bus */ - virtual void unlock(void) - { - _mutex->unlock(); - } + virtual void unlock(void); virtual ~I2C() { diff --git a/drivers/I2CSlave.h b/drivers/I2CSlave.h index e270e3a342d..f2075d1d600 100644 --- a/drivers/I2CSlave.h +++ b/drivers/I2CSlave.h @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited + * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -92,10 +92,7 @@ class I2CSlave { * * @param hz The bus frequency in Hertz. */ - void frequency(int hz) - { - i2c_frequency(&_i2c, hz); - } + void frequency(int hz); /** Check if this I2C Slave has been addressed. * @@ -105,10 +102,7 @@ class I2CSlave { * @retval WriteAddressed The master is writing to this slave. * @retval WriteGeneral The master is writing to all slave. */ - int receive(void) - { - return i2c_slave_receive(&_i2c); - } + int receive(void); /** Read specified number of bytes from an I2C master. * @@ -119,19 +113,13 @@ class I2CSlave { * @retval 0 If the number of bytes read is equal to length requested. * @retval nonzero On error or if the number of bytes read is less than requested. */ - int read(char *data, int length) - { - return i2c_slave_read(&_i2c, data, length) != length; - } + int read(char *data, int length); /** Read a single byte from an I2C master. * * @return The byte read. */ - int read(void) - { - return i2c_byte_read(&_i2c, 0); - } + int read(void); /** Write to an I2C master. * @@ -142,10 +130,7 @@ class I2CSlave { * @retval 0 If written all bytes successfully. * @retval nonzero On error or if the number of bytes written is less than requested. */ - int write(const char *data, int length) - { - return i2c_slave_write(&_i2c, data, length) != length; - } + int write(const char *data, int length); /** Write a single byte to an I2C master. * @@ -156,10 +141,7 @@ class I2CSlave { * @retval 1 If an ACK is received. * @retval 2 On timeout. */ - int write(int data) - { - return i2c_byte_write(&_i2c, data); - } + int write(int data); /** Set the I2C slave address. * @@ -172,10 +154,7 @@ class I2CSlave { /** Reset the I2C slave back into the known ready receiving state. */ - void stop(void) - { - i2c_stop(&_i2c); - } + void stop(void); #if !defined(DOXYGEN_ONLY) diff --git a/drivers/InterruptIn.h b/drivers/InterruptIn.h index 4b9a4dbdc11..3c6cf092d23 100644 --- a/drivers/InterruptIn.h +++ b/drivers/InterruptIn.h @@ -85,11 +85,7 @@ class InterruptIn : private NonCopyable { */ InterruptIn(PinName pin, PinMode mode); - virtual ~InterruptIn() - { - // No lock needed in the destructor - gpio_irq_free(&gpio_irq); - } + virtual ~InterruptIn(); /** Read the input, represented as 0 or 1 (int) * @@ -97,19 +93,11 @@ class InterruptIn : private NonCopyable { * An integer representing the state of the input pin, * 0 for logical 0, 1 for logical 1 */ - int read() - { - // Read only - return gpio_read(&gpio); - } + int read(); /** An operator shorthand for read() */ - operator int() - { - // Underlying call is atomic - return read(); - } + operator int(); /** Attach a function to call when a rising edge occurs on the input @@ -188,10 +176,7 @@ class InterruptIn : private NonCopyable { Callback _rise; Callback _fall; - void irq_init(PinName pin) - { - gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this); - } + void irq_init(PinName pin); #endif }; diff --git a/drivers/InterruptManager.h b/drivers/InterruptManager.h index 612c5980d67..f53d206a63c 100644 --- a/drivers/InterruptManager.h +++ b/drivers/InterruptManager.h @@ -174,23 +174,12 @@ class InterruptManager : private NonCopyable { #if !defined(DOXYGEN_ONLY) private: - InterruptManager() - { - // No mutex needed in constructor - memset(_chains, 0, NVIC_NUM_VECTORS * sizeof(CallChain *)); - } + InterruptManager(); ~InterruptManager(); - void lock() - { - _mutex.lock(); - } - - void unlock() - { - _mutex.unlock(); - } + void lock(); + void unlock(); template pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front = false) @@ -209,21 +198,10 @@ class InterruptManager : private NonCopyable { pFunctionPointer_t add_common(void (*function)(void), IRQn_Type irq, bool front = false); bool must_replace_vector(IRQn_Type irq); - int get_irq_index(IRQn_Type irq) - { - // Pure function - no lock needed - return (int)irq + NVIC_USER_IRQ_OFFSET; - } - - void irq_helper() - { - _chains[__get_IPSR()]->call(); - } + int get_irq_index(IRQn_Type irq); + void irq_helper(); void add_helper(void (*function)(void), IRQn_Type irq, bool front = false); - static void static_irq_helper() - { - InterruptManager::get()->irq_helper(); - } + static void static_irq_helper(); CallChain *_chains[NVIC_NUM_VECTORS]; static InterruptManager *_instance; diff --git a/drivers/QSPI.h b/drivers/QSPI.h index 42fcfa9b8b7..1084e0eec9c 100644 --- a/drivers/QSPI.h +++ b/drivers/QSPI.h @@ -192,17 +192,11 @@ class QSPI : private NonCopyable { protected: /** Acquire exclusive access to this SPI bus */ - virtual void lock(void) - { - _mutex->lock(); - } + virtual void lock(void); /** Release exclusive access to this SPI bus */ - virtual void unlock(void) - { - _mutex->unlock(); - } + virtual void unlock(void); qspi_t _qspi; diff --git a/drivers/RawSerial.h b/drivers/RawSerial.h index 71c5a49bd4f..061d93fa063 100644 --- a/drivers/RawSerial.h +++ b/drivers/RawSerial.h @@ -69,10 +69,7 @@ class RawSerial: public SerialBase, private NonCopyable { * @note * Either tx or rx may be specified as NC if unused */ - RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) : SerialBase(tx, rx, baud) - { - // No lock needed in the constructor - } + RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); /** Write a char to the serial port * @@ -104,17 +101,11 @@ class RawSerial: public SerialBase, private NonCopyable { /* Acquire exclusive access to this serial port */ - virtual void lock(void) - { - // No lock used - external synchronization required - } + virtual void lock(void); /* Release exclusive access to this serial port */ - virtual void unlock(void) - { - // No lock used - external synchronization required - } + virtual void unlock(void); #endif }; diff --git a/drivers/SPI.h b/drivers/SPI.h index b3f57723198..d9117ac84d3 100644 --- a/drivers/SPI.h +++ b/drivers/SPI.h @@ -115,18 +115,7 @@ class SPI : private NonCopyable { * @param sclk SPI Clock pin. * @param ssel SPI Chip Select pin. */ - SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel = NC) : -#if DEVICE_SPI_ASYNCH - _irq(this), -#endif - _mosi(mosi), - _miso(miso), - _sclk(sclk), - _hw_ssel(ssel), - _sw_ssel(NC) - { - _do_construct(); - } + SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel = NC); /** Create a SPI master connected to the specified pins. * @@ -142,18 +131,7 @@ class SPI : private NonCopyable { * @param sclk SPI Clock pin. * @param ssel SPI Chip Select pin. */ - SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel, use_gpio_ssel_t) : -#if DEVICE_SPI_ASYNCH - _irq(this), -#endif - _mosi(mosi), - _miso(miso), - _sclk(sclk), - _hw_ssel(NC), - _sw_ssel(ssel, 1) - { - _do_construct(); - } + SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel, use_gpio_ssel_t); virtual ~SPI(); @@ -205,17 +183,11 @@ class SPI : private NonCopyable { /** Acquire exclusive access to this SPI bus. */ - virtual void lock(void) - { - _peripheral->mutex->lock(); - } + virtual void lock(void); /** Release exclusive access to this SPI bus. */ - virtual void unlock(void) - { - _peripheral->mutex->unlock(); - } + virtual void unlock(void); /** Assert the Slave Select line, acquiring exclusive access to this SPI bus. * @@ -272,12 +244,7 @@ class SPI : private NonCopyable { /** Clear the queue of transfers. */ - void clear_transfer_buffer() - { -#if TRANSACTION_QUEUE_SIZE_SPI - _peripheral->transaction_buffer->reset(); -#endif - } + void clear_transfer_buffer(); /** Clear the queue of transfers and abort the on-going transfer. */ @@ -363,18 +330,7 @@ class SPI : private NonCopyable { * * @param data Transaction data. */ - void start_transaction(transaction_t *data) - { - start_transfer( - data->tx_buffer, - data->tx_length, - data->rx_buffer, - data->rx_length, - data->width, - data->callback, - data->event - ); - } + void start_transaction(transaction_t *data); /** Dequeue a transaction and start the transfer if there was one pending. */ diff --git a/drivers/SPISlave.h b/drivers/SPISlave.h index 411e2b380fd..13d4f0f68bf 100644 --- a/drivers/SPISlave.h +++ b/drivers/SPISlave.h @@ -101,29 +101,20 @@ class SPISlave : private NonCopyable { * @retval 0 No data waiting. * @retval 1 Data waiting. */ - int receive(void) - { - return (spi_slave_receive(&_spi)); - } + int receive(void); /** Retrieve data from receive buffer as slave. * * @return The data in the receive buffer. */ - int read(void) - { - return (spi_slave_read(&_spi)); - } + int read(void); /** Fill the transmission buffer with the value to be written out * as slave on the next received message from the master. * * @param value The data to be transmitted next. */ - void reply(int value) - { - spi_slave_write(&_spi, value); - } + void reply(int value); #if !defined(DOXYGEN_ONLY) diff --git a/drivers/Serial.h b/drivers/Serial.h index c3fa6f12ae6..7dad33a6131 100644 --- a/drivers/Serial.h +++ b/drivers/Serial.h @@ -73,9 +73,7 @@ class Serial : public SerialBase, public Stream, private NonCopyable { * @note * Either tx or rx may be specified as NC (Not Connected) if unused */ - Serial(PinName tx, PinName rx, const char *name = NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) : SerialBase(tx, rx, baud), Stream(name) - { - } + Serial(PinName tx, PinName rx, const char *name = NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); /** Create a Serial port, connected to the specified transmit and receive pins, with the specified baud @@ -87,9 +85,7 @@ class Serial : public SerialBase, public Stream, private NonCopyable { * @note * Either tx or rx may be specified as NC (Not Connected) if unused */ - Serial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud), Stream(NULL) - { - } + Serial(PinName tx, PinName rx, int baud); /* Stream gives us a FileHandle with non-functional poll()/readable()/writable. Pass through * the calls from the SerialBase instead for backwards compatibility. This problem is @@ -110,25 +106,10 @@ class Serial : public SerialBase, public Stream, private NonCopyable { #if !(DOXYGEN_ONLY) protected: - virtual int _getc() - { - // Mutex is already held - return _base_getc(); - } - virtual int _putc(int c) - { - // Mutex is already held - return _base_putc(c); - } - virtual void lock() - { - _mutex.lock(); - } - virtual void unlock() - { - _mutex.unlock(); - } - + virtual int _getc(); + virtual int _putc(int c); + virtual void lock(); + virtual void unlock(); PlatformMutex _mutex; #endif diff --git a/drivers/SerialBase.h b/drivers/SerialBase.h index d3cdb4a7733..3acf9cbf1a2 100644 --- a/drivers/SerialBase.h +++ b/drivers/SerialBase.h @@ -163,17 +163,11 @@ class SerialBase : private NonCopyable { /** Acquire exclusive access to this serial port */ - virtual void lock(void) - { - // Stub - } + virtual void lock(void); /** Release exclusive access to this serial port */ - virtual void unlock(void) - { - // Stub - } + virtual void unlock(void); #endif public: @@ -300,11 +294,7 @@ class SerialBase : private NonCopyable { SerialBase(PinName tx, PinName rx, int baud); virtual ~SerialBase(); - int _base_getc() - { - // Mutex is already held - return serial_getc(&_serial); - } + int _base_getc(); int _base_putc(int c); diff --git a/drivers/Timer.h b/drivers/Timer.h index 4fd2007dccc..8d4d22a7ca6 100644 --- a/drivers/Timer.h +++ b/drivers/Timer.h @@ -90,17 +90,11 @@ class Timer : private NonCopyable { * * @returns Time passed in microseconds */ - int read_us() - { - return read_high_resolution_us(); - } + int read_us(); /** An operator shorthand for read() */ - operator float() - { - return read(); - } + operator float(); /** Get in a high resolution type the time passed in microseconds. * Returns a 64 bit integer. diff --git a/drivers/TimerEvent.h b/drivers/TimerEvent.h index ef02df81830..5bd6eab7d2e 100644 --- a/drivers/TimerEvent.h +++ b/drivers/TimerEvent.h @@ -36,12 +36,7 @@ namespace mbed { class TimerEvent : private NonCopyable { public: TimerEvent(); - - TimerEvent(const ticker_data_t *data) - : event(), _ticker_data(data) - { - ticker_set_handler(_ticker_data, (&TimerEvent::irq)); - } + TimerEvent(const ticker_data_t *data); /** The handler registered with the underlying timer interrupt * @@ -51,10 +46,7 @@ class TimerEvent : private NonCopyable { /** Destruction removes it... */ - virtual ~TimerEvent() - { - remove(); - } + virtual ~TimerEvent(); #if !defined(DOXYGEN_ONLY) protected: @@ -73,10 +65,7 @@ class TimerEvent : private NonCopyable { * from the past the event is scheduled after ticker's overflow. * For reference @see convert_timestamp */ - void insert(timestamp_t timestamp) - { - ticker_insert_event(_ticker_data, &event, timestamp, (uint32_t)this); - } + void insert(timestamp_t timestamp); /** Set absolute timestamp of the internal event. * @param timestamp event's us timestamp @@ -85,17 +74,11 @@ class TimerEvent : private NonCopyable { * Do not insert more than one timestamp. * The same @a event object is used for every @a insert/insert_absolute call. */ - void insert_absolute(us_timestamp_t timestamp) - { - ticker_insert_event_us(_ticker_data, &event, timestamp, (uint32_t)this); - } + void insert_absolute(us_timestamp_t timestamp); /** Remove timestamp. */ - void remove() - { - ticker_remove_event(_ticker_data, &event); - } + void remove(); ticker_event_t event; diff --git a/drivers/UARTSerial.h b/drivers/UARTSerial.h index 77454a014bb..04660d81656 100644 --- a/drivers/UARTSerial.h +++ b/drivers/UARTSerial.h @@ -61,10 +61,7 @@ class UARTSerial : private SerialBase, public FileHandle, private NonCopyablelock(); +} + +void I2C::unlock() +{ + _mutex->unlock(); +} + int I2C::recover(PinName sda, PinName scl) { DigitalInOut pin_sda(sda, PIN_INPUT, PullNone, 1); diff --git a/drivers/source/I2CSlave.cpp b/drivers/source/I2CSlave.cpp index cb37e88ef5f..489926c1463 100644 --- a/drivers/source/I2CSlave.cpp +++ b/drivers/source/I2CSlave.cpp @@ -27,12 +27,47 @@ I2CSlave::I2CSlave(PinName sda, PinName scl) : _i2c() i2c_slave_mode(&_i2c, 1); } +void I2CSlave::frequency(int hz) +{ + i2c_frequency(&_i2c, hz); +} + void I2CSlave::address(int address) { int addr = (address & 0xFF) | 1; i2c_slave_address(&_i2c, 0, addr, 0); } -} // namespace mbed +int I2CSlave::receive(void) +{ + return i2c_slave_receive(&_i2c); +} + +int I2CSlave::read(char *data, int length) +{ + return i2c_slave_read(&_i2c, data, length) != length; +} + +int I2CSlave::read(void) +{ + return i2c_byte_read(&_i2c, 0); +} + +int I2CSlave::write(const char *data, int length) +{ + return i2c_slave_write(&_i2c, data, length) != length; +} + +int I2CSlave::write(int data) +{ + return i2c_byte_write(&_i2c, data); +} + +void I2CSlave::stop(void) +{ + i2c_stop(&_i2c); +} + +} #endif diff --git a/drivers/source/InterruptIn.cpp b/drivers/source/InterruptIn.cpp index fef25f99907..a4ab5f0135a 100644 --- a/drivers/source/InterruptIn.cpp +++ b/drivers/source/InterruptIn.cpp @@ -24,7 +24,10 @@ namespace mbed { // compatibility. // If not for that, we could simplify by having only the 2-param // constructor, with a default value for the PinMode. -InterruptIn::InterruptIn(PinName pin) : gpio(), gpio_irq(), _rise(NULL), _fall(NULL) +InterruptIn::InterruptIn(PinName pin) : gpio(), + gpio_irq(), + _rise(NULL), + _fall(NULL) { // No lock needed in the constructor irq_init(pin); @@ -42,6 +45,23 @@ InterruptIn::InterruptIn(PinName pin, PinMode mode) : gpio_init_in_ex(&gpio, pin, mode); } +void InterruptIn::irq_init(PinName pin) +{ + gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this); +} + +InterruptIn::~InterruptIn() +{ + // No lock needed in the destructor + gpio_irq_free(&gpio_irq); +} + +int InterruptIn::read() +{ + // Read only + return gpio_read(&gpio); +} + void InterruptIn::mode(PinMode pull) { core_util_critical_section_enter(); @@ -108,6 +128,12 @@ void InterruptIn::disable_irq() core_util_critical_section_exit(); } +InterruptIn::operator int() +{ + // Underlying call is atomic + return read(); +} + } // namespace mbed #endif diff --git a/drivers/source/InterruptManager.cpp b/drivers/source/InterruptManager.cpp index 465b8c13c14..179731b4199 100644 --- a/drivers/source/InterruptManager.cpp +++ b/drivers/source/InterruptManager.cpp @@ -57,6 +57,12 @@ InterruptManager *InterruptManager::get() return _instance; } +InterruptManager::InterruptManager() +{ + // No mutex needed in constructor + memset(_chains, 0, NVIC_NUM_VECTORS * sizeof(CallChain *)); +} + void InterruptManager::destroy() { // Not a good idea to call this unless NO interrupt at all @@ -121,6 +127,32 @@ bool InterruptManager::remove_handler(pFunctionPointer_t handler, IRQn_Type irq) return ret; } +void InterruptManager::irq_helper() +{ + _chains[__get_IPSR()]->call(); +} + +int InterruptManager::get_irq_index(IRQn_Type irq) +{ + // Pure function - no lock needed + return (int)irq + NVIC_USER_IRQ_OFFSET; +} + +void InterruptManager::static_irq_helper() +{ + InterruptManager::get()->irq_helper(); +} + +void InterruptManager::lock() +{ + _mutex.lock(); +} + +void InterruptManager::unlock() +{ + _mutex.unlock(); +} + } // namespace mbed #endif diff --git a/drivers/source/QSPI.cpp b/drivers/source/QSPI.cpp index 49246fdedd5..c79c949e3b3 100644 --- a/drivers/source/QSPI.cpp +++ b/drivers/source/QSPI.cpp @@ -206,6 +206,16 @@ qspi_status_t QSPI::command_transfer(int instruction, int address, const char *t return ret_status; } +void QSPI::lock() +{ + _mutex->lock(); +} + +void QSPI::unlock() +{ + _mutex->unlock(); +} + // Note: Private helper function to initialize qspi HAL bool QSPI::_initialize() { diff --git a/drivers/source/RawSerial.cpp b/drivers/source/RawSerial.cpp index 8c289999e78..8fab077f9a7 100644 --- a/drivers/source/RawSerial.cpp +++ b/drivers/source/RawSerial.cpp @@ -24,6 +24,11 @@ namespace mbed { +RawSerial::RawSerial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud) +{ + // No lock needed in the constructor +} + int RawSerial::getc() { lock(); @@ -84,6 +89,20 @@ int RawSerial::vprintf(const char *format, std::va_list arg) return len; } +/** Acquire exclusive access to this serial port + */ +void RawSerial::lock() +{ + // No lock used - external synchronization required +} + +/** Release exclusive access to this serial port + */ +void RawSerial::unlock() +{ + // No lock used - external synchronization required +} + } // namespace mbed #endif diff --git a/drivers/source/SPI.cpp b/drivers/source/SPI.cpp index 66c3b3ef41d..61d337dbf07 100644 --- a/drivers/source/SPI.cpp +++ b/drivers/source/SPI.cpp @@ -28,6 +28,32 @@ namespace mbed { SPI::spi_peripheral_s SPI::_peripherals[SPI_PERIPHERALS_USED]; int SPI::_peripherals_used; +SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel) : +#if DEVICE_SPI_ASYNCH + _irq(this), +#endif + _mosi(mosi), + _miso(miso), + _sclk(sclk), + _hw_ssel(ssel), + _sw_ssel(NC) +{ + _do_construct(); +} + +SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel, use_gpio_ssel_t) : +#if DEVICE_SPI_ASYNCH + _irq(this), +#endif + _mosi(mosi), + _miso(miso), + _sclk(sclk), + _hw_ssel(NC), + _sw_ssel(ssel, 1) +{ + _do_construct(); +} + void SPI::_do_construct() { // No lock needed in the constructor @@ -162,6 +188,11 @@ void SPI::_set_ssel(int val) } } +void SPI::lock() +{ + _peripheral->mutex->lock(); +} + void SPI::select() { lock(); @@ -171,6 +202,11 @@ void SPI::select() } } +void SPI::unlock() +{ + _peripheral->mutex->unlock(); +} + void SPI::deselect() { if (--_select_count == 0) { @@ -207,6 +243,13 @@ void SPI::abort_transfer() #endif } +void SPI::clear_transfer_buffer() +{ +#if TRANSACTION_QUEUE_SIZE_SPI + _peripheral->transaction_buffer->reset(); +#endif +} + void SPI::abort_all_transfers() { clear_transfer_buffer(); @@ -279,6 +322,11 @@ void SPI::unlock_deep_sleep() #if TRANSACTION_QUEUE_SIZE_SPI +void SPI::start_transaction(transaction_t *data) +{ + start_transfer(data->tx_buffer, data->tx_length, data->rx_buffer, data->rx_length, data->width, data->callback, data->event); +} + void SPI::dequeue_transaction() { Transaction t; diff --git a/drivers/source/SPISlave.cpp b/drivers/source/SPISlave.cpp index 02127e6c899..7993e087121 100644 --- a/drivers/source/SPISlave.cpp +++ b/drivers/source/SPISlave.cpp @@ -44,6 +44,21 @@ void SPISlave::frequency(int hz) spi_frequency(&_spi, _hz); } +int SPISlave::receive(void) +{ + return (spi_slave_receive(&_spi)); +} + + int SPISlave::read(void) +{ + return (spi_slave_read(&_spi)); +} + +void SPISlave::reply(int value) +{ + spi_slave_write(&_spi, value); +} + } // namespace mbed #endif diff --git a/drivers/source/Serial.cpp b/drivers/source/Serial.cpp index e3dccd0d955..74325084447 100644 --- a/drivers/source/Serial.cpp +++ b/drivers/source/Serial.cpp @@ -20,6 +20,36 @@ namespace mbed { +Serial::Serial(PinName tx, PinName rx, const char *name, int baud) : SerialBase(tx, rx, baud), Stream(name) +{ +} + +Serial::Serial(PinName tx, PinName rx, int baud): SerialBase(tx, rx, baud), Stream(NULL) +{ +} + +int Serial::_getc() +{ + // Mutex is already held + return _base_getc(); +} + +int Serial::_putc(int c) +{ + // Mutex is already held + return _base_putc(c); +} + +void Serial::lock() +{ + _mutex.lock(); +} + +void Serial::lock() +{ + _mutex.unlock(); +} + } // namespace mbed #endif diff --git a/drivers/source/SerialBase.cpp b/drivers/source/SerialBase.cpp index 09372d71dc0..856944fd347 100644 --- a/drivers/source/SerialBase.cpp +++ b/drivers/source/SerialBase.cpp @@ -66,6 +66,7 @@ int SerialBase::readable() return ret; } + int SerialBase::writeable() { lock(); @@ -106,6 +107,12 @@ void SerialBase::_irq_handler(uint32_t id, SerialIrq irq_type) } } +int SerialBase::_base_getc() +{ + // Mutex is already held + return serial_getc(&_serial); +} + int SerialBase::_base_putc(int c) { // Mutex is already held @@ -144,6 +151,16 @@ void SerialBase::send_break() unlock(); } +void SerialBase::lock() +{ + // Stub +} + +void SerialBase:: unlock() +{ + // Stub +} + SerialBase::~SerialBase() { // No lock needed in destructor @@ -277,6 +294,7 @@ int SerialBase::read(uint8_t *buffer, int length, const event_callback_t &callba return result; } + int SerialBase::read(uint16_t *buffer, int length, const event_callback_t &callback, int event, unsigned char char_match) { int result = 0; @@ -290,6 +308,7 @@ int SerialBase::read(uint16_t *buffer, int length, const event_callback_t &callb return result; } + void SerialBase::start_read(void *buffer, int buffer_size, char buffer_width, const event_callback_t &callback, int event, unsigned char char_match) { _rx_asynch_set = true; diff --git a/drivers/source/Timer.cpp b/drivers/source/Timer.cpp index 18120edd626..d4f2276a416 100644 --- a/drivers/source/Timer.cpp +++ b/drivers/source/Timer.cpp @@ -27,7 +27,8 @@ Timer::Timer() : _running(), _start(), _time(), _ticker_data(get_us_ticker_data( reset(); } -Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker_data(data), _lock_deepsleep(!data->interface->runs_in_deep_sleep) +Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker_data(data), + _lock_deepsleep(!data->interface->runs_in_deep_sleep) { reset(); } @@ -70,6 +71,11 @@ void Timer::stop() core_util_critical_section_exit(); } +int Timer::read_us() +{ + return read_high_resolution_us(); +} + float Timer::read() { return (float)read_high_resolution_us() / 1000000.0f; @@ -107,4 +113,9 @@ void Timer::reset() core_util_critical_section_exit(); } +Timer::operator float() +{ + return read(); +} + } // namespace mbed diff --git a/drivers/source/TimerEvent.cpp b/drivers/source/TimerEvent.cpp index a225d1fd1b1..be3037e62f2 100644 --- a/drivers/source/TimerEvent.cpp +++ b/drivers/source/TimerEvent.cpp @@ -26,10 +26,36 @@ TimerEvent::TimerEvent() : event(), _ticker_data(get_us_ticker_data()) ticker_set_handler(_ticker_data, (&TimerEvent::irq)); } +TimerEvent::TimerEvent(const ticker_data_t *data) : event(), _ticker_data(data) +{ + ticker_set_handler(_ticker_data, (&TimerEvent::irq)); +} + void TimerEvent::irq(uint32_t id) { TimerEvent *timer_event = (TimerEvent *)id; timer_event->handler(); } +TimerEvent::~TimerEvent() +{ + remove(); +} + +// insert in to linked list +void TimerEvent::insert(timestamp_t timestamp) +{ + ticker_insert_event(_ticker_data, &event, timestamp, (uint32_t)this); +} + +void TimerEvent::insert_absolute(us_timestamp_t timestamp) +{ + ticker_insert_event_us(_ticker_data, &event, timestamp, (uint32_t)this); +} + +void TimerEvent::remove() +{ + ticker_remove_event(_ticker_data, &event); +} + } // namespace mbed diff --git a/drivers/source/UARTSerial.cpp b/drivers/source/UARTSerial.cpp index 628bc62da0a..feae1975c89 100644 --- a/drivers/source/UARTSerial.cpp +++ b/drivers/source/UARTSerial.cpp @@ -28,12 +28,34 @@ namespace mbed { -UARTSerial::UARTSerial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud), _blocking(true), _tx_irq_enabled(false), _rx_irq_enabled(false), _tx_enabled(true), _rx_enabled(true), _dcd_irq(NULL) +UARTSerial::UARTSerial(PinName tx, PinName rx, int baud) : + SerialBase(tx, rx, baud), + _blocking(true), + _tx_irq_enabled(false), + _rx_irq_enabled(false), + _tx_enabled(true), + _rx_enabled(true), + _dcd_irq(NULL) { /* Attatch IRQ routines to the serial device. */ enable_rx_irq(); } +UARTSerial::~UARTSerial() +{ + delete _dcd_irq; +} + + void UARTSerial::dcd_irq() +{ + wake(); +} + + void UARTSerial::set_baud(int baud) +{ + SerialBase::baud(baud); +} + void UARTSerial::set_data_carrier_detect(PinName dcd_pin, bool active_high) { delete _dcd_irq; @@ -65,6 +87,26 @@ void UARTSerial::set_flow_control(Flow type, PinName flow1, PinName flow2) } #endif +int UARTSerial::close() +{ + /* Does not let us pass a file descriptor. So how to close ? + * Also, does it make sense to close a device type file descriptor*/ + return 0; +} + + int UARTSerial::isatty() +{ + return 1; + +} + +off_t UARTSerial::seek(off_t offset, int whence) +{ + /*XXX lseek can be done theoratically, but is it sane to mark positions on a dynamically growing/shrinking + * buffer system (from an interrupt context) */ + return -ESPIPE; +} + int UARTSerial::sync() { api_lock(); @@ -237,6 +279,28 @@ short UARTSerial::poll(short events) const return revents; } +void UARTSerial::lock() +{ + // This is the override for SerialBase. + // No lock required as we only use SerialBase from interrupt or from + // inside our own critical section. +} + +void UARTSerial::unlock() +{ + // This is the override for SerialBase. +} + +void UARTSerial::api_lock(void) +{ + _mutex.lock(); +} + +void UARTSerial::api_unlock(void) +{ + _mutex.unlock(); +} + void UARTSerial::rx_irq(void) { bool was_empty = _rxbuf.empty(); From 2c3e4ec82e2d9408d40b6d4e879d83e150e4887c Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 11:51:31 +0100 Subject: [PATCH 28/35] Add Doxygen to Watchdog and relocate source file --- drivers/Watchdog.h | 12 ++++++++++-- drivers/{ => source}/Watchdog.cpp | 0 2 files changed, 10 insertions(+), 2 deletions(-) rename drivers/{ => source}/Watchdog.cpp (100%) diff --git a/drivers/Watchdog.h b/drivers/Watchdog.h index 5d4126e965c..5ced069908b 100644 --- a/drivers/Watchdog.h +++ b/drivers/Watchdog.h @@ -28,8 +28,9 @@ #include namespace mbed { - -/** \addtogroup drivers */ +/** \ingroup drivers */ +/** \addtogroup drivers-public-api */ +/** @{*/ /** Hardware system timer that will reset the system in the case of system failures or * malfunctions. There is only one instance in the system. * @@ -49,6 +50,10 @@ namespace mbed { * @note Synchronization level: Interrupt safe * @ingroup drivers */ +/** + * \defgroup drivers_Watchdog Watchdog class + * @{ + */ class Watchdog : private NonCopyable { public: @@ -129,6 +134,9 @@ class Watchdog : private NonCopyable { bool _running; }; +/** @}*/ +/** @}*/ + } // namespace mbed #endif // DEVICE_WATCHDOG diff --git a/drivers/Watchdog.cpp b/drivers/source/Watchdog.cpp similarity index 100% rename from drivers/Watchdog.cpp rename to drivers/source/Watchdog.cpp From 7f1049be41b4579fc15db547680ef6e993264a4e Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 11:55:42 +0100 Subject: [PATCH 29/35] Fix events test --- events/source/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/source/Makefile b/events/source/Makefile index 6e636bc87b1..e1831985234 100644 --- a/events/source/Makefile +++ b/events/source/Makefile @@ -17,7 +17,7 @@ endif ifdef WORD CFLAGS += -m$(WORD) endif -CFLAGS += -I. -I.. -I../.. +CFLAGS += -I. -I.. -I../.. -I../../.. CFLAGS += -std=c99 CFLAGS += -Wall CFLAGS += -D_XOPEN_SOURCE=600 From 69b016a64e73fbfeceef7dda351dfe74d7308b7e Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 11:58:10 +0100 Subject: [PATCH 30/35] Fix astyle issues --- drivers/source/SPISlave.cpp | 2 +- drivers/source/UARTSerial.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/source/SPISlave.cpp b/drivers/source/SPISlave.cpp index 7993e087121..db870cdea2a 100644 --- a/drivers/source/SPISlave.cpp +++ b/drivers/source/SPISlave.cpp @@ -49,7 +49,7 @@ int SPISlave::receive(void) return (spi_slave_receive(&_spi)); } - int SPISlave::read(void) +int SPISlave::read(void) { return (spi_slave_read(&_spi)); } diff --git a/drivers/source/UARTSerial.cpp b/drivers/source/UARTSerial.cpp index feae1975c89..5d65a8bee64 100644 --- a/drivers/source/UARTSerial.cpp +++ b/drivers/source/UARTSerial.cpp @@ -46,12 +46,12 @@ UARTSerial::~UARTSerial() delete _dcd_irq; } - void UARTSerial::dcd_irq() +void UARTSerial::dcd_irq() { wake(); } - void UARTSerial::set_baud(int baud) +void UARTSerial::set_baud(int baud) { SerialBase::baud(baud); } @@ -94,7 +94,7 @@ int UARTSerial::close() return 0; } - int UARTSerial::isatty() +int UARTSerial::isatty() { return 1; From 8fa81d30ddde712b39db0453534701d1bccd72c9 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 12:53:37 +0100 Subject: [PATCH 31/35] Fix Serial unlock method definition --- drivers/source/Serial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/source/Serial.cpp b/drivers/source/Serial.cpp index 74325084447..03ee49697ad 100644 --- a/drivers/source/Serial.cpp +++ b/drivers/source/Serial.cpp @@ -45,7 +45,7 @@ void Serial::lock() _mutex.lock(); } -void Serial::lock() +void Serial::unlock() { _mutex.unlock(); } From f5cbb0df07d4bbedfd651e7c620eb3110c43abf8 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 10 Jul 2019 13:43:16 +0100 Subject: [PATCH 32/35] Fix events tests by appending source location in `internal` dir --- events/source/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/events/source/Makefile b/events/source/Makefile index e1831985234..aeb62700960 100644 --- a/events/source/Makefile +++ b/events/source/Makefile @@ -4,7 +4,7 @@ CC = gcc AR = ar SIZE = size -SRC += $(wildcard *.c) +SRC += $(wildcard *.c) $(wildcard ../internal/*.c) OBJ := $(SRC:.c=.o) DEP := $(SRC:.c=.d) ASM := $(SRC:.c=.s) @@ -17,7 +17,7 @@ endif ifdef WORD CFLAGS += -m$(WORD) endif -CFLAGS += -I. -I.. -I../.. -I../../.. +CFLAGS += -I. -I.. -I../.. CFLAGS += -std=c99 CFLAGS += -Wall CFLAGS += -D_XOPEN_SOURCE=600 From e7dd1807ae58daf198761612614ec7dff67108f6 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Thu, 11 Jul 2019 13:28:46 +0100 Subject: [PATCH 33/35] Restore AnalogOut operator method implementation to header Removing the implementation does not result in a header removal from AnalogOut.h loses optimisation by forcing an the method to return a usually-not-used `*this`. It also prevents tailcall and will produce unpleasant code and increase stack usage. --- drivers/AnalogOut.h | 14 ++++++++++++-- drivers/source/AnalogOut.cpp | 14 -------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/AnalogOut.h b/drivers/AnalogOut.h index 6e1bc7db6fb..7b0e5d70f7e 100644 --- a/drivers/AnalogOut.h +++ b/drivers/AnalogOut.h @@ -99,12 +99,22 @@ class AnalogOut { /** An operator shorthand for write() * \sa AnalogOut::write() */ - AnalogOut &operator= (float percent); + AnalogOut &operator= (float percent) + { + // Underlying write call is thread safe + write(percent); + return *this; + } /** An operator shorthand for write() * \sa AnalogOut::write() */ - AnalogOut &operator= (AnalogOut &rhs); + AnalogOut &operator= (AnalogOut &rhs) + { + // Underlying write call is thread safe + write(rhs.read()); + return *this; + } /** An operator shorthand for read() * \sa AnalogOut::read() diff --git a/drivers/source/AnalogOut.cpp b/drivers/source/AnalogOut.cpp index 0ca51c0f710..aaba38088e4 100644 --- a/drivers/source/AnalogOut.cpp +++ b/drivers/source/AnalogOut.cpp @@ -43,20 +43,6 @@ float AnalogOut::read() return ret; } -AnalogOut &AnalogOut::operator= (float percent) -{ - // Underlying write call is thread safe - write(percent); - return *this; -} - -AnalogOut &AnalogOut::operator= (AnalogOut &rhs) -{ - // Underlying write call is thread safe - write(rhs.read()); - return *this; -} - } // namespace mbed #endif // DEVICE_ANALOGOUT From 488af02a2f4254f2c23272cfda24f926682cf7d2 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Thu, 11 Jul 2019 15:17:46 +0100 Subject: [PATCH 34/35] Move source files from `internal` dirs to `source` dirs The `internal` dirs should only contain header files. --- drivers/{internal => source}/TableCRC.cpp | 0 events/source/Makefile | 4 ++-- events/{internal => source}/equeue.c | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename drivers/{internal => source}/TableCRC.cpp (100%) rename events/{internal => source}/equeue.c (100%) diff --git a/drivers/internal/TableCRC.cpp b/drivers/source/TableCRC.cpp similarity index 100% rename from drivers/internal/TableCRC.cpp rename to drivers/source/TableCRC.cpp diff --git a/events/source/Makefile b/events/source/Makefile index aeb62700960..1323c96bf00 100644 --- a/events/source/Makefile +++ b/events/source/Makefile @@ -4,7 +4,7 @@ CC = gcc AR = ar SIZE = size -SRC += $(wildcard *.c) $(wildcard ../internal/*.c) +SRC += $(wildcard *.c) OBJ := $(SRC:.c=.o) DEP := $(SRC:.c=.d) ASM := $(SRC:.c=.s) @@ -17,7 +17,7 @@ endif ifdef WORD CFLAGS += -m$(WORD) endif -CFLAGS += -I. -I.. -I../.. +CFLAGS += -I. -I.. CFLAGS += -std=c99 CFLAGS += -Wall CFLAGS += -D_XOPEN_SOURCE=600 diff --git a/events/internal/equeue.c b/events/source/equeue.c similarity index 100% rename from events/internal/equeue.c rename to events/source/equeue.c From da4baf3a9834a5d4bbaeca7c0457090399d619db Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Thu, 11 Jul 2019 15:46:00 +0100 Subject: [PATCH 35/35] Fixing events tests --- events/source/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/source/Makefile b/events/source/Makefile index 1323c96bf00..6e636bc87b1 100644 --- a/events/source/Makefile +++ b/events/source/Makefile @@ -17,7 +17,7 @@ endif ifdef WORD CFLAGS += -m$(WORD) endif -CFLAGS += -I. -I.. +CFLAGS += -I. -I.. -I../.. CFLAGS += -std=c99 CFLAGS += -Wall CFLAGS += -D_XOPEN_SOURCE=600