/* initialize the IO subsystems for the appropriate dongles */
static void io_init(void)
{
#ifdef IMME
    
 #ifdef IMMEDONGLE   // CC1110 on IMME pink dongle
    // IM-ME Dongle.  It's a CC1110, so no USB stuffs.  Still, a bit of stuff to init for talking 
    // to it's own Cypress USB chip
    P0SEL |= (BIT5 | BIT3);     // Select SCK and MOSI as SPI
    P0DIR |= BIT4 | BIT6;       // SSEL and LED as output
    P0 &= ~(BIT4 | BIT2);       // Drive SSEL and MISO low

    P1IF = 0;                   // clear P1 interrupt flag
    IEN2 |= IEN2_P1IE;          // enable P1 interrupt
    P1IEN |= BIT1;              // enable interrupt for P1.1

    P1DIR |= BIT0;              // P1.0 as output, attention line to cypress
    P1 &= ~BIT0;                // not ready to receive
 #else              // full blown IMME with screen and keyboard
    
    //Disable WDT
    IEN2&=~IEN2_WDTIE;
    IEN0&=~EA;
	setIOPorts();
	configureSPI();
	LCDReset();
  
    //Startup display.
    setDisplayStart(0);
    SSN = LOW;
    setNormalReverse(0);
    erasescreen();
    drawstr(0,0, "IMME SNIFF v0.1");
    SSN = HIGH;

    //immeLCDInitScreen();
    //sleepMillis(100);
  
 #endif 
#else       // CC1111
 #ifdef DONSDONGLES
    // CC1111 USB Dongle
    // turn on LED and BUTTON
    P1DIR |= 3;
    // Activate BUTTON - Do we need this?
    //CC1111EM_BUTTON = 1;

 #else
    // CC1111 USB (ala Chronos watch dongle), we just need LED
    P1DIR |= 3;

 #endif      // CC1111

 #ifndef VIRTUAL_COM
    // Turn off LED
    LED = 0;
 #endif

#endif // conditional
}
Exemple #2
0
/********************************************************************
 * Function:        static void InitializeSystem(void)
 * Overview:        InitializeSystem is a centralize initialization
 *                  routine. All required USB initialization routines
 *                  are called from here.
 *
 *                  User application initialization routine should
 *                  also be called from here.                  
 *******************************************************************/
