File tree Expand file tree Collapse file tree 2 files changed +58
-10
lines changed
libraries/esp8266/examples/I2SInput Expand file tree Collapse file tree 2 files changed +58
-10
lines changed Original file line number Diff line number Diff line change @@ -45,16 +45,16 @@ extern void ets_wdt_disable(void);
45
45
// placed onto the list when they're filled by DMA
46
46
47
47
typedef struct slc_queue_item {
48
- uint32_t blocksize : 12 ;
49
- uint32_t datalen : 12 ;
50
- uint32_t unused : 5 ;
51
- uint32_t sub_sof : 1 ;
52
- volatile uint32_t eof : 1 ;
53
- volatile uint32_t owner : 1 ;
54
- uint32_t * buf_ptr ;
55
- uint32_t * next_link_ptr ;
48
+ uint32_t blocksize : 12 ;
49
+ uint32_t datalen : 12 ;
50
+ uint32_t unused : 5 ;
51
+ uint32_t sub_sof : 1 ;
52
+ uint32_t eof : 1 ;
53
+ volatile uint32_t owner : 1 ; // DMA can change this value
54
+ uint32_t * buf_ptr ;
55
+ struct slc_queue_item * next_link_ptr ;
56
56
// This is my own way of tracking item ID
57
- volatile uint32_t myid ;
57
+ volatile uint32_t myid ;
58
58
} slc_queue_item_t ;
59
59
60
60
typedef struct i2s_state {
@@ -210,7 +210,7 @@ static void ICACHE_FLASH_ATTR _alloc_channel(i2s_state_t *ch) {
210
210
ch -> slc_items [x ].datalen = SLC_BUF_LEN * 4 ;
211
211
ch -> slc_items [x ].blocksize = SLC_BUF_LEN * 4 ;
212
212
ch -> slc_items [x ].buf_ptr = (uint32_t * )& ch -> slc_buf_pntr [x ][0 ];
213
- ch -> slc_items [x ].next_link_ptr = (uint32_t * )(( x < (SLC_BUF_CNT - 1 ))?(& ch -> slc_items [x + 1 ]):(& ch -> slc_items [0 ]) );
213
+ ch -> slc_items [x ].next_link_ptr = (x < (SLC_BUF_CNT - 1 ))?(& ch -> slc_items [x + 1 ]):(& ch -> slc_items [0 ]);
214
214
ch -> slc_items [x ].myid = 0 ;
215
215
}
216
216
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ I2S stereo microphone (input) example
3
+ Run using the Arduion Serial Plotter to see waveform.
4
+ Released to the Public Domain by Earle F. Philhower, III
5
+ */
6
+
7
+ #include < ESP8266WiFi.h>
8
+ #include < i2s.h>
9
+
10
+ void dump ()
11
+ {
12
+ Serial.printf (" I2SC: %08x\n " , I2SC);
13
+ Serial.printf (" I2SFC: %08x\n " , I2SFC);
14
+ Serial.printf (" I2SCC: %08x\n " , I2SCC);
15
+ Serial.printf (" I2SRXEN: %08x\n " , I2SRXEN);
16
+ Serial.printf (" SLCC0: %08x\n " , SLCC0);
17
+ Serial.printf (" SLCRXDC: %08x\n " , SLCRXDC);
18
+ Serial.printf (" SLCTXL: %08x\n " , SLCTXL);
19
+ Serial.printf (" SLCIE: %08x\n " , SLCIE);
20
+ }
21
+
22
+ void setup () {
23
+ Serial.begin (115200 );
24
+ WiFi.forceSleepBegin ();
25
+ delay (500 );
26
+
27
+ i2s_rxtx_begin (true , false ); // Enable I2S RX
28
+ i2s_set_rate (11025 );
29
+ dump ();
30
+
31
+ delay (1000 );
32
+
33
+ while (1 ) {
34
+ uint32_t l, r;
35
+ i2s_read_sample (&l, &r, true );
36
+ int16_t lh = l>>16 ;
37
+ int16_t rh = r>>16 ;
38
+ char withScale[256 ];
39
+ sprintf (withScale, " %d %d" , lh, rh);
40
+ Serial.println (withScale);
41
+ yield ();
42
+ }
43
+ }
44
+
45
+ void loop () {
46
+ }
47
+
48
+
You can’t perform that action at this time.
0 commit comments