@@ -53,8 +53,6 @@ typedef struct slc_queue_item {
53
53
volatile uint32_t owner : 1 ; // DMA can change this value
54
54
uint32_t * buf_ptr ;
55
55
struct slc_queue_item * next_link_ptr ;
56
- // This is my own way of tracking item ID
57
- volatile uint32_t myid ;
58
56
} slc_queue_item_t ;
59
57
60
58
typedef struct i2s_state {
@@ -158,13 +156,16 @@ static void ICACHE_RAM_ATTR i2s_slc_queue_append_item(i2s_state_t *ch, uint32_t
158
156
}
159
157
160
158
// This routine is called as soon as the DMA routine has something to tell us. All we
161
- // handle here is the RX_EOF_INT status, which indicate the DMA has sent a buffer whose
159
+ // handle here is the *_EOF_INT status, which indicate the DMA has finished a buffer whose
162
160
// descriptor has the 'EOF' field set to 1.
163
161
void ICACHE_RAM_ATTR i2s_slc_isr (void ) {
162
+ ETS_SLC_INTR_DISABLE ();
163
+ // TODO - Seems like there's a chance of missed IRQ notification because the clear happens at least 1 cycle
164
+ // after the status read. Not sure if there's a HW way to prevernt this, even atomic SWAP
165
+ // won't help since these are 2 separate addresses. Ugh!
164
166
uint32_t slc_intr_status = SLCIS ;
165
167
SLCIC = 0xFFFFFFFF ;
166
168
if (slc_intr_status & SLCIRXEOF ) {
167
- ETS_SLC_INTR_DISABLE ();
168
169
tx_irqs ++ ;
169
170
slc_queue_item_t * finished_item = (slc_queue_item_t * )SLCRXEDA ;
170
171
memset ((void * )finished_item -> buf_ptr , 0x00 , SLC_BUF_LEN * 4 );//zero the buffer so it is mute in case of underflow
@@ -175,20 +176,17 @@ void ICACHE_RAM_ATTR i2s_slc_isr(void) {
175
176
if (tx -> callback ) {
176
177
tx -> callback ();
177
178
}
178
- ETS_SLC_INTR_ENABLE ();
179
179
}
180
180
if (slc_intr_status & SLCITXEOF ) {
181
- ETS_SLC_INTR_DISABLE ();
182
181
rx_irqs ++ ;
183
182
slc_queue_item_t * finished_item = (slc_queue_item_t * )SLCTXEDA ;
184
183
finished_item -> owner = 1 ; // Or else RX just stops
185
- finished_item -> myid ++ ;
186
184
i2s_slc_queue_append_item (rx , finished_item -> buf_ptr );
187
185
if (rx -> callback ) {
188
186
rx -> callback ();
189
187
}
190
- ETS_SLC_INTR_ENABLE ();
191
188
}
189
+ ETS_SLC_INTR_ENABLE ();
192
190
}
193
191
194
192
void i2s_set_callback (void (* callback ) (void )){
@@ -213,14 +211,13 @@ static void _alloc_channel(i2s_state_t *ch) {
213
211
ch -> slc_items [x ].blocksize = SLC_BUF_LEN * 4 ;
214
212
ch -> slc_items [x ].buf_ptr = (uint32_t * )& ch -> slc_buf_pntr [x ][0 ];
215
213
ch -> slc_items [x ].next_link_ptr = (x < (SLC_BUF_CNT - 1 ))?(& ch -> slc_items [x + 1 ]):(& ch -> slc_items [0 ]);
216
- ch -> slc_items [x ].myid = 0 ;
217
214
}
218
215
}
219
216
#if 0
220
217
void dumprx ()
221
218
{
222
219
for (int i = 0 ; i < SLC_BUF_CNT ; i ++ ) {
223
- printf ("%d: %d %d %d %d %d %d %p %p\n" , i , rx -> slc_items [ i ]. myid , rx -> slc_items [i ].owner , rx -> slc_items [i ].eof , rx -> slc_items [i ].sub_sof , rx -> slc_items [i ].datalen , rx -> slc_items [i ].blocksize ,
220
+ printf ("%d: %d %d %d %d %d %d %p %p\n" , i , 0 , rx -> slc_items [i ].owner , rx -> slc_items [i ].eof , rx -> slc_items [i ].sub_sof , rx -> slc_items [i ].datalen , rx -> slc_items [i ].blocksize ,
224
221
rx -> slc_items [i ].buf_ptr , rx -> slc_items [i ].next_link_ptr );
225
222
}
226
223
}
0 commit comments