/* 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
}
Пример #2
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();
}
Пример #3
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);
}
Пример #4
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;
    }
  }
}
Пример #5
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;
		}
    }
}