Skip to content

Commit aee5fd4

Browse files
mprseithinuel
authored andcommitted
Fix K64F SAI driver: receiver pops one sample from the queue and returns true if psample is NULL.
Adapt implementation to the requirements.
1 parent 3ee54cb commit aee5fd4

File tree

1 file changed

+14
-11
lines changed
  • targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api

1 file changed

+14
-11
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/sai_api.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,22 @@ bool sai_transfer(sai_t *obj, uint32_t *sample) {
155155

156156
bool ret = false;
157157
if (obj->is_receiver) {
158-
if (sample != NULL) {
159-
uint32_t flags = SAI_RxGetStatusFlag(obj->base);
160-
if ((flags & I2S_RCSR_RE_MASK) == 0) {
161-
SAI_RxEnable(obj->base, true);
162-
}
163-
ret = (flags & I2S_RCSR_FRF_MASK) == I2S_RCSR_FRF_MASK;
164-
if (ret) {
165-
*sample = SAI_ReadData(obj->base, obj->channel);
166-
}
167-
if ((flags & I2S_RCSR_FEF_MASK) == I2S_RCSR_FEF_MASK) {
168-
SAI_RxClearStatusFlags(obj->base, I2S_RCSR_FEF_MASK);
158+
uint32_t flags = SAI_RxGetStatusFlag(obj->base);
159+
if ((flags & I2S_RCSR_RE_MASK) == 0) {
160+
SAI_RxEnable(obj->base, true);
161+
}
162+
ret = (flags & I2S_RCSR_FRF_MASK) == I2S_RCSR_FRF_MASK;
163+
uint32_t tmpsample = 0;
164+
if (ret) {
165+
tmpsample = SAI_ReadData(obj->base, obj->channel);
166+
167+
if (sample != NULL) {
168+
*sample = tmpsample;
169169
}
170170
}
171+
if ((flags & I2S_RCSR_FEF_MASK) == I2S_RCSR_FEF_MASK) {
172+
SAI_RxClearStatusFlags(obj->base, I2S_RCSR_FEF_MASK);
173+
}
171174
} else {
172175
uint32_t tmp_sample = 0;
173176
if (sample != NULL) { tmp_sample = *sample; }

0 commit comments

Comments
 (0)