static void InitializeSystem(void)
{
        ANSELA = 0x00;
        ANSELB = 0x00;
        ANSELC = 0x00;

        TRISA = 0; 
        LATA = 0; 

        TRISB = 0; 
        LATB = 0; 

        TRISC = 0; 
        LATC = 0; 

        LCDReset();

//	The USB specifications require that USB peripheral devices must never source
//	current onto the Vbus pin.  Additionally, USB peripherals should not source
//	current on D+ or D- when the host/hub is not actively powering the Vbus line.
//	When designing a self powered (as opposed to bus powered) USB peripheral
//	device, the firmware should make sure not to turn on the USB module and D+
//	or D- pull up resistor unless Vbus is actively powered.  Therefore, the
//	firmware needs some means to detect when Vbus is being powered by the host.
//	A 5V tolerant I/O pin can be connected to Vbus (through a resistor), and
// 	can be used to detect when Vbus is high (host actively powering), or low
//	(host is shut down or otherwise not supplying power).  The USB firmware
// 	can then periodically poll this I/O pin to know when it is okay to turn on
//	the USB module/D+/D- pull up resistor.  When designing a purely bus powered
//	peripheral device, it is not possible to source current on D+ or D- when the
//	host is not actively providing power on Vbus. Therefore, implementing this
//	bus sense feature is optional.  This firmware can be made to use this bus
//	sense feature by making sure "USE_USB_BUS_SENSE_IO" has been defined in the
//	HardwareProfile.h file.    
    #if defined(USE_USB_BUS_SENSE_IO)
        tris_usb_bus_sense = INPUT_PIN; // See HardwareProfile.h
    #endif
    
//	If the host PC sends a GetStatus (device) request, the firmware must respond
//	and let the host know if the USB peripheral device is currently bus powered
//	or self powered.  See chapter 9 in the official USB specifications for details
//	regarding this request.  If the peripheral device is capable of being both
//	self and bus powered, it should not return a hard coded value for this request.
//	Instead, firmware should check if it is currently self or bus powered, and
//	respond accordingly.  If the hardware has been configured like demonstrated
//	on the PICDEM FS USB Demo Board, an I/O pin can be polled to determine the
//	currently selected power source.  On the PICDEM FS USB Demo Board, "RA2" 
//	is used for	this purpose.  If using this feature, make sure "USE_SELF_POWER_SENSE_IO"
//	has been defined in HardwareProfile - (platform).h, and that an appropriate I/O pin 
//  has been mapped	to it.
    #if defined(USE_SELF_POWER_SENSE_IO)
    tris_self_power = INPUT_PIN;	// See HardwareProfile.h
    #endif
    
    UserInit();

    USBDeviceInit();	//usb_device.c.  Initializes USB module SFRs and firmware
    					//variables to known states.
}//end InitializeSystem
Exemple #3
0
int main( int argc, char *argv[])
{
	// Imposto i valori iniziali della dimensione dell'LCD...
	rect.x=LCD_X_OFFSET;
	rect.y=LCD_Y_OFFSET;
	rect.w=LCD_WIDTH-1;
	rect.h=LCD_HEIGHT-1;
	rect.r=rect.g=rect.b=0;

	font.x=LCD_X_OFFSET;
	font.y=LCD_Y_OFFSET;
	font.size=SMALL;
	font.fr=font.fg=font.fb=250;	// foreground == WHITE
	font.br=font.bg=font.bb=0;	// background == BLACK

	parse_opts(argc, argv);
	
	// Inizializzo l'LCD della Nokia, controller compatibile al PCF8833
	InitLcd( PCF8833, device);
	
	if ( noreset==0) LCDReset();
	
	if ( clearcmd) {
		LCDDrawScreen( RGB( rect.r, rect.g, rect.b));
		usleep( 250000);
	}

	if ( isStringToDsiplay) {
		if ( strlen( StringToDsiplay)==1 && StringToDsiplay[0]=='-') {	// stdin
			StringToDsiplay=readLine( stdin );
		}

		LCDSetCurr_XY( rect.x, rect.y);
		LCDPutStr( StringToDsiplay, font.x, font.y, font.size, RGB(font.fr,font.fg, font.fb), RGB(font.br,font.bg, font.bb));
	}

	if ( (filename != (const char*)NULL) && isImage) LCDWritebmp( (const char*)filename, rect.x, rect.y, rect.w, rect.h);
	//if ( (FullScreenFilename != (const char*)NULL) && isFullScreen) LCDWriteRGB( (const char*)FullScreenFilename);
	if ( (FullScreenFilename != (const char*)NULL) && isFullScreen) LCDWriteFullScreenRGB_2( (const char*)FullScreenFilename);
	if ( (MoveFilename != (const char*)NULL) && isMovie) {
		if ( LoopFor == -1) {
			if (LCDMovieRGB( (const char*)MoveFilename)) {
				return 1;
			}
		} else {
			while( LoopFor--) {
				if (LCDMovieRGB( (const char*)MoveFilename)) {
					return 1;
				}
			}
		}
	}


	return 0;
}
Exemple #4
0
void main(void) {
  //Disable WDT
  IEN2&=~IEN2_WDTIE;
  IEN0&=~EA;
  
  xtalClock(); // fastest speed
  setIOPorts();
  configureSPI();
  LCDReset();
  setDisplayStart(0);
  
  //Start the game right-off.
  zombiegotcha();
}
Exemple #5
0
void LCDInit(void)
{
	int i;

	LCDReset();

	LCDSend(PSWRESET);			// software reset
	SpinDelay(100);
	LCDSend(PSLEEPOUT);			// exit sleep mode
	LCDSend(PBSTRON);			// booster on
	LCDSend(PDISPON);			// display on
	LCDSend(PNORON);			// normal on
	LCDSend(PMADCTL);			// rotate display 180 deg
	LCDSend(0xC0);

	LCDSend(PCOLMOD);			// color mode
	LCDSend(0x02);				// 8bpp color mode

    LCDSend(PSETCON);			// set contrast
    LCDSend(0xDC);

	// clear display
    LCDSetXY(0,0);
	LCDSend(PRAMWR);			// Write to display
	i=LCD_XRES*LCD_YRES;
	while(i--) LCDSend(WHITE);
  
  // test text on different colored backgrounds
	LCDString(" The quick brown fox  ",	(char *)&FONT6x8,1,1+8*0,WHITE  ,BLACK );
	LCDString("  jumped over the     ",	(char *)&FONT6x8,1,1+8*1,BLACK  ,WHITE );
	LCDString("     lazy dog.        ",	(char *)&FONT6x8,1,1+8*2,YELLOW ,RED   );
	LCDString(" AaBbCcDdEeFfGgHhIiJj ",	(char *)&FONT6x8,1,1+8*3,RED    ,GREEN );
	LCDString(" KkLlMmNnOoPpQqRrSsTt ",	(char *)&FONT6x8,1,1+8*4,MAGENTA,BLUE  );
	LCDString("UuVvWwXxYyZz0123456789",	(char *)&FONT6x8,1,1+8*5,BLUE   ,YELLOW);
	LCDString("`-=[]_;',./~!@#$%^&*()",	(char *)&FONT6x8,1,1+8*6,BLACK  ,CYAN  );
	LCDString("     _+{}|:\\\"<>?     ",(char *)&FONT6x8,1,1+8*7,BLUE  ,MAGENTA);
  
	// color bands
	LCDFill(0, 1+8* 8, 132, 8, BLACK);
	LCDFill(0, 1+8* 9, 132, 8, WHITE);
	LCDFill(0, 1+8*10, 132, 8, RED);
	LCDFill(0, 1+8*11, 132, 8, GREEN);
	LCDFill(0, 1+8*12, 132, 8, BLUE);
	LCDFill(0, 1+8*13, 132, 8, YELLOW);
	LCDFill(0, 1+8*14, 132, 8, CYAN);
	LCDFill(0, 1+8*15, 132, 8, MAGENTA);

}
Exemple #6
0
int main(void)
{
	int i;
	xtalClock();
	setIOPorts();
	configureSPI();
	LCDReset();

	clear();
	SSN = LOW;
	for (i = 0; i < 8; i++) {
		setCursor(i, i*8);
		printf("KEEP HACKING");
	}
	SSN = HIGH;

	while (1);
}
Exemple #7
0
void main(void) {
  bit test_radio = 0;
  bit bounce_radio = 0;

  /* Initialize app modules. Not reinitialized upon reset. */
  message_init();
  compose_init();
  inbox_init();
  info_init();
  
reset:
  sleepy_ = 0;
  state_ = STATE_VIEW;
  
  if (bounce_radio) {
    repeater_mode();
  }
  
  /* Initialize system modules. */
  clock_init();
  setIOPorts();
  configureSPI();
  LCDReset();
  radio_init();
  random_init();
  
  inbox_draw();

  if (test_radio) {
    run_test_radio();
  }

  /* Main loop. */
  radio_listen();
  while (1) {
    poll_keyboard();

    /* Send and receive messages. */
    message_tick();

    /* Handle background tasks (like progress bar) */
    if (compose_tick() && state_ == STATE_COMPOSE) {
      compose_draw();
    }
    if (info_tick() && state_ == STATE_INFO) {
      info_draw();
    }

    /* go to sleep (more or less a shutdown) if power button pressed */
    if (sleepy_) {
      clear();
      clock_delayms(1000);
      SSN = LOW;
      LCDPowerSave();
      SSN = HIGH;
      sleep();
      /* reset on wake */
      goto reset;
    }
  }
}
Exemple #8
0
void main(void) {
	u16 i;
    pktbuf = radio_getbuf();
    ch = 0;

reset:
	centerFreq = DEFAULT_FREQ;
	userFreq = centerFreq;
	sleepy = 0;
    packetDone = 0;

	xtalClock();
	setIOPorts();
	configureSPI();
	LCDReset();
	radio_init();
    clear();
    printDebugHeader();
    setFrequency(centerFreq);
    printDebugFrequency(centerFreq, ch);

	while (1) {
		poll_keyboard();
        pollPacket();

        /* Show current RSSI */
        SSN = LOW;
        setCursor(5, 78);
        printf("%3u", (RSSI ^ 0x80));
        SSN = HIGH;

        /* TODO Mod this when more than one channel */
		if (userFreq != centerFreq) {
			centerFreq = setFrequency(userFreq);
            chan_table[ch].ss = 0;
            chan_table[ch].max = 0;
            printDebugFrequency(centerFreq, ch);
        }

		/* Go to sleep (more or less a shutdown) if power button pressed */
		if (sleepy) {
			clear();
			sleepMillis(1000);
			SSN = LOW;
			LCDPowerSave();
			SSN = HIGH;

			while (1) {
				sleep();

				/* Power button depressed long enough to wake? */
				sleepy = 0;
				for (i = 0; i < DEBOUNCE_COUNT; i++) {
					sleepMillis(DEBOUNCE_PERIOD);
					if (keyscan() != KPWR) sleepy = 1;
				}
				if (!sleepy) break;
			}

			/* Reset on wake */
			goto reset;
		}
    }
}