Skip to content

Commit aa83f09

Browse files
committed
drivers: i2s: stm32_sai fix drain and stop of tx stream
Fix two issues with the SAI TX Stream. 1. Drain command does not release the last memory buffer 2. TX Stream status does not change to READY after STOPPING Signed-off-by: Mario Paja <mariopaja@hotmail.com>
1 parent 93620ef commit aa83f09

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/i2s/i2s_stm32_sai.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
134134
struct i2s_stm32_sai_data *dev_data = CONTAINER_OF(hsai, struct i2s_stm32_sai_data, hsai);
135135
struct stream *stream = &dev_data->stream;
136136
struct queue_item item;
137-
void *mem_block_tmp;
138137
int ret;
139138

140139
if (stream->state == I2S_STATE_ERROR) {
@@ -154,6 +153,7 @@ void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
154153

155154
if (stream->last_block) {
156155
LOG_DBG("TX Stopped ...");
156+
stream->state = I2S_STATE_READY;
157157
goto exit;
158158
}
159159

@@ -171,8 +171,6 @@ void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
171171
goto exit;
172172
}
173173

174-
mem_block_tmp = stream->mem_block;
175-
176174
stream->mem_block = item.buffer;
177175
stream->mem_block_len = item.size;
178176

@@ -183,9 +181,9 @@ void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
183181
LOG_ERR("HAL_SAI_Transmit_DMA: <FAILED>");
184182
}
185183

186-
k_mem_slab_free(stream->i2s_cfg.mem_slab, mem_block_tmp);
187184
exit:
188-
/* EXIT */
185+
/* Free memory slab & exit */
186+
k_mem_slab_free(stream->i2s_cfg.mem_slab, stream->mem_block);
189187
}
190188

191189
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)

0 commit comments

Comments
 (0)