void play_song(int* notebuf, int* accidentalsbuf, int* octavebuf, int length) { PWM_1_Start(); PWM_2_Start(); PWM_3_Start(); PWM_4_Start(); for (int i = 0; i < length; i+=4) { PWM_1_WriteCompare((note_lengths[note_lookup[notebuf[i]]+accidentalsbuf[i]]/2)>>octavebuf[i]); PWM_1_WritePeriod(note_lengths[note_lookup[notebuf[i]]+accidentalsbuf[i]]>>octavebuf[i]); PWM_1_WriteCounter(0); PWM_2_WriteCompare((note_lengths[note_lookup[notebuf[i+1]]+accidentalsbuf[i]]/2)>>octavebuf[i+1]); PWM_2_WritePeriod(note_lengths[note_lookup[notebuf[i+1]]+accidentalsbuf[i]]>>octavebuf[i+1]); PWM_2_WriteCounter(0); PWM_3_WriteCompare((note_lengths[note_lookup[notebuf[i+2]]+accidentalsbuf[i]]/2)>>octavebuf[i+2]); PWM_3_WritePeriod(note_lengths[note_lookup[notebuf[i+2]]+accidentalsbuf[i]]>>octavebuf[i+2]); PWM_3_WriteCounter(0); PWM_4_WriteCompare((note_lengths[note_lookup[notebuf[i+3]]+accidentalsbuf[i]]/2)>>octavebuf[i+3]); PWM_4_WritePeriod(note_lengths[note_lookup[notebuf[i+3]]+accidentalsbuf[i]]>>octavebuf[i+3]); PWM_4_WriteCounter(0); if (Keypad_1_Status_Reg_Read() & 0x10) break; CyDelay(TEMPO_MS); } PWM_1_Stop(); PWM_2_Stop(); PWM_3_Stop(); PWM_4_Stop(); }
/******************************************************************************* * Function Name: PWM_1_Sleep ******************************************************************************** * * Summary: * Stops the component operation and saves the user configuration. * * Parameters: * None * * Return: * None * *******************************************************************************/ void PWM_1_Sleep(void) { if(0u != (PWM_1_BLOCK_CONTROL_REG & PWM_1_MASK)) { PWM_1_backup.enableState = 1u; } else { PWM_1_backup.enableState = 0u; } PWM_1_Stop(); PWM_1_SaveConfig(); }
/******************************************************************************* * Function Name: PWM_1_Sleep ******************************************************************************** * * Summary: * Disables block's operation and saves the user configuration. Should be called * just prior to entering sleep. * * Parameters: * None * * Return: * None * * Global variables: * PWM_1_backup.PWMEnableState: Is modified depending on the enable * state of the block before entering sleep mode. * *******************************************************************************/ void PWM_1_Sleep(void) { #if(PWM_1_UseControl) if(PWM_1_CTRL_ENABLE == (PWM_1_CONTROL & PWM_1_CTRL_ENABLE)) { /*Component is enabled */ PWM_1_backup.PWMEnableState = 1u; } else { /* Component is disabled */ PWM_1_backup.PWMEnableState = 0u; } #endif /* (PWM_1_UseControl) */ /* Stop component */ PWM_1_Stop(); /* Save registers configuration */ PWM_1_SaveConfig(); }
uint8 campbell_cond_stop() { /* Stop of all components */ ADC_DelSig_1_Stop(); Comp_1_Stop(); Comp_2_Stop(); Comp_3_Stop(); //Comp_4_Stop(); AMux_1_Stop(); Sample_Hold_1_Stop(); Sample_Hold_2_Stop(); Sample_Hold_3_Stop(); //Sample_Hold_4_Stop(); PWM_1_Stop(); PWM_2_Stop(); Cond_Vout_Write(1u); return 1u; }