Skip to content

pcbcupid/PCBCUPID-NAU8325

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PCBCUPID NAU8325 Audio Amplifier Library

An advanced Arduino-compatible library for configuring and controlling the NAU8325 Class-D audio amplifier over I2C—featuring dynamic MCLK configuration, ESP32 compatibility, and full support for audio path management and clock tree logic.


Overview

The PCBCUPID NAU8325 library offers a robust interface to the NAU8325 Codec With Stereo Class-D amplifier. It provides:

  • Automatic MCLK configuration
  • Oversampling selection
  • Volume control
  • Automatic Level Control (ALC)
  • Abstraction of low-level register management

Tailored for ESP32(tested - GLYPHC3, GLYPHH2 & GLYPHC6), and other Arduino-compatible microcontrollers (not tested), this library simplifies the integration of high-performance audio output into your embedded projects.


Key Features & Enhancements

Full Clock Tree Management

  • Automatic MCLK-to-FS ratio matching
  • Validates MCLK frequency range
  • Dynamically selects N1, N2, N3 clock divider/multiplier
  • Configurable DAC oversampling (OSR 32–256)

Platform Compatibility

  • Full support for ESP32 both RISC-V & ARM
  • Uses TwoWire interface with custom I2C instance support
  • Multiple begin() overloads for flexible setup

Audio Path Configuration

  • Independent left/right volume control
  • Automatic Level Control (ALC) with programmable timing
  • VMID bias and Class-D power management
  • Soft mute/unmute functionality

Hardware Support

Supported ICs:

  • NAU8325 Codec With Stereo Class-D Audio Amplifier

Compatible Platforms:

  • ESP32 (all variants)
  • Arduino compatible microcontroller with I2S & I2C interface

Core Features & Functions

Initialization

bool begin(uint32_t fs, uint8_t bits_per_sample, uint16_t ratio);
bool begin(uint32_t fs, uint8_t bits_per_sample); // Default ratio = 256
bool begin(); // Defaults to 44100 Hz, 16-bit, ratio = 256

Audio Control

void setVolume(uint8_t left, uint8_t right);
void softMute(bool enable);

Power Management

void powerOn(); // Enable DACs and analog path
void powerOff(); // Soft mute and disable analog blocks

Clock & Oversampling

void setOversampling(OversamplingMode mode); // OSR_64, OSR_128, etc.
void setPowerUpDefault(bool enable); // Enables analog default on boot

Utilities

void resetChip(); // Hardware reset
uint16_t readDeviceId(); // Returns 0x21F2 if successful


Sample Rate Support

Sample Rate Supported MCLK Frequencies (Hz) Default Ratio
8000 Hz 2048000, 3200000, 4000000 256
16000 Hz 4096000, 6400000, 8000000 256
44100 Hz 11289600, 17640000, 22050000 256
48000 Hz 12288000, 19200000, 24000000 256
96000 Hz 24576000, 38400000, 48000000 256

All necessary divider/multiplier (N1, N2, N3) selections are handled internally.


Examples

Included examples demonstrate:

  • Simple I2S configuration & Audio Generation
  • I2S configuration + MP3 Decoder + SD card integration

Examples are located in the examples/ directory of the library.


Documentation & Resources


Credits & Attribution

This library was developed and maintained by PCBCUPID, based on the NAU8325 codec specifications and the I2C protocol defined by Nuvoton Technology Corporation. We gratefully acknowledge the open-source community for foundational research and NAU8325 references.

Original Author:

  • Karthik Elumalai – @PCBCUPID
  • Version: 1.0.0
  • License: MIT License (refer to the LICENSE file for terms)

Contributing

We welcome contributions and feedback from the community. You can:

  • Report issues or suggest improvements
  • Submit pull requests with enhancements or fixes
  • Share example projects using this library

Please refer to the Contributing Guidelines before submitting changes.


License

This library is licensed under the MIT License. See the LICENSE file for full details.


Made with 🎵 by PCBCUPID


About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages