
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the 
// application
/////////////////////////////////////////////////////////////////////////////

/*
void INITPRG(){//LOAD PRG FROM EEPROM
	unsigned char i;
	for(i=0;i<16;i++){
		prg[i]=MIOS_EEPROM_Read(0x00 + i);
		if(prg[i]==0xFF)prg[i]=0x00;//prevent errors
		MIOS_MIDI_TxBufferPut(192 + i);//PRG CHANGE
		MIOS_MIDI_TxBufferPut(prg[i]);//PRG CHANGE NUM
	}
	return;
}
*/

void Init(void) __wparam
{

	// init default charset
	MIOS_CLCD_SpecialCharsInit(lcd_charset);
	
	// initialize the shift registers
	MIOS_SRIO_NumberSet(16);           // use up to 16 shift registers
	MIOS_SRIO_UpdateFrqSet(1);         // set update frequency

	// Touch sensor sensitivity *must* be 0, otherwise Port D.4 (CORE::J14) cannot be used as Clock Output
	MIOS_SRIO_TS_SensitivitySet(0);    // disable touch sensors

	// initialize the AIN driver
	MIOS_AIN_NumberSet(8);   // nb pots connected
	MIOS_AIN_UnMuxed();      // no AINX4 modules are used
	MIOS_AIN_DeadbandSet(7); // should be 7 when 7bit resolution is used

	// initialize the scan matrix driver
	SM_Init();

	// YOUHOOO !!!! //////////////////////////
	MCLOCK_Init();
	MCLOCK_BPMSet(120);

	//INITPAT();

	transpose=36;

	//MIDICHN(0);

	//INITPRG();
	//BS_DETECT();//BANCKSTICK DETECTION



}
