/* 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
void compose_draw() {
  int8_t row, msg_len, msg_pos = 0, col;
  
  clear();

  SSN = LOW;
  setDisplayStart(0);
  setCursor(0, 0);
  printf("Enter your message below:");

  row = 1;
  msg_len = strlen(compose_buffer_);
  while (row < CHAR_HEIGHT && msg_pos < msg_len + 1) {
    setCursor(row, 0);
    for (col = 0; col < CHAR_WIDTH && msg_pos < msg_len + 1; ++col, ++msg_pos) {
      if (msg_pos == msg_len) {
        if (msg_pos == cursor_pos_) {
          if (alt_on_) {
            putchar_mask('^', 0x80);
          } else {
            putchar_mask(' ', 0x80);
          }
        }
      } else {
        if (msg_pos == cursor_pos_) {
          putchar_mask(compose_buffer_[msg_pos], 0x80);
        } else {
          putchar(compose_buffer_[msg_pos]);
        }
      }
    }
    row += 1;
  }

  if (state_ == COMPOSE_STATE_CONFIRM) {
    setCursor(5, 0);
    printf("Really send? (Y/N)");
  }
  
  if (alt_on_) {
    setCursor(7, 0);
    printf("alt keys on");
  }

  SSN = HIGH;
}
Пример #4
0
/* clear all LCD pixels */
void clear() {
    u8 row;
    u8 col;

    SSN = LOW;
    setDisplayStart(0);

    /* normal display mode (not inverted) */
    setNormalReverse(0);

    for (row = 0; row <= 9; row++) {
        setCursor(row, 0);
        for (col = 0; col < WIDTH; col++)
            txData(0x00);
    }

    SSN = HIGH;
}
Пример #5
0
/* For debugging, a simple test of the radio. */
void run_test_radio() {
  uint8_t wait_col = 55;
  uint8_t num_rcvd;

  clear();
  display_print_message("SENDING MSG", 0, 0);

  radio_send_packet("CORN MUFFIN", 11);
  while (radio_still_sending()) {          
    clock_delayms(100);
    display_print_message(".", 0, wait_col);
    wait_col += 5;
  }

  display_print_message("SENT! WAITING..", 1, 0);
  
  num_rcvd = radio_recv_packet_block(buf);
  buf[21]='\0';
  display_print_message(buf, 2, 0);
    
  setDisplayStart(0);
  SSN = LOW;
  setCursor(3, 0);
  printf("%d bytes RSSI=%d LQI=%02X", num_rcvd, radio_last_rssi, radio_last_lqi);
  SSN = HIGH;

  RFST = RFST_SIDLE;
  clock_delayms(100);
  
  display_print_message("SENDING ANOTHER", 4, 0);

  radio_send_packet("POOP", 5);
  while (radio_still_sending()) {          
    clock_delayms(100);
    SSN = LOW;
    setCursor(5, 0);
    printf("%d %d %d", rf_packet_ix, rf_packet_n, rf_packet[0]); 
    SSN = HIGH;
  }

  display_print_message("SENT!", 5, 0);
}
Пример #6
0
static void send_message() {

//  while(1) {

  SSN = LOW;
  setDisplayStart(0);
  setCursor(6, 0);
  printf("Transmitting!");

  radio_send_packet(compose_buffer_);
  setCursor(7, 0);
  putchar('8');
  SSN = HIGH;
  
  while (radio_still_sending()) {
    clock_delayms(400);
    SSN = LOW;
    putchar('=');
    SSN = HIGH;
  }
  radio_listen(); // go back into receive mode

  clock_delayms(500);
  SSN = LOW;
  putchar('D');
  SSN = HIGH;
  clock_delayms(500);

//  }

  /* Reset the compose view. */
  state_ = COMPOSE_STATE_WRITING;
  compose_new_message();


  /* Switch back to the inbox view. */
  switch_state(STATE_VIEW);
}