Merge pull request #8410 from cmonr/rollup-aus_writathon

Rollup: Austin Writathon + a few more docs PRs
pull/8339/head
Cruz Monrreal 2018-10-12 19:34:26 -05:00 committed by GitHub
commit f54ca872b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 210 additions and 178 deletions

View File

@ -1,5 +1,6 @@
### Description
<!--
<!--
Required
Add detailed description of what you are reporting.
Good example: https://os.mbed.com/docs/latest/reference/workflow.html
@ -13,19 +14,15 @@
### Issue request type
<!--
<!--
Required
Please add only one X to one of the following types. Do not fill multiple types. (Split the issue otherwise.)
Please note this is not a GitHub task list; indenting the boxes or changing the format to add a '.' or '*' in front
of them changes the meaning incorrectly. The only changes to make are to add a description under the
description heading and to add an 'x' to the correct box.
[X] Question
[ ] Enhancement
[ ] Bug
Please add only one X to one of the following types. Do not fill multiple types (split the issue otherwise.)
Please note this is not a GitHub task list, indenting the boxes or changing the format to add a '.' or '*' in front
of them would change the meaning incorrectly. The only changes to be made are to add a description text under the
description heading and to add a 'x' to the correct box.
-->
[ ] Question
[ ] Enhancement
[ ] Bug
[ ] Question
[ ] Enhancement
[ ] Bug

View File

