TLV320_RBSP class, defined on the I2C master bus.
Dependents: MovPlayer GR-PEACH_Audio_Playback_Sample GR-PEACH_Audio_Playback_7InchLCD_Sample RGA-MJPEG_VideoDemo ... more
Fork of TLV320_RBSP by
Revision 2:b1fab4a2b59d, committed 2015-08-18
- Comitter:
- dkato
- Date:
- Tue Aug 18 04:06:41 2015 +0000
- Parent:
- 1:4b34a496efac
- Child:
- 3:db6504d3f914
- Commit message:
- The audio clock is changed to 12M.
Changed in this revision
| TLV320_RBSP.cpp | Show annotated file Show diff for this revision Revisions of this file |
| TLV320_RBSP.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/TLV320_RBSP.cpp Mon Jun 22 09:17:17 2015 +0000
+++ b/TLV320_RBSP.cpp Tue Aug 18 04:06:41 2015 +0000
@@ -25,21 +25,16 @@
#include "TLV320_RBSP.h"
#include "pinmap.h"
-static const PinMap PinMap_AUDIO_XOUT[] = {
-// pin ch func
- {P5_5 , 0 , 5},
- {P3_13 , 0 , 4},
- {P8_7 , 0 , 3},
- {NC , NC , 0}
-};
+#define MCLK_12MHZ
+#undef MCLK_11_2896MHZ
-TLV320_RBSP::TLV320_RBSP(PinName xout, PinName cs, PinName sda, PinName scl, PinName sck, PinName ws, PinName tx, PinName rx, uint8_t int_level, int32_t max_write_num, int32_t max_read_num)
+TLV320_RBSP::TLV320_RBSP(PinName cs, PinName sda, PinName scl, PinName sck, PinName ws, PinName tx, PinName rx, uint8_t int_level, int32_t max_write_num, int32_t max_read_num)
: mI2c_(sda, scl), mI2s_(sck, ws, tx, rx, int_level, max_write_num, max_read_num), audio_cs_(cs) {
audio_cs_ = 0;
mAddr = 0x34;
- pinmap_pinout(xout, PinMap_AUDIO_XOUT);
audio_path_control = 0;
+ // I2S Mode
ssif_cfg.enabled = true;
ssif_cfg.int_level = 0x78;
ssif_cfg.slave_mode = true;
@@ -54,7 +49,7 @@
ssif_cfg.serial_alignment = SSIF_CFG_DATA_FIRST;
ssif_cfg.parallel_alignment = SSIF_CFG_LEFT;
ssif_cfg.ws_delay = SSIF_CFG_DELAY;
- ssif_cfg.noise_cancel = SSIF_CFG_DISABLE_NOISE_CANCEL;
+ ssif_cfg.noise_cancel = SSIF_CFG_ENABLE_NOISE_CANCEL;
ssif_cfg.tdm_mode = SSIF_CFG_DISABLE_TDM;
ssif_cfg.romdec_direct.mode = SSIF_CFG_DISABLE_ROMDEC_DIRECT;
ssif_cfg.romdec_direct.p_cbfunc = NULL;
@@ -160,7 +155,7 @@
mI2c_.write(mAddr, cmd, 2);
}
-void TLV320_RBSP::format(char length) {
+bool TLV320_RBSP::format(char length) {
cmd[0] = DIGITAL_AUDIO_INTERFACE_FORMAT;
cmd[1] = (1 << 6); // Master
switch (length) { // input data into instruction byte
@@ -181,30 +176,62 @@
cmd[1] |= 0x0E;
break;
default:
- return;
+ return false;
}
mI2s_.ConfigChannel(&ssif_cfg);
mI2c_.write(mAddr, cmd, 2);
+
+ return true;
}
bool TLV320_RBSP::frequency(int hz) {
- char rate;
+ char control_setting;
+#if defined(MCLK_12MHZ)
switch (hz) {
- case 8021:
- rate = 0x0B;
+ case 96000:
+ control_setting = 0x1D;
+ break;
+ case 88200:
+ control_setting = 0x3F;
+ break;
+ case 48000:
+ control_setting = 0x01;
break;
case 44100:
- rate = 0x08;
+ control_setting = 0x23;
+ break;
+ case 32000:
+ control_setting = 0x19;
break;
- case 88200:
- rate = 0x0F;
+ case 8021:
+ control_setting = 0x2F;
+ break;
+ case 8000:
+ control_setting = 0x0D;
break;
default:
return false;
}
+#elif defined(MCLK_11_2896MHZ)
+ switch (hz) {
+ case 88200:
+ control_setting = 0x3C;
+ break;
+ case 44100:
+ control_setting = 0x20;
+ break;
+ case 8021:
+ control_setting = 0x2C;
+ break;
+ default:
+ return false;
+ }
+#else
+ #error MCLK error
+#endif
cmd[0] = SAMPLE_RATE_CONTROL;
- cmd[1] = (rate << 2); // Sampling rate control
+ cmd[1] = control_setting;
mI2c_.write(mAddr, cmd, 2);
return true;
--- a/TLV320_RBSP.h Mon Jun 22 09:17:17 2015 +0000
+++ b/TLV320_RBSP.h Tue Aug 18 04:06:41 2015 +0000
@@ -35,7 +35,6 @@
/** Create a TLV320_RBSP object defined on the I2C port
*
- * @param xout AUDIO_X1 clock output
* @param cs Control port input latch/address select (codec pin)
* @param sda I2C data line pin
* @param scl I2C clock line pin
@@ -47,7 +46,7 @@
* @param max_write_num The upper limit of write buffer (SSIF)
* @param max_read_num The upper limit of read buffer (SSIF)
*/
- TLV320_RBSP(PinName xout, PinName cs, PinName sda, PinName scl, PinName sck, PinName ws, PinName tx, PinName rx, uint8_t int_level = 0x80, int32_t max_write_num = 16, int32_t max_read_num = 16);
+ TLV320_RBSP(PinName cs, PinName sda, PinName scl, PinName sck, PinName ws, PinName tx, PinName rx, uint8_t int_level = 0x80, int32_t max_write_num = 16, int32_t max_read_num = 16);
/** Overloaded power() function default = 0x80, record requires 0x02
*
@@ -66,8 +65,9 @@
/** Set I2S interface bit length and mode
*
* @param length Set bit length to 16, 20, 24 or 32 bits
+ * @return true = success, false = failure
*/
- void format(char length);
+ bool format(char length);
/** Set sample frequency
*
@@ -84,6 +84,14 @@
*/
void reset(void);
+ /** Get a value of SSIF channel number
+ *
+ * @return SSIF channel number
+ */
+ int32_t GetSsifChNo(void) {
+ return mI2s_.GetSsifChNo();
+ };
+
/** Enqueue asynchronous write request
*
* @param p_data Location of the data
