Ejemplo n.º 1
0
void SPIClass::begin(MOSI mosi, MISO miso, SCK sck)
{
    USPICTL=BIT(SPICP1)|BIT(SPIEN)|BIT(SPIBLOCK);

    pinMode(mosi, OUTPUT);
    pinMode(miso, INPUT);
    pinMode(sck, OUTPUT);

    pinModePPS(sck,HIGH);
    pinModePPS(mosi,HIGH);

    outputPinForFunction( mosi, IOPIN_USPI_MOSI );
    outputPinForFunction( sck, IOPIN_USPI_SCK);
    inputPinForFunction( miso, IOPIN_USPI_MISO );
}
Ejemplo n.º 2
0
/* Constructor
 */
ZPU_WM8731::ZPU_WM8731(uint32_t clock_i, uint32_t bclk_o, uint32_t dac_data_o, uint32_t dac_lrc_o)
{
    pinMode(clock_i, INPUT );                      // Define FPGA pin as an input
    inputPinForFunction(clock_i, WM8731_CLOCK);    // Connect FPGA line to PPS bit

    pinMode(bclk_o, OUTPUT);
    pinModePPS(bclk_o, HIGH);
    outputPinForFunction(bclk_o, WM8731_BCLK);
    
    pinMode(dac_data_o, OUTPUT);
    pinModePPS(dac_data_o, HIGH);
    outputPinForFunction(dac_data_o, WM8731_DAC_DATA);
    
    pinMode(dac_lrc_o, OUTPUT);
    pinModePPS(dac_lrc_o, HIGH);
    outputPinForFunction(dac_lrc_o, WM8731_DAC_LRC);
}
Ejemplo n.º 3
0
void RETROCADE::initSD()
{
  int i;
  USPICTL=BIT(SPICP1)|BIT(SPICPOL)|BIT(SPISRE)|BIT(SPIEN)|BIT(SPIBLOCK);
  outputPinForFunction( SDIPIN, IOPIN_USPI_MOSI );
  pinModePPS(SDIPIN,HIGH);
  pinMode(SDIPIN,OUTPUT);

  outputPinForFunction( SCKPIN, IOPIN_USPI_SCK);
  pinModePPS(SCKPIN,HIGH);
  pinMode(SCKPIN,OUTPUT);

  pinModePPS(CSPIN,LOW);
  pinMode(CSPIN,OUTPUT);

  inputPinForFunction( SDOPIN, IOPIN_USPI_MISO );
  pinMode(SDOPIN,INPUT);    

  Serial.println("Starting SD Card");
  
	digitalWrite(CSPIN,HIGH);

	for (i=0;i<51200;i++)
		USPIDATA=0xff;

	digitalWrite(CSPIN,LOW);

	for (i=0;i<51200;i++)
		USPIDATA=0xff;  

  if (!SD.begin(CSPIN)) {
	Serial.println("init failed!");
	Serial.println(SD.errorCode());
        sdFs = false;
  } else {
  	Serial.println("done.");
	sdFs = true;
  }  
  //root = SD.open("/");
}
Ejemplo n.º 4
0
void SPIClass::begin(MOSI mosi, MISO miso, SCK sck)
{
    if (deviceBegin(VENDOR_ZPUINO, PRODUCT_ZPUINO_SPI)!=0) {
        return;
    }

    REG(0)=BIT(SPICP1)|BIT(SPIEN)|BIT(SPIBLOCK);

    pinMode(mosi, OUTPUT);
    pinMode(miso, INPUT);
    pinMode(sck, OUTPUT);

    pinModePPS(sck,HIGH);
    pinModePPS(mosi,HIGH);

    int ppspin = DeviceRegistry::getPPSOutputPin( getSlot(), PPS_INDEX_MOSI );
    outputPinForFunction( mosi, ppspin );
    ppspin = DeviceRegistry::getPPSOutputPin( getSlot(), PPS_INDEX_SCK );
    outputPinForFunction( sck, ppspin);
    ppspin = DeviceRegistry::getPPSInputPin( getSlot(), PPS_INDEX_MISO );
    inputPinForFunction( miso, ppspin );
}
Ejemplo n.º 5
0
void setup(void)
{
	// setup 1KHz timer
	setupTimer();	
	
	// init LCD
	LCD_init();
	
	// init PPS
	// SPKR thru PPS
	pinMode(OUTPUTPIN,OUTPUT);
	pinModePPS(OUTPUTPIN,HIGH);
	outputPinForFunction( OUTPUTPIN, 14); 	
	
	/* set all the channels to same frequency, max level, no noise */
	/*unsigned int slots[] = { 10, 11 };
	unsigned int i;
	ym2149_channel_t chan;

	for (i = 0; i < sizeof(slots) / sizeof(slots[0]); ++i)
	{
		
		// select the YM module
		setDeviceSlot(slots[i]);

		for (chan = YM2149_CH_A; chan < YM2149_CH_MAX; ++chan)
		{
			setChannelFrequency(chan, 0x0500);
			setChannelMixerNoise(chan, 1); // 1 means disabled
			setChannelMixerTone(chan, 0);
			setChannelVolume(chan, 0x0f);
		}
	}*/


	setDeviceSlot(10);
	setChannelFrequency(YM2149_CH_C, 0x0500);
	setChannelMixerNoise(YM2149_CH_C, 1); // 1 means disabled
	setChannelMixerTone(YM2149_CH_C, 0);
	setChannelVolume(YM2149_CH_C, 0x0f);

	pokey_setDeviceSlot(12); 
	pokey_channel_t pokchan;
	for (pokchan = POKEY_CH_A; pokchan < POKEY_CH_D; ++pokchan) 
	{ 
		pokey_setChannelPeriodMultiplier(pokchan, 0x90); 
		pokey_setChannelControl(pokchan, 0x00); 	 
	}
	pokey_setAudioCtrl(0x0);
}
Ejemplo n.º 6
0
void Zpu_ILI9340::begin(void) 
{
//  SPI.begin(WISHBONESLOT(_slot));
//  SPI.begin(MOSI(_mosi), MISO(_miso), SCK(_sclk));
//  SPI.setClockDivider(SPI_CLOCK_DIV4); // 8 MHz (full! speed!)
//  SPI.setBitOrder(MSBFIRST);
//  SPI.setDataMode(SPI_MODE0);

  USPICTL=BIT(SPICP1)|BIT(SPICPOL)|BIT(SPISRE)|BIT(SPIEN)|BIT(SPIBLOCK);

  pinModePPS(_mosi,HIGH);
  pinMode(_mosi, OUTPUT);
  outputPinForFunction(_mosi, IOPIN_USPI_MOSI );

  pinModePPS(_sclk,HIGH);
  pinMode(_sclk, OUTPUT);
  outputPinForFunction(_sclk, IOPIN_USPI_SCK);

  pinMode(_miso, INPUT);
  inputPinForFunction(_miso, IOPIN_USPI_MISO );

  pinModePPS(_cs, LOW);
  pinMode(_cs, OUTPUT);

  pinModePPS(_dc, LOW);
  pinMode(_dc, OUTPUT);

  pinModePPS(_rst, LOW);
  pinMode(_rst, OUTPUT);

  digitalWrite(_rst, LOW);
  digitalWrite(_sclk, LOW);
  digitalWrite(_mosi, LOW);

  // toggle RST low to reset
  digitalWrite(_rst, HIGH);
  delay(5);
  digitalWrite(_rst, LOW);
  delay(20);
  digitalWrite(_rst, HIGH);
  delay(150);

  writecommand(0xEF);
  writedata(0x03);
  writedata(0x80);
  writedata(0x02);

  writecommand(0xCF);  
  writedata(0x00); 
  writedata(0xC1); 
  writedata(0x30); 

  writecommand(0xED);  
  writedata(0x64); 
  writedata(0x03); 
  writedata(0x12); 
  writedata(0x81); 
 
  writecommand(0xE8);  
  writedata(0x85); 
  writedata(0x00); 
  writedata(0x78); 

  writecommand(0xCB);  
  writedata(0x39); 
  writedata(0x2C); 
  writedata(0x00); 
  writedata(0x34); 
  writedata(0x02); 
 
  writecommand(0xF7);  
  writedata(0x20); 

  writecommand(0xEA);  
  writedata(0x00); 
  writedata(0x00); 
 
  writecommand(ILI9340_PWCTR1);    //Power control 
  writedata(0x23);   //VRH[5:0] 
 
  writecommand(ILI9340_PWCTR2);    //Power control 
  writedata(0x10);   //SAP[2:0];BT[3:0] 
 
  writecommand(ILI9340_VMCTR1);    //VCM control 
  writedata(0x3e); //�Աȶȵ���
  writedata(0x28); 
  
  writecommand(ILI9340_VMCTR2);    //VCM control2 
  writedata(0x86);  //--
 
  writecommand(ILI9340_MADCTL);    // Memory Access Control 
  writedata(ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);

  writecommand(ILI9340_PIXFMT);    
  writedata(0x55); 
  
  writecommand(ILI9340_FRMCTR1);    
  writedata(0x00);  
  writedata(0x18); 
 
  writecommand(ILI9340_DFUNCTR);    // Display Function Control 
  writedata(0x08); 
  writedata(0x82);
  writedata(0x27);  
 
  writecommand(0xF2);    // 3Gamma Function Disable 
  writedata(0x00); 
 
  writecommand(ILI9340_GAMMASET);    //Gamma curve selected 
  writedata(0x01); 
 
  writecommand(ILI9340_GMCTRP1);    //Set Gamma 
  writedata(0x0F); 
  writedata(0x31); 
  writedata(0x2B); 
  writedata(0x0C); 
  writedata(0x0E); 
  writedata(0x08); 
  writedata(0x4E); 
  writedata(0xF1); 
  writedata(0x37); 
  writedata(0x07); 
  writedata(0x10); 
  writedata(0x03); 
  writedata(0x0E); 
  writedata(0x09); 
  writedata(0x00); 
  
  writecommand(ILI9340_GMCTRN1);    //Set Gamma 
  writedata(0x00); 
  writedata(0x0E); 
  writedata(0x14); 
  writedata(0x03); 
  writedata(0x11); 
  writedata(0x07); 
  writedata(0x31); 
  writedata(0xC1); 
  writedata(0x48); 
  writedata(0x08); 
  writedata(0x0F); 
  writedata(0x0C); 
  writedata(0x31); 
  writedata(0x36); 
  writedata(0x0F); 

  writecommand(ILI9340_SLPOUT);    //Exit Sleep 
  delay(120); 
  writecommand(ILI9340_DISPON);    //Display on 
}
Ejemplo n.º 7
0
void TimerClass::setPWMOutputPin(int pin)
{
	pinMode(pin,OUTPUT);
	pinModePPS(pin,HIGH);
	outputPinForFunction( pin, IOPIN_TIMER1_OC);
}
Ejemplo n.º 8
0
void RETROCADE::setupMegaWing()
{
  activeChannel = 0;
  activeInstrument = 0;
  smallfsActiveTrack = 0;
  timeout = TIMEOUTMAX;
  smallFs = false;
  sdFs = false;
  invadersCurLoc = 0;
  invadersCurSeg = 1;
  invadersTimer = INVADERSTIMERMAX;
  lcdMode = MENU_WELCOME;
  buttonPressed = None;
  

  SIGMADELTACTL=0x3;
  //Move the audio output to the appropriate pins on the Papilio Hardware
  pinMode(AUDIO_J1_L,OUTPUT);
  digitalWrite(AUDIO_J1_L,HIGH);
  //outputPinForFunction(AUDIO_J1_L, IOPIN_SIGMADELTA0);
  outputPinForFunction(AUDIO_J1_L, 8);
  pinModePPS(AUDIO_J1_L, HIGH);

  pinMode(AUDIO_J1_R,OUTPUT);
  digitalWrite(AUDIO_J1_R,HIGH);
  outputPinForFunction(AUDIO_J1_R, 8);
  //outputPinForFunction(AUDIO_J1_R, IOPIN_SIGMADELTA1);
  pinModePPS(AUDIO_J1_R, HIGH);
  
  pinMode(AUDIO_J2_L,OUTPUT);
  digitalWrite(AUDIO_J2_L,HIGH);
  outputPinForFunction(AUDIO_J2_L, 8);
  pinModePPS(AUDIO_J2_L, HIGH);

  pinMode(AUDIO_J2_R,OUTPUT);
  digitalWrite(AUDIO_J2_R,HIGH);
  outputPinForFunction(AUDIO_J2_R, 8);
  pinModePPS(AUDIO_J2_R, HIGH);
  
  //Move the second serial port pin to where we need it, this is for MIDI input.
  pinMode(SERIAL1RXPIN,INPUT);
  inputPinForFunction(SERIAL1RXPIN, 1);
  pinMode(SERIAL1TXPIN,OUTPUT);
  //digitalWrite(SERIAL1TXPIN,HIGH);
  outputPinForFunction(SERIAL1TXPIN, 6);
  pinModePPS(SERIAL1TXPIN, HIGH);
 
   //Start SmallFS
  if (SmallFS.begin()<0) {
	Serial.println("No SmalLFS found.");
  }
  else{
     Serial.println("SmallFS Started.");
     smallFs = true; 
  }
 
  //Setup SD Card
  initSD();
  
  //Setup Joystick
  pinMode(JSELECT, INPUT); 
  pinMode(JUP, INPUT); 
  pinMode(JDOWN, INPUT); 
  pinMode(JLEFT, INPUT); 
  pinMode(JRIGHT, INPUT);  
 
  //Setup LCD
  pinMode(WING_C_14, OUTPUT);     //Set contrast to GND
  digitalWrite(WING_C_14, LOW);   //Set contrast to GND    
 // set up the LCD's number of columns and rows:
 lcd.begin(16,2);
 // clear the LCD screen:
 lcd.clear();
 lcd.setCursor(0,1);
 lcd.print("RetroCade Synth");

 //Setup timer for YM and mod players
  TMR0CTL = 0;
  TMR0CNT = 0;
  TMR0CMP = ((CLK_FREQ/2) / FREQ )- 1;
  TMR0CTL = _BV(TCTLENA)|_BV(TCTLCCM)|_BV(TCTLDIR)|
  	_BV(TCTLCP0) | _BV(TCTLIEN);
  INTRMASK = BIT(INTRLINE_TIMER0); // Enable Timer0 interrupt
  INTRCTL=1;    

}