void __attribute__ ((interrupt)) TIMER1_IRQHandler() {
    // Clear interrupt flag 
    *TIMER1_IFC = 1;
    
	//check if at end of note, may go to next note
	if ( counter >= current_note_length ) {
        counter = 0;
        note_counter++;
    } else {
        counter++;
    }
	
	//check if at end of song, resets values if true and end function
    if ( note_counter >= current_song->length ) {
        music_cleanup();
        gpio_led_clear();
        dac_disable();
        timer_disable();
        sleep_setup(0b110);
        return;
    }
    
	//creates temp pointer to note, play that frequency
    Note* n_temp = current_song->notes[note_counter];
    int offset = (song_iterator % n_temp->length);
    music_note_to_dac(n_temp, offset);
    song_iterator++;
}
static void dac_setup(void)
{
    gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO5);
    dac_disable(CHANNEL_2);
    dac_disable_waveform_generation(CHANNEL_2);
    dac_enable(CHANNEL_2);
    dac_set_trigger_source(DAC_CR_TSEL2_SW);
}
static void dac_setup(void)
{
	gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO5);
	dac_disable(CHANNEL_2);
	dac_disable_waveform_generation(CHANNEL_2);
	dac_enable(CHANNEL_2);
	dac_set_trigger_source(DAC_CR_TSEL2_SW);
}
Exemple #4
0
void funcgen_plat_output(int channel, bool enable) {
	switch (channel) {
	case 1: if (enable) {
			dac_enable(CHANNEL_2);
		} else {
			dac_disable(CHANNEL_2);
		}
		break;
	case 0:
	default:
		if (enable) {
			dac_enable(CHANNEL_1);
		} else {
			dac_disable(CHANNEL_1);
		}
		break;
	}
}
Exemple #5
0
void sound_stop (void)
{
	TCC0.INTCTRLA = TC_OVFINTLVL_OFF_gc;
	dac_disable();
	
	//Enable power reduction for TCC0 
	PR.PRPC |= 0x01;

	WavFifo = 0;		/* Unregister FIFO control structure */
}
Exemple #6
0
void analogout_free(dac_t *obj)
{
    MBED_ASSERT(obj);
    struct system_pinmux_config pin_conf;

    dac_disable(&dac_instance);
    pin_conf.direction = SYSTEM_PINMUX_PIN_DIR_INPUT;
    pin_conf.input_pull = SYSTEM_PINMUX_PIN_PULL_UP;
    pin_conf.powersave    = false;
    pin_conf.mux_position = SYSTEM_PINMUX_GPIO;
    system_pinmux_pin_set_config(PA02, &pin_conf);  /*PA02 is the only DAC pin available*/
}
Exemple #7
0
void analogout_free(dac_t *obj)
{
    MBED_ASSERT(obj);
    struct system_pinmux_config pin_conf;

    dac_disable(&(obj->dac_instance));
    pin_conf.direction = SYSTEM_PINMUX_PIN_DIR_INPUT;
    pin_conf.input_pull = SYSTEM_PINMUX_PIN_PULL_UP;
    pin_conf.powersave    = false;
    pin_conf.mux_position = SYSTEM_PINMUX_GPIO;
    system_pinmux_pin_set_config(obj->pin, &pin_conf);
}
Exemple #8
0
void dac_init(void)
{
	rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_120MHZ]); //nastaveni globalnich hodin
	rcc_periph_clock_enable(RCC_GPIOA);     //pusteni hodin pro port A
	rcc_periph_clock_enable(RCC_DAC);       //pusteni hodin pro DAC

	gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4); //pin4 portu A nako analogovy bez pullu/pulldown
	dac_disable(CHANNEL_1);         //zakazani kanalu 1 DAC
	dac_disable_waveform_generation(CHANNEL_1);     //bastaveni generovani signalu na kanalu 1 DAC
	dac_enable(CHANNEL_1);          //Povoleni DAC na kanalu 1
	dac_set_trigger_source(DAC_CR_TSEL1_SW); //Triger kanalu 1 nastaven na softwarovy
}
Exemple #9
0
//=======================================================================================
//		audio dac ramp down 
//=======================================================================================
void avi_audio_decode_rampdown(void)
{
	dac_disable();
}