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

📄 i2s_codec.txt

📁 STM32F103ZET6+UCOSII+UCGUI源码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
;;;355    {   
000002  4604              MOV      r4,r0
;;;356      /* Pause Playing the audio file */
;;;357      I2S_CODEC_Pause();
000004  f7fffffe          BL       I2S_CODEC_Pause
;;;358    
;;;359      /* Increment the Audio pointer */
;;;360      IncrementVar_AudioDataIndex((AudioDataLength / 100) * Step);
000008  4b08              LDR      r3,|L19.44|
00000a  2164              MOVS     r1,#0x64
00000c  68d8              LDR      r0,[r3,#0xc]  ; AudioDataLength
00000e  fbb0f0f1          UDIV     r0,r0,r1
000012  4360              MULS     r0,r4,r0
000014  f7fffffe          BL       IncrementVar_AudioDataIndex
;;;361    
;;;362      /* Insure the index parity */
;;;363      AudioDataIndex &= 0xFFFFFFFE;
000018  6958              LDR      r0,[r3,#0x14]  ; AudioDataIndex
00001a  f0200001          BIC      r0,r0,#1
00001e  6158              STR      r0,[r3,#0x14]  ; AudioDataIndex
000020  6958              LDR      r0,[r3,#0x14]  ; AudioDataIndex
;;;364    
;;;365      /* Resume playing from the new position */
;;;366      I2S_CODEC_Play((GetVar_AudioDataIndex()));
000022  e8bd4010          POP      {r4,lr}
000026  f7ffbffe          B.W      I2S_CODEC_Play
;;;367    }
;;;368    
                          ENDP

00002a  0000              DCW      0x0000
                  |L19.44|
                          DCD      ||.data||

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

                  I2S_CODEC_Init PROC
;;;115    *******************************************************************************/
;;;116    u32 I2S_CODEC_Init(u32 OutputDevice, u32 Address)
000000  e92d4ffe          PUSH     {r1-r11,lr}
;;;117    {
;;;118    	u32 count = 0;
;;;119    
;;;120      /* Set the audio file address */
;;;121      AudioFileAddress = (vu32) Address;
000004  4c2d              LDR      r4,|L20.188|
000006  4605              MOV      r5,r0                 ;117
000008  60a1              STR      r1,[r4,#8]  ; AudioFileAddress
00000a  2024              MOVS     r0,#0x24
00000c  f88d0008          STRB     r0,[sp,#8]
000010  2600              MOVS     r6,#0
000012  f88d6009          STRB     r6,[sp,#9]
000016  f88d600a          STRB     r6,[sp,#0xa]
00001a  2001              MOVS     r0,#1
00001c  f88d000b          STRB     r0,[sp,#0xb]
000020  a802              ADD      r0,sp,#8
000022  f7fffffe          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  f7fffffe          BL       I2S_GPIO_Config
;;;128    
;;;129    	/* Read the Audio file to extract the audio data length and frequency */
;;;130      errorcode = AudioFile_Init();
00002a  f7fffffe          BL       AudioFile_Init
;;;131    
;;;132      if (errorcode < 3)
;;;133      {
;;;134        /* Turn on LD2 connected to PF.07 */
;;;135        GPIO_SetBits(GPIOF, GPIO_Pin_7);
00002e  f8dfa090          LDR      r10,|L20.192|
000032  62e0              STR      r0,[r4,#0x2c]         ;132  ; errorcode
000034  2803              CMP      r0,#3                 ;132
000036  d206              BCS      |L20.70|
000038  2180              MOVS     r1,#0x80
00003a  4650              MOV      r0,r10
00003c  f7fffffe          BL       GPIO_SetBits
;;;136      
;;;137        return errorcode;
000040  6ae0              LDR      r0,[r4,#0x2c]  ; errorcode
                  |L20.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  e8bd8ffe          POP      {r1-r11,pc}
                  |L20.70|
000046  2101              MOVS     r1,#1
000048  46a0              MOV      r8,r4                 ;141
00004a  88a7              LDRH     r7,[r4,#4]            ;141  ; i2saudiofreq
00004c  0388              LSLS     r0,r1,#14             ;141
00004e  f7fffffe          BL       RCC_APB1PeriphClockCmd
000052  f8df9070          LDR      r9,|L20.196|
000056  4648              MOV      r0,r9                 ;141
000058  f7fffffe          BL       SPI_I2S_DeInit
00005c  f44f7400          MOV      r4,#0x200             ;141
000060  f8ad4000          STRH     r4,[sp,#0]            ;141
000064  f8ad6004          STRH     r6,[sp,#4]            ;141
000068  f8ad7008          STRH     r7,[sp,#8]            ;141
00006c  f8ad6002          STRH     r6,[sp,#2]            ;141
000070  f8ad4006          STRH     r4,[sp,#6]            ;141
000074  f8ad600a          STRH     r6,[sp,#0xa]          ;141
000078  4669              MOV      r1,sp                 ;141
00007a  4648              MOV      r0,r9                 ;141
00007c  f7fffffe          BL       I2S_Init
000080  2200              MOVS     r2,#0                 ;141
000082  2171              MOVS     r1,#0x71              ;141
000084  4648              MOV      r0,r9                 ;141
000086  f7fffffe          BL       SPI_I2S_ITConfig
00008a  2101              MOVS     r1,#1                 ;141
00008c  4648              MOV      r0,r9                 ;141
00008e  f7fffffe          BL       I2S_Cmd
000092  2318              MOVS     r3,#0x18              ;147
000094  4622              MOV      r2,r4                 ;147
000096  2100              MOVS     r1,#0                 ;147
000098  b2a8              UXTH     r0,r5                 ;147
00009a  f8c85028          STR      r5,[r8,#0x28]         ;147  ; CurrentOutputDevice
00009e  f7fffffe          BL       CODEC_Config
0000a2  b128              CBZ      r0,|L20.176|
0000a4  2140              MOVS     r1,#0x40              ;152
0000a6  4650              MOV      r0,r10                ;152
0000a8  f7fffffe          BL       GPIO_SetBits
0000ac  2003              MOVS     r0,#3                 ;154
0000ae  e7c8              B        |L20.66|
                  |L20.176|
0000b0  4621              MOV      r1,r4                 ;158
0000b2  4650              MOV      r0,r10                ;158
0000b4  f7fffffe          BL       GPIO_SetBits
0000b8  2000              MOVS     r0,#0                 ;160
0000ba  e7c2              B        |L20.66|
;;;162    
                          ENDP

                  |L20.188|
                          DCD      ||.data||
                  |L20.192|
                          DCD      0x40011c00
                  |L20.196|
                          DCD      0x40003800

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

                  I2S_CODEC_Mute PROC
;;;325    *******************************************************************************/
;;;326    void I2S_CODEC_Mute(u32 Command)
000000  b510              PUSH     {r4,lr}
;;;327    { 
000002  4604              MOV      r4,r0
;;;328    	u32 tmp = 0;
;;;329    
;;;330    	/* Read the current value of the config register number 0x0E */
;;;331      tmp = CODEC_ReadRegister(0x0E);
000004  200e              MOVS     r0,#0xe
000006  f7fffffe          BL       CODEC_ReadRegister
;;;332    
;;;333      /* Set the Mute mode */
;;;334    	if (Command == MUTE_ON)
00000a  2c01              CMP      r4,#1
00000c  d102              BNE      |L21.20|
;;;335      {
;;;336        tmp |= 0x20; 
00000e  f0400120          ORR      r1,r0,#0x20
000012  e001              B        |L21.24|
                  |L21.20|
;;;337      }
;;;338      else /* MUTE_OFF Disable the Mute */
;;;339      {
;;;340        tmp &= 0xD1; 
000014  f00001d1          AND      r1,r0,#0xd1
                  |L21.24|
;;;341      }
;;;342      
;;;343      /* Write back the CODEC config register w/the new value */
;;;344      CODEC_WriteRegister(0x0E, tmp);
000018  e8bd4010          POP      {r4,lr}
00001c  200e              MOVS     r0,#0xe
00001e  f7ffbffe          B.W      CODEC_WriteRegister
;;;345    }
;;;346    
                          ENDP


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

                  I2S_CODEC_Pause PROC
;;;206    *******************************************************************************/
;;;207    u32 I2S_CODEC_Pause()
000000  b510              PUSH     {r4,lr}
;;;208    {
;;;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  480a              LDR      r0,|L22.48|
000008  f7fffffe          BL       SPI_I2S_ITConfig
00000c  4909              LDR      r1,|L22.52|
00000e  2002              MOVS     r0,#2
000010  6248              STR      r0,[r1,#0x24]  ; AudioPlayStatus
000012  6a48              LDR      r0,[r1,#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;
000014  2000              MOVS     r0,#0
000016  6308              STR      r0,[r1,#0x30]  ; monovar
;;;217      tmpvar = 0;
000018  6348              STR      r0,[r1,#0x34]  ; tmpvar
;;;218    
;;;219      if (WAVE_Format.NumChannels == Channel_MONO) 
00001a  4807              LDR      r0,|L22.56|
00001c  88c0              LDRH     r0,[r0,#6]  ; WAVE_Format
00001e  2801              CMP      r0,#1
000020  d103              BNE      |L22.42|
;;;220      {
;;;221        /* Force the parity of the address */ 
;;;222        AudioDataIndex &= 0xFFFFFFFE; 
000022  6948              LDR      r0,[r1,#0x14]  ; AudioDataIndex
000024  f0200001          BIC      r0,r0,#1
000028  6148              STR      r0,[r1,#0x14]  ; AudioDataIndex
                  |L22.42|
;;;223      }
;;;224      /* Return the current data pointer position */
;;;225      return AudioDataIndex;
00002a  6948              LDR      r0,[r1,#0x14]  ; AudioDataIndex
;;;226    }
00002c  bd10              POP      {r4,pc}
;;;227    
                          ENDP

00002e  0000              DCW      0x0000
                  |L22.48|
                          DCD      0x40003800
                  |L22.52|
                          DCD      ||.data||
                  |L22.56|
                          DCD      ||.bss||+0x64

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

                  I2S_CODEC_Play PROC
;;;185    *******************************************************************************/
;;;186    u32 I2S_CODEC_Play(u32 AudioStartPosition)
000000  b510              PUSH     {r4,lr}
;;;187    {   
;;;188    	/* Send the read command to the media */
;;;189      Media_StartReadSequence(AudioFileAddress + AudioStartPosition + 1); 
000002  4c06              LDR      r4,|L23.28|
000004  68a0              LDR      r0,[r4,#8]  ; AudioFileAddress
000006  2001              MOVS     r0,#1
000008  6260              STR      r0,[r4,#0x24]  ; AudioPlayStatus
00000a  6a60              LDR      r0,[r4,#0x24]  ; AudioPlayStatus
;;;190    
;;;191      /* Set Playing status to inform other modules about the codec status */
;;;192      SetVar_AudioPlayStatus(AudioPlayStatus_PLAYING);
;;;193    
;;;194      /* Enable the I2S2 TXE Interrupt  => Generate the clocks*/ 
;;;195      SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, ENABLE);
00000c  2201              MOVS     r2,#1
00000e  2171              MOVS     r1,#0x71
000010  4803              LDR      r0,|L23.32|
000012  f7fffffe          BL       SPI_I2S_ITConfig
;;;196    
;;;197      return AudioDataIndex;
000016  6960              LDR      r0,[r4,#0x14]  ; AudioDataIndex
;;;198    }
000018  bd10              POP      {r4,pc}
;;;199    
                          ENDP

00001a  0000              DCW      0x0000
                  |L23.28|
                          DCD      ||.data||
                  |L23.32|
                          DCD      0x40003800

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

                  I2S_CODEC_PowerDown PROC
;;;398    *************************************************

⌨️ 快捷键说明

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