⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pmic_audio.cpp

📁 Microsoft WinCE 6.0 BSP FINAL release source code for use with the i.MX27ADS TO2 WCE600_FINAL_MX27_S
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    REGFIELD ADDSTDC;       /*!< Adder Channel Stereo DAC Selection           */
    REGFIELD ADDRXIN;       /*!< Adder Channel Line In Selection              */
} REGISTER_RX0;

/*!
 * @brief This variable is used to access the RX0 hardware register.
 *
 * This variable defines how to access all of the fields within the
 * RX0 hardware register. The initial values consist of the offset
 * and mask values needed to access each of the register fields.
 */
static const REGISTER_RX0 regRX0 = {
    {  0, 0x000001 }, /* VAUDIOON      */
    {  1, 0x000002 }, /* BIASEN        */
    {  2, 0x000004 }, /* BIASSPEED     */
    {  3, 0x000008 }, /* ASPEN         */
    {  4, 0x000010 }, /* ASPSEL        */
    {  5, 0x000020 }, /* ALSPEN        */
    {  6, 0x000040 }, /* ALSPREF       */
    {  7, 0x000080 }, /* ALSPSEL       */
    {  8, 0x000100 }, /* LSPLEN        */
    {  9, 0x000200 }, /* AHSREN        */
    { 10, 0x000400 }, /* AHSLEN        */
    { 11, 0x000800 }, /* AHSSEL        */
    { 12, 0x001000 }, /* HSPGDIS       */
    { 13, 0x002000 }, /* HSDETEN       */
    { 14, 0x004000 }, /* HSDETAUTOB    */
    { 15, 0x008000 }, /* ARXOUTREN     */
    { 16, 0x010000 }, /* ARXOUTLEN     */
    { 17, 0x020000 }, /* ARXOUTSEL     */
    { 18, 0x040000 }, /* CDCOUTEN      */
    { 19, 0x080000 }, /* HSLDETEN      */
    { 21, 0x200000 }, /* ADDCDC        */
    { 22, 0x400000 }, /* ADDSTDC       */
    { 23, 0x800000 }  /* ADDRXIN       */
};

/*!
 * @brief This structure lists all fields of the RX1 hardware register.
 */
typedef struct
{
    REGFIELD PGARXEN;       /*!< Codec Receive PGA Enable                    */
    REGFIELD PGARX;         /*!< Codec Receive Gain Setting                  */
    REGFIELD PGASTEN;       /*!< Stereo DAC PGA Enable                       */
    REGFIELD PGAST;         /*!< Stereo DAC Gain Setting                     */
    REGFIELD ARXINEN;       /*!< Amplifier Arx Enable                        */
    REGFIELD ARXIN;         /*!< Amplifier Arx Additional Gain Setting       */
    REGFIELD PGARXIN;       /*!< PGArxin Gain Setting                        */
    REGFIELD MONO;          /*!< Mono Adder Setting                          */
    REGFIELD BAL;           /*!< Balance Control                             */
    REGFIELD BALLR;         /*!< Left/Right Channel Balance                  */
} REGISTER_RX1;

/*!
 * @brief This variable is used to access the RX1 hardware register.
 *
 * This variable defines how to access all of the fields within the
 * RX0 hardware register. The initial values consist of the offset
 * and mask values needed to access each of the register fields.
 */
static const REGISTER_RX1 regRX1 = {
    {  0, 0x000001 }, /* PGARXEN       */
    {  1, 0x00001e }, /* PGARX         */
    {  5, 0x000020 }, /* PGASTEN       */
    {  6, 0x0003c0 }, /* PGAST         */
    { 10, 0x000400 }, /* ARXINEN       */
    { 11, 0x000800 }, /* ARXIN         */
    { 12, 0x00f000 }, /* PGARXIN       */
    { 16, 0x030000 }, /* MONO          */
    { 18, 0x1c0000 }, /* BAL           */
    { 21, 0x200000 }  /* BALLR         */
};

/*!
 * @brief This structure lists all fields of the AUDIO_TX hardware register.
 *
 */
