Skip to content

Conversation

@zkkkk12
Copy link

@zkkkk12 zkkkk12 commented Jan 5, 2026

Use mutexlock to replace critical section protection when using adc_isr_thread

Note: Please adhere to Contributing Guidelines.

Summary
The modification replaces critical section protection with mutex locks in ADC driver functions when CONFIG_ADC_ISR_THREAD is enabled, ensuring thread-safe hardware operations without unnecessarily disabling interrupts.

Impact
Benefits:

Reduced Interrupt Latency: Interrupts remain enabled during hardware operations
Better System Throughput: Other interrupts can still be serviced
Improved Real-time Performance: Shorter critical sections mean better determinism
Testing
The ADC function was tested and verified to be working correctly using NuttX's built-in adc_drivers.(apps/examples/adc)
Test Results:
Test results: When you input adc -p in the nsh terminal, the pin corresponding to channel adc0 is shown below.

[core2] adc -p
[core2] adc_main:g_adcstate.count: 3
[core2] adc_main: Hardware initialized. Opening the ADC device: /dev/adc0
[core2] Sample:
[core2] 1: channel: 32 value: 986
[core2] 2: channel: 34 value: 933

Use mutexlock to replace critical section protection when using adc_isr_thread

Signed-off-by: zhangkai25 <[email protected]>
@github-actions github-actions bot added Area: Drivers Drivers issues Size: S The size of the change in this PR is small labels Jan 5, 2026
@xiaoxiang781216 xiaoxiang781216 merged commit daf5715 into apache:master Jan 5, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants