Example #1
0
void BSP_Init(void)
{
    SystemInit();
	SysTick_init();		
	MYLCD_Init();
	USART1_Init();
	Normal_Init();
	DAC_Initialize();
	DAC_Output(1, 2048);
	DAC_Output(2, 2048);
}
Example #2
0
void SysTick_Handler(void) {
	if(voiceIndex > 2000)
		DAC_Output((Instrument_CurrentVoltage(voiceIndex) - 2048) /* * Instrument_EnvelopeMultiplier(voiceIndex) / ENVELOPE_SCALE */ + 2048);
	Note *newNote = Song_CurrentNote();
	if(newNote != previousNote) {
		previousNote = newNote;
		if(newNote->pitch == 0)
			NVIC_ST_RELOAD_R = 0;
		else
			NVIC_ST_RELOAD_R = 800000 / newNote->pitch;
		voiceIndex %= 64;
	}
	voiceIndex += 1;
}