gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
i2s.h
1
2/*
3 * MIT License
4 *
5 * Copyright (c) 2023 Joey Castillo
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26#pragma once
27
28#include <stdint.h>
29#include <stdbool.h>
30#include "sam.h"
31#include "system.h"
32
57#ifdef I2S
58
59typedef enum {
60 I2S_SLOT_SIZE_8 = 0,
61 I2S_SLOT_SIZE_16 = 1,
62 I2S_SLOT_SIZE_24 = 2,
63 I2S_SLOT_SIZE_32 = 3,
64} i2s_slot_size_t;
65
66typedef enum {
67 I2S_DATA_SIZE_32 = 0,
68 I2S_DATA_SIZE_24 = 1,
69 I2S_DATA_SIZE_20 = 2,
70 I2S_DATA_SIZE_18 = 3,
71 I2S_DATA_SIZE_16 = 4,
73 I2S_DATA_SIZE_8 = 6,
76
81
88
93
102void i2s_init(void);
103
107void i2s_disable(void);
108
119void i2s_set_rx_serializer(uint8_t serializer);
120
131void i2s_set_tx_serializer(uint8_t serializer);
132
145void i2s_configure_clock_unit(uint8_t clock_unit, generic_clock_generator_t clocksource,
146 uint8_t mckdiv, i2s_slot_size_t slot_size, uint8_t num_slots);
147
154void i2s_configure_rx(i2s_rx_mode_t mode, uint8_t clock_unit, i2s_data_size_t data_size);
155
162void i2s_configure_tx(uint8_t clock_unit, i2s_data_size_t data_size);
163
168void i2s_enable_clock_unit(uint8_t clock_unit);
169
174void i2s_disable_clock_unit(uint8_t clock_unit);
175
181void i2s_enable_rx(void);
182
186void i2s_disable_rx(void);
187
193void i2s_enable_tx(void);
194
198void i2s_disable_tx(void);
199
200#endif
201
i2s_rx_mode_t
Definition i2s.h:89
void i2s_disable(void)
Disables the I2S peripheral and turns off its bus clock.
void i2s_configure_tx(uint8_t clock_unit, i2s_data_size_t data_size)
Configures the TX serializer.
void i2s_configure_rx(i2s_rx_mode_t mode, uint8_t clock_unit, i2s_data_size_t data_size)
Configures the RX serializer.
void i2s_set_rx_serializer(uint8_t serializer)
Sets which serializer index to use for RX operations.
void i2s_enable_rx(void)
Enables the RX serializer.
void i2s_enable_clock_unit(uint8_t clock_unit)
Enables a clock unit.
i2s_frame_sync_width_t
Definition i2s.h:82
i2s_bit_delay_t
Definition i2s.h:77
void i2s_set_tx_serializer(uint8_t serializer)
Sets which serializer index to use for TX operations.
void i2s_disable_rx(void)
Disables the RX serializer.
void i2s_init(void)
Initializes the I2S peripheral, but does not enable it.
i2s_data_size_t
Definition i2s.h:66
void i2s_disable_tx(void)
Disables the TX serializer.
void i2s_enable_tx(void)
Enables the TX serializer.
void i2s_disable_clock_unit(uint8_t clock_unit)
Disables a clock unit.
void i2s_configure_clock_unit(uint8_t clock_unit, generic_clock_generator_t clocksource, uint8_t mckdiv, i2s_slot_size_t slot_size, uint8_t num_slots)
Configures a clock unit's clock source and frame format.
@ I2S_RX_MODE_PDM2
PDM receive: one bit sampled on each clock edge.
Definition i2s.h:91
@ I2S_RX_MODE_NORMAL
Standard I2S receive.
Definition i2s.h:90
@ I2S_FRAME_SYNC_WIDTH_HALF
Frame sync pulse is half a frame wide.
Definition i2s.h:84
@ I2S_FRAME_SYNC_WIDTH_BURST
Burst mode: 1-bit pulse per data sample.
Definition i2s.h:86
@ I2S_FRAME_SYNC_WIDTH_BIT
Frame sync pulse is 1 bit wide.
Definition i2s.h:85
@ I2S_FRAME_SYNC_WIDTH_SLOT
Frame sync pulse is 1 slot wide.
Definition i2s.h:83
@ I2S_BIT_DELAY_LJ
Left justified (0-bit delay)
Definition i2s.h:78
@ I2S_BIT_DELAY_I2S
Standard I2S (1-bit delay)
Definition i2s.h:79
@ I2S_DATA_SIZE_16C
16-bit compact stereo
Definition i2s.h:72
@ I2S_DATA_SIZE_8C
8-bit compact stereo
Definition i2s.h:74