Beispiel #1
0
void configure_playback(void) {
    int i;
    // Defaults, just in case read fails
    FX1mode = 0x00;
    FX2mode = 0x01;
    tempo = 0x80;
    latchHold = 0xFFFF;


    // Misc initialisation
    pressed = 0x0000;
    playing = 0x0000;
    looping = 0x0000;
    loopMod = 0xFFFF;

    // Retrieve values from config file
    FIL cfgFile;
    sdcard_openFile(&cfgFile, 16);
    FX1mode = sdcard_readByte(&cfgFile);
    FX2mode = sdcard_readByte(&cfgFile);
    tempo = sdcard_readByte(&cfgFile);

    for (i = 0; i < 16; i++)
    {
        // Shift in the latch/hold bit
        uint8_t lhBit = sdcard_readByte(&cfgFile);
        latchHold |= ((!!lhBit) << i);
        // Read the loop mode bit
        btnLoopMode[i] = sdcard_readByte(&cfgFile);
        // Set position ptr to 0
        whereLastPress[i] = 0;
    }
    sdcard_closeFile(&cfgFile);

}
Beispiel #2
0
void timers_init(void) {
	unsigned long ulDACPeriod, ulPktPeriod, ulTempoPeriod, ulPollPeriod;

	// Initialise the output buffer
	int i;
	for (i = 0; i < BUFFER_SIZE; i++)
	{
		oBuff[i] = 0x8000;
	}

	// Open file pointers
	for (i = 0; i < 16; i++)
	{
		sdcard_openFile(&fPtrs[i], i);
	}

	// Configure the Tempo LED
	ROM_GPIOPinTypeGPIOOutput(LED_TEMPO);
	ROM_GPIOPinWrite(LED_TEMPO, 0x00);

	// Configure the DAC output timer - Timer 0
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
	ulDACPeriod = (ROM_SysCtlClockGet() / 44100); // 44.1 kHz for DAC samples
	ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ulDACPeriod);
	// Set up interrupt
	ROM_IntPrioritySet(INT_TIMER0A, 0x00);
	ROM_IntEnable(INT_TIMER0A);
	ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	// Enable Timer
	ROM_TimerEnable(TIMER0_BASE, TIMER_A);

	// Configure the SD Card buffer timer - Timer 1
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
	ulPktPeriod = (ROM_SysCtlClockGet() / BUFFERUPDATE_FREQ); // 100 Hz for DAC samples
	ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, ulPktPeriod);
	// Set up interrupt
	ROM_IntPrioritySet(INT_TIMER1A, 0x40);
	ROM_IntEnable(INT_TIMER1A);
	ROM_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	// Enable Timer
	ROM_TimerEnable(TIMER1_BASE, TIMER_A);

	// Configure the Tempo timer - Timer 2
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
	ROM_TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);
	ulTempoPeriod = (ROM_SysCtlClockGet() / TEMPO_FREQUENCY);
	ROM_TimerLoadSet(TIMER2_BASE, TIMER_A, ulTempoPeriod);
	// Set up interrupt
	ROM_IntPrioritySet(INT_TIMER2A, 0x20);
	ROM_IntEnable(INT_TIMER2A);
	ROM_TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	// Enable Timer
	ROM_TimerEnable(TIMER2_BASE, TIMER_A);

	// Configure the poll timer
	ulPollPeriod = (ROM_SysCtlClockGet() / POLL_FREQUENCY);
	ROM_TimerLoadSet(TIMER2_BASE, TIMER_B, ulPollPeriod);
	// Set up interrupt
	ROM_IntPrioritySet(INT_TIMER2B, 0x20);
	ROM_IntEnable(INT_TIMER2B);
	ROM_TimerIntEnable(TIMER2_BASE, TIMER_TIMB_TIMEOUT);
	// Enable Timer
	ROM_TimerEnable(TIMER2_BASE, TIMER_B);

}