Esempio n. 1
0
//---------------------------
void glcd_init(void)
{
	unsigned int tcmr,tfmr;
	unsigned char i;
  
  PIO_Configure(GLcdpins,PIO_LISTSIZE(GLcdpins));
	PIO_Configure(sscPins, PIO_LISTSIZE(sscPins));	
	
	PIO_Set(&GLcdpins[3]);
	PIO_Set(&GLcdpins[4]);
	
	SSC_Configure(AT91C_BASE_SSC,AT91C_ID_SSC,500000,BOARD_MCK);
    
  tcmr=AT91C_SSC_CKS_TK|AT91C_SSC_CKO_DATA_TX|AT91C_SSC_START_CONTINOUS;
  tfmr=SSC_DATLEN(8)|SSC_DATNB(15)|SSC_FSLEN(16)|AT91C_SSC_FSOS_LOW|AT91C_SSC_FSDEN ;
    
  SSC_ConfigureTransmitter(AT91C_BASE_SSC,tcmr,tfmr);
  SSC_EnableTransmitter(AT91C_BASE_SSC);
	
	PIO_Set(&GLcdpins[5]); 
  //PIO_Clear(&GLcdpins[5]);
	for(i = 0; i < 3; i++);
  GLCD_WriteCommand((DISPLAY_ON_CMD | ON), i);
	
}	
Esempio n. 2
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 );
}
Esempio n. 3
0
File: main.c Progetto: 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);
}
Esempio n. 4
0
// ============================================================================
void lcd_init()
{
	unsigned int tcmr,tfmr;
  
  PIO_Configure(Lcdpins,PIO_LISTSIZE(Lcdpins));
	PIO_Configure(sscPins, PIO_LISTSIZE(sscPins));
	
  SSC_Configure(AT91C_BASE_SSC,AT91C_ID_SSC,500000,BOARD_MCK);
    
  tcmr=AT91C_SSC_CKS_TK|AT91C_SSC_CKO_DATA_TX|AT91C_SSC_START_CONTINOUS;
  tfmr=SSC_DATLEN(8)|SSC_DATNB(15)|SSC_FSLEN(16)|AT91C_SSC_FSOS_LOW|AT91C_SSC_FSDEN ;
    
  SSC_ConfigureTransmitter(AT91C_BASE_SSC,tcmr,tfmr);
  SSC_EnableTransmitter(AT91C_BASE_SSC);
	
	
        
	// disable peripheral mode of this pins
	clcd_Delay();
	setD4567(0);
	//---------one------
	setD4567((1<<5)|(1<<4));
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//-----------two-----------
	setD4567((1<<5)|(1<<4));
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//-------three-------------
	setD4567(1<<5);
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//--------4 _BV--dual line---------------
	lcd_command(0x28);
	
	//-----increment address, invisible cursor shift------
	lcd_command(0x0c);

	clcd_Delay();
	
	
		// disable peripheral mode of this pins
	clcd_Delay();
	setD4567(0);
	//---------one------
	setD4567((1<<5)|(1<<4));
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//-----------two-----------
	setD4567((1<<5)|(1<<4));
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//-------three-------------
	setD4567(1<<5);
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//--------4 _BV--dual line---------------
	lcd_command(0x28);
	
	//-----increment address, invisible cursor shift------
	lcd_command(0x0c);

	clcd_Delay();
	
	

  PIO_Configure(Lcdpins,PIO_LISTSIZE(Lcdpins));
	PIO_Configure(sscPins, PIO_LISTSIZE(sscPins));
	
	
		// disable peripheral mode of this pins
	clcd_Delay();
	setD4567(0);
	//---------one------
	setD4567((1<<5)|(1<<4));
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//-----------two-----------
	setD4567((1<<5)|(1<<4));
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//-------three-------------
	setD4567(1<<5);
        PIO_Set(&Lcdpins[1]);
	clcd_minDelay();
        PIO_Clear(&Lcdpins[1]);
	clcd_Delay();
	//--------4 _BV--dual line---------------
	lcd_command(0x28);
	
	//-----increment address, invisible cursor shift------
	lcd_command(0x0c);

	clcd_Delay();

}