有一个文件,我正在尝试将其传输到 SAI2。由于某些原因 ????我没有进入 DMA 回调。DMA 处于正常模式。任何人都可以阐明这一点吗?
- /* USER CODE BEGIN 2 */
- HAL_DMA_RegisterCallback(&hdma_sai2_a, HAL_DMA_XFER_CPLT_CB_ID, &DMA_XferCmplt_Callback);
- /* USER CODE END 2 */
- /* Infinite loop */
- /* USER CODE BEGIN WHILE */
- while (1)
- {
- if (ISR.DMA_TxCmplt)
- {
- ISR.DMA_TxCmplt = F;
- /*
- * after each DMA check if high current
- * if NOT then disable SAI dma
- */
- if (adcValue[1] < (HIGH_CURRENT))
- hsai_BlockA2.Instance->CR1 &= ~SAI_xCR1_DMAEN;
- }
- if (ISR.A_ConversionComplete)
- {
- ISR.A_ConversionComplete = F;
- /*
- * checks to see if actuator has
- * bottomed out due to high current
- */
- if (adcValue[1] > (HIGH_CURRENT))
- {
- hsai_BlockA2.Instance->CR1 |= SAI_xCR1_DMAEN;
- /*
- * if we are engaging and high current
- * shut off motor drive and alarm
- */
- if (ISR.Sw_EngageFlag)
- {
- HAL_GPIO_WritePin(MotorCntrlA_GPIO_Port, MotorCntrlA_Pin, GPIO_PIN_RESET);
- PlayAudio(a4_tone, a4_tone_length);
- ISR.Sw_EngageFlag = F;
- }
- /*
- * if we are dis-engaging and high current
- * shut off motor drive and alarm
- */
- if (ISR.Sw_DisengageFlag)
- {
- HAL_GPIO_WritePin(MotorCntrlB_GPIO_Port, MotorCntrlB_Pin, GPIO_PIN_RESET);
- PlayAudio(a4_tone, a4_tone_length);
- ISR.Sw_DisengageFlag = F;
- }
- //dma buffer created by PlayAudio to audio chip
- HAL_DMA_Start_IT(&hdma_sai2_a, (uint32_t)playout_buffer, (uint32_t)&hsai_BlockA2.Instance->DR, a4_tone_length);
- }
- }
- void PlayAudio(const int16_t *buffer, int32_t n_samples)
- {
- for (int i=0; i < n_samples; i++) { // Duplicate each sample. The SAI insists on 2 channels of mono
- playout_buffer[i*2] = buffer * LEVEL_REDUCtiON;
- playout_buffer[i*2+1] = buffer * LEVEL_REDUCTION;
- }
- }
- void DMA_XferCmplt_Callback(DMA_HandleTypeDef *hdma)
- {
- if (hdma == &hdma_sai2_a)
- ISR.DMA_TxCmplt = T;
- }