Ticker constructor calls directly target specific ticker init function. Currently there is no problem, since ticker interface initialization functions are protected against multi-calls and simply returns if not called for the first time (interface initialization can be performed only once). According to the new Thicker HAL API requirements:
The function ticker_init allows the ticker to keep counting and disables the ticker interrupt.
Disabling interrupts while some Ticker interrupts are already scheduled for sure will destroy the schedule. Ticker interface should be initialized only once and it is already done by: static void initialize(const ticker_data_t *ticker) function in /m-bed/hal/mbed_ticker_api.c file.
CRC class `MbedCRC.h` is templated class created to support hardware/software
CRCs. Default CRC will be hardware CRC when support for HAL is available.
Polynomial tables are available for 8/16 bit CCITT, 7/16 bit for SD card and
32-bit ANSI. Polynomial table implementation will be used if Hardware CRC is
not available.
In case device does not have hardware CRC and polynomial table is not supported,
CRC is still available and is computed runtime bit by bit for all data input.
- Add flag to SPI class to track if the SPI instance has locked deep sleep mode.
- Wrap call to sleep_manager_lock_deep_sleep to only be called if SPI instance
hasn't already locked deep sleep.
- Wrap call to sleep_manager_unlock_deep_sleep to only be called if SPI has
currently locked deep sleep mode.
- Add flag to I2C class to track if the I2C instance has locked deep sleep mode.
- Wrap call to sleep_manager_lock_deep_sleep to only be called if I2C instance
hasn't already locked deep sleep.
- Wrap call to sleep_manager_unlock_deep_sleep to only be called if I2C has
currently locked deep sleep mode.
Previously, write() was somewhat soft - it only ever made one attempt to
wait for buffer space, so it would take as much data as would fit in the
buffer in one call.
This is not the intent of a POSIX filehandle write. It should try to
send everything if blocking, and only send less if interrupted by a
signal:
- If the O_NONBLOCK flag is clear, write() shall block the calling
thread until the data can be accepted.
- If the O_NONBLOCK flag is set, write() shall not block the thread.
If some data can be written without blocking the thread, write()
shall write what it can and return the number of bytes written.
Otherwise, it shall return -1 and set errno to [EAGAIN].
This "send all" behaviour is of slightly limited usefulness in POSIX, as
you still usually have to worry about the interruption possibility:
- If write() is interrupted by a signal before it writes any data, it
shall return -1 with errno set to [EINTR].
- If write() is interrupted by a signal after it successfully writes
some data, it shall return the number of bytes written.
But as mbed OS does not have the possibility of signal interruption, if we
strengthen write to write everything, we can make applications' lives
easier - they can just do "write(large amount)" confident that it will
all go in one call (if no errors).
So, rework to make multiple writes to the buffer, blocking as necessary,
until all data is written.
This change does not apply to read(), which is correct in only blocking until
some data is available:
- If O_NONBLOCK is set, read() shall return -1 and set errno to [EAGAIN].
- If O_NONBLOCK is clear, read() shall block the calling thread until some
data becomes available.
- The use of the O_NONBLOCK flag has no effect if there is some data
available.
If a LowPowerTimer is started and then goes out of scope then a
deep sleep lock underflow can occur. This is because the
the variable '_lock_deepsleep' is checked when starting the timer
but is not checked in the destructor, which unconditionally releases
the deep sleep lock.
Release the deep sleep lock when running instances of the Timer class
are deleted. This ensures that deep sleep locks are properly released
by the Timer class.
Add passthrough APIs to enable the flow control and format methods from
SerialBase to be accessed.
Modify the RX data pump so it stops reading data and disables the IRQ
when the buffer is full, to allow UART automatic flow control to work.
In principle it would also be possible as a future enhancement to
provide XON/XOFF flow control, or manual RTS/CTS control using GPIO, but
this commit at least restores the functionality present in Serial,
SerialBase and RawSerial that was missing in UARTSerial.
UARTSerial inherits both FileHandle::readable() [public] and
SerialBase::readable() [private], so calling readable() on a UARTSerial
object produces an ambiguous member error.
Add using declarations to direct towards the FileHandle versions of
readable and writable.
There's currently no ambiguity for writable, as SerialBase uses the
spelling 'writeable', but add a using directive for that anyway, in case
SerialBase gains 'writable' later.
attach/detach can be multiple invoked. Therefore lock/unlock deep sleep
only for the very first time it is invoked (when callbacks
are actually changed).
Any driver with attach or async API should be considered for deep sleep.
Add locking to those that require in most cases
high-frequency clocks:
- CAN
- I2C
- SPI
- Serial
- Ticker/Timeout/Timer