typedef struct
{
    REGFIELD MC1BEN;             /*!< Microphone Bias 1 Enable                */
    REGFIELD MC2BEN;             /*!< Microphone Bias 2 Enable                */
    REGFIELD MC2BDETDBNC;        /*!< Microphone Bias Detect Debounce Setting */
    REGFIELD MC2BDETEN;          /*!< Microphone Bias 2 Detect Enable         */
    REGFIELD AMC1REN;            /*!< Amplifier Amc1R Enable                  */
    REGFIELD AMC1RITOV;          /*!< Amplifier Amc1R I-to-V Mode Enable      */
    REGFIELD AMC1LEN;            /*!< Amplifier Amc1L Enable                  */
    REGFIELD AMC1LITOV;          /*!< Amplifier Amc1L I-to-V Mode Enable      */
    REGFIELD AMC2EN;             /*!< Amplifier Amc2 Enable                   */
    REGFIELD AMC2ITOV;           /*!< Amplifier Amc2 I-to-V Mode Enable       */
    REGFIELD ATXINEN;            /*!< Amplifier Atxin Enable                  */
#if 0 /* This field is currently reserved but not used. */
    REGFIELD ATXOUTEN;           /*!< Reserved for Output TXOUT Enable        */
#endif
    REGFIELD RXINREC;            /*!< RXINR/RXINL to Voice CODEC ADC Routing  */
    REGFIELD PGATXR;             /*!< Transmit Gain Setting Right Channel     */
    REGFIELD PGATXL;             /*!< Transmit Gain Setting Left Channel      */
} REGISTER_AUDIO_TX;

/*!
 * @brief This variable is used to access the AUDIO_TX hardware register.
 *
 * This variable defines how to access all of the fields within the
 * AUDIO_TX hardware register. The initial values consist of the offset
 * and mask values needed to access each of the register fields.
 */
static const REGISTER_AUDIO_TX regAUDIO_TX = {
    {  0, 0x000001 }, /* MC1BEN             */
    {  1, 0x000002 }, /* MC2BEN             */
    {  2, 0x000004 }, /* MC2BDETDBNC        */
    {  3, 0x000008 }, /* MC2BDETEN          */
                      /* Reserved           */
    {  5, 0x000020 }, /* AMC1REN            */
    {  6, 0x000040 }, /* AMC1RITOV          */
    {  7, 0x000080 }, /* AMC1LEN            */
    {  8, 0x000100 }, /* AMC1LITOV          */
    {  9, 0x000200 }, /* AMC2EN             */
    { 10, 0x000400 }, /* AMC2ITOV           */
    { 11, 0x000800 }, /* ATXINEN            */
    { 13, 0x002000 }, /* RXINREC            */
    { 14, 0x07c000 }, /* PGATXR             */
    { 19, 0xf80000 }  /* PGATXL             */
};

/*!
 * @brief This structure lists all fields of the SSI_NETWORK hardware register.
 *
 */
typedef struct
{
    REGFIELD CDCTXRXSLOT;        /*!< Codec Timeslot Assignment               */
    REGFIELD CDCTXSECSLOT;       /*!< Codec Secondary Transmit Timeslot       */
    REGFIELD CDCRXSECSLOT;       /*!< Codec Secondary Receive Timeslot        */
    REGFIELD CDCRXSECGAIN;       /*!< Codec Secondary Receive Channel Gain    */
    REGFIELD CDCSUMGAIN;         /*!< Codec Summed Receive Gain Setting       */
    REGFIELD CDCFSDLY;           /*!< Codec Framesync Delay                   */
    REGFIELD STDCSLOTS;          /*!< Stereo DAC Number of Timeslots Select   */
    REGFIELD STDCRXSLOT;         /*!< Stereo DAC Number of Timeslots Select   */
    REGFIELD STDCRXSECSLOT;      /*!< Stereo DAC Secondary Receive Timeslot   */
    REGFIELD STDCRXSECGAIN;      /*!< Stereo DAC Secondary Channel Gain       */
    REGFIELD STDCSUMGAIN;        /*!< Stereo DAC Summed Receive Signal Gain   */
} REGISTER_SSI_NETWORK;

