SPI peripherals' asynch transaction buffers are now wrapped by
SingletonPtr, which needs to take the singleton_lock Mutex when first
accessed. If it was first accessed by an asynch transaction started from
IRQ, that would not be possible.
Add a SingletonPtr::get() call to the SPI construction process so that
the peripheral's buffer is fully constructed before any SPI methods can
be called, meaning asynch methods won't fail from IRQ.
(Other pre-existing synchronisation issues with async remain, but this
avoids a new trap in Mbed OS 5.12).
The length calculation in UARTSerial::write_unbuffered was wrong,
meaning it would truncate output data to half length.
This would show up if `platform.stdio-buffered-serial` was configured to
true, `platform.stdio-convert-newlines` was still false - `mbed_error`
crashes would be garbled.
This wasn't usually spotted because applications generally have both
settings false or both true, and if newline conversion is on, then
`mbed_error_puts` writes 1 character at a time to FileHandle::write,
avoiding the length error.
The knowledge that lp_ticker runs in deep sleep was hard-coded with a
comparison check of a ticker_data_t pointer against get_lp_ticker_data.
Remove this hard-coded check, which adds a linker dependency against
the low power ticker even if not being used - put a flag into the
ticker_interface_t.
A future extension might be to move this flag into the ticker_info_t
provided by the HAL, but for the moment keep the assumption that
lp_ticker does run, us_ticker doesn't.
This commit takes some of the work done on the SPI class from #8445, and
refines it, to provide the per-peripheral mutex functionality.
This also implements GPIO-based SSEL, which exposes a new
select()/deselect() API for users to group transfers, and should work on
every platform (unlike the HAL-based SSEL). This requires users to use a
new constructor to avoid backwards compatibility issues.
To activate the per-peripheral mutex, the HAL must define SPI_COUNT and
provide spi_get_peripheral_name(). (In #8445 this is a reworked
spi_get_module, but the name is changed here to avoid a collision with
existing HALs - this commit is designed to work without wider HAL
changes).
Fixes: #9149
Aborting of asynchronous operation is necessarily hazardous, as
operation can end in interrupt anywhere from the point of decision
until it is actually aborted down the abort_...() method.
Proper deep sleep unlocking requires then use of the critical
section and should be contained completely within API implementation.
1. As RX and TX flows are separate on Serial device, read and write
functionalities should be completely separate, including any deep
sleep locking etc.
2. User may want to use asynchronous API without a callback (especially
for write operations), for example in a command-response scheme
end of write operation is usually meaningless. The intuitive
method is to submit NULL pointer for a callback. For this reason
depending on the _callback field in determining whether the
operation is in progress seems to be uncertain, so introduced
additional flags for this purpose.
Few boards may fail the write actions due to HW limitations (like critical
drivers that disable flash operations). Just retry a few times until success.
In addition, remove the redundant retries in NVStore (not needed now).
The DEVICE_FOO macros are always defined (either 0 or 1).
This patch replaces any instances of a define check on a DEVICE_FOO
macro with value test instead.
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
DEVICE_SERIAL is always defined (either 0 or 1).
Remove the faulty checks introduces in commit
26b9a1f6a3 and replace them with
value checks as originally implemented.
Fixes#8913
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
- Consider data section in GCC_ARM toolchain
- Consider init_array section in IAR toolchain
- Rename macro to FLASHIAP_APP_ROM_END_ADDR for clarity sake
Make the following changes:
-Allow a vector specific ARM MPU driver by defining MBED_MPU_CUSTOM
-Allow ROM address to be configured for ARMv7-M devices by
setting the define MBED_MPU_ROM_END
-Add ROM write protection
-Add new functions and lock
-enable at boot
-disable during flash programming
Rename MpuXnLock to ScopedMpuXnLock so it has the same naming
convention as ScopedMutexLock. Also make this class inherit from
NonCopyable to prevent misuse.
When programming flash using the FlashIAP API allow execution from
ram. Many devices require flashing to be done from RAM.
Also allow execution from ram when running the low level flash tests.
Current serial implementation has a send_break() command which
sends a break command on the UART for a fixed amount of time.
Added functions to allow users to send a break in a non-blocking
fashion, as well as for a user-specified amount of time.