-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathAdafruit_ZeroI2S.h
75 lines (64 loc) · 1.87 KB
/
Adafruit_ZeroI2S.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*!
* @file Adafruit_ZeroI2S.h
*
* This is a library for the I2S peripheral on SAMD21 and SAMD51 devices
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Written by Dean Miller for Adafruit Industries.
*
* BSD license, all text here must be included in any redistribution.
*
*/
#ifndef ADAFRUIT_ZEROI2S_H
#define ADAFRUIT_ZEROI2S_H
#include <Arduino.h>
/**************************************************************************/
/*!
@brief available I2S slot sizes
*/
/**************************************************************************/
typedef enum _I2SSlotSize {
I2S_8_BIT = 0,
I2S_16_BIT,
I2S_24_BIT,
I2S_32_BIT
} I2SSlotSize;
/**************************************************************************/
/*!
@brief number of I2S slots to use (stereo)
*/
/**************************************************************************/
#define I2S_NUM_SLOTS 2
/**************************************************************************/
/*!
@brief Class that stores state and functions for interacting with I2S
peripheral on SAMD21 and SAMD51 devices
*/
/**************************************************************************/
class Adafruit_ZeroI2S {
public:
Adafruit_ZeroI2S(uint8_t FS_PIN, uint8_t SCK_PIN, uint8_t TX_PIN,
uint8_t RX_PIN);
Adafruit_ZeroI2S();
~Adafruit_ZeroI2S() {}
bool begin(I2SSlotSize width, int fs_freq, int mck_mult = 256);
void enableTx();
void disableTx();
void enableRx();
void disableRx();
void enableMCLK();
void disableMCLK();
bool txReady();
bool rxReady();
void write(int32_t left, int32_t right);
void read(int32_t *left, int32_t *right);
private:
int8_t _fs, _sck, _tx, _rx;
#ifndef __SAMD51__
int8_t _i2sserializer, _i2sclock;
#endif
};
#endif