linguini1 opened a new pull request, #19406:
URL: https://github.com/apache/nuttx/pull/19406

   ## Summary
   
   This PR introduces support for PWM-based audio on the Raspberry Pi 4B:
   
   - PWM driver support for both channels of PWM0 and PWM1 (audio jack PWM)
   - Oneshot timer support for the (4) BCM2711 system timers
   - Device driver registration for PWM and audio tone drivers
   - A configuration with the PWM example to test audio, which is documented
   
   The PWM audio isn't the best sounding because it is PWM. There have been 
suggestions on how to improve NuttX's audio support to allow translating PCM 
audio to PWM with DMA, but for now that is beyond the scope of these 
improvements.
   
   ## Impact
   
   Closes #16950.
   Closes #19374.
   
   Part of my GSoC milestones, completing the audio jack support milestone.
   
   Really hurts your ears if you wear earbuds to test; I recommend a device 
with its own analog volume control knob, and cautiously testing the volume of 
the sound before committing to wearing earbuds/headphones. I put this warning 
in the docs, but this is a warning to reviewers too!
   
   ## Testing
   
   Built the PWM audio configuration that is included in this PR and verified 
on the device that audio comes through the headphone jack. To my (not perfectly 
trained ears), the audio frequencies I set for a few notes (i.e. middle C) have 
sound which matches what my desktop computer played for a recording of middle C 
I found online.
   
   I also registered the one-shot driver as a character driver and performed 
the one-shot test, which passed:
   
   ```console
   nsh> oneshot                                                                 
                     
   oneshot_ioctl: cmd=5664 arg=004de0a0                                         
                     
   oneshot_ioctl: cmd=5665 arg=004de0b0                                         
                     
   bcm2711_tim_irq_en: Interrupt for timer 0 enabled.                           
                     
   Opening /dev/oneshot0                                                        
                     
   Maximum delay is 18446744073709551615                                        
                     
   Starting oneshot timer with delay 2000000 microseconds                       
                     
   Waiting...                                                                   
                     
   bcm2711_tim_irq_en: Interrupt for timer 0 disabled.                          
                     
   bcm2711_tim_handler: Callback...                                             
                     
   bcm2711_tim_handler: Callback called for oneshot 0.                          
                     
   Finished                                                    
   ```
   
   And finally, I checked the PWM0 interface output using my logic analyzer and 
both the frequency and duty cycle settings seem to work perfectly fine:
   
   <img width="1815" height="648" alt="swappy-20260708_201755" 
src="https://github.com/user-attachments/assets/67266a60-eb5c-464f-879e-66a59aec2a9b";
 />


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to