예제 #1
0
/**
 * \brief Application entry point for ssc_dam_audio example.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main( void )
{    
    uint16_t data = 0;
    /* Disable watchdog */
    WDT_Disable( WDT ) ;
 
    /* Enable I and D cache */
    SCB_EnableICache();
    SCB_EnableDCache();

    /* Output example information */
    printf("-- SSC DMA Audio Example %s --\n\r", SOFTPACK_VERSION);
    printf("-- %s\n\r", BOARD_NAME);
    printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

    /* Configure systick for 1 ms. */
    printf( "Configure system tick to get 1ms tick period.\n\r" ) ;
    if ( TimeTick_Configure( ) )
    {
        printf("-F- Systick configuration error\n\r" ) ;
    }

    /* Configure all pins */
    PIO_Configure(pinsSsc, PIO_LISTSIZE(pinsSsc));

    /* Configure SSC */
    SSC_Configure(AUDIO_IF , 0 , SSC_MCK );
    SSC_ConfigureReceiver(AUDIO_IF,I2S_SLAVE_RX_SETTING,I2S_SLAVE_RX_FRM_SETTING);
    SSC_DisableReceiver(AUDIO_IF);
    SSC_ConfigureTransmitter(AUDIO_IF,I2S_SLAVE_TX_SETTING,I2S_SLAVE_TX_FRM_SETTING);
    SSC_DisableTransmitter(AUDIO_IF);

    /* Configure DMA */
    Dma_configure();

    /* Configure and enable the TWI (required for accessing the DAC) */
    PMC_EnablePeripheral(ID_TWIHS0);
    TWI_ConfigureMaster(TWIHS0, TWI_CLOCK, BOARD_MCK);
    TWID_Initialize(&twid, TWIHS0);
    /* Configure TWI interrupts */
    NVIC_ClearPendingIRQ(TWIHS0_IRQn);
    NVIC_EnableIRQ(TWIHS0_IRQn);

    /* check that WM8904 is present */
    WM8904_Write(&twid, WM8904_SLAVE_ADDRESS, 22, 0);
    data=WM8904_Read(&twid, WM8904_SLAVE_ADDRESS, 0);
    if( data != 0x8904){
        printf("WM8904 not found!\n\r");
        while(1);
    }
    /* Initialize the audio DAC */
    WM8904_Init(&twid, WM8904_SLAVE_ADDRESS, PMC_MCKR_CSS_SLOW_CLK); 

    /* Enable the DAC master clock */
    PMC_ConfigurePCK2(PMC_MCKR_CSS_SLOW_CLK, PMC_MCKR_PRES_CLK_1 );
    printf("Insert Line-in cable with PC Headphone output\n\r");
    PlayRecording();
    while ( 1 );
}
예제 #2
0
파일: main.c 프로젝트: gstroe/Arm
/**
 * Configure the TWI and DACC for audio output.
 * \param sampleRate Audio sample rate.
 * \param mck        MCK frequency.
 */
static void _ConfigureAudioPlay(uint32_t sampleRate, uint32_t mck)
{
	/* -- Pins Configuration -- */
	PIO_Configure(pinsAudio, PIO_LISTSIZE(pinsAudio));

	/* -- SSC Configuration -- */
	sampleRate = sampleRate; /*dummy */
	SSC_Configure(SSC, 0, mck);
	SSC_DisableTransmitter(SSC);
	SSC_DisableReceiver(SSC);
	SSC_ConfigureTransmitter(SSC, I2S_SLAVE_TX_SETTING, I2S_SLAVE_TX_FRM_SETTING);
	SSC_DisableTransmitter(SSC);

	/* Enable TWI peripheral clock */
	PMC_EnablePeripheral(ID_TWIHS0);
	/* Configure and enable the TWI (required for accessing the DAC) */
	TWI_ConfigureMaster(TWIHS0, TWI_CLOCK, mck);
	TWID_Initialize(&twid, TWIHS0);

	/* Initialize the audio DAC
	 */
	WM8904_Write(&twid, WM8904_SLAVE_ADDRESS, WM8904_REG_RESET, 0);
	Wait(100);

	/* WM8904 as master */
	if (WM8904_Read(&twid, WM8904_SLAVE_ADDRESS, 0) != 0x8904) {
		printf("WM8904 not found!\n\r");

		while (1);
	}

	WM8904_Init(&twid, WM8904_SLAVE_ADDRESS, PMC_MCKR_CSS_SLOW_CLK);
	_SyncAdjust(0);
	PMC_ConfigurePCK2(PMC_MCKR_CSS_SLOW_CLK, PMC_MCKR_PRES_CLK_1);
	/* Mute */
	AudioPlayEnable(0);
}