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

📄 i2s_codec.txt

📁 STM32外部SRAM用作datamemery的程序 开发环境MDK
💻 TXT
📖 第 1 页 / 共 5 页
字号:
                          AREA ||i.I2S_CODEC_Init||, CODE, READONLY, ALIGN=2

                  I2S_CODEC_Init PROC
;;;116    u32 I2S_CODEC_Init(u32 OutputDevice, u32 Address)
;;;117    {
000000  e92de92d          PUSH     {r1-r11,lr}
;;;118    	u32 count = 0;
;;;119    
;;;120      /* Set the audio file address */
;;;121      AudioFileAddress = (vu32) Address;
000004  4c2d              LDR      r4,|L12.188|
000006  4607              MOV      r7,r0                 ;117
000008  60a1              STR      r1,[r4,#8]  ; AudioFileAddress
00000a  2024              MOVS     r0,#0x24
00000c  f88df88d          STRB     r0,[sp,#8]
000010  2500              MOVS     r5,#0
000012  f88df88d          STRB     r5,[sp,#9]
000016  f88df88d          STRB     r5,[sp,#0xa]
00001a  2001              MOVS     r0,#1
00001c  f88df88d          STRB     r0,[sp,#0xb]
000020  a802              ADD      r0,sp,#8
000022  f7fff7ff          BL       NVIC_Init
;;;122    
;;;123      /* Configure I2S interrupt Channel */
;;;124      NVIC_Config();
;;;125    
;;;126      /* Configure the I2S2, I2C1 and GPIOF pins */
;;;127      I2S_GPIO_Config(); 
000026  f7fff7ff          BL       I2S_GPIO_Config
;;;128    
;;;129    	/* Read the Audio file to extract the audio data length and frequency */
;;;130      errorcode = AudioFile_Init();
00002a  f7fff7ff          BL       AudioFile_Init
00002e  f8dff8df          LDR      r9,|L12.192|
;;;131    
;;;132      if (errorcode < 3)
000032  62e0              STR      r0,[r4,#0x2c]  ; errorcode
000034  2803              CMP      r0,#3
000036  d206              BCS      |L12.70|
;;;133      {
;;;134        /* Turn on LD2 connected to PF.07 */
;;;135        GPIO_SetBits(GPIOF, GPIO_Pin_7);
000038  2180              MOVS     r1,#0x80
00003a  4648              MOV      r0,r9
00003c  f7fff7ff          BL       GPIO_SetBits
;;;136      
;;;137        return errorcode;
000040  6ae0              LDR      r0,[r4,#0x2c]  ; errorcode
                  |L12.66|
;;;138      }
;;;139    
;;;140      /* Configure the SPI2 peripheral in I2S mode */
;;;141      I2S_Config(I2S_STANDARD, I2S_MCLKOUTPUT, i2saudiofreq); 
;;;142    
;;;143      /* Set the current output device */
;;;144      CurrentOutputDevice = OutputDevice;
;;;145    
;;;146      /* Codec Configuration via I2C interface */
;;;147      count = CODEC_Config(OutputDevice, I2S_STANDARD, I2S_MCLKOUTPUT, DEFAULT_VOL);
;;;148    
;;;149      if (count != 0)
;;;150      {
;;;151        /* Turn on LD1 connected to PF.06 */
;;;152        GPIO_SetBits(GPIOF, GPIO_Pin_6);
;;;153    
;;;154        return 3;
;;;155      }
;;;156    
;;;157      /* Turn on LD4 connected to PF.09 */
;;;158      GPIO_SetBits(GPIOF, GPIO_Pin_9);
;;;159    
;;;160      return 0; /* Configuration is OK */
;;;161    }
000042  e8bde8bd          POP      {r1-r11,pc}
                  |L12.70|
000046  2101              MOVS     r1,#1
000048  f8b4f8b4          LDRH     r8,[r4,#4]            ;141  ; i2saudiofreq
00004c  0388              LSLS     r0,r1,#14             ;141
00004e  f7fff7ff          BL       RCC_APB1PeriphClockCmd
000052  f8dff8df          LDR      r10,|L12.196|
000056  4650              MOV      r0,r10                ;141
000058  f7fff7ff          BL       SPI_I2S_DeInit
00005c  f44ff44f          MOV      r6,#0x200             ;141
000060  f8adf8ad          STRH     r6,[sp,#0]            ;141
000064  f8adf8ad          STRH     r5,[sp,#4]            ;141
000068  f8adf8ad          STRH     r8,[sp,#8]            ;141
00006c  f8adf8ad          STRH     r5,[sp,#2]            ;141
000070  f8adf8ad          STRH     r6,[sp,#6]            ;141
000074  f8adf8ad          STRH     r5,[sp,#0xa]          ;141
000078  4669              MOV      r1,sp                 ;141
00007a  4650              MOV      r0,r10                ;141
00007c  f7fff7ff          BL       I2S_Init
000080  2200              MOVS     r2,#0                 ;141
000082  2171              MOVS     r1,#0x71              ;141
000084  4650              MOV      r0,r10                ;141
000086  f7fff7ff          BL       SPI_I2S_ITConfig
00008a  2101              MOVS     r1,#1                 ;141
00008c  4650              MOV      r0,r10                ;141
00008e  f7fff7ff          BL       I2S_Cmd
000092  2318              MOVS     r3,#0x18              ;147
000094  4632              MOV      r2,r6                 ;147
000096  2100              MOVS     r1,#0                 ;147
000098  b2b8              UXTH     r0,r7                 ;147
00009a  62a7              STR      r7,[r4,#0x28]         ;147  ; CurrentOutputDevice
00009c  f7fff7ff          BL       CODEC_Config
0000a0  b128              CBZ      r0,|L12.174|
0000a2  2140              MOVS     r1,#0x40              ;152
0000a4  4648              MOV      r0,r9                 ;152
0000a6  f7fff7ff          BL       GPIO_SetBits
0000aa  2003              MOVS     r0,#3                 ;154
0000ac  e7c9              B        |L12.66|
                  |L12.174|
0000ae  4631              MOV      r1,r6                 ;158
0000b0  4648              MOV      r0,r9                 ;158
0000b2  f7fff7ff          BL       GPIO_SetBits
0000b6  2000              MOVS     r0,#0                 ;160
0000b8  e7c3              B        |L12.66|
;;;162    
                          ENDP

0000ba  0000              DCW      0x0000
                  |L12.188|
0000bc  00000000          DCD      ||.data||
                  |L12.192|
0000c0  40011c00          DCD      0x40011c00
                  |L12.196|
0000c4  40003800          DCD      0x40003800

                          AREA ||i.I2S_CODEC_ReplayConfig||, CODE, READONLY, ALIGN=2

                  I2S_CODEC_ReplayConfig PROC
;;;172      /* Audio Replay number set by user */
;;;173      AudioReplay = Repetions;
000000  4901              LDR      r1,|L13.8|
000002  6188              STR      r0,[r1,#0x18]  ; AudioReplay
;;;174      
;;;175      /* Audio Replays number remaining (if AudioReplay != 0) */
;;;176      AudioReplayCount = Repetions;
;;;177    }
000004  61c8              STR      r0,[r1,#0x1c]  ; AudioReplayCount
000006  4770              BX       lr
;;;178    
                          ENDP

                  |L13.8|
000008  00000000          DCD      ||.data||

                          AREA ||i.SetVar_AudioPlayStatus||, CODE, READONLY, ALIGN=2

                  SetVar_AudioPlayStatus PROC
000000  4901              LDR      r1,|L14.8|
000002  6248              STR      r0,[r1,#0x24]  ; AudioPlayStatus
000004  6a48              LDR      r0,[r1,#0x24]  ; AudioPlayStatus
000006  4770              BX       lr
                          ENDP

                  |L14.8|
000008  00000000          DCD      ||.data||

                          AREA ||i.Media_StartReadSequence||, CODE, READONLY, ALIGN=1

                  Media_StartReadSequence PROC
000000  4770              BX       lr
                          ENDP


                          AREA ||i.I2S_CODEC_Play||, CODE, READONLY, ALIGN=2

                  I2S_CODEC_Play PROC
000000  b510              PUSH     {r4,lr}
000002  4c05              LDR      r4,|L16.24|
000004  68a0              LDR      r0,[r4,#8]  ; AudioFileAddress
000006  2001              MOVS     r0,#1
000008  6260              STR      r0,[r4,#0x24]  ; AudioPlayStatus
00000a  4602              MOV      r2,r0
00000c  2171              MOVS     r1,#0x71
00000e  4803              LDR      r0,|L16.28|
000010  f7fff7ff          BL       SPI_I2S_ITConfig
000014  6960              LDR      r0,[r4,#0x14]  ; AudioDataIndex
000016  bd10              POP      {r4,pc}
                          ENDP

                  |L16.24|
000018  00000000          DCD      ||.data||
                  |L16.28|
00001c  40003800          DCD      0x40003800

                          AREA ||i.I2S_CODEC_Pause||, CODE, READONLY, ALIGN=2

                  I2S_CODEC_Pause PROC
;;;207    u32 I2S_CODEC_Pause()
;;;208    {
000000  b510              PUSH     {r4,lr}
;;;209      /* Disable the I2S2 TXE Interrupt  => stop the clocks*/ 
;;;210      SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, DISABLE);
000002  2200              MOVS     r2,#0
000004  2171              MOVS     r1,#0x71
000006  4809              LDR      r0,|L17.44|
000008  f7fff7ff          BL       SPI_I2S_ITConfig
00000c  4808              LDR      r0,|L17.48|
00000e  2102              MOVS     r1,#2
000010  6241              STR      r1,[r0,#0x24]  ; AudioPlayStatus
;;;211    
;;;212      /* Set Paused status to inform other modules about the codec status */
;;;213      SetVar_AudioPlayStatus(AudioPlayStatus_PAUSED);
;;;214      
;;;215      /* Reset local variables */
;;;216      monovar = 0;
000012  2100              MOVS     r1,#0
000014  6301              STR      r1,[r0,#0x30]  ; monovar
;;;217      tmpvar = 0;
000016  6341              STR      r1,[r0,#0x34]  ; tmpvar
;;;218    
;;;219      if (WAVE_Format.NumChannels == Channel_MONO) 
000018  4906              LDR      r1,|L17.52|
00001a  88c9              LDRH     r1,[r1,#6]  ; WAVE_Format
00001c  2901              CMP      r1,#1
00001e  d103              BNE      |L17.40|
;;;220      {
;;;221        /* Force the parity of the address */ 
;;;222        AudioDataIndex &= 0xFFFFFFFE; 
000020  6941              LDR      r1,[r0,#0x14]  ; AudioDataIndex
000022  f021f021          BIC      r1,r1,#1
000026  6141              STR      r1,[r0,#0x14]  ; AudioDataIndex
                  |L17.40|
;;;223      }
;;;224      /* Return the current data pointer position */
;;;225      return AudioDataIndex;
000028  6940              LDR      r0,[r0,#0x14]  ; AudioDataIndex
;;;226    }
00002a  bd10              POP      {r4,pc}
;;;227    
                          ENDP

                  |L17.44|
00002c  40003800          DCD      0x40003800
                  |L17.48|
000030  00000000          DCD      ||.data||
                  |L17.52|
000034  00000064          DCD      ||.bss||+0x64

                          AREA ||i.I2S_CODEC_PowerDown||, CODE, READONLY, ALIGN=2

                  I2S_CODEC_PowerDown PROC
000000  b510              PUSH     {r4,lr}
000002  2802              CMP      r0,#2
000004  d109              BNE      |L18.26|
000006  2140              MOVS     r1,#0x40
000008  2000              MOVS     r0,#0
00000a  f7fff7ff          BL       CODEC_WriteRegister
00000e  2100              MOVS     r1,#0
000010  e8bde8bd          POP      {r4,lr}
000014  4608              MOV      r0,r1
000016  f7fff7ff          B.W      CODEC_WriteRegister
                  |L18.26|
00001a  e8bde8bd          POP      {r4,lr}
00001e  f44ff44f          MOV      r1,#0x800
000022  4801              LDR      r0,|L18.40|
000024  f7fff7ff          B.W      GPIO_ResetBits
                          ENDP

                  |L18.40|
000028  40012000          DCD      0x40012000

                          AREA ||i.I2S_CODEC_Stop||, CODE, READONLY, ALIGN=2

                  I2S_CODEC_Stop PROC
;;;236    u32 I2S_CODEC_Stop()
;;;237    {
000000  b570              PUSH     {r4-r6,lr}
;;;238    	/* Disable the I2S2 TXE Interrupt  => stop the clocks */ 
;;;239      SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, DISABLE);
000002  2200              MOVS     r2,#0
000004  2171              MOVS     r1,#0x71
000006  4807              LDR      r0,|L19.36|
000008  f7fff7ff          BL       SPI_I2S_ITConfig
;;;240    
;;;241    	/* Reinitialize the audio data pointer */
;;;242      AudioDataIndex = 0;
00000c  4d06              LDR      r5,|L19.40|
00000e  2400              MOVS     r4,#0
000010  616c              STR      r4,[r5,#0x14]  ; AudioDataIndex
;;;243    
;;;244      /* Power off the Codec to save power and protect the Codec itself */
;;;245      I2S_CODEC_PowerDown(CodecPowerDown_SW);
000012  2002              MOVS     r0,#2
000014  f7fff7ff          BL       I2S_CODEC_PowerDown
000018  626c              STR      r4,[r5,#0x24]  ; AudioPlayStatus
;;;246    
;;;247      /* Set Paused status to inform other modules about the codec status */
;;;248      SetVar_AudioPlayStatus(Au

⌨️ 快捷键说明

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