@ -1,6 +1,6 @@
## Unit testing
This document describes how to write and test unit tests for Mbed OS. To prevent and solve problems, please see the [troubleshooting](#troubleshooting) section.
This document describes how to write and test unit tests for Arm Mbed OS. To prevent and solve problems, please see the [troubleshooting](#troubleshooting) section.
### Introduction
@ -16,7 +16,7 @@ Please install the following dependencies to use Mbed OS unit testing.
- Python 2.7.x, 3.5 or newer.
- Pip 10.0 or newer.
- Gcovr 4.1 or newer.
- Mbed CLI 1.8.0 or newer.
- Arm Mbed CLI 1.8.0 or newer.
Detailed instructions for supported operating systems are below.
@ -30,7 +30,7 @@ Detailed instructions for supported operating systems are below.
sudo easy_install pip
```
1. Install Gcovr and [Mbed CLI](https://os.mbed.com/docs/latest/tools/arm-mbed-cli.html) with `pip install "gcovr>=4.1" mbed-cli`.
1. Install Gcovr and [Mbed CLI](https://os.mbed.com/docs/latest/tools/developing-arm-mbed-cli.html) with `pip install "gcovr>=4.1" mbed-cli`.
#### Installing dependencies on macOS
@ -43,7 +43,7 @@ Detailed instructions for supported operating systems are below.
sudo easy_install pip
```
1. Install Gcovr and [Mbed CLI](https://os.mbed.com/docs/latest/tools/arm-mbed-cli.html) with `pip install "gcovr>=4.1" mbed-cli`.
1. Install Gcovr and [Mbed CLI](https://os.mbed.com/docs/latest/tools/developing-arm-mbed-cli.html) with `pip install "gcovr>=4.1" mbed-cli`.
#### Installing dependencies on Windows
@ -51,7 +51,7 @@ Detailed instructions for supported operating systems are below.
1. Download CMake binaries from https://cmake.org/download/, and run the installer.
1. Download Python 2.7 or Python 3 from https://www.python.org/getit/, and run the installer.
1. Add MinGW, CMake and Python into system PATH.
1. Install Gcovr and [Mbed CLI](https://os.mbed.com/docs/latest/tools/arm-mbed-cli.html) with `pip install "gcovr>=4.1" mbed-cli`.
1. Install Gcovr and [Mbed CLI](https://os.mbed.com/docs/latest/tools/developing-arm-mbed-cli.html) with `pip install "gcovr>=4.1" mbed-cli`.
### Test code structure
@ -69,7 +69,7 @@ The build system automatically generates names of test suites. The name is const
### Unit testing with Mbed CLI
Mbed CLI supports unit tests through `mbed test --unittests` command. For information on using Mbed CLI, please see the [CLI documentation in handbook](https://os.mbed.com/docs/latest/tools/arm-mbed-cli.html).
Mbed CLI supports unit tests through `mbed test --unittests` command. For information on using Mbed CLI, please see the [CLI documentation](https://os.mbed.com/docs/latest/tools/developing-arm-mbed-cli.html).
### Writing unit tests
@ -154,7 +154,7 @@ TEST_F(TestSemaphore, constructor)
### Building and running unit tests
Use Mbed CLI to build and run unit tests. For advanced use, you can run CMake and a make program directly.
Use Mbed CLI to build and run unit tests. For advanced use, you can run CMake and a Make program directly.
#### Build tests directly with CMake
@ -162,9 +162,11 @@ Use Mbed CLI to build and run unit tests. For advanced use, you can run CMake an
1. Move to the build directory `cd UNITTESTS/build`.
1. Run CMake using a relative path to `UNITTESTS` folder as the argument. So from `UNITTESTS/build` use `cmake ..`:
- Add `-g [generator]` if generating other than Unix Makefiles such in case of MinGW use `-g "MinGW Makefiles"`.
- Add `-DCOVERAGE:True` to add coverage compiler flags.
- Add `-DCMAKE_MAKE_PROGRAM=<value>`, `-DCMAKE_CXX_COMPILER=<value>` and `-DCMAKE_C_COMPILER=<value>` to use a specific Make program and compilers.
- Add `-DCMAKE_BUILD_TYPE=Debug` to build a debug build.
- Add `-DCOVERAGE=True` to add coverage compiler flags.
- See the [CMake manual](https://cmake.org/cmake/help/v3.0/manual/cmake.1.html) for more information.
1. Run a make program (Make, Gmake, Mingw32-make and so on) to build the tests.
1. Run a Make program to build the tests.
#### Run tests directly with CTest
@ -177,14 +179,24 @@ Run a test binary in the build directory to run a unit test suite. To run multip
1. Add test executables into the list.
1. Run them.
### Debugging
1. Use Mbed CLI to build a debug build. For advanced use, run CMake directly with `-DCMAKE_BUILD_TYPE=Debug`, and then run a Make program.
1. Run GDB with a test executable as an argument to debug unit tests.
### Get code coverage
Use Mbed CLI to generate code coverage reports. For advanced use, you can run Gcovr or any other code coverage tool directly in the build directory.
Use Mbed CLI to generate code coverage reports. For advanced use, follow these steps:
1. Run CMake with both `-DCMAKE_BUILD_TYPE=Debug` and `-DCOVERAGE=True`.
1. Run a Make program to build the tests.
1. Run the tests.
1. Run Gcovr or any other code coverage tool directly in the build directory.
### Troubleshooting
**Problem:** Generic problems with CMake or with the build process.
* **Solution**: Delete the build directory. Make sure that CMake, g++, gcc and a make program can be found in the path and are correct versions.
* **Solution**: Delete the build directory. Make sure that CMake, g++, GCC and a Make program can be found in the path and are correct versions.
**Problem:** Virus protection identifies files generated by CMake as malicious and quarantines the files on Windows.
* **Solution**: Restore the false positive files from the quarantine.

View File

@ -85,7 +85,7 @@ public:
class CAN : private NonCopyable<CAN> {
public:
/** Creates an CAN interface connected to specific pins.
/** Creates a CAN interface connected to specific pins.
*
* @param rd read from transmitter
* @param td transmit to transmitter
@ -94,11 +94,14 @@ public:
* @code
* #include "mbed.h"
*
*
* Ticker ticker;
* DigitalOut led1(LED1);
* DigitalOut led2(LED2);
* CAN can1(p9, p10);
* CAN can2(p30, p29);
* //The constructor takes in RX, and TX pin respectively.
* //These pins, for this example, are defined in mbed_app.json
* CAN can1(MBED_CONF_APP_CAN1_RD, MBED_CONF_APP_CAN1_TD);
* CAN can2(MBED_CONF_APP_CAN2_RD, MBED_CONF_APP_CAN2_TD);
*
* char counter = 0;
*
@ -121,14 +124,15 @@ public:
* wait(0.2);
* }
* }
*
* @endcode
*/
CAN(PinName rd, PinName td);
/** Initialize CAN interface and set the frequency
*
* @param rd the rd pin
* @param td the td pin
* @param rd the read pin
* @param td the transmit pin
* @param hz the bus frequency in hertz
*/
CAN(PinName rd, PinName td, int hz);
@ -288,12 +292,14 @@ public:
static void _irq_handler(uint32_t id, CanIrqType type);
#if !defined(DOXYGEN_ONLY)
protected:
virtual void lock();
virtual void unlock();
can_t _can;
Callback<void()> _irq[IrqCnt];
PlatformMutex _mutex;
#endif
};
} // namespace mbed

View File

@ -48,6 +48,7 @@ namespace mbed {
* }
*
* int main() {
* // register trigger() to be called upon the rising edge of event
* event.rise(&trigger);
* while(1) {
* led = !led;
@ -71,7 +72,10 @@ public:
* and the pin configured to the specified mode.
*
* @param pin InterruptIn pin to connect to
* @param mode The mode to set the pin to (PullUp/PullDown/etc.)
* @param mode Desired Pin mode configuration.
* (Valid values could be PullNone, PullDown, PullUp and PullDefault.
* See PinNames.h for your target for definitions)
*
*/
InterruptIn(PinName pin, PinMode mode);
@ -142,11 +146,12 @@ public:
/** Set the input pin mode
*
* @param pull PullUp, PullDown, PullNone
* @param pull PullUp, PullDown, PullNone, PullDefault
* See PinNames.h for your target for definitions)
*/
void mode(PinMode pull);
/** Enable IRQ. This method depends on hw implementation, might enable one
/** Enable IRQ. This method depends on hardware implementation, might enable one
* port interrupts. For further information, check gpio_irq_enable().
*/
void enable_irq();
@ -157,7 +162,7 @@ public:
void disable_irq();
static void _irq_handler(uint32_t id, gpio_irq_event event);
#if !defined(DOXYGEN_ONLY)
protected:
gpio_t gpio;
gpio_irq_t gpio_irq;
@ -166,6 +171,7 @@ protected:
Callback<void()> _fall;
void irq_init(PinName pin);
#endif
};
} // namespace mbed

View File

@ -84,11 +84,14 @@ public:
* @param io3 4th IO pin used for sending/receiving data during data phase of a transaction
* @param sclk QSPI Clock pin
* @param ssel QSPI chip select pin
* @param mode Mode specifies the SPI mode(Mode=0 uses CPOL=0, CPHA=0, Mode=1 uses CPOL=1, CPHA=1)
* default value = 0
* @param mode Clock polarity and phase mode (0 - 3) of SPI
* (Default: Mode=0 uses CPOL=0, CPHA=0, Mode=1 uses CPOL=1, CPHA=1)
*
*/
QSPI(PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName ssel = NC, int mode = 0);
virtual ~QSPI()
{
}
/** Configure the data transmission format
*
@ -96,7 +99,7 @@ public:
* @param address_width Bus width used by address phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD)
* @param address_size Size in bits used by address phase(Valid values are QSPI_CFG_ADDR_SIZE_8, QSPI_CFG_ADDR_SIZE_16, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_ADDR_SIZE_32)
* @param alt_width Bus width used by alt phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD)
* @param alt_size Size in bits used by alt phase(Valid values are QSPI_CFG_ADDR_SIZE_8, QSPI_CFG_ADDR_SIZE_16, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_ADDR_SIZE_32)
* @param alt_size Size in bits used by alt phase(Valid values are QSPI_CFG_ALT_SIZE_8, QSPI_CFG_ALT_SIZE_16, QSPI_CFG_ALT_SIZE_24, QSPI_CFG_ALT_SIZE_32)
* @param data_width Bus width used by data phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD)
* @param dummy_cycles Number of dummy clock cycles to be used after alt phase
*
@ -179,6 +182,7 @@ public:
*/
qspi_status_t command_transfer(int instruction, int address, const char *tx_buffer, size_t tx_length, const char *rx_buffer, size_t rx_length);
#if !defined(DOXYGEN_ONLY)
protected:
/** Acquire exclusive access to this SPI bus
*/
@ -188,12 +192,6 @@ protected:
*/
virtual void unlock(void);
public:
virtual ~QSPI()
{
}
protected:
qspi_t _qspi;
bool acquire(void);
@ -223,6 +221,7 @@ private:
* This function builds the qspi command struct to be send to Hal
*/
inline void _build_qspi_command(int instruction, int address, int alt);
#endif
};
} // namespace mbed

View File

@ -35,7 +35,7 @@ namespace mbed {
*
* Example:
* @code
* // Toggle the blinking led after 5 seconds
* // Toggle the blinking LED after 5 seconds
*
* #include "mbed.h"
*
@ -70,7 +70,7 @@ public:
{
}
// When low power ticker is in use, then do not disable deep-sleep.
// 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(true)
{
#if DEVICE_LPTICKER
@ -106,13 +106,13 @@ public:
attach(callback(obj, method), t);
}
/** Attach a function to be called by the Ticker, specifying the interval in micro-seconds
/** Attach a function to be called by the Ticker, specifying the interval in microseconds
*
* @param func pointer to the function to be called
* @param t the time between calls in micro-seconds
*
* @note setting @a t to a value shorter that it takes to process the ticker callback
* will cause the system to hang. Ticker callback will be called constantly with no time
* @note setting @a t to a value shorter than it takes to process the ticker callback
* causes the system to hang. Ticker callback is called constantly with no time
* for threads scheduling.
*
*/
@ -128,11 +128,11 @@ public:
core_util_critical_section_exit();
}
/** Attach a member function to be called by the Ticker, specifying the interval in micro-seconds
/** Attach a member function to be called by the Ticker, specifying the interval in microseconds
*
* @param obj pointer to the object to call the member function on
* @param method pointer to the member function to be called
* @param t the time between calls in micro-seconds
* @param t the time between calls in microseconds
* @deprecated
* The attach_us function does not support cv-qualifiers. Replaced by
* attach_us(callback(obj, method), t).
@ -155,14 +155,16 @@ public:
*/
void detach();
#if !defined(DOXYGEN_ONLY)
protected:
void setup(us_timestamp_t t);
virtual void handler();
protected:
us_timestamp_t _delay; /**< Time delay (in microseconds) for re-setting the multi-shot callback. */
us_timestamp_t _delay; /**< Time delay (in microseconds) for resetting the multishot callback. */
Callback<void()> _function; /**< Callback. */
bool _lock_deepsleep; /**< Flag which indicates if deep-sleep should be disabled. */
bool _lock_deepsleep; /**< Flag which indicates if deep sleep should be disabled. */
#endif
};
} // namespace mbed

View File

@ -25,7 +25,7 @@ namespace mbed {
/** A Timeout is used to call a function at a point in the future
*
* You can use as many seperate Timeout objects as you require.
* You can use as many separate Timeout objects as you require.
*
* @note Synchronization level: Interrupt safe
*

View File

@ -30,7 +30,7 @@ namespace mbed {
*
* Example:
* @code
* // Count the time to toggle a LED
* // Count the time to toggle an LED
*
* #include "mbed.h"
*
@ -65,7 +65,7 @@ public:
/** Reset the timer to 0.
*
* If it was already counting, it will continue
* If it was already running, it will continue
*/
void reset();
@ -75,15 +75,15 @@ public:
*/
float read();
/** Get the time passed in milli-seconds
/** Get the time passed in milliseconds
*
* @returns Time passed in milli seconds
* @returns Time passed in milliseconds
*/
int read_ms();
/** Get the time passed in micro-seconds
/** Get the time passed in microseconds
*
* @returns Time passed in micro seconds
* @returns Time passed in microseconds
*/
int read_us();
@ -91,18 +91,21 @@ public:
*/
operator float();
/** Get in a high resolution type the time passed in micro-seconds.
/** Get in a high resolution type the time passed in microseconds.
* Returns a 64 bit integer.
*/
us_timestamp_t read_high_resolution_us();
#if !defined(DOXYGEN_ONLY)
protected:
us_timestamp_t slicetime();
int _running; // whether the timer is running
us_timestamp_t _start; // the start time of the latest slice
us_timestamp_t _time; // any accumulated time from previous slices
const ticker_data_t *_ticker_data;
bool _lock_deepsleep; // flag which indicates if deep-sleep should be disabled
bool _lock_deepsleep; // flag that indicates if deep sleep should be disabled
};
#endif
} // namespace mbed

View File

@ -56,7 +56,7 @@ public:
/**
* @brief As a singleton, return the single instance of the class.
* Reason for this class being a singleton is the following:
* - Ease the use for users of this class not having to coordinate instantiations.
* - Ease of use for users of this class not having to coordinate instantiations.
* - Lazy instantiation of internal data (which we can't achieve with simple static classes).
*
* @returns Singleton instance reference.
@ -65,27 +65,27 @@ public:
{
// Use this implementation of singleton (Meyer's) rather than the one that allocates
// the instance on the heap, as it ensures destruction at program end (preventing warnings
// from memory checking tools such as valgrind).
// from memory checking tools, such as valgrind).
static DeviceKey instance;
return instance;
}
~DeviceKey();
/** Derive a new key based on the salt string. key type can be with values 16 bytes and 32 bytes
* @param isalt input buffer used to create the new key. Same input will generate always the same key
* @param isalt_size size of the data in salt buffer
* @param output buffer to receive the derived key. Size must be 16 bytes or 32 bytes
/** Derive a new key based on the salt string.
* @param isalt Input buffer used to create the new key. Same input always generates the same key
* @param isalt_size Size of the data in salt buffer.
* @param output Buffer to receive the derived key. Size must be 16 bytes or 32 bytes
* according to the ikey_type parameter
* @param ikey_type type of the required key. Type must be 16 bytes or 32 bytes.
* @param ikey_type Type of the required key. Must be 16 bytes or 32 bytes.
* @return 0 on success, negative error code on failure
*/
int generate_derived_key(const unsigned char *isalt, size_t isalt_size, unsigned char *output, uint16_t ikey_type);
/** Set a device key into the NVStore. In case TRNG support is missing, Call this method
/** Set a device key into the NVStore. If TRNG support is missing, call this method
* before calling device_key_derived_key. This method should be called only once!
* @param value input buffer contain the key.
* @param isize size of the supplied key. Must be 16 bytes or 32 bytes.
* @param value Input buffer contain the key.
* @param isize Size of the supplied key. Must be 16 bytes or 32 bytes.
* @return 0 on success, negative error code on failure
*/
int device_inject_root_of_trust(uint32_t *value, size_t isize);
@ -95,40 +95,40 @@ private:
DeviceKey();
/** Read a device key from the NVStore
* @param output buffer for the returned key.
* @param size input: the size of the output buffer.
* output: the actual size of the written data
* @param output Buffer for the returned key.
* @param size Input: The size of the output buffer.
* Output: The actual size of the written data
* @return 0 on success, negative error code on failure
*/
int read_key_from_nvstore(uint32_t *output, size_t& size);
/** Set a device key into the NVStore
* @param input input buffer contain the key.
* @param isize the size of the input buffer.
* @param input Input buffer contain the key.
* @param isize The size of the input buffer.
* @return 0 on success, negative error code on failure
*/
int write_key_to_nvstore(uint32_t *input, size_t isize);
/** Get a derived key base on a salt string. The methods implements
* Section 5.1 in NIST SP 800-108, Recommendation for Key Derivation Using Pseudorandom Functions
* @param ikey_buff input buffer holding the ROT key
* @param ikey_size size of the input key. Must be 16 bytes or 32 bytes.
* @param isalt input buffer contain some string.
* @param isalt_size size of the supplied input string.
* @param output buffer for the derived key result.
* @param ikey_type the requested key size. Must be 16 bytes or 32 bytes.
/** Get a derived key base on a salt string. The methods implements Section 5.1
* in NIST SP 800-108, Recommendation for Key Derivation Using Pseudorandom Functions
* @param ikey_buff Input buffer holding the ROT key
* @param ikey_size Size of the input key. Must be 16 bytes or 32 bytes.
* @param isalt Input buffer contain some string.
* @param isalt_size Size of the supplied input string.
* @param output Buffer for the derived key result.
* @param ikey_type The requested key size. Must be 16 bytes or 32 bytes.
* @return 0 on success, negative error code on failure
*/
int get_derived_key(uint32_t *ikey_buff, size_t ikey_size, const unsigned char *isalt, size_t isalt_size,
unsigned char *output, uint32_t ikey_type);
/** Generate a random ROT key by using TRNG
* @param output output buffer for the generated key.
* @param size input: the size of the buffer. if size is less
* then 16 bytes the method will generate an
* error. 16-31 bytes will create a 16 byte key.
* 32 or higher will generate a 32 bytes key
* output: the actual written size to the buffer
* @param output Output buffer for the generated key.
* @param size Input: The size of the buffer. If size is less
* than 16 bytes, the method generates an
* error. 16-31 bytes creates a 16-byte key.
* 32 or higher generates a 32-byte key
* Output: The actual written size to the buffer
* @return 0 on success, negative error code on failure
*/
int generate_key_by_trng(uint32_t *output, size_t size);

1
mbed.h
View File

@ -73,6 +73,7 @@
#include "drivers/UARTSerial.h"
#include "drivers/FlashIAP.h"
#include "drivers/MbedCRC.h"
#include "drivers/QSPI.h"
// mbed Internal components
#include "drivers/Timer.h"

View File

@ -90,7 +90,7 @@ extern "C" {
* System Error Status-es - 0x80XX0100 to 0x80XX0FFF - This corresponds to System error codes range(all values are negative). Bits 23-16 will be module type(marked with XX)\n
* Custom Error Status-es - 0xA0XX1000 to 0xA0XXFFFF - This corresponds to Custom error codes range(all values are negative). Bits 23-16 will be module type(marked with XX)\n\n
*
* The ERROR CODE(values encoded into ERROR CODE bit-field in mbed_error_status_t) value range for each error type is also seperated as below:\n
* The ERROR CODE(values encoded into ERROR CODE bit-field in mbed_error_status_t) value range for each error type is also separated as below:\n
* Posix Error Codes - 1 to 255.\n
* System Error Codes - 256 to 4095.\n
* Custom Error Codes - 4096 to 65535.\n
@ -231,31 +231,32 @@ typedef enum _mbed_error_type_t {
* @note
* \n Below are the module code mappings:\n
\verbatim
MBED_MODULE_APPLICATION 0 Application
MBED_MODULE_PLATFORM 1 Platform
MODULE_KERNEL 2 RTX Kernel
MBED_MODULE_NETWORK_STACK 3 Network stack
MBED_MODULE_HAL 4 HAL - Hardware Abstraction Layer
MBED_MODULE_NETWORK_STACKMODULE_MEMORY_SUBSYSTEM 5 Memory Subsystem
MBED_MODULE_FILESYSTEM 6 Filesystem
MBED_MODULE_BLOCK_DEVICE 7 Block device
MBED_MODULE_DRIVER 8 Driver
MBED_MODULE_DRIVER_SERIAL 9 Serial Driver
MBED_MODULE_DRIVER_RTC 10 RTC Driver
MBED_MODULE_DRIVER_I2C 11 I2C Driver
MODULE_DRIVER_SPI 12 SPI Driver
MODULE_DRIVER_GPIO 13 GPIO Driver
MODULE_DRIVER_ANALOG 14 Analog Driver
MODULE_DRIVER_DIGITAL 15 DigitalIO Driver
MODULE_DRIVER_CAN 16 CAN Driver
MODULE_DRIVER_ETHERNET 17 Ethernet Driver
MODULE_DRIVER_CRC 18 CRC Module
MODULE_DRIVER_PWM 19 PWM Driver
MODULE_DRIVER_QSPI 20 QSPI Driver
MODULE_DRIVER_USB 21 USB Driver
MODULE_TARGET_SDK 22 SDK
MBED_MODULE_APPLICATION 0 Application
MBED_MODULE_PLATFORM 1 Platform
MBED_MODULE_KERNEL 2 RTX Kernel
MBED_MODULE_NETWORK_STACK 3 Network stack
MBED_MODULE_HAL 4 HAL - Hardware Abstraction Layer
MBED_MODULE_MEMORY_SUBSYSTEM 5 Memory Subsystem
MBED_MODULE_FILESYSTEM 6 Filesystem
MBED_MODULE_BLOCK_DEVICE 7 Block device
MBED_MODULE_DRIVER 8 Driver
MBED_MODULE_DRIVER_SERIAL 9 Serial Driver
MBED_MODULE_DRIVER_RTC 10 RTC Driver
MBED_MODULE_DRIVER_I2C 11 I2C Driver
MBED_MODULE_DRIVER_SPI 12 SPI Driver
MBED_MODULE_DRIVER_GPIO 13 GPIO Driver
MBED_MODULE_DRIVER_ANALOG 14 Analog Driver
MBED_MODULE_DRIVER_DIGITAL 15 DigitalIO Driver
MBED_MODULE_DRIVER_CAN 16 CAN Driver
MBED_MODULE_DRIVER_ETHERNET 17 Ethernet Driver
MBED_MODULE_DRIVER_CRC 18 CRC Module
MBED_MODULE_DRIVER_PWM 19 PWM Driver
MBED_MODULE_DRIVER_QSPI 20 QSPI Driver
MBED_MODULE_DRIVER_USB 21 USB Driver
MBED_MODULE_TARGET_SDK 22 SDK
MBED_MODULE_BLE 23 BLE
MBED_MODULE_UNKNOWN 255 Unknown module
MBED_MODULE_UNKNOWN 255 Unknown module
\endverbatim
*
*/
@ -265,7 +266,7 @@ typedef enum _mbed_module_type {
MBED_MODULE_KERNEL,
MBED_MODULE_NETWORK_STACK,
MBED_MODULE_HAL,
MBED_MODULE_NETWORK_STACKMODULE_MEMORY_SUBSYSTEM,
MBED_MODULE_MEMORY_SUBSYSTEM,
MBED_MODULE_FILESYSTEM,
MBED_MODULE_BLOCK_DEVICE,
MBED_MODULE_DRIVER,
@ -290,7 +291,7 @@ typedef enum _mbed_module_type {
MBED_MODULE_MAX = MBED_MODULE_UNKNOWN
} mbed_module_type_t;
//Use MBED_SUCCESS(=0) or any postive number for successful returns
//Use MBED_SUCCESS(=0) or any positive number for successful returns
#define MBED_SUCCESS 0
#define MBED_POSIX_ERROR_BASE 0
@ -469,7 +470,7 @@ typedef enum _mbed_module_type {
INVALID_DATA 258 Invalid data
INVALID_FORMAT 259 Invalid format
INVALID_INDEX 260 Invalid Index
INVALID_SIZE 261 Inavlid Size
INVALID_SIZE 261 Invalid Size
INVALID_OPERATION 262 Invalid Operation
NOT_FOUND 263 Not Found
ACCESS_DENIED 264 Access Denied
@ -484,9 +485,9 @@ typedef enum _mbed_module_type {
OPERATION_ABORTED 273 Operation failed
WRITE_PROTECTED 274 Attempt to write to write-protected resource
NO_RESPONSE 275 No response
SEMAPHORE_LOCK_FAILED 276 Sempahore lock failed
SEMAPHORE_LOCK_FAILED 276 Semaphore lock failed
MUTEX_LOCK_FAILED 277 Mutex lock failed
SEMAPHORE_UNLOCK_FAILED 278 Sempahore unlock failed
SEMAPHORE_UNLOCK_FAILED 278 Semaphore unlock failed
MUTEX_UNLOCK_FAILED 279 Mutex unlock failed
CRC_ERROR 280 CRC error or mismatch
OPEN_FAILED 281 Open failed
@ -524,11 +525,14 @@ typedef enum _mbed_module_type {
DEVICE_BUSY 313 Device Busy
CONFIG_UNSUPPORTED 314 Configuration not supported
CONFIG_MISMATCH 315 Configuration mismatch
ALREADY_INITIALIZED 316 Already initialzied
ALREADY_INITIALIZED 316 Already initialized
HARDFAULT_EXCEPTION 317 HardFault exception
MEMMANAGE_EXCEPTION 318 MemManage exception
BUSFAULT_EXCEPTION 319 BusFault exception
USAGEFAULT_EXCEPTION 320 UsageFault exception
BLE_NO_FRAME_INITIALIZED, 321 BLE No frame initialized
BLE_BACKEND_CREATION_FAILED 322 BLE Backend creation failed
BLE_BACKEND_NOT_INITIALIZED 323 BLE Backend not initialized
\endverbatim
*
* @note
@ -561,13 +565,12 @@ typedef enum _mbed_module_type {
*
* \verbatim
++ MbedOS Error Info ++
Error Status: 0x80040103
Error Code: 259
Error Module: 04
Error Message: HAL Module error
Error Location: 0x000067C7
Error Value: 0x00005566
Current Thread: Id: 0x200024A8 EntryFn: 0x0000FB0D StackSize: 0x00001000 StackMem: 0x200014A8 SP: 0x2002FFD8
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x5CD1
Error Value: 0x4A2A
Current Thread: Id: 0x20001E80 Entry: 0x5EB1 StackSize: 0x1000 StackMem: 0x20000E80 SP: 0x2002FF90
For more info, visit: https://mbed.com/s/error?error=0x80FF013D&mbedos=999999&core=0x410FC241&compile=1&ver=5060528
-- MbedOS Error Info --
\endverbatim
*/
@ -717,7 +720,7 @@ typedef enum _mbed_error_code {
MBED_DEFINE_SYSTEM_ERROR(INVALID_DATA_DETECTED, 2), /* 258 Invalid data detected */
MBED_DEFINE_SYSTEM_ERROR(INVALID_FORMAT, 3), /* 259 Invalid format */
MBED_DEFINE_SYSTEM_ERROR(INVALID_INDEX, 4), /* 260 Invalid Index */
MBED_DEFINE_SYSTEM_ERROR(INVALID_SIZE, 5), /* 261 Inavlid Size */
MBED_DEFINE_SYSTEM_ERROR(INVALID_SIZE, 5), /* 261 Invalid Size */
MBED_DEFINE_SYSTEM_ERROR(INVALID_OPERATION, 6), /* 262 Invalid Operation */
MBED_DEFINE_SYSTEM_ERROR(ITEM_NOT_FOUND, 7), /* 263 Item Not Found */
MBED_DEFINE_SYSTEM_ERROR(ACCESS_DENIED, 8), /* 264 Access Denied */
@ -732,9 +735,9 @@ typedef enum _mbed_error_code {
MBED_DEFINE_SYSTEM_ERROR(OPERATION_ABORTED, 17), /* 273 Operation failed */
MBED_DEFINE_SYSTEM_ERROR(WRITE_PROTECTED, 18), /* 274 Attempt to write to write-protected resource */
MBED_DEFINE_SYSTEM_ERROR(NO_RESPONSE, 19), /* 275 No response */
MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_LOCK_FAILED, 20), /* 276 Sempahore lock failed */
MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_LOCK_FAILED, 20), /* 276 Semaphore lock failed */
MBED_DEFINE_SYSTEM_ERROR(MUTEX_LOCK_FAILED, 21), /* 277 Mutex lock failed */
MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_UNLOCK_FAILED, 22), /* 278 Sempahore unlock failed */
MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_UNLOCK_FAILED, 22), /* 278 Semaphore unlock failed */
MBED_DEFINE_SYSTEM_ERROR(MUTEX_UNLOCK_FAILED, 23), /* 279 Mutex unlock failed */
MBED_DEFINE_SYSTEM_ERROR(CRC_ERROR, 24), /* 280 CRC error or mismatch */
MBED_DEFINE_SYSTEM_ERROR(OPEN_FAILED, 25), /* 281 Open failed */
@ -772,7 +775,7 @@ typedef enum _mbed_error_code {
MBED_DEFINE_SYSTEM_ERROR(DEVICE_BUSY, 57), /* 313 Device Busy */
MBED_DEFINE_SYSTEM_ERROR(CONFIG_UNSUPPORTED, 58), /* 314 Configuration not supported */
MBED_DEFINE_SYSTEM_ERROR(CONFIG_MISMATCH, 59), /* 315 Configuration mismatch */
MBED_DEFINE_SYSTEM_ERROR(ALREADY_INITIALIZED, 60), /* 316 Already initialzied */
MBED_DEFINE_SYSTEM_ERROR(ALREADY_INITIALIZED, 60), /* 316 Already initialized */
MBED_DEFINE_SYSTEM_ERROR(HARDFAULT_EXCEPTION, 61), /* 317 HardFault exception */
MBED_DEFINE_SYSTEM_ERROR(MEMMANAGE_EXCEPTION, 62), /* 318 MemManage exception */
MBED_DEFINE_SYSTEM_ERROR(BUSFAULT_EXCEPTION, 63), /* 319 BusFault exception */
@ -919,7 +922,6 @@ void error(const char *format, ...);
* Callback/Error hook function prototype. Applications needing a callback when an error is reported can use mbed_set_error_hook function
* to register a callback/error hook function using the following prototype. When an error happens in the system error handling
* implementation will invoke this callback with the mbed_error_status_t reported and the error context at the time of error.
* @param error_status mbed_error_status_t status being reported.
* @param error_ctx Error context structure associated with this error.
* @return void
*

View File

@ -28,12 +28,14 @@ extern "C" {
#include <stdint.h>
#include <stddef.h>
/* Operation types for tracer */
/**
* enum Memory operation types for tracer
*/
enum {
MBED_MEM_TRACE_MALLOC,
MBED_MEM_TRACE_REALLOC,
MBED_MEM_TRACE_CALLOC,
MBED_MEM_TRACE_FREE
MBED_MEM_TRACE_MALLOC, /**< Identifier for malloc operation */
MBED_MEM_TRACE_REALLOC, /**< Identifier for realloc operation */
MBED_MEM_TRACE_CALLOC, /**< Identifier for calloc operation */
MBED_MEM_TRACE_FREE /**< Identifier for free operation */
};
/**

View File

@ -29,7 +29,7 @@ namespace mbed {
// timeout -1 forever, or milliseconds
int poll(pollfh fhs[], unsigned nfhs, int timeout)
{
/**
/*
* TODO Proper wake-up mechanism.
* In order to correctly detect availability of read/write a FileHandle, we needed
* a select or poll mechanisms. We opted for poll as POSIX defines in

View File

@ -42,17 +42,17 @@ extern "C" {
* struct mbed_stats_heap_t definition
*/
typedef struct {
uint32_t current_size; /**< Bytes allocated currently. */
uint32_t max_size; /**< Max bytes allocated at a given time. */
uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */
uint32_t reserved_size; /**< Current number of bytes allocated for the heap. */
uint32_t alloc_cnt; /**< Current number of allocations. */
uint32_t alloc_fail_cnt; /**< Number of failed allocations. */
uint32_t overhead_size; /**< Overhead added to heap for stats. */
uint32_t current_size; /**< Bytes currently allocated on the heap */
uint32_t max_size; /**< Maximum bytes allocated on the heap at one time since reset */
uint32_t total_size; /**< Cumulative sum of bytes allocated on the heap that have not been freed */
uint32_t reserved_size; /**< Current number of bytes reserved for the heap */
uint32_t alloc_cnt; /**< Current number of allocations that have not been freed since reset */
uint32_t alloc_fail_cnt; /**< Number of failed allocations since reset */
uint32_t overhead_size; /**< Number of bytes used to store heap statistics. This overhead takes up space on the heap, reducing the available heap space */
} mbed_stats_heap_t;
/**
* Fill the passed in heap stat structure with heap stats.
* Fill the passed in heap stat structure with the heap statistics.
*
* @param stats A pointer to the mbed_stats_heap_t structure to fill
*/
@ -62,14 +62,14 @@ void mbed_stats_heap_get(mbed_stats_heap_t *stats);
* struct mbed_stats_stack_t definition
*/
typedef struct {
uint32_t thread_id; /**< Identifier for thread that owns the stack or 0 if multiple threads. */
uint32_t max_size; /**< Maximum number of bytes used on the stack. */
uint32_t reserved_size; /**< Current number of bytes allocated for the stack. */
uint32_t stack_cnt; /**< Number of stacks stats accumulated in the structure. */
uint32_t thread_id; /**< Identifier for the thread that owns the stack or 0 if representing accumulated statistics */
uint32_t max_size; /**< Maximum number of bytes used on the stack since the thread was started */
uint32_t reserved_size; /**< Current number of bytes reserved for the stack */
uint32_t stack_cnt; /**< The number of stacks represented in the accumulated statistics or 1 if repesenting a single stack */
} mbed_stats_stack_t;
/**
* Fill the passed in structure with stack stats accumulated for all threads. The thread_id will be 0
* Fill the passed in structure with stack statistics accumulated for all threads. The thread_id will be 0
* and stack_cnt will represent number of threads.
*
* @param stats A pointer to the mbed_stats_stack_t structure to fill
@ -77,12 +77,13 @@ typedef struct {
void mbed_stats_stack_get(mbed_stats_stack_t *stats);
/**
* Fill the passed array of stat structures with the stack stats for each available thread.
* Fill the passed array of structures with the stack statistics for each available thread.
*
* @param stats A pointer to an array of mbed_stats_stack_t structures to fill
* @param count The number of mbed_stats_stack_t structures in the provided array
* @return The number of mbed_stats_stack_t structures that have been filled,
* this is equal to the number of stacks on the system.
* @return The number of mbed_stats_stack_t structures that have been filled.
* If the number of stacks on the system is less than or equal to count, it will equal the number of stacks on the system.
* If the number of stacks on the system is greater than count, it will equal count.
*/
size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
@ -90,10 +91,10 @@ size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
* struct mbed_stats_cpu_t definition
*/
typedef struct {
us_timestamp_t uptime; /**< Time since system is up and running */
us_timestamp_t idle_time; /**< Time spent in idle thread since system is up and running */
us_timestamp_t sleep_time; /**< Time spent in sleep since system is up and running */
us_timestamp_t deep_sleep_time; /**< Time spent in deep sleep since system is up and running */
us_timestamp_t uptime; /**< Time since the system has started */
us_timestamp_t idle_time; /**< Time spent in the idle thread since the system has started */
us_timestamp_t sleep_time; /**< Time spent in sleep since the system has started */
us_timestamp_t deep_sleep_time; /**< Time spent in deep sleep since the system has started */
} mbed_stats_cpu_t;
/**
@ -107,21 +108,22 @@ void mbed_stats_cpu_get(mbed_stats_cpu_t *stats);
* struct mbed_stats_thread_t definition
*/
typedef struct {
uint32_t id; /**< Thread Object Identifier */
uint32_t state; /**< Thread Object State */
uint32_t priority; /**< Thread Priority */
uint32_t stack_size; /**< Thread Stack Size */
uint32_t stack_space; /**< Thread remaining stack size */
const char *name; /**< Thread Object name */
uint32_t id; /**< ID of the thread */
uint32_t state; /**< State of the thread */
uint32_t priority; /**< Priority of the thread (higher number indicates higher priority) */
uint32_t stack_size; /**< Current number of bytes reserved for the stack */
uint32_t stack_space; /**< Current number of free bytes remaining on the stack */
const char *name; /**< Name of the thread */
} mbed_stats_thread_t;
/**
* Fill the passed array of stat structures with the thread stats for each available thread.
* Fill the passed array of stat structures with the thread statistics for each available thread.
*
* @param stats A pointer to an array of mbed_stats_thread_t structures to fill
* @param count The number of mbed_stats_thread_t structures in the provided array
* @return The number of mbed_stats_thread_t structures that have been filled,
* this is equal to the number of threads on the system.
* @return The number of mbed_stats_thread_t structures that have been filled.
* If the number of threads on the system is less than or equal to count, it will equal the number of threads on the system.
* If the number of threads on the system is greater than count, it will equal count.
*/
size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count);
@ -138,14 +140,14 @@ typedef enum {
* struct mbed_stats_sys_t definition
*/
typedef struct {
uint32_t os_version; /**< Mbed OS Version (Release only) */
uint32_t cpu_id; /**< CPUID Register data (Cortex-M only supported) */
uint32_t os_version; /**< Mbed OS version (populated only for tagged releases) */
uint32_t cpu_id; /**< CPUID register data (Cortex-M only supported) */
mbed_compiler_id_t compiler_id; /**< Compiler ID \ref mbed_compiler_id_t */
uint32_t compiler_version; /**< Compiler version */
} mbed_stats_sys_t;
/**
* Fill the passed in sys stat structure with system stats.
* Fill the passed in system stat structure with system statistics.
*
* @param stats A pointer to the mbed_stats_sys_t structure to fill
*/

View File

@ -54,13 +54,13 @@ typedef mbed::ScopedLock<Mutex> ScopedMutexLock;
*/
/** The Mutex class is used to synchronize the execution of threads.
This is for example used to protect access to a shared resource.
This is, for example, used to protect access to a shared resource.
@note You cannot use member functions of this class in ISR context. If you require Mutex functionality within
ISR handler, consider using @a Semaphore.
@note
Memory considerations: The mutex control structures will be created on current thread's stack, both for the Mbed OS
Memory considerations: The mutex control structures are created on the current thread's stack, both for the Mbed OS
and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
*/
class Mutex : private mbed::NonCopyable<Mutex> {
@ -85,16 +85,16 @@ public:
@a osOK the mutex has been obtained.
@note You cannot call this function from ISR context.
@note This function treats RTOS errors as fatal system errors, so can only return osOK.
@note This function treats RTOS errors as fatal system errors, so it can only return osOK.
Use of the return value is deprecated, as the return is expected to become void in the future.
*/
osStatus lock(void);
/**
For backwards compatibility.
Wait until a Mutex becomes available.
@deprecated Do not use this function. This function has been replaced with lock(), trylock() and trylock_for() functions.
Wait until a Mutex becomes available.
@param millisec timeout value or 0 in case of no time-out.
@return status code that indicates the execution status of the function:
@a osOK the mutex has been obtained.
@ -102,7 +102,7 @@ public:
@a osErrorResource the mutex could not be obtained when no timeout was specified.
@note You cannot call this function from ISR context.
@note This function treats RTOS errors as fatal system errors, so can only return osOK or
@note This function treats RTOS errors as fatal system errors, so it can only return osOK or
osErrorResource in case when millisec is 0 or osErrorTimeout if millisec is not osWaitForever.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.10.0", "Replaced with lock(), trylock() and trylock_for() functions")
@ -147,7 +147,7 @@ public:
@a osOK the mutex has been released.
@note You cannot call this function from ISR context.
@note This function treats RTOS errors as fatal system errors, so can only return osOK.
@note This function treats RTOS errors as fatal system errors, so it can only return osOK.
Use of the return value is deprecated, as the return is expected to become void in the future.
*/
osStatus unlock();