Microchip® Advanced Software Framework

Quick Start Guide for the SAM4L IIS driver

This is the quickstart guide for the SAM4L 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 IIS module to master in loopback mode.

Prerequisites

  1. System Clock Management (Sysclock)

Clock setup steps

Example code

Enable the following macro in the conf_clock.h:

#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_DFLL
#define CONFIG_DFLL0_SOURCE GENCLK_SRC_OSC32K

Add the following code in the application C-file:

Workflow

  1. Set system clock source as DFLL:
    #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_DFLL
  2. Set DFLL source as OSC32K:
    #define CONFIG_DFLL0_SOURCE GENCLK_SRC_OSC32K
  3. Initialize the system clock.

Usage steps

Example code

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

config.num_tx_channels = IIS_CHANNEL_STEREO;
config.num_rx_channels = IIS_CHANNEL_STEREO;
config.loopback = true;
config.master = true;

Workflow

  1. Initialize the module with given configuration
    config.num_tx_channels = IIS_CHANNEL_STEREO;
    config.num_rx_channels = IIS_CHANNEL_STEREO;
    config.loopback = true;
    config.master = true;
  2. Enable the module
  3. Enable transmission, reception and clocks
  4. Use write/read function to access the data