/*------------------------------------------------------------------------------------------------------------*/ char VS10xx_INIT( void ) { // Steuerleitungen einrichten für MP3-Decoder POWER_DDR |= ( 1<<POWER ); RESET_DDR |= ( 1<<RESET ); BSYNC_DDR |= ( 1<<BSYNC ); DREQ_DDR &= ~( 1<<DREQ ); SS2_DDR |= ( 1<<SS2 ); // Steuerleitungen auf Startzustand setzen RESET_PORT |= ( 1<<RESET ); BSYNC_PORT &= ~( 1<<BSYNC ); DREQ_PORT &= ~( 1<<DREQ ); SS2_PORT |= ( 1<<SS2 ); SPI2_init(); // MP3-Decoder einschalten POWER_PORT |= ( 1<<POWER ); // 100ms warten bis Spannung stabil ist und Controller sie initialisiert hat CLOCK_delay( 1000 ); // reset the decoder CLOCK_delay(30); VS10xx_reset(HARD_RESET); CLOCK_delay(30); VS10xx_nulls(32); VS10xx_reset(SOFT_RESET); VS10xx_set_xtal (); // Wenn xtal nicht erfolgreich gesetzt ist REv.2 der Hardware vorhanden und muss per // HardwareSPI angesteuert werden if ( VS10xx_read( VS10xx_Register_CLOCKF ) != VS10xx_CLOCKF ) { hardwarespi=1; SPI0_init( SPI_HALF_SPEED ); // reset the decoder CLOCK_delay(30); if ( VS10xx_reset(HARD_RESET) == RESET_FAILED ) return( RESET_FAILED ); CLOCK_delay(30); VS10xx_nulls(32); if ( VS10xx_reset(SOFT_RESET) == RESET_FAILED ) return( RESET_FAILED ); VS10xx_set_xtal (); } // VS10xx_vol ( 200, 200 ); VS10xx_vol ( 255, 255 ); return( RESET_OK ); }
void SPI_init(){ switch(Current_SPI){ case SPI1: SPI1_init(); break; case SPI2: SPI2_init(); break; default: return; // error } }
void nrf_init (void) { SPI2_init (); nrf_reset (); nrf_write_reg (R_CONFIG, R_CONFIG_PRIM_RX | R_CONFIG_PWR_UP | R_CONFIG_EN_CRC); nrf_write_reg (R_EN_AA, 0); nrf_write_reg (R_RF_SETUP, R_RF_SETUP_DR_2M | R_RF_SETUP_RF_PWR_3); nrf_write_reg (R_STATUS, R_STATUS_MAX_RT); }