/*!
 * @brief This variable is used to access the SSI_NETWORK hardware register.
 *
 * This variable defines how to access all of the fields within the
 * SSI_NETWORK hardware register. The initial values consist of the offset
 * and mask values needed to access each of the register fields.
 */
static const REGISTER_SSI_NETWORK regSSI_NETWORK = {
    {  2, 0x00000c }, /* CDCTXRXSLOT        */
    {  4, 0x000030 }, /* CDCTXSECSLOT       */
    {  6, 0x0000c0 }, /* CDCRXSECSLOT       */
    {  8, 0x000300 }, /* CDCRXSECGAIN       */
    { 10, 0x000400 }, /* CDCSUMGAIN         */
    { 11, 0x000800 }, /* CDCFSDLY           */
    { 12, 0x003000 }, /* STDCSLOTS          */
    { 14, 0x00c000 }, /* STDCRXSLOT         */
    { 16, 0x030000 }, /* STDCRXSECSLOT      */
    { 18, 0x0c0000 }, /* STDCRXSECGAIN      */
    { 20, 0x100000 }  /* STDCSUMGAIN        */
};

/*! Define a mask to access the entire hardware register. */
static const unsigned int REG_FULLMASK = 0xffffff;

/*! Reset value for the AUD_CODEC register. */
static const unsigned int RESET_AUDIO_CODEC = 0x180027;

/*! Reset value for the ST_DAC register. */
static const unsigned int RESET_STEREO_DAC = 0x0e0004;

/*! Reset value for the RX0 register. */
static const unsigned int RESET_RX0 = 0x001000;

/*! Reset value for the RX1 register. */
static const unsigned int RESET_RX1 = 0x00d35a;

/*! Reset value for the AUDIO_TX register. */
static const unsigned int RESET_AUDIO_TX = 0x420000;

/*! Reset value for the SSI_NETWORK register. */
static const unsigned int RESET_SSI_NETWORK = 0x013060;

/*! Constant NULL value for initializing/reseting the audio handles. */
static const PMIC_AUDIO_HANDLE AUDIO_HANDLE_NULL = (PMIC_AUDIO_HANDLE)NULL;

/*!
 * @brief This structure maintains the current state of the Stereo DAC.
 */
typedef struct
{
    PMIC_AUDIO_HANDLE              handle;       /*!< Handle used to access
                                                      the Stereo DAC.         */
    HANDLE_STATE                   handleState;  /*!< Current handle state.   */
    PMIC_AUDIO_DATA_BUS            busID;        /*!< Data bus used to access
                                                      the Stereo DAC.         */
    PMIC_AUDIO_BUS_PROTOCOL        protocol;     /*!< Data bus protocol.      */
    PMIC_AUDIO_BUS_MODE            masterSlave;  /*!< Master/Slave mode
                                                      select.                 */
    PMIC_AUDIO_NUMSLOTS            numSlots;     /*!< Number of timeslots
                                                      used.                   */
    PMIC_AUDIO_CALLBACK            callback;     /*!< Event notification
                                                      callback function
                                                      pointer.                */
    PMIC_AUDIO_EVENTS              eventMask;    /*!< Event notification mask.*/
    PMIC_AUDIO_CLOCK_IN_SOURCE     clockIn;      /*!< Stereo DAC clock input
                                                      source select.          */
    PMIC_AUDIO_STDAC_SAMPLING_RATE samplingRate; /*!< Stereo DAC sampling rate
                                                      select.                 */
    PMIC_AUDIO_STDAC_CLOCK_IN_FREQ clockFreq;    /*!< Stereo DAC clock input
                                                      frequency.              */
    PMIC_AUDIO_CLOCK_INVERT        invert;       /*!< Stereo DAC clock signal
                                                      invert select.          */
    PMIC_AUDIO_STDAC_TIMESLOTS     timeslot;     /*!< Stereo DAC data
                                                      timeslots select.       */
    PMIC_AUDIO_STDAC_CONFIG        config;       /*!< Stereo DAC configuration
                                                      options.                */
} PMIC_AUDIO_STDAC_STATE;

