立即注册 登录
逆天PCB论坛 返回首页

freebird126的个人空间 https://bbs.ntpcb.com/?140237 [收藏] [复制] [RSS]

日志

WM8960 IIC调试日志

已有 482 次阅读2021-11-13 15:12

#include "stdint.h"
#include "stdio.h"
#include "swi2c4.h"
#include "wm8960.h"
#include "system.h"
#include "stm32f10x.h"
// PCM从模式,8K采样,16bit位宽,256k位时钟,MCLK=12.288MHz
// 单端MIC 左声道输入linput1,rinput2=线路音输入
void init_wm8960(void)
{
// uint8_t i;
//    for(i=0;i<10;i++)
//      SWI2C4_write(0x34,wm8960REG[i][0],wm8960REG[i][1]);
    swi2c4_write(0x34,0X0F<<1|0x01,0xFF);//Reset
    swi2c4_write(0x34,0X00<<1|0x01,0x43+20);//Left Input Volume/Left Input PGA Analogue Mute
    swi2c4_write(0x34,0X01<<1|0x01,0x43+20);//Right Input Volume
//    swi2c4_write(0x34,0X02<<1|0x01,0x7F-30);//LOUT1 Volume+6db Headphone Output
//    swi2c4_write(0x34,0X03<<1|0x01,0x7F-30);//ROUT1 Volume Headphone Output
  swi2c4_write(0x34,0X04<<1|0x01,0xD0);//NOTE:slave mode LRCLK
        swi2c4_write(0x34,0X05<<1,0x00);//DAC Digital Soft Mute-No mute
      swi2c4_write(0x34,0X07<<1|0X00,0x03);//Enable slave mode
//       swi2c4_write(0x34,0X08<<1,0xCC);//Clocking(2)
      swi2c4_write(0x34,0X09<<1,0x40);//Loopback enabled
    
//   swi2c4_write(0x34,0X14<<1|0x00,0xF1);//Noise Gate
//    swi2c4_write(0x34,0X15<<1|0x01,0xC3-20);//Left ADC Digital Volume Control
//    swi2c4_write(0x34,0X16<<1|0x01,0xC3-20);//Right ADC Digital Volume Control
    swi2c4_write(0x34,0X17<<1|0x01,0xD0);//DAC Mono Mix
//    swi2c4_write(0x34,0X18<<1,0x04);//Selects disable mode for ADCLRC and DACLRC(Master mode)
    
    swi2c4_write(0x34,0X19<<1|0x01,0xFE);//Power Mgmt (1) NOTE:0 = Master clock enabled   1 = Master clock disabled
    swi2c4_write(0x34,0X1A<<1|0X01,0x82);//Power Mgmt (2)
    
    swi2c4_write(0x34,0X20<<1|0X01,0X18);//Connect Left Input PGA to Left Input Boost Mixer
    //swi2c4_write(0x34,0X21<<1|0X01,0x28);//Connect Right Input PGA to Right Input Boost Mixer

    swi2c4_write(0x34,0X22<<1|0X01,0x00);//Left DAC to Left Output Mixer
    swi2c4_write(0x34,0X25<<1|0X01,0x00);//Right DAC to Right Output Mixer

  swi2c4_write(0x34,0X26<<1|0X00,0x80);//Left Output Mixer to Mono Output Mixer Control
//    swi2c4_write(0x34,0X27<<1|0X00,0x80);//Right Output Mixer to Mono Output Mixer Control

  swi2c4_write(0x34,0X2A<<1|0X00,0x00);//OUT3 Volume =0dB  default=-6db

  swi2c4_write(0x34,0X2B<<1|0X00,0x02);//LINPUT2/3 to Boost Mixer Gain
    swi2c4_write(0x34,0X2C<<1|0X00,0x02);//RINPUT2/3 to Boost Mixer Gain
    
    swi2c4_write(0x34,0X2D<<1,0xf0);//Left Input Boost Mixer to Left Output Mixer
//    swi2c4_write(0x34,0X2E<<1,0x80);//Right Input Boost Mixer to Right Output Mixer
    
    swi2c4_write(0x34,0X2F<<1,0x2C);//Power Mgmt (3)
    swi2c4_write(0x34,0X30<<1,0x42);
    /*
        swi2c4_write(0x34,0X0F<<1|0x01,0xFF);//Reset
    swi2c4_write(0x34,0X00<<1|0x01,0x03+40);//Left Input Volume/Left Input PGA Analogue Mute
    swi2c4_write(0x34,0X01<<1|0x01,0x03+40);//Right Input Volume
    swi2c4_write(0x34,0X02<<1|0x01,0x7F-30);//LOUT1 Volume+6db
    swi2c4_write(0x34,0X03<<1|0x01,0x7F-30);//ROUT1 Volume
    swi2c4_write(0x34,0X05<<1,0x00);//DAC Digital Soft Mute-No mute
    swi2c4_write(0x34,0X07<<1,0x4A);//Enable master mode
    swi2c4_write(0x34,0X08<<1,0xC4);//Clocking(2)
    swi2c4_write(0x34,0X09<<1,0x40);//Loopback enabled
    
    swi2c4_write(0x34,0X15<<1|0x01,0xFF);//Left ADC Digital Volume Control
    swi2c4_write(0x34,0X16<<1|0x01,0xFF);//Right ADC Digital Volume Control
    
    swi2c4_write(0x34,0X19<<1,0xFE);//Power Mgmt (1)
    swi2c4_write(0x34,0X1A<<1|0X01,0xE0);//Power Mgmt (2)
    
    swi2c4_write(0x34,0X20<<1|0X01,0X08);//Connect Left Input PGA to Left Input Boost Mixer
    swi2c4_write(0x34,0X21<<1|0X01,0x08);//Connect Right Input PGA to Left Input Boost Mixer

    swi2c4_write(0x34,0X22<<1|0X01,0x00);//Left DAC to Left Output Mixer
    swi2c4_write(0x34,0X25<<1|0X01,0x00);//Right DAC to Right Output Mixer
    
//    swi2c4_write(0x34,0X2B<<1,0x00);//LINPUT2/3 to Boost Mixer Gain
//    swi2c4_write(0x34,0X2C<<1,0x00);//RINPUT2/3 to Boost Mixer Gain
    
//    swi2c4_write(0x34,0X2D<<1,0x80);//Left Input Boost Mixer to Left Output Mixer
//    swi2c4_write(0x34,0X2E<<1,0x80);//Right Input Boost Mixer to Right Output Mixer
    swi2c4_write(0x34,0X2F<<1,0x3C);//Power Mgmt (3)
*/
    
  printf("wm8960 Write over!\r\n");
    Delay_ms(200);
}

路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

Copyright ©2011-2024 NTpcb.com All Right Reserved.  Powered by Discuz! (NTpcb)

本站信息均由会员发表,不代表NTpcb立场,如侵犯了您的权利请发帖投诉

( 闽ICP备2024076463号-1 ) 论坛技术支持QQ群171867948 ,论坛问题,充值问题请联系QQ1308068381

平平安安
TOP
返回顶部