View detail for Atmel AT07908: SAM4L Inter-IC Sound Controller (IISC)

APPLICATION NOTE
AT07908: SAM4L Inter-IC Sound Controller (IISC)
ASF PROGRAMMERS MANUAL
SAM4L Inter-IC Sound Controller (IISC)
This driver for SAM4L devices provides an interface for the configuration and
management of the device's Inter-IC Sound Controller (IISC) module.
The IISC provides a 5-wire, bidirectional, synchronous, digital audio link with off-chip
audio devices.
The outline of this documentation is as follows:
●
Prerequisites
●
Module Overview
●
Special Considerations
●
Extra Information
●
Examples
●
API Overview
42315A-MCU-05/2014
Table of Contents
SAM4L Inter-IC Sound Controller (IISC) ............................................ 1
Software License ................................................................................ 4
1. Prerequisites ................................................................................. 5
2. Module Overview .......................................................................... 6
3. Special Considerations ................................................................. 7
4. Extra Information .......................................................................... 8
5. Examples ...................................................................................... 9
6. API Overview .............................................................................. 10
6.1.
6.2.
6.3.
6.4.
Variable and Type Definitions ...................................................... 10
6.1.1.
Type iis_callback_t ....................................................... 10
6.1.2.
Type iis_interrupt_source_t ............................................ 10
Structure Definitions ................................................................... 10
6.2.1.
Struct iis_config ............................................................ 10
6.2.2.
Struct iis_dev_inst ......................................................... 10
Function Definitions ................................................................... 11
6.3.1.
Function iis_clear_status() ............................................. 11
6.3.2.
Function iis_disable() .................................................... 11
6.3.3.
Function iis_disable_clocks() .......................................... 11
6.3.4.
Function iis_disable_interrupt() ....................................... 11
6.3.5.
Function iis_disable_reception() ...................................... 12
6.3.6.
Function iis_disable_transmission() .................................. 12
6.3.7.
Function iis_enable() .................................................... 12
6.3.8.
Function iis_enable_clocks() ........................................... 12
6.3.9.
Function iis_enable_interrupt() ........................................ 13
6.3.10. Function iis_enable_reception() ....................................... 13
6.3.11. Function iis_enable_transmission() .................................. 13
6.3.12. Function iis_get_config_defaults() .................................... 13
6.3.13. Function iis_get_interrupt_mask() .................................... 14
6.3.14. Function iis_get_status() ................................................ 14
6.3.15. Function iis_init() .......................................................... 14
6.3.16. Function iis_read() ....................................................... 15
6.3.17. Function iis_reset() ....................................................... 15
6.3.18. Function iis_set_callback() ............................................. 15
6.3.19. Function iis_write() ....................................................... 16
Enumeration Definitions .............................................................. 16
6.4.1.
Enum iis_data_format ................................................... 16
6.4.2.
Enum iis_dma_channel ................................................. 17
6.4.3.
Enum iis_fs_rate .......................................................... 17
6.4.4.
Enum iis_interrupt_source ............................................. 17
6.4.5.
Enum iis_number_of_channels ....................................... 18
6.4.6.
Enum iis_slot_length ..................................................... 18
7. Extra Information for the Inter-IC Sound Controller .................... 19
7.1.
7.2.
7.3.
7.4.
Acronyms ................................................................................
Dependencies ...........................................................................
Errata ......................................................................................
Module History .........................................................................
19
19
19
19
8. Examples for the Inter-IC Sound Controller ............................... 21
8.1.
Quick Start Guide for the SAM4L IIS driver .................................... 21
8.1.1.
Basic Use Case ............................................................ 21
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
2
8.1.2.
8.1.3.
Clock Setup Steps ........................................................ 21
Usage Steps ................................................................ 21
Index ................................................................................................. 24
Document Revision History .............................................................. 25
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
3
Software License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of Atmel may not be used to endorse or promote products derived from this software without specific
prior written permission.
4. This software may only be redistributed and used in connection with an Atmel microcontroller product.
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN
NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
4
1.
Prerequisites
There are no prerequisites for this module.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
5
2.
Module Overview
The Inter-IC Sound Controller (IISC) provides a 5-wire, bidirectional, synchronous, digital audio link with external
audio devices.
2
This module is compliant with the Inter-IC Sound (I S) bus specification.
The IISC consists of a Receiver, a Transmitter, and a common Clock Generator, that can be enabled separately, to
provide Master, Slave, or Controller modes with Receiver, Transmitter, or both active.
The IISC can use either a single DMA channel for both audio channels or one DMA channel per audio channel.
This allows high bitrate data transfer without processor intervention to the following external devices:
●
Audio CODECs in Master, Slave, or Controller mode
●
Stereo DAC or ADC through dedicated I S serial interface
2
The 8- and 16-bit compact stereo format allows the required DMA bandwidth to be reduced by transferring the left
and right samples within the same data word.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
6
3.
Special Considerations
●
Power Management
If the CPU enters a low power sleep mode that disables clocks used by the IISC, the IISC will stop functioning
and resume operation after the system wakes up from sleep mode.
The clock for the IISC bus interface is generated by the Power Manager. It is recommended to disable the IISC
before disabling the clock in order to avoid freezing the IISC in an undefined state.
●
DMA
The IISC DMA handshake interfaces are connected to the Peripheral DMA Controller. Using the IISC DMA
functionality requires the Peripheral DMA Controller (PDCA) to be configured first.
●
Interrupts
The IISC interrupt line is connected to the device's Interrupt Controller. Using the IISC interrupt requires the
Interrupt Controller to be configured first.
●
Debug Operation
When an external debugger forces the CPU into debug mode, the IISC continues normal operation. If the
IISC module is configured such that it requires periodically servicing by the CPU through interrupt requests (or
similar) then improper operation or data loss may result.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
7
4.
Extra Information
For extra information, see Extra Information for the Inter-IC Sound Controller. This includes:
●
Acronyms
●
Dependencies
●
Errata
●
Module History
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
8
5.
Examples
For a list of examples related to this driver, see Examples for the Inter-IC Sound Controller.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
9
6.
API Overview
6.1
Variable and Type Definitions
6.1.1
Type iis_callback_t
typedef void(* iis_callback_t )(void)
Callback function prototype.
6.1.2
Type iis_interrupt_source_t
typedef enum iis_interrupt_source iis_interrupt_source_t
IISC interrupt source ID type.
6.2
Structure Definitions
6.2.1
Struct iis_config
Configuration setting structure.
Table 6-1. Members
6.2.2
Type
Name
Description
enum iis_data_format
data_format
Number of bits per sample.
enum iis_fs_rate
fs_ratio
Master Clock to Sample Frequency
(fs) Ratio.
bool
loopback
1 for loopback, 0 for normal.
bool
master
1 for master, 0 for slave.
enum iis_number_of_channels
rx_channels
Number of channels for Rx.
enum iis_dma_channel
rx_dma
DMA channel usage for IIS
reception.
enum iis_slot_length
slot_length
Number of bits of the slot.
enum iis_number_of_channels
tx_channels
Number of channels for Tx.
enum iis_dma_channel
tx_dma
DMA channel usage for IIS
transmission.
Type
Name
Description
struct iis_config *
cfg
Pointer to IIS configuration
structure.
Iisc *
hw_dev
Base Address of the IISC module.
Struct iis_dev_inst
Table 6-2. Members
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
10
6.3
Function Definitions
6.3.1
Function iis_clear_status()
Clear the IISC interrupt status.
void iis_clear_status(
struct iis_dev_inst *const dev_inst,
iis_interrupt_source_t source)
Table 6-3. Parameters
6.3.2
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
[in]
source
Interrupt source ID
Function iis_disable()
Disable the IIS module.
void iis_disable(
struct iis_dev_inst *const dev_inst)
Table 6-4. Parameters
6.3.3
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Function iis_disable_clocks()
Disable the IISC module clocks.
void iis_disable_clocks(
struct iis_dev_inst * dev_inst)
Table 6-5. Parameters
6.3.4
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Function iis_disable_interrupt()
Disable the specified IISC interrupt source.
void iis_disable_interrupt(
struct iis_dev_inst *const dev_inst,
iis_interrupt_source_t source)
Table 6-6. Parameters
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
11
6.3.5
Data direction
Parameter name
Description
[in]
source
Interrupt source ID
Function iis_disable_reception()
Disable the IISC module receiver.
void iis_disable_reception(
struct iis_dev_inst * dev_inst)
Table 6-7. Parameters
6.3.6
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Function iis_disable_transmission()
Disable the IISC module transmitter.
void iis_disable_transmission(
struct iis_dev_inst * dev_inst)
Table 6-8. Parameters
6.3.7
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Function iis_enable()
Enable the IISC module.
void iis_enable(
struct iis_dev_inst *const dev_inst)
Table 6-9. Parameters
6.3.8
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Function iis_enable_clocks()
Enable the IIS module clocks.
void iis_enable_clocks(
struct iis_dev_inst * dev_inst)
Table 6-10. Parameters
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
12
6.3.9
Function iis_enable_interrupt()
Enable the specified IISC interrupt source.
void iis_enable_interrupt(
struct iis_dev_inst *const dev_inst,
iis_interrupt_source_t source)
Table 6-11. Parameters
6.3.10
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
[in]
source
Interrupt source ID
Function iis_enable_reception()
Enable the IISC module receiver.
void iis_enable_reception(
struct iis_dev_inst * dev_inst)
Table 6-12. Parameters
6.3.11
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Function iis_enable_transmission()
Enable the IISC module transmitter.
void iis_enable_transmission(
struct iis_dev_inst * dev_inst)
Table 6-13. Parameters
6.3.12
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Function iis_get_config_defaults()
Get the default IIS module configuration.
void iis_get_config_defaults(
struct iis_config *const cfg)
Data Type
Format
Data format
32 bits
Slot length
32 bits
Sample frequency ratio
1024
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
13
Data Type
Format
Tx channel
Stereo
Rx channel
Stereo
DMA for Tx
One DMA channel for One IIS Tx channel
DMA for Rx
One DMA channel for One IIS Rx channel
Loopback
No
Master
Yes
Table 6-14. Parameters
6.3.13
Data direction
Parameter name
Description
[out]
cfg
Pointer to an IISC configuration
structure
Function iis_get_interrupt_mask()
Get the IISC interrupt mask value.
uint32_t iis_get_interrupt_mask(
struct iis_dev_inst *const dev_inst)
Table 6-15. Parameters
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Returns
6.3.14
Interrupt mask value.
Function iis_get_status()
Get the IISC status value.
uint32_t iis_get_status(
struct iis_dev_inst * dev_inst)
Table 6-16. Parameters
Returns
6.3.15
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
IISC status value.
Function iis_init()
Initialize and configure the IISC module.
enum status_code iis_init(
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
14
struct iis_dev_inst *const dev_inst,
Iisc * iisc,
struct iis_config *const cfg)
Table 6-17. Parameters
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
[in]
iisc
Device structure pointer
[in]
cfg
Pointer to an IISC configuration
structure
Table 6-18. Return Values
6.3.16
Return value
Description
STATUS_OK
Success
Function iis_read()
Read a single element of data.
enum status_code iis_read(
struct iis_dev_inst * dev_inst,
uint32_t * data)
Table 6-19. Parameters
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
[out]
*data
Pointer for received data
Table 6-20. Return Values
6.3.17
Return value
Description
STATUS_OK
Success
STATUS_ERR_TIMEOUT
Operation timed out
Function iis_reset()
Reset the IISC module.
void iis_reset(
struct iis_dev_inst * dev_inst)
Table 6-21. Parameters
6.3.18
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
Function iis_set_callback()
Set an IISC callback.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
15
void iis_set_callback(
struct iis_dev_inst *const dev_inst,
iis_interrupt_source_t source,
iis_callback_t callback,
uint8_t irq_level)
Table 6-22. Parameters
6.3.19
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
[in]
source
Interrupt source ID
[in]
callback
IISC callback function pointer
[in]
irq_level
Interrupt level
Function iis_write()
Write a single element of data.
enum status_code iis_write(
struct iis_dev_inst * dev_inst,
uint32_t data)
Table 6-23. Parameters
Data direction
Parameter name
Description
[in]
dev_inst
Driver structure pointer
[in]
data
The data element to write
Table 6-24. Return Values
Return value
Description
STATUS_OK
Success
STATUS_ERR_TIMEOUT
Operation timed out
6.4
Enumeration Definitions
6.4.1
Enum iis_data_format
IISC data format.
Table 6-25. Members
Enum value
Description
IIS_DATE_32BIT
32 bit mono or stereo format.
IIS_DATE_24BIT
24 bit mono or stereo format.
IIS_DATE_20BIT
20 bit mono or stereo format.
IIS_DATE_18BIT
18 bit mono or stereo format.
IIS_DATE_16BIT
16 bit mono or stereo format.
IIS_DATE_16BIT_COMPACT
16 bit compact stereo format, with left and right
samples packed in the same word to reduce
data transfers.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
16
6.4.2
Enum value
Description
IIS_DATE_8BIT
8 bit mono or stereo format.
IIS_DATE_8BIT_COMPACT
8 bit compact stereo format, with left and right
samples packed in the same word to reduce
data transfers.
Enum iis_dma_channel
DMA channel usage for an IISC data transfer type.
Table 6-26. Members
6.4.3
Enum value
Description
IIS_ONE_DMA_CHANNEL_FOR_BOTH_CHANNELS
One DMA channel for both channels.
IIS_ONE_DMA_CHANNEL_FOR_ONE_CHANNEL
One DMA channel for one channel.
Enum iis_fs_rate
Supported Master Clock to Sample Frequency (fs) Ratio.
Table 6-27. Members
6.4.4
Enum value
Description
IIS_FS_RATE_16
Master Clock to Sample Frequency Ratio 16.
IIS_FS_RATE_32
Master Clock to Sample Frequency Ratio 32.
IIS_FS_RATE_48
Master Clock to Sample Frequency Ratio 48.
IIS_FS_RATE_64
Master Clock to Sample Frequency Ratio 64.
IIS_FS_RATE_96
Master Clock to Sample Frequency Ratio 96.
IIS_FS_RATE_128
Master Clock to Sample Frequency Ratio 128.
IIS_FS_RATE_192
Master Clock to Sample Frequency Ratio 192.
IIS_FS_RATE_256
Master Clock to Sample Frequency Ratio 256.
IIS_FS_RATE_384
Master Clock to Sample Frequency Ratio 384.
IIS_FS_RATE_512
Master Clock to Sample Frequency Ratio 512.
IIS_FS_RATE_768
Master Clock to Sample Frequency Ratio 768.
IIS_FS_RATE_1024
Master Clock to Sample Frequency Ratio 1024.
Enum iis_interrupt_source
IISC interrupt source ID type.
Table 6-28. Members
Enum value
Description
IIS_INTERRUPT_RXRDY
Receive Ready.
IIS_INTERRUPT_RXOR
Receive Overrun.
IIS_INTERRUPT_TXRDY
Transmit Ready.
IIS_INTERRUPT_TXUR
Transmit Underrun.
_IIS_INTERRUPT_SOURCE_NUM
Number of interrupt sources.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
17
6.4.5
Enum iis_number_of_channels
Mono or stereo channel setting type.
Table 6-29. Members
6.4.6
Enum value
Description
IIS_CHANNEL_MONO
Mono.
IIS_CHANNEL_STEREO
Stereo.
Enum iis_slot_length
IISC channel data slot length type.
Table 6-30. Members
Enum value
Description
IIS_SLOT_LENGTH_8BIT
8 bit IISC channel data slot length.
IIS_SLOT_LENGTH_16BIT
16 bit IISC channel data slot length.
IIS_SLOT_LENGTH_24BIT
24 bit IISC channel data slot length.
IIS_SLOT_LENGTH_32BIT
32 bit IISC channel data slot length.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
18
7.
Extra Information for the Inter-IC Sound Controller
7.1
Acronyms
Below is a table listing the acronyms used in this module, along with their intended meanings.
7.2
Acronym
Definition
ADC
Analog-to-Digital Converter
DAC
Digital-to-Analog Converter
DMA
Direct Memory Access
PDCA
Peripheral DMA Controller
QSG
Quick Start Guide
Dependencies
This driver has the following dependencies:
●
I/O Lines
The IISC pins may be multiplexed with I/O Controller lines. The user must first program the I/O Controller to
assign the desired IISC pins to their peripheral function. If the IISC I/O lines are not used by the application,
they can be used for other purposes by the I/O Controller. It is required to enable only the IISC inputs and
outputs actually in use.
●
Power Management
If the CPU enters a sleep mode that disables clocks used by the IISC, the IISC will stop functioning and
resume operation after the system wakes up from sleep mode.
●
Clocks
The clock for the IISC bus interface (CLK_IISC) is generated by the Power Manager. It is recommended to
disable the IISC before disabling the clock, to avoid freezing the IISC in an undefined state. One of the generic
clocks is connected to the IISC. The generic clock (GCLK_IISC) can be set to a wide range of frequencies and
clock sources. The GCLK_IISC must be enabled and configured before use.
●
DMA
The IISC DMA handshake interfaces are connected to the Peripheral DMA Controller. Using the IISC DMA
functionality requires the Peripheral DMA Controller to be programmed first.
●
Interrupts
The IISC interrupt line is connected to the Interrupt Controller. Using the IISC interrupt requires the Interrupt
Controller to be programmed first.
●
Debug Operation
When an external debugger forces the CPU into debug mode, the IISC continues normal operation. If this
module is configured in a way that requires it to be periodically serviced by the CPU through interrupt requests
or similar, improper operation or data loss may result during debugging.
7.3
Errata
There are no errata related to this driver.
7.4
Module History
An overview of the module history is presented in the table below, with details on the enhancements and fixes
made to the module since its first release. The current version of this corresponds to the newest version in the
table.
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
19
Changelog
Initial document release
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
20
8.
Examples for the Inter-IC Sound Controller
This is a list of the available Quick Start Guides (QSGs) and example applications for SAM4L Inter-IC Sound
Controller (IISC). QSGs are simple examples with step-by-step instructions to configure and use this driver in
a selection of use cases. Note that QSGs can be compiled as a standalone application or be added to the user
application.
●
8.1
Quick Start Guide for the SAM4L IIS driver
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.
8.1.1
Basic Use Case
This use case will demonstrate how to initialize the IIS module in Master mode with loopback enabled.
8.1.1.1
Prerequisites
●
System Clock Management (Sysclock)
8.1.2
Clock Setup Steps
8.1.2.1
Example Code
Enable the following macros in the header file conf_clock.h:
#define CONFIG_SYSCLK_SOURCE
#define CONFIG_DFLL0_SOURCE
SYSCLK_SRC_DFLL
GENCLK_SRC_OSC32K
Add the following code to your application C-file:
sysclk_init();
8.1.2.2
Workflow
1.
Set the system clock source to DFLL:
#define CONFIG_SYSCLK_SOURCE
2.
Set Set the DFLL clock source to OSC32K:
#define CONFIG_DFLL0_SOURCE
3.
SYSCLK_SRC_DFLL
GENCLK_SRC_OSC32K
Initialize the system clock:
sysclk_init();
8.1.3
Usage Steps
8.1.3.1
Example Code
Add to, e.g., main loop in your application C-file:
uint32_t data = 0;
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
21
struct iis_config config;
struct iis_dev_inst dev_inst;
config.data_format = IIS_DATE_16BIT_COMPACT;
config.slot_length = IIS_SLOT_LENGTH_16BIT;
config.fs_ratio = IIS_FS_RATE_256;
config.tx_channels = IIS_CHANNEL_STEREO;
config.rx_channels = IIS_CHANNEL_STEREO;
config.loopback = true;
config.master = true;
if (iis_init(&dev_inst, IISC, &config) != STATUS_OK)
{
return -1;
}
iis_enable(&dev_inst);
iis_enable_transmission(&dev_inst);
iis_enable_clocks(&dev_inst);
iis_enable_reception(&dev_inst);
if (iis_write(&dev_inst, data) != STATUS_OK)
{
return -1;
}
if (iis_read(&dev_inst, &data) != STATUS_OK)
{
return -1;
}
8.1.3.2
Workflow
1.
Initialize the IISC module with a given configuration:
uint32_t data = 0;
struct iis_config config;
struct iis_dev_inst dev_inst;
config.data_format = IIS_DATE_16BIT_COMPACT;
config.slot_length = IIS_SLOT_LENGTH_16BIT;
config.fs_ratio = IIS_FS_RATE_256;
config.tx_channels = IIS_CHANNEL_STEREO;
config.rx_channels = IIS_CHANNEL_STEREO;
config.loopback = true;
config.master = true;
if (iis_init(&dev_inst, IISC, &config) != STATUS_OK)
{
return -1;
}
2.
Enable the IISC module:
iis_enable(&dev_inst);
3.
Enable transmitter, receiver, and clocks:
iis_enable_transmission(&dev_inst);
iis_enable_clocks(&dev_inst);
iis_enable_reception(&dev_inst);
4.
Use write/read functions to transfer data:
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
22
if (iis_write(&dev_inst, data) != STATUS_OK)
{
return -1;
}
if (iis_read(&dev_inst, &data) != STATUS_OK)
{
return -1;
}
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
23
Index
E
Enumeration Definitions
iis_data_format, 16
iis_dma_channel, 17
iis_fs_rate, 17
iis_interrupt_source, 17
iis_number_of_channels, 18
iis_slot_length, 18
F
Function Definitions
iis_clear_status, 11
iis_disable, 11
iis_disable_clocks, 11
iis_disable_interrupt, 11
iis_disable_reception, 12
iis_disable_transmission, 12
iis_enable, 12
iis_enable_clocks, 12
iis_enable_interrupt, 13
iis_enable_reception, 13
iis_enable_transmission, 13
iis_get_config_defaults, 13
iis_get_interrupt_mask, 14
iis_get_status, 14
iis_init, 14
iis_read, 15
iis_reset, 15
iis_set_callback, 15
iis_write, 16
S
Structure Definitions
iis_config, 10
iis_dev_inst, 10
T
Type Definitions
iis_callback_t, 10
iis_interrupt_source_t, 10
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
24
Document Revision History
Doc. Rev.
Date
Comments
42315A
05/2014
Initial document release
AT07908: SAM4L Inter-IC Sound Controller (IISC) [APPLICATION NOTE]
42315A-MCU-05/2014
25
Atmel Corporation
1600 Technology Drive, San Jose, CA 95110 USA
T: (+1)(408) 441.0311
F: (+1)(408) 436.4200
|
www.atmel.com
© 2014 Atmel Corporation. All rights reserved. / Rev.: 42315A-MCU-05/2014
®
®
Atmel , Atmel logo and combinations thereof, Enabling Unlimited Possibilities , and others are registered trademarks or trademarks of Atmel Corporation or its
subsidiaries. Other terms and product names may be trademarks of others.
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by
this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL
ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF
INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at
any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be
used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.
Similar pages
View detail for Atmel AT09331: ASF USB Stack Manual
View detail for Atmel AT07893: SAM4L Peripheral DMA Controller (PDCA)
View detail for Atmel AT06863: SAM4L Peripheral Event Controller (PEVC) Driver
AT07912: SAM4L Parallel Capture (PARC) ASF
View detail for Atmel AT09253: SAM4L Analog Comparator Interface Controller (ACIFC) Driver
View detail for Atmel AT07900: SAM4 Digital-to-Analog Converter Controller (DACC)
View detail for Atmel AT07336: Common Non-Volatile Memory (NVM) Driver
View detail for Atmel AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART)
View detail for Atmel AT07337: SAM4 Real-Time Clock (RTC)
View detail for Atmel AT06861: SAM Supply Controller (SUPC)
View detail for Atmel AT07911: Glue Logic Controller (GLOC)
View detail for Atmel AT07942: SAM4L Asynchronous Timer (AST)
View detail for Atmel AT13481: SAM L22/C21/C20 Frequency Meter (FREQM) Driver
View detail for Atmel AT10732: SAM L True Random Number Generator (TRNG) Driver
View detail for Atmel AT07899: SAM3S/4E /4S Analog Comparator Controller (ACC)
View detail for Atmel AT03665: ASF Manual (SAM D20)
View detail for Atmel AT07910: SAM4L Liquid Crystal Display (LCDCA) Driver
View detail for Atmel AT03789: SAM D10/D11/D20/D21/DA1/R Brown Out Detector (BOD) Driver
View detail for Atmel AT11512: SAM L Brown Out Detector (BOD) Driver
View detail for Atmel AT10799: SAM L21 Operational Amplifier Controller (OPAMP) Driver
View detail for Atmel AT03248: SAM D/R/L/C Port (PORT) Driver