cs8403a.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:3k
源码类别:

DVD

开发平台:

C/C++

  1. #include "config.h"
  2. #include "regmap.h"
  3. #include "global.h"
  4. #include "sio.h"
  5. #include "epp.h"
  6. #include "func.h"
  7. #include "memmap.h"
  8. #ifdef CS8403_ENABLE
  9. #define CS8403A_BASE_64     (32) //32 * 64K(2^16)
  10. #define CS8403A_BASE_S      (ROM_BASE_UNCACHED | ((CS8403A_BASE_64*2)<<16))
  11. //#define CS8403A_BASE_64     (0x100) //32 * 64K(2^16)
  12. //#define CS8403A_BASE_S      (ROM_BASE_UNCACHED | (0x1000000) )
  13. void write_cs8403a(BYTE StartAdd,BYTE CmdData);
  14. static inline void SET_RW_0(void)
  15. {
  16.     
  17.     
  18.     #ifdef SPHE8202
  19.    // GPIO_O_SET(17,0);
  20.     
  21.     GPIO_O_SET(16,0);
  22.     #else
  23.     regs0->gpio_out[55 / 16] &= ~(0x1 << (55 % 16));
  24.     #endif
  25.     
  26.     
  27. }
  28. static inline void SET_RW_1(void)
  29. {
  30.     #ifndef SPHE8202
  31.     regs0->gpio_out[55 / 16] |= (0x1 << (55 % 16));
  32.     #endif
  33.     //GPIO_O_SET(17,1);
  34.     //delay_1ms(10);
  35.     GPIO_O_SET(16,1);
  36.     
  37.     
  38. }
  39. static inline void init_cs8403a(void)
  40. {
  41.     //UINT32 u;
  42.     BYTE  i;
  43.   
  44.     write_cs8403a(1,0x00);
  45.     //write_cs8403a(2,0x80);//CHIP DIABLE and MUTE
  46.     write_cs8403a(2,0x83);//CHIP ENABLE and MUTE
  47.     write_cs8403a(3,0x0D);//I2S LEft alignment
  48.   
  49.     write_cs8403a(4,0x00);//USER data
  50.     write_cs8403a(5,0x00);//USER data
  51.     write_cs8403a(6,0x00);//USER data
  52.     write_cs8403a(7,0x00);//USER data
  53.   
  54.     write_cs8403a(8,0x00);//CHANELL STATUS
  55.     write_cs8403a(9,0x98);//CHANELL STATUS
  56.     write_cs8403a(10,0x00);//CHANELL STATUS
  57.     write_cs8403a(11,0x40);//CHANELL STATUS 48kHZ
  58.     //write_cs8403a(11,0x00);//CHANELL STATUS 44kHZ
  59.     for(i=12;i<32;i++)
  60.     {
  61.     
  62.         write_cs8403a(i,0x00);//CHANELL STATUS
  63.         
  64.     }
  65.     
  66.     regs0->sft_cfg1=regs0->sft_cfg1&(~(1<<0x02));//pin77,GPIO 17
  67.     GPIO_M_SET(17,1);
  68.     GPIO_E_SET(17,1);
  69. GPIO_O_SET(17,1);
  70.     
  71. }
  72. void init_cs8403a__(void)
  73. {
  74.     BYTE i;
  75.     regs0->rom1_base = CS8403A_BASE_64;
  76.     regs0->rom2_base = CS8403A_BASE_64*2;
  77.     regs0->rom3_base = CS8403A_BASE_64*3;
  78. #ifdef SPHE8202
  79.     regs0->sft_cfg1=regs0->sft_cfg1&(~(1<<0x03));//pin76,GPIO 16
  80. GPIO_M_SET(16,1);
  81.     GPIO_E_SET(16,1);
  82. //regs0->sft_cfg1=regs0->sft_cfg1&(~(1<<0x02));//pin77,GPIO 17
  83. regs0->sft_cfg1=regs0->sft_cfg1|((1<<0x02));//pin77,GPIO 17
  84. //GPIO_M_SET(17,1);
  85.     //GPIO_E_SET(17,1);
  86. //GPIO_O_SET(17,1);
  87. #else
  88. regs0->sft_cfg1 |= (0x7<<1);
  89. #endif
  90.     for(i=0;i<2;i++)
  91.     {
  92.     
  93.         init_cs8403a();
  94.         
  95.         
  96.         
  97.     }
  98. }
  99. void write_cs8403a(BYTE StartAdd,BYTE CmdData)
  100. {
  101.     BYTE  *sndPtr; //write pointer   
  102.     sndPtr = (BYTE *)(CS8403A_BASE_S+StartAdd);
  103.     SET_RW_0();
  104.        
  105.     *sndPtr= CmdData;
  106.     SET_RW_1();
  107. }
  108. #endif