/*------------------------------------------------------------------- ** ** Soluciones del examen de Programación de Sistemas y Dispositivos ** Curso 2017-18, Primera Convocatoria, 23 de enero de 2018 ** **-----------------------------------------------------------------*/ /*------------------------------------------------------------------- ** Ejercicio 1 **-----------------------------------------------------------------*/ #include #include #include #include #include void timer0_isr( void ) __attribute__ ((interrupt ("IRQ"))); volatile boolean flag; volatile char ch; void main( void ) { sys_init(); uart0_init(); timers_init(); flag = FALSE; timer0_open_ms( timer0_isr, 20, TIMER_INTERVAL ); while( 1 ) if( flag ) { uart0_putchar( ch ); flag = FALSE; } } void timer0_isr( void ) { if( UFSTAT0 & 0xF ) { ch = URXH0; flag = TRUE; } I_ISPC = BIT_TIMER0; } /*------------------------------------------------------------------- ** Ejercicio 2 **-----------------------------------------------------------------*/ #include #include #include #include uint8 keypad_getchar_flag( volatile boolean *flag ) { uint8 scancode; while( PDATG & 0x2 && !*flag ); if( *flag ) return 0xff; sw_delay_ms( KEYPAD_KEYDOWN_DELAY ); scancode = keypad_scan(); while( !(PDATG & 0x2) && !*flag ); if( *flag ) return 0xff; sw_delay_ms( KEYPAD_KEYUP_DELAY ); return scancode; } /*------------------------------------------------------------------- ** Ejercicio 3 **-----------------------------------------------------------------*/ #include #include void iis_playFrom( int16 *buffer, uint32 length, uint32 decsegs ) { uint32 i; int16 ch1, ch2; for( i=decsegs*1600*2; i #include inline void iis_getSampleHalfRate( int16 *ch0, int16 *ch1 ) { while( (IISFCON & 0x0F) < 2 ); *ch0 = IISFIF; *ch1 = IISFIF; while( (IISFCON & 0x0F) < 2 ); *ch0 = (IISFIF + *ch0) >> 1; *ch1 = (IISFIF + *ch1) >> 1; } /* inline void iis_getSampleHalfRate( int16 *ch0, int16 *ch1 ) { int16 ch0aux, ch1aux; iis_getSample( &ch0aux, &ch1aux ); iis_getSample( ch0, ch1 ); *ch0 = ( ch0aux + *ch0 ) >> 1; *ch1 = ( ch1aux + *ch1 ) >> 1; } */