/*!
 * @brief This variable maintains the current state of the Stereo DAC.
 *
 * This variable tracks the current state of the Stereo DAC audio hardware
 * along with any information that is required by the device driver to
 * manage the hardware (e.g., callback functions and event notification
 * masks).
 *
 * The initial values represent the reset/power on state of the Stereo DAC.
 */
static PMIC_AUDIO_STDAC_STATE stDAC = {
    (PMIC_AUDIO_HANDLE)NULL,       /* handle       */
    HANDLE_FREE,                   /* handleState  */
    AUDIO_DATA_BUS_1,              /* busID        */
    NORMAL_MSB_JUSTIFIED_MODE,     /* protocol     */
    BUS_SLAVE_MODE,                /* masterSlave  */
    USE_2_TIMESLOTS,               /* numSlots     */
    (PMIC_AUDIO_CALLBACK)NULL,     /* callback     */
    (PMIC_AUDIO_EVENTS)NULL,       /* eventMask    */
    CLOCK_IN_CLIA,                 /* clockIn      */
    STDAC_RATE_44_1_KHZ,           /* samplingRate */
    STDAC_CLI_13MHZ,               /* clockFreq    */
    NO_INVERT,                     /* invert       */
    USE_TS0_TS1,                   /* timeslot     */
    (PMIC_AUDIO_STDAC_CONFIG)0     /* config       */
};

/*!
 * @brief This structure maintains the current state of the Voice CODEC.
 */
typedef struct
{
    PMIC_AUDIO_HANDLE               handle;       /*!< Handle used to access
                                                       the Voice CODEC.       */
    HANDLE_STATE                    handleState;  /*!< Current handle state.  */
    PMIC_AUDIO_DATA_BUS             busID;        /*!< Data bus used to access
                                                       the Voice CODEC.       */
    PMIC_AUDIO_BUS_PROTOCOL         protocol;     /*!< Data bus protocol.     */
    PMIC_AUDIO_BUS_MODE             masterSlave;  /*!< Master/Slave mode
                                                       select.                */
    PMIC_AUDIO_NUMSLOTS             numSlots;     /*!< Number of timeslots
                                                       used.                  */
    PMIC_AUDIO_CALLBACK             callback;     /*!< Event notification
                                                       callback function
                                                       pointer.               */
    PMIC_AUDIO_EVENTS               eventMask;    /*!< Event notification
                                                       mask.                  */
    PMIC_AUDIO_CLOCK_IN_SOURCE      clockIn;      /*!< Voice CODEC clock input
                                                       source select.         */
    PMIC_AUDIO_VCODEC_SAMPLING_RATE samplingRate; /*!< Voice CODEC sampling
                                                       rate select.           */
    PMIC_AUDIO_VCODEC_CLOCK_IN_FREQ clockFreq;    /*!< Voice CODEC clock input
                                                       frequency.             */
    PMIC_AUDIO_CLOCK_INVERT         invert;       /*!< Voice CODEC clock
                                                       signal invert select.  */
    PMIC_AUDIO_VCODEC_TIMESLOT      timeslot;     /*!< Voice CODEC data
                                                       timeslot select.       */
    PMIC_AUDIO_VCODEC_TIMESLOT      secondaryTXtimeslot; /*!< Voice CODEC
                                                              secondary TX
                                                              timeslot.       */
    PMIC_AUDIO_VCODEC_CONFIG        config;          /*!< Voice CODEC
                                                          configuration
                                                          options.            */
    PMIC_AUDIO_INPUT_CONFIG         inputConfig;     /*!< Voice CODEC
                                                          recording
                                                          configuration.      */
    PMIC_MICROPHONE_STATE           leftChannelMic;  /*!< Left channel
                                                          microphone
                                                          configuration.      */
    PMIC_MICROPHONE_STATE           rightChannelMic; /*!< Right channel
                                                          microphone
                                                          configuration.      */
} PMIC_AUDIO_VCODEC_STATE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -