Skip to content

Commit 36f2f6c

Browse files
committed
fix K66F & K64F implementation to support "restart" of a receiver/transmitter.
1 parent 3c7dab4 commit 36f2f6c

File tree

1 file changed

+10
-2
lines changed
  • targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api

1 file changed

+10
-2
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/sai_api.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,17 @@ sai_result_t sai_init(sai_t *obj, sai_init_t *init) {
118118
obj->channel = 0U; // we should get it from the sd pin
119119

120120
config.protocol = kSAI_BusI2S;
121-
122121
if (init->is_receiver) {
123122
config.masterSlave = kSAI_Slave;
124123
SAI_RxInit(obj->base, &config);
124+
// do this "manually" because SAI_RxSoftwareReset is not available on all targets.
125+
obj->base->RCSR |= I2S_RCSR_SR_MASK | I2S_RCSR_FR_MASK; // this will reset both chan 0 & 1.
126+
obj->base->RCSR &= ~(I2S_RCSR_SR_MASK | I2S_RCSR_FR_MASK);
125127
} else {
126128
SAI_TxInit(obj->base, &config);
129+
// do this "manually" because SAI_TxSoftwareReset is not available on all targets.
130+
obj->base->TCSR |= I2S_TCSR_SR_MASK | I2S_TCSR_FR_MASK; // this will reset both chan 0 & 1.
131+
obj->base->TCSR &= ~(I2S_TCSR_SR_MASK | I2S_TCSR_FR_MASK);
127132
}
128133

129134
/* Configure the audio format */
@@ -203,6 +208,9 @@ void sai_free(sai_t *obj) {
203208
SAI_TxEnable(obj->base, false);
204209
sai_transmitter_initialized = false;
205210
}
206-
// Should it also unclock the periph ?
211+
212+
if (!sai_receiver_initialized && !sai_transmitter_initialized) {
213+
SAI_Deinit(obj->base);
214+
}
207215
}
208216
#endif

0 commit comments

Comments
 (0)