目录
  • 一、准备工作
  • 二、编译代码
  • 三、测试

6.I2S主从数据传输测试.

该教程演示如何通过两块开发板实现I2S主从数据传输测试

一、准备工作

  • 准备2块BearPi-Pico H2821开发板

二、编译代码

在Windows下编译操作
  1. 点击左侧的“KConfig”,打开配置界面.

    Alt text

  2. 选择Support I2S Sample.

    [*] Enable Sample.
    [*]     Enable the Sample of peripheral.
    [ ]         Enable all the sample of peripheral, it's just for build.
    [ ]         Support ADC Sample.
    [ ]         Support BLINKY Sample.
    [ ]         Support BUTTON Sample.
    [ ]         Support DMA Sample.
    [ ]         Support I2C Sample.
    [*]         Support I2S Sample.
                    I2S Sample Configuration  --->
    
    
  3. 设置I2S主设备的I2S id和GPIO,id只能设置为,GPIO可设置任意引脚。

    I2S Sample Configuration  --->
        
        [*] Support I2S Master Sample.
        (0)     Choose I2S master bus id.
        (13)    Choose I2S CLK master pin.
        (14)    Choose I2S WS master pin.
        (15)    Choose I2S DO master pin.
        (16)    Choose I2S DI master pin.
    
  4. 按下"Save"键保存配置。

    Alt text

  5. 编译烧录固件

    参考环境搭建教程编译烧录代码

  6. 设置I2S从设备的I2S id和GPIO,id可设置为0或1,GPIO可设置任意引脚。

    I2S Sample Configuration  --->
        [*] Support I2S Slave Sample.
        (0)     Choose I2S slave bus id. (NEW)
        (13)    Choose I2S CLK slave pin. (NEW)
        (14)    Choose I2S WS slave pin. (NEW)
        (15)    Choose I2S DO slave pin. (NEW)
        (16)    Choose I2S DI slave pin. (NEW)
    
  7. 按下"Save"键保存配置。

    Alt texts

  8. 编译烧录固件

    参考环境搭建教程编译烧录代码

三、测试

烧录固件后按下开发的复位按键,将两块开发板设置为I2S CLK的引脚接一起;将两块开发板设置为I2S WS的引脚接一起;将一块开发板设置为I2S DO的引脚与另外一块开发板设置为I2S DI的引脚接一起;将一块开发板设置为I2S DI的引脚与另外一块开发板设置为I2S DO的引脚接一起;将两块开发板GND引脚接一起;观察两块开发板的运行日志。

主设备端日志:

i2s master write start!
i2s master write start!
i2s master write start!
i2s master write start!

从设备端日志:

left rx data is:0x100000
right rx data is:0x100000
left rx data is:0x100001
right rx data is:0x100001
left rx data is:0x100002
right rx data is:0x100002
left rx data is:0x100003
right rx data is:0x100003
left rx data is:0x100004
right rx data is:0x100004
left rx data is:0x100005
right rx data is:0x100005
left rx data is:0x100007
right rx data is:0x100007
left rx data is:0x10000c
right rx data is:0x10000c
left rx data is:0x10000d
right rx data is:0x10000d
left rx data is:0x10000e
right rx data is:0x10000e
left rx data is:0x10000f
right rx data is:0x10000f
left rx data is:0x100010
right rx data is:0x100010
left rx data is:0x100011
right rx data is:0x100011
left rx data is:0x100012
right rx data is:0x100012