Library to control and transfer data from NXP SGTL5000. As used on the Teensy Audio Shield. It uses DMA to transfer I2S FIFO data.

The Library now supports dual codecs. Allowing all 4 channels of the Teensy I2S interface to RX and TX data to separate SGTL5000 devices.

The ISR routines that handles pointer swaps for double buffering has been fully coded in assembler to reduce overhead and now takes < 800nS per FIFO transfer when using all 4 channels.

Support added for all typical sample rates and system Clock speeds of 96Mhz or 120Mhz.

Pause and Resume functions added to allow quick and simple suppression of IRQs and stream halting and restart. This required software triggered IRQ, in order to ensure accurate word sync control.

Files at this revision

API Documentation at this revision

Comitter:
aidan1971
Date:
Wed Sep 27 11:23:28 2017 +0000
Parent:
13:83c2aaf4a338
Commit message:
doc updates

Changed in this revision

sgtl5000.h Show annotated file Show diff for this revision Revisions of this file
diff -r 83c2aaf4a338 -r 9043626add45 sgtl5000.h
--- a/sgtl5000.h	Wed Sep 27 11:20:43 2017 +0000
+++ b/sgtl5000.h	Wed Sep 27 11:23:28 2017 +0000
@@ -59,9 +59,10 @@
 *
 *   uint32_t main()
 *   {
+*       codec.init();    
 *       codec.modify_i2c(SGTL5000_ANA_HP_CTRL, 0x18, SGTL5000_ANA_HP_CTRL_HP_VOL_RIGHT_MASK);   // Headphone volume control with 0.5 dB steps.0x00 = +12 dB, 0x01 = +11.5 dB, 0x18 = 0 dB,...0x7F = -51.5 dB
 *       codec.modify_i2c(SGTL5000_ANA_HP_CTRL, 0x18, SGTL5000_ANA_HP_CTRL_HP_VOL_LEFT_MASK);
-*       codec.init();
+*
 *       codec.attach_SYNC_NB((uint32_t)&I2S_SYNC_ISR);
 *       codec.sample_rate(96);
 *       codec.start_SYNC((uint32_t)&RX_AudioL, (uint32_t)&RX_AudioR, (uint32_t)&TX_AudioL, (uint32_t)&TX_AudioR, I2S_FIFO_BS)
@@ -98,12 +99,13 @@
 *
 *   uint32_t main()
 *   {
+*       codec1_ctrl.init();
+*       codec2.init();
 *       codec1_ctrl.modify_i2c(SGTL5000_ANA_HP_CTRL, 0x18, SGTL5000_ANA_HP_CTRL_HP_VOL_RIGHT_MASK);     // Headphone volume control with 0.5 dB steps.0x00 = +12 dB, 0x01 = +11.5 dB, 0x18 = 0 dB,...0x7F = -51.5 dB
 *       codec1_ctrl.modify_i2c(SGTL5000_ANA_HP_CTRL, 0x18, SGTL5000_ANA_HP_CTRL_HP_VOL_LEFT_MASK);
 *       codec2.modify_i2c(SGTL5000_ANA_HP_CTRL, 0x01, SGTL5000_ANA_HP_CTRL_HP_VOL_RIGHT_MASK);          // Headphone volume control with 0.5 dB steps.0x00 = +12 dB, 0x01 = +11.5 dB, 0x18 = 0 dB,...0x7F = -51.5 dB
 *       codec2.modify_i2c(SGTL5000_ANA_HP_CTRL, 0x01, SGTL5000_ANA_HP_CTRL_HP_VOL_LEFT_MASK);           // Seperate codec settings.
-*       codec1_ctrl.init();
-*       codec2.init();
+*
 *       codec1_ctrl.attach_SYNC_NB((uint32_t)&I2S_SYNC_ISR);
 *       codec1_ctrl.sample_rate(96);
 *       codec1_ctrl.start_SYNC((uint32_t)&RX_AudioL1, (uint32_t)&RX_AudioR1, (uint32_t)&TX_AudioL1, (uint32_t)&TX_AudioR1, I2S_FIFO_BS, true, true, false, false, 14, 15,