Microchip® Advanced Software Framework

Quick Start Guide for the SAMG53/SAMG54 I2S driver

This is the quickstart guide for the SAMG53 Inter-IC Sound Controller driver, with step-by-step instructions on how to configure and use the driver in a selection of use cases.

The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.

Basic use case

This use case will demonstrate how to initialize the I2S module to master in loopback mode.

Prerequisites

  1. System Clock Management (Sysclock)

Clock setup steps

Example code

Add the following code in the application C-file:

Workflow

  1. Initialize the system clock.

Usage steps

Example code

Add to, e.g., main loop in application C-file:

struct i2s_config config;
struct i2s_dev_inst dev_inst;
config.data_format = I2S_DATE_16BIT;
config.fs_ratio = I2S_FS_RATE_256;
config.loopback = true;
i2s_init(&dev_inst, I2SC, &config);
i2s_enable(&dev_inst);

Workflow

  1. Initialize the module with given configuration
    struct i2s_config config;
    struct i2s_dev_inst dev_inst;
    config.data_format = I2S_DATE_16BIT;
    config.fs_ratio = I2S_FS_RATE_256;
    config.loopback = true;
    i2s_init(&dev_inst, I2SC, &config);
  2. Enable the module
    i2s_enable(&dev_inst);
  3. Enable transmission, reception and clocks
  4. Use write/read function to access the data
    i2s_write(&dev_inst, data);
    i2s_read(&dev_inst, &data);