This reverts commit bb52288561.
Event though this fixes a deadlock in the new protocol, it
actually breaks fair locking as one side could lock multiple
times in a row.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Clear the thread ID to 0 when unlocking the mutex to prevent deadlock.
If the thread holding never reacquire it, other threads would be
permanently blocked with a stale thread ID.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The removal of unused USB commands that are still sent by the IDE
causes tinyusb boards to crash on connect currently. Flushing the
excess received bytes for unknown commands solves this issue.
This adds a simple code profiler that leverages both SysTick and
the Performance Monitoring Unit (PMU) available on Armv8.1-M cores.
SysTick provides a simple high-resolution timer source, while the PMU
offers a cycle counter and multiple configurable event counters that
can track low-level performance metrics such as cache misses, pipeline
stalls, etc... See the Armv8.1-M Performance Monitoring User Guide
for additional details.
Function-level instrumentation is enabled using -finstrument-functions
on select files to automatically record statistics on entry/exit.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit refactors the TinyUSB debug interface with the following changes:
- Handle disabled IRQs.
- Replace global variables with centralized state.
- Add timeout, and validation for more robust transfers (as much as possible
given the protocol limits).
- Remove obsolete/unsupported commands (attr read/write, script save etc..)
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This allows drivers to override standard resolutions,
or use custom ones, without affecting other CSIs.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
- Abort if synchronization takes too long.
- Reinit SPI on transfer restart (fixes an issue on N6).
- Clean up vospi code.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Check if VOSPI_SYNC_MS has elapsed since the last abort instead
of delaying on every call. This avoids blocking other CSIs on
back-to-back resync's.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Use C11 atomic operations to implement the mutex instead
of hard-coded intrinsics. This generates more efficient
assembly on newer ARM architectures by taking advantage
of the new LDA/STL instructions (and their exclusive variants),
which avoid full memory barriers while still providing
memory ordering guarantees.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This patch decouples the clock from the main CSI state,
further separating the CSI instance from the port's CSI
driver. Additionally, it allows CSIs to use different clocks,
in theory, though they must first be detected somehow in
order to switch clocks.
As a side effect of sharing the clock, set_frequency will be
called more frequently (the default call plus once per CSI).
However, the frequency is now checked, and the clock is only
reconfigured if the new frequency exceeds a configurable
tolerance.
Finally, get_clk_frequency now accepts a boolean to return
either the exact clock frequency, for sensors that require
it, or the nominal frequency.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Simplify the detection logic and handle the case where
all detected sensors (one or more) are auxiliary.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>