Skip to content

Commit ce8fb1e

Browse files
committed
Merge branch 'feature/refactor_i2s_driver' into 'master'
refactor(i2s): Refactor i2s driver for esp8266 idf See merge request sdk/ESP8266_RTOS_SDK!712
2 parents ed02e83 + 7a5bf33 commit ce8fb1e

File tree

5 files changed

+915
-1
lines changed

5 files changed

+915
-1
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// Copyright 2018-2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef _SLC_REGISTER_H_
16+
#define _SLC_REGISTER_H_
17+
18+
#include "eagle_soc.h"
19+
20+
#define REG_I2S_BASE (0x60000e00)
21+
22+
#define I2STXFIFO (REG_I2S_BASE + 0x0000)
23+
#define I2SRXFIFO (REG_I2S_BASE + 0x0004)
24+
25+
#define I2SCONF (REG_I2S_BASE + 0x0008)
26+
#define I2S_BCK_DIV_NUM 0x0000003F
27+
#define I2S_BCK_DIV_NUM_S 22
28+
#define I2S_CLKM_DIV_NUM 0x0000003F
29+
#define I2S_CLKM_DIV_NUM_S 16
30+
#define I2S_BITS_MOD 0x0000000F
31+
#define I2S_BITS_MOD_S 12
32+
#define I2S_RECE_MSB_SHIFT (BIT(11))
33+
#define I2S_TRANS_MSB_SHIFT (BIT(10))
34+
#define I2S_I2S_RX_START (BIT(9))
35+
#define I2S_I2S_TX_START (BIT(8))
36+
#define I2S_MSB_RIGHT (BIT(7))
37+
#define I2S_RIGHT_FIRST (BIT(6))
38+
#define I2S_RECE_SLAVE_MOD (BIT(5))
39+
#define I2S_TRANS_SLAVE_MOD (BIT(4))
40+
#define I2S_I2S_RX_FIFO_RESET (BIT(3))
41+
#define I2S_I2S_TX_FIFO_RESET (BIT(2))
42+
#define I2S_I2S_RX_RESET (BIT(1))
43+
#define I2S_I2S_TX_RESET (BIT(0))
44+
#define I2S_I2S_RESET_MASK 0xf
45+
46+
#define I2SINT_RAW (REG_I2S_BASE + 0x000c)
47+
#define I2S_I2S_TX_REMPTY_INT_RAW (BIT(5))
48+
#define I2S_I2S_TX_WFULL_INT_RAW (BIT(4))
49+
#define I2S_I2S_RX_REMPTY_INT_RAW (BIT(3))
50+
#define I2S_I2S_RX_WFULL_INT_RAW (BIT(2))
51+
#define I2S_I2S_TX_PUT_DATA_INT_RAW (BIT(1))
52+
#define I2S_I2S_RX_TAKE_DATA_INT_RAW (BIT(0))
53+
54+
55+
#define I2SINT_ST (REG_I2S_BASE + 0x0010)
56+
#define I2S_I2S_TX_REMPTY_INT_ST (BIT(5))
57+
#define I2S_I2S_TX_WFULL_INT_ST (BIT(4))
58+
#define I2S_I2S_RX_REMPTY_INT_ST (BIT(3))
59+
#define I2S_I2S_RX_WFULL_INT_ST (BIT(2))
60+
#define I2S_I2S_TX_PUT_DATA_INT_ST (BIT(1))
61+
#define I2S_I2S_RX_TAKE_DATA_INT_ST (BIT(0))
62+
63+
#define I2SINT_ENA (REG_I2S_BASE + 0x0014)
64+
#define I2S_I2S_TX_REMPTY_INT_ENA (BIT(5))
65+
#define I2S_I2S_TX_WFULL_INT_ENA (BIT(4))
66+
#define I2S_I2S_RX_REMPTY_INT_ENA (BIT(3))
67+
#define I2S_I2S_RX_WFULL_INT_ENA (BIT(2))
68+
#define I2S_I2S_TX_PUT_DATA_INT_ENA (BIT(1))
69+
#define I2S_I2S_RX_TAKE_DATA_INT_ENA (BIT(0))
70+
71+
#define I2SINT_CLR (REG_I2S_BASE + 0x0018)
72+
#define I2S_I2S_TX_REMPTY_INT_CLR (BIT(5))
73+
#define I2S_I2S_TX_WFULL_INT_CLR (BIT(4))
74+
#define I2S_I2S_RX_REMPTY_INT_CLR (BIT(3))
75+
#define I2S_I2S_RX_WFULL_INT_CLR (BIT(2))
76+
#define I2S_I2S_PUT_DATA_INT_CLR (BIT(1))
77+
#define I2S_I2S_TAKE_DATA_INT_CLR (BIT(0))
78+
79+
#define I2STIMING (REG_I2S_BASE + 0x001c)
80+
#define I2S_TRANS_BCK_IN_INV (BIT(22))
81+
#define I2S_RECE_DSYNC_SW (BIT(21))
82+
#define I2S_TRANS_DSYNC_SW (BIT(20))
83+
#define I2S_RECE_BCK_OUT_DELAY 0x00000003
84+
#define I2S_RECE_BCK_OUT_DELAY_S 18
85+
#define I2S_RECE_WS_OUT_DELAY 0x00000003
86+
#define I2S_RECE_WS_OUT_DELAY_S 16
87+
#define I2S_TRANS_SD_OUT_DELAY 0x00000003
88+
#define I2S_TRANS_SD_OUT_DELAY_S 14
89+
#define I2S_TRANS_WS_OUT_DELAY 0x00000003
90+
#define I2S_TRANS_WS_OUT_DELAY_S 12
91+
#define I2S_TRANS_BCK_OUT_DELAY 0x00000003
92+
#define I2S_TRANS_BCK_OUT_DELAY_S 10
93+
#define I2S_RECE_SD_IN_DELAY 0x00000003
94+
#define I2S_RECE_SD_IN_DELAY_S 8
95+
#define I2S_RECE_WS_IN_DELAY 0x00000003
96+
#define I2S_RECE_WS_IN_DELAY_S 6
97+
#define I2S_RECE_BCK_IN_DELAY 0x00000003
98+
#define I2S_RECE_BCK_IN_DELAY_S 4
99+
#define I2S_TRANS_WS_IN_DELAY 0x00000003
100+
#define I2S_TRANS_WS_IN_DELAY_S 2
101+
#define I2S_TRANS_BCK_IN_DELAY 0x00000003
102+
#define I2S_TRANS_BCK_IN_DELAY_S 0
103+
104+
#define I2S_FIFO_CONF (REG_I2S_BASE + 0x0020)
105+
#define I2S_I2S_RX_FIFO_MOD 0x00000007
106+
#define I2S_I2S_RX_FIFO_MOD_S 16
107+
#define I2S_I2S_TX_FIFO_MOD 0x00000007
108+
#define I2S_I2S_TX_FIFO_MOD_S 13
109+
#define I2S_I2S_DSCR_EN (BIT(12))
110+
#define I2S_I2S_TX_DATA_NUM 0x0000003F
111+
#define I2S_I2S_TX_DATA_NUM_S 6
112+
#define I2S_I2S_RX_DATA_NUM 0x0000003F
113+
#define I2S_I2S_RX_DATA_NUM_S 0
114+
115+
116+
#define I2SRXEOF_NUM (REG_I2S_BASE + 0x0024)
117+
#define I2S_I2S_RX_EOF_NUM 0xFFFFFFFF
118+
#define I2S_I2S_RX_EOF_NUM_S 0
119+
120+
#define I2SCONF_SIGLE_DATA (REG_I2S_BASE + 0x0028)
121+
#define I2S_I2S_SIGLE_DATA 0xFFFFFFFF
122+
#define I2S_I2S_SIGLE_DATA_S 0
123+
124+
#define I2SCONF_CHAN (REG_I2S_BASE + 0x002c)
125+
#define I2S_RX_CHAN_MOD 0x00000003
126+
#define I2S_RX_CHAN_MOD_S 3
127+
#define I2S_TX_CHAN_MOD 0x00000007
128+
#define I2S_TX_CHAN_MOD_S 0
129+
130+
#endif
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// Copyright 2018-2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once
16+
17+
#include <stdint.h>
18+
#include "esp8266/eagle_soc.h"
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
/* ESP8266 I2S Register Definitions */
25+
26+
typedef volatile struct {
27+
uint32_t tx_fifo;
28+
uint32_t rx_fifo;
29+
union {
30+
struct {
31+
uint32_t tx_reset: 1;
32+
uint32_t rx_reset: 1;
33+
uint32_t tx_fifo_reset: 1;
34+
uint32_t rx_fifo_reset: 1;
35+
uint32_t tx_slave_mod: 1;
36+
uint32_t rx_slave_mod: 1;
37+
uint32_t right_first: 1;
38+
uint32_t msb_right: 1;
39+
uint32_t tx_start: 1;
40+
uint32_t rx_start: 1;
41+
uint32_t tx_msb_shift: 1;
42+
uint32_t rx_msb_shift: 1;
43+
uint32_t bits_mod: 4;
44+
uint32_t clkm_div_num: 6;
45+
uint32_t bck_div_num: 6;
46+
uint32_t reserved28: 4;
47+
};
48+
uint32_t val;
49+
} conf;
50+
union {
51+
struct {
52+
uint32_t rx_take_data: 1;
53+
uint32_t tx_put_data: 1;
54+
uint32_t rx_wfull: 1;
55+
uint32_t rx_rempty: 1;
56+
uint32_t tx_wfull: 1;
57+
uint32_t tx_rempty: 1;
58+
uint32_t reserved6: 26;
59+
};
60+
uint32_t val;
61+
} int_raw;
62+
union {
63+
struct {
64+
uint32_t rx_take_data: 1;
65+
uint32_t tx_put_data: 1;
66+
uint32_t rx_wfull: 1;
67+
uint32_t rx_rempty: 1;
68+
uint32_t tx_wfull: 1;
69+
uint32_t tx_rempty: 1;
70+
uint32_t reserved6: 26;
71+
};
72+
uint32_t val;
73+
} int_st;
74+
union {
75+
struct {
76+
uint32_t rx_take_data: 1;
77+
uint32_t tx_put_data: 1;
78+
uint32_t rx_wfull: 1;
79+
uint32_t rx_rempty: 1;
80+
uint32_t tx_wfull: 1;
81+
uint32_t tx_rempty: 1;
82+
uint32_t reserved6: 26;
83+
};
84+
uint32_t val;
85+
} int_ena;
86+
union {
87+
struct {
88+
uint32_t take_data: 1;
89+
uint32_t put_data: 1;
90+
uint32_t rx_wfull: 1;
91+
uint32_t rx_rempty: 1;
92+
uint32_t tx_wfull: 1;
93+
uint32_t tx_rempty: 1;
94+
uint32_t reserved6: 26;
95+
};
96+
uint32_t val;
97+
} int_clr;
98+
union {
99+
struct {
100+
uint32_t tx_bck_in_delay: 2;
101+
uint32_t tx_ws_in_delay: 2;
102+
uint32_t rx_bck_in_delay: 2;
103+
uint32_t rx_ws_in_delay: 2;
104+
uint32_t rx_sd_in_delay: 2;
105+
uint32_t tx_bck_out_delay: 2;
106+
uint32_t tx_ws_out_delay: 2;
107+
uint32_t tx_sd_out_delay: 2;
108+
uint32_t rx_ws_out_delay: 2;
109+
uint32_t rx_bck_out_delay: 2;
110+
uint32_t tx_dsync_sw: 1;
111+
uint32_t rx_dsync_sw: 1;
112+
uint32_t tx_bck_in_inv: 1;
113+
uint32_t reserved23: 9;
114+
};
115+
uint32_t val;
116+
} timing;
117+
union {
118+
struct {
119+
uint32_t rx_data_num: 6;
120+
uint32_t tx_data_num: 6;
121+
uint32_t dscr_en: 1;
122+
uint32_t tx_fifo_mod: 3;
123+
uint32_t rx_fifo_mod: 3;
124+
uint32_t reserved19: 13;
125+
};
126+
uint32_t val;
127+
} fifo_conf;
128+
uint32_t rx_eof_num;
129+
uint32_t conf_single_data;
130+
union {
131+
struct {
132+
uint32_t tx_chan_mod: 3;
133+
uint32_t rx_chan_mod: 2;
134+
uint32_t reserved5: 27;
135+
};
136+
uint32_t val;
137+
} conf_chan;
138+
} i2s_struct_t;
139+
140+
extern volatile i2s_struct_t I2S;
141+
142+
#ifdef __cplusplus
143+
}
144+
#endif /* end of __cplusplus */
145+

0 commit comments

Comments
 (0)