test public
Dependencies: HttpServer_snapshot_mbed-os
TLV320_RBSP.h
00001 /******************************************************************************* 00002 * DISCLAIMER 00003 * This software is supplied by Renesas Electronics Corporation and is only 00004 * intended for use with Renesas products. No other uses are authorized. This 00005 * software is owned by Renesas Electronics Corporation and is protected under 00006 * all applicable laws, including copyright laws. 00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING 00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT 00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. 00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR 00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE 00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00016 * Renesas reserves the right, without notice, to make changes to this software 00017 * and to discontinue the availability of this software. By using this software, 00018 * you agree to the additional terms and conditions found by accessing the 00019 * following link: 00020 * http://www.renesas.com/disclaimer* 00021 * Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved. 00022 *******************************************************************************/ 00023 00024 #ifndef MBED_TLV320_RBSP_H 00025 #define MBED_TLV320_RBSP_H 00026 00027 #include "mbed.h" 00028 #include "AUDIO_RBSP.h" 00029 #include "R_BSP_Ssif.h" 00030 00031 /** TLV320_RBSP class, defined on the I2C master bus 00032 * 00033 */ 00034 class TLV320_RBSP : public AUDIO_RBSP { 00035 public: 00036 00037 /** Create a TLV320_RBSP object defined on the I2C port 00038 * 00039 * @param cs Control port input latch/address select (codec pin) 00040 * @param sda I2C data line pin 00041 * @param scl I2C clock line pin 00042 * @param sck SSIF serial bit clock 00043 * @param ws SSIF word selection 00044 * @param tx SSIF serial data output 00045 * @param rx SSIF serial data input 00046 * @param int_level Interupt priority (SSIF) 00047 * @param max_write_num The upper limit of write buffer (SSIF) 00048 * @param max_read_num The upper limit of read buffer (SSIF) 00049 */ 00050 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); 00051 00052 virtual ~TLV320_RBSP() {} 00053 00054 /** Overloaded power() function default = 0x80, record requires 0x02 00055 * 00056 * @param device Call individual devices to power up/down 00057 * Device power 0x00 = On 0x80 = Off 00058 * Clock 0x00 = On 0x40 = Off 00059 * Oscillator 0x00 = On 0x20 = Off 00060 * Outputs 0x00 = On 0x10 = Off 00061 * DAC 0x00 = On 0x08 = Off 00062 * ADC 0x00 = On 0x04 = Off 00063 * Microphone input 0x00 = On 0x02 = Off 00064 * Line input 0x00 = On 0x01 = Off 00065 */ 00066 void power(int device); 00067 00068 /** Overloaded power() 00069 * 00070 * @param type true=power up, false=power down 00071 */ 00072 virtual void power(bool type = true) { 00073 if (type) { 00074 power(0x00); 00075 } else { 00076 power(0x80); 00077 } 00078 } 00079 00080 /** Set I2S interface bit length and mode 00081 * 00082 * @param length Set bit length to 16, 20, 24 or 32 bits 00083 * @return true = success, false = failure 00084 */ 00085 virtual bool format(char length); 00086 00087 /** Set sample frequency 00088 * 00089 * @param frequency Sample frequency of data in Hz 00090 * @return true = success, false = failure 00091 * 00092 * The TLV320 supports the following frequencies: 8kHz, 8.021kHz, 32kHz, 44.1kHz, 48kHz, 88.2kHz, 96kHz 00093 * Default is 44.1kHz 00094 */ 00095 virtual bool frequency(int hz); 00096 00097 /** Reset TLV320 00098 * 00099 */ 00100 void reset(void); 00101 00102 /** Get a value of SSIF channel number 00103 * 00104 * @return SSIF channel number 00105 */ 00106 int32_t GetSsifChNo(void) { 00107 return mI2s_.GetSsifChNo(); 00108 }; 00109 00110 /** Enqueue asynchronous write request 00111 * 00112 * @param p_data Location of the data 00113 * @param data_size Number of bytes to write 00114 * @param p_data_conf Asynchronous control block structure 00115 * @return Number of bytes written on success. negative number on error. 00116 */ 00117 virtual int write(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf = NULL) { 00118 return mI2s_.write(p_data, data_size, p_data_conf); 00119 }; 00120 00121 /** Enqueue asynchronous read request 00122 * 00123 * @param p_data Location of the data 00124 * @param data_size Number of bytes to read 00125 * @param p_data_conf Asynchronous control block structure 00126 * @return Number of bytes read on success. negative number on error. 00127 */ 00128 virtual int read(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf = NULL) { 00129 return mI2s_.read(p_data, data_size, p_data_conf); 00130 }; 00131 00132 /** Line in volume control i.e. record volume 00133 * 00134 * @param leftVolumeIn Left line-in volume 00135 * @param rightVolumeIn Right line-in volume 00136 * @return Returns "true" for success, "false" if parameters are out of range 00137 * Parameters accept a value, where 0.0 < parameter < 1.0 and where 0.0 maps to -34.5dB 00138 * and 1.0 maps to +12dB (0.74 = 0 dB default). 00139 */ 00140 bool inputVolume(float leftVolumeIn, float rightVolumeIn); 00141 00142 /** Headphone out volume control 00143 * 00144 * @param leftVolumeOut Left headphone-out volume 00145 * @param rightVolumeOut Right headphone-out volume 00146 * @return Returns "true" for success, "false" if parameters are out of range 00147 * Parameters accept a value, where 0.0 < parameter < 1.0 and where 0.0 maps to -73dB (mute) 00148 * and 1.0 maps to +6dB (0.5 = default) 00149 */ 00150 virtual bool outputVolume(float leftVolumeOut, float rightVolumeOut); 00151 00152 /** Analog audio path control (Bypass) function default = false 00153 * 00154 * @param bypassVar Route analogue audio direct from line in to headphone out 00155 */ 00156 void bypass(bool bypassVar); 00157 00158 /** Analog audio path control (Input select for ADC) function default = false 00159 * 00160 * @param micVar Input select for ADC. true : Microphone , false : Line 00161 */ 00162 void mic(bool micVar); 00163 00164 /** Microphone volume 00165 * 00166 * @param mute Microphone mute. true : mute , false : normal 00167 * @param boost Microphone boost. true : 20dB , false : 0dB 00168 */ 00169 void micVolume(bool mute, bool boost); 00170 00171 /** Microphone volume 00172 * 00173 * @param VolumeIn Microphone volume 00174 * @return Returns "true" for success, "false" if parameters are out of range 00175 */ 00176 virtual bool micVolume(float VolumeIn) { 00177 if (VolumeIn > 0) { 00178 if (VolumeIn >= 0.5) { 00179 micVolume(false , true); 00180 } else { 00181 micVolume(false, false); 00182 } 00183 } else { 00184 micVolume(true, false); 00185 } 00186 return true; 00187 } 00188 00189 /** Digital audio path control 00190 * 00191 * @param softMute Mute output 00192 */ 00193 void mute(bool softMute); 00194 00195 protected: 00196 char cmd[2]; // the address and command for TLV320 internal registers 00197 int mAddr; // register write address 00198 private: 00199 DigitalOut audio_cs_; 00200 I2C mI2c_; // MUST use the I2C port 00201 R_BSP_Ssif mI2s_; 00202 ssif_channel_cfg_t ssif_cfg; 00203 char audio_path_control; 00204 /** Digital interface activation 00205 * 00206 */ 00207 void activateDigitalInterface_(void); 00208 00209 // TLV320AIC23B register addresses as defined in the TLV320AIC23B datasheet 00210 #define LEFT_LINE_INPUT_CHANNEL_VOLUME_CONTROL (0x00 << 1) 00211 #define RIGHT_LINE_INPUT_CHANNEL_VOLUME_CONTROL (0x01 << 1) 00212 #define LEFT_CHANNEL_HEADPHONE_VOLUME_CONTROL (0x02 << 1) 00213 #define RIGHT_CHANNEL_HEADPHONE_VOLUME_CONTROL (0x03 << 1) 00214 #define ANALOG_AUDIO_PATH_CONTROL (0x04 << 1) 00215 #define DIGITAL_AUDIO_PATH_CONTROL (0x05 << 1) 00216 #define POWER_DOWN_CONTROL (0x06 << 1) 00217 #define DIGITAL_AUDIO_INTERFACE_FORMAT (0x07 << 1) 00218 #define SAMPLE_RATE_CONTROL (0x08 << 1) 00219 #define DIGITAL_INTERFACE_ACTIVATION (0x09 << 1) 00220 #define RESET_REGISTER (0x0F << 1) 00221 }; 00222 00223 #endif
Generated on Wed Jul 13 2022 05:33:37 by 1.7.2