@@ -339,12 +339,12 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
339339
340340 // Only PA04 (DAC_CH1) is supported as left channel.
341341 if (left_channel != & pin_PA04 ) {
342- mp_raise_ValueError ( MP_ERROR_TEXT ( "AudioOut requires pin A0 (PA04)" ) );
342+ raise_ValueError_invalid_pin_name ( MP_QSTR_left_channel );
343343 }
344344
345345 // Right channel must be PA05 (DAC_CH2 / A1) if provided.
346346 if (right_channel != NULL && right_channel != & pin_PA05 ) {
347- mp_raise_ValueError ( MP_ERROR_TEXT ( "AudioOut right channel requires pin A1 (PA05)" ) );
347+ raise_ValueError_invalid_pin_name ( MP_QSTR_right_channel );
348348 }
349349
350350 // Claim pins first. The pin-claim system is what serialises this driver
@@ -393,7 +393,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
393393 __HAL_RCC_DAC_CLK_ENABLE ();
394394 handle .Instance = DAC ;
395395 if (HAL_DAC_Init (& handle ) != HAL_OK ) {
396- mp_raise_ValueError (MP_ERROR_TEXT ("DAC init error " ));
396+ mp_raise_ValueError (MP_ERROR_TEXT ("DAC Device Init Error " ));
397397 }
398398 }
399399
@@ -403,7 +403,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
403403 ch_cfg .DAC_Trigger = DAC_TRIGGER_NONE ;
404404 ch_cfg .DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE ;
405405 if (HAL_DAC_ConfigChannel (& handle , & ch_cfg , DAC_CHANNEL_1 ) != HAL_OK ) {
406- mp_raise_ValueError (MP_ERROR_TEXT ("DAC channel config error " ));
406+ mp_raise_ValueError (MP_ERROR_TEXT ("DAC Channel Init Error " ));
407407 }
408408
409409 // Ramp DAC output up to quiescent value to prevent an audible pop.
@@ -447,9 +447,8 @@ void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t *self) {
447447
448448void common_hal_audioio_audioout_play (audioio_audioout_obj_t * self ,
449449 mp_obj_t sample , bool loop ) {
450- if (common_hal_audioio_audioout_deinited (self )) {
451- mp_raise_ValueError (MP_ERROR_TEXT ("AudioOut is deinited" ));
452- }
450+ // The shared-bindings layer guards every entry point with
451+ // check_for_deinit, so a deinited self can't reach this function.
453452 common_hal_audioio_audioout_stop (self );
454453
455454 // Extract sample format metadata via the canonical accessors so the
@@ -536,15 +535,15 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self,
536535 tim6_handle .Init .ClockDivision = TIM_CLOCKDIVISION_DIV1 ;
537536 tim6_handle .Init .AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE ;
538537 if (HAL_TIM_Base_Init (& tim6_handle ) != HAL_OK ) {
539- mp_raise_RuntimeError (MP_ERROR_TEXT ("TIM6 init failed" ));
538+ mp_raise_RuntimeError_varg (MP_ERROR_TEXT ("%q init failed" ), MP_QSTR_TIM6 );
540539 }
541540
542541 // TRGO = Update event → triggers DAC conversion each period.
543542 TIM_MasterConfigTypeDef master_cfg = {0 };
544543 master_cfg .MasterOutputTrigger = TIM_TRGO_UPDATE ;
545544 master_cfg .MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE ;
546545 if (HAL_TIMEx_MasterConfigSynchronization (& tim6_handle , & master_cfg ) != HAL_OK ) {
547- mp_raise_RuntimeError (MP_ERROR_TEXT ("TIM6 master cfg failed" ));
546+ mp_raise_RuntimeError_varg (MP_ERROR_TEXT ("%q init failed" ), MP_QSTR_TIM6 );
548547 }
549548 // NOTE: ports/atmel-samd's audio_dma_setup_playback handles AUDIO_DMA_OK
550549 // and two specific error codes but lets any other non-OK return fall
@@ -582,7 +581,7 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self,
582581 hdma -> Init .Priority = DMA_PRIORITY_VERY_HIGH ;
583582 hdma -> Init .FIFOMode = DMA_FIFOMODE_DISABLE ;
584583 if (HAL_DMA_Init (hdma ) != HAL_OK ) {
585- mp_raise_RuntimeError (MP_ERROR_TEXT ("DMA init failed" ));
584+ mp_raise_RuntimeError_varg (MP_ERROR_TEXT ("%q init failed" ), MP_QSTR_DMA );
586585 }
587586 __HAL_LINKDMA (& handle , DMA_Handle1 , * hdma );
588587
@@ -605,7 +604,7 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self,
605604 hdma_r -> Init .Priority = DMA_PRIORITY_VERY_HIGH ;
606605 hdma_r -> Init .FIFOMode = DMA_FIFOMODE_DISABLE ;
607606 if (HAL_DMA_Init (hdma_r ) != HAL_OK ) {
608- mp_raise_RuntimeError (MP_ERROR_TEXT ("DMA init failed (right)" ) );
607+ mp_raise_RuntimeError_varg (MP_ERROR_TEXT ("%q init failed" ), MP_QSTR_DMA );
609608 }
610609 __HAL_LINKDMA (& handle , DMA_Handle2 , * hdma_r );
611610
@@ -630,7 +629,7 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self,
630629 }
631630 m_free (self -> dma_buffer );
632631 self -> dma_buffer = NULL ;
633- mp_raise_RuntimeError (MP_ERROR_TEXT ("DAC DMA start failed" ));
632+ mp_raise_RuntimeError_varg (MP_ERROR_TEXT ("%q init failed" ), MP_QSTR_DAC );
634633 }
635634
636635 if (self -> right_channel != NULL ) {
@@ -646,7 +645,7 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self,
646645 self -> dma_buffer = NULL ;
647646 m_free (self -> dma_buffer_r );
648647 self -> dma_buffer_r = NULL ;
649- mp_raise_RuntimeError (MP_ERROR_TEXT ("DAC DMA start failed (right channel)" ) );
648+ mp_raise_RuntimeError_varg (MP_ERROR_TEXT ("%q init failed" ), MP_QSTR_DAC );
650649 }
651650 }
652651
0 commit comments