/** * @brief Manages the full Transfer complete event. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack(void) { /* Calculate the remaining audio data in the file and the new size for the DMA transfer. If the Audio files size is less than the DMA max data transfer size, so there is no calculation to be done, just restart from the beginning of the file ... */ /* Check if the end of file has been reached */ if(AudioRemSize > 0) { /* Replay from the current position */ BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)CurrentPos, DMA_MAX(AudioRemSize)); /* Update the current pointer position */ CurrentPos += DMA_MAX(AudioRemSize); /* Update the remaining number of data to be played */ AudioRemSize -= DMA_MAX(AudioRemSize); } else { /* Set the current audio pointer position */ CurrentPos = (uint16_t *)(AUDIO_FILE_ADDRESS + AUDIO_START_OFFSET_ADDRESS); /* Replay from the beginning */ BSP_AUDIO_OUT_Play((uint16_t*)CurrentPos, (AUDIO_FILE_SIZE - AUDIO_START_OFFSET_ADDRESS)); /* Update the remaining number of data to be played */ AudioRemSize = AudioTotalSize - DMA_MAX(AudioTotalSize); /* Update the current audio pointer position */ CurrentPos += DMA_MAX(AudioTotalSize); } }
/** * @brief Manages the DMA Half Transfer complete interrupt. * @param None * @retval None */ void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) { if(AudioState == AUDIO_STATE_PLAY) { BufferCtl.state = BUFFER_OFFSET_HALF; BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&BufferCtl.buff[AUDIO_OUT_BUFFER_SIZE /2], AUDIO_OUT_BUFFER_SIZE /2); } }
/** * @brief Calculates the remaining file size and new position of the pointer. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack(void) { if(AudioState == AUDIO_STATE_PLAY) { BufferCtl.state = BUFFER_OFFSET_FULL; BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&BufferCtl.buff[0], AUDIO_OUT_BUFFER_SIZE /2); } }
/** * @brief Manages the DMA Half Transfer complete interrupt. * @param None * @retval None */ void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) { if(haudio.state == AUDIOPLAYER_PLAY) { BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&haudio.buffer[AUDIO_BUFFER_SIZE /2], AUDIO_BUFFER_SIZE /2); osMessagePut ( AudioEvent, BUFFER_OFFSET_HALF, 0); } }
/** * @brief Manages the DMA Transfer complete interrupt. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack(void) { if(haudio.state == AUDIOPLAYER_PLAY) { BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&haudio.buffer[0], AUDIO_BUFFER_SIZE /2); osMessagePut ( AudioEvent, BUFFER_OFFSET_FULL, 0); } }
/** * @brief Manages the DMA Half Transfer complete interrupt. * @param None * @retval None */ void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) { if(audio_state == AUDIO_STATE_PLAY) { buffer_ctl.offset = BUFFER_OFFSET_HALF; BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&buffer_ctl.buff[AUDIO_BUFFER_SIZE /2], AUDIO_BUFFER_SIZE /2); } }
/** * @brief Calculates the remaining file size and new position of the pointer. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack(void) { if(audio_state == AUDIO_STATE_PLAY) { buffer_ctl.offset = BUFFER_OFFSET_FULL; BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&buffer_ctl.buff[0], AUDIO_BUFFER_SIZE /2); } }
/** * @brief Manages the DMA Half Transfer complete interrupt. * @param None * @retval None */ static void AUDIO_HalfTransfer_CallBack(void) { if(haudio.in.state == AUDIO_RECORDER_PLAYING) { BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&haudio.buff[AUDIO_OUT_BUFFER_SIZE /2], AUDIO_OUT_BUFFER_SIZE /2); osMessagePut ( AudioEvent, PLAY_BUFFER_OFFSET_HALF, 0); } }
/** * @brief Manages the DMA Half Transfer complete interrupt. * @param None * @retval None */ void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) { if(audio_state == AUDIO_STATE_PLAYING) { /* Continue Playing from 2nd half buffer */ BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&buffer_ctl.buff[AUDIO_BUFFER_SIZE /2], AUDIO_BUFFER_SIZE /2); buffer_ctl.state = BUFFER_OFFSET_HALF; } }
/** * @brief Calculates the remaining file size and new position of the pointer. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack(void) { if(audio_state == AUDIO_STATE_PLAYING) { /* Continue Playing from 1st half buffer */ BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&buffer_ctl.buff[0], AUDIO_BUFFER_SIZE /2); buffer_ctl.state = BUFFER_OFFSET_FULL; } }
/** * @brief Handles AUDIO command. * @param pbuf: Pointer to buffer of data to be sent * @param size: Number of data to be sent (in bytes) * @param cmd: Command opcode * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL */ static int8_t Audio_PlaybackCmd(uint8_t *pbuf, uint32_t size, uint8_t cmd) { switch(cmd) { case AUDIO_CMD_START: BSP_AUDIO_OUT_Play((uint16_t *)pbuf, 2*size); break; case AUDIO_CMD_PLAY: BSP_AUDIO_OUT_ChangeBuffer((uint16_t *)pbuf, 2*size); break; } return 0; }
/** * @brief Calculates the remaining file size and new position of the pointer. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack() { uint32_t replay = 0; if (AudioRemSize > 0) { /* Replay from the current position */ BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)CurrentPos, DMA_MAX(AudioRemSize)); /* Update the current pointer position */ CurrentPos += DMA_MAX(AudioRemSize); /* Update the remaining number of data to be played */ AudioRemSize -= DMA_MAX(AudioRemSize); } else { /* Request to replay audio file from beginning */ replay = 1; } /* Audio sample used for play*/ if((AudioTest == 0) && (replay == 1)) { /* Replay from the beginning */ /* Set the current audio pointer position */ CurrentPos = (uint16_t *)(AUDIO_FILE_ADDRESS); /* Replay from the beginning */ BSP_AUDIO_OUT_Play(CurrentPos, DMA_MAX(AudioTotalSize)); /* Update the remaining number of data to be played */ AudioRemSize = AudioTotalSize - DMA_MAX(AudioTotalSize); /* Update the current audio pointer position */ CurrentPos += DMA_MAX(AudioTotalSize); } /*Audio sample saved during record*/ if((AudioTest == 1) && (replay == 1)) { /* Set the total number of data to be played */ AudioTotalSize = WR_BUFFER_SIZE; /* Update the remaining number of data to be played */ AudioRemSize = AudioTotalSize - DMA_MAX(AudioTotalSize); /* Update the current audio pointer position */ CurrentPos = WrBufffer + DMA_MAX(AudioTotalSize); /* Replay from the beginning */ BSP_AUDIO_OUT_Play(WrBufffer, DMA_MAX(AudioTotalSize)); } }
/** * @brief Calculates the remaining file size and new position of the pointer. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack() { uint32_t replay = 0; if (AudioRemSize > 0) { /* Replay from the current position */ if (BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)CurrentPos, DMA_MAX(AudioRemSize)) != 0) { Error_Handler(); } /* Update the current pointer position */ CurrentPos += DMA_MAX(AudioRemSize); /* Update the remaining number of data to be played */ AudioRemSize -= DMA_MAX(AudioRemSize); } else { /* Request to replay audio file from beginning */ replay = 1; } /* Audio sample used for play*/ if(replay == 1) { /* Replay from the beginning */ /* Set the current audio pointer position */ CurrentPos = (uint16_t *)(AUDIO_FILE_ADDRESS); /* Replay from the beginning */ if (BSP_AUDIO_OUT_Play(CurrentPos,DMA_MAX(AudioTotalSize)) != 0) { Error_Handler(); } /* Toggle Green Led, each time a replay is requested */ BSP_LED_Toggle(LED_GREEN); /* Update the remaining number of data to be played */ AudioRemSize = AudioTotalSize - DMA_MAX(AudioTotalSize); /* Update the current audio pointer position */ CurrentPos += DMA_MAX(AudioTotalSize); } }
/** * @brief Calculates the remaining file size and new position of the pointer. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack(void) { BufferOffset = BUFFER_OFFSET_FULL; BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&Audio_BufferStereo[0], sizeof(Audio_BufferStereo) /2); }
/** * @brief Calculates the remaining file size and new position of the pointer. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack(void) { buffer_offset = BUFFER_OFFSET_FULL; BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)&Audio_Buffer[0], AUDIO_BUFFER_SIZE / 2); }