Exemplo n.º 1
0
void TicTacToeDisplay_runTest()
{
	display_init();
		TicTacToeDisplay_init();

	char number = buttons_read();
	char read = number & HEX_F;
	char s_read = switches_read();
	display_clearOldTouchData();

	bool go = true;
	while(go)
	{
		s_read = switches_read();
		number = buttons_read();
		read = number & HEX_F;
		utils_msDelay(50);


	if(display_isTouched())
	{
		utils_msDelay(50);
		display_clearOldTouchData();

		if(display_isTouched())
			TicTacToeDisplay_touchScreenComputeBoardRowColumn(&row, &column);

		if(s_read == 0x1)
		{
		TicTacToeDisplay_drawO(row, column);display_clearOldTouchData();
		}

		else
		{
		TicTacToeDisplay_drawX(row, column);display_clearOldTouchData();
		}


		display_clearOldTouchData();


	}
	if((read & 0x1) == HEX_ONE)
	{
		TicTacToeDisplay_init();
	}

	 if((read & 0x2) == 0x02)
	{
		TicTacToeDisplay_complete();
		go = false;
	}



	display_clearOldTouchData();


	}
}
Exemplo n.º 2
0
void ticTacToeDisplay_runTest()
{
    while(1) //until button 1 is pressed
    {
        while(buttons_read() != (TICTACTOEDISPLAY_BTN0_ON))//until button 0 is pressed
        {
            if(buttons_read() == (TICTACTOEDISPLAY_BTN1_ON))//button has been pressed
            {
                display_setTextSize(TICTACTOEDISPLAY_TEXT_SIZE);  // this sets the text size
                display_setCursor(TICTACTOEDISPLAY_HALF_WIDTH-TICTACTOEDISPLAY_ONE_THIRD_WIDTH, //position x coordinate of cursor
                        TICTACTOEDISPLAY_HALF_HEIGHT - TICTACTOEDISPLAY_ONE_SIXTH_HEIGHT);//position y coordinate of cursor
                display_println("Game Over!");//print to the lcd
                return;//return out of both loops immediately
            }

            if(display_isTouched())
            {
                display_clearOldTouchData(); // Throws away all previous touch data.
                uint8_t row, column;
                ticTacToeDisplay_touchScreenComputeBoardRowColumn(&row, &column);//compute location of square
                if(switches_read() == TICTACTOEDISPLAY_SWITCH0_ON)//SW0 is up
                {
                    ticTacToeDisplay_drawO(row, column);//draw O character
                }
                if(switches_read() == TICTACTOEDISPLAY_SWITCH0_OFF)//SW0 is down
                {
                    ticTacToeDisplay_drawX(row, column);//draw X character
                }
            }
        }
        ticTacToeDisplay_init();//clear the screen
    }
}
// Runs a test of the display. Does the following.
// Draws the board. Each time you touch one of the screen areas, the screen will paint
// an X or an O, depending on whether switch 0 (SW0) is slid up (O) or down (X).
// When BTN0 is pushed, the screen is cleared. The test terminates when BTN1 is pushed.
void ticTacToeDisplay_runTest() {
	uint8_t* row = 0;
	uint8_t* column = 0;
	ticTacToeDisplay_init();
	while(1){
		ticTacToeDisplay_touchScreenComputeBoardRowColumn(row , column );

		if ((buttons_read() & BUTTON_ISOLATE_BITS) & BUTTONS_ISOLATE_BIT_B0) {
			ticTacToeDisplay_clear();
		}
		if ((buttons_read() & BUTTON_ISOLATE_BITS) & BUTTONS_ISOLATE_BIT_B1) {
			ticTacToeDisplay_gameOver();
			break;
		}
	}
}
Exemplo n.º 4
0
/**
Gazell Link Layer Configuration tool main application.
*/
void main(void)
{
  bool radio_activity;
  uint8_t buttons;
  
  mcu_init();
 
  gzll_init();
  app_init();
  lcd_init();
     
  EA = 1;

  app_execute(0);

  while(1)
  {       
    buttons = buttons_read();
    radio_activity = com_execute();
   
    if(buttons || radio_activity)
    {
      app_execute(buttons);       
    }
  }
}
Exemplo n.º 5
0
void buttons_runTest() {
  buttons_init();  // Initialize buttons
  display_init();  // Initialize display, which sets Rotation = 1 by default
  display_fillScreen(DISPLAY_BLACK); // blank the screen
  display_setTextColor(DISPLAY_BLACK);  // Change text color to black
  display_setTextSize(BUTTONS_TEXT_SIZE); // Make text larger

  // Set the values of the global variables
  x_max = display_width();
  y_max = display_height();

  // Set the values of screen positions
  x_fourth = FOURTH(x_max);
  x_half = HALF(x_max);
  x_three_fourths = THREE_FOURTHS(x_max);
  y_fourth = FOURTH(y_max);
  y_half = HALF(y_max);
  y_three_fourths = THREE_FOURTHS(y_max);

  // Do an initial read of button values
  int32_t buttonValues = buttons_read();

  // Until all 4 BTNS are pressed simultaneously, write info to the LCD
  while (buttonValues != BUTTONS_ALL_BTNS_ON) {

    // Draw the Rects/Text on the LCD corresponding to current buttons
    buttons_write_LCD(buttonValues);

    // Poll new value of buttons
    buttonValues = buttons_read();
  }

  // After all buttons are pushed simultaneously, finish test.
  display_fillScreen(DISPLAY_BLACK);  // blank screen
  display_setTextColor(DISPLAY_CYAN); // change text color
  display_setCursor(0,0);  // reset cursor to origin
  display_println("Button Test Finished!");  // print that the test is complete
}
Exemplo n.º 6
0
Arquivo: timer.c Projeto: fuxii/sd2iec
/* Called by the timer interrupt when the button state has changed */
static void buttons_changed(void) {
  /* Check if the previous state was stable for two ticks */
  if (time_after(ticks, lastbuttonchange + DEBOUNCE_TICKS)) {
    if (active_keys & IGNORE_KEYS) {
      active_keys &= ~IGNORE_KEYS;
    } else if (BUTTON_PREV && /* match only if PREV exists */
               !(buttonstate & (BUTTON_PREV|BUTTON_NEXT))) {
      /* Both buttons held down */
        active_keys |= KEY_HOME;
    } else if (!(buttonstate & BUTTON_NEXT) &&
               (buttons_read() & BUTTON_NEXT)) {
      /* "Next" button released */
      active_keys |= KEY_NEXT;
    } else if (BUTTON_PREV && /* match only if PREV exists */
               !(buttonstate & BUTTON_PREV) &&
               (buttons_read() & BUTTON_NEXT)) {
      active_keys |= KEY_PREV;
    }
  }

  lastbuttonchange = ticks;
  buttonstate = buttons_read();
}
Exemplo n.º 7
0
//*********************************************************************************************
// verifySequence_runTest()
// Tests the verifySequence state machine.
// It prints instructions to the touch-screen. The user responds by tapping the
// correct colors to match the sequence.
// Users can test the error conditions by waiting too long to tap a color or
// by tapping an incorrect color.
//*********************************************************************************************
void verifySequence_runTest()
{
    display_init();  // Always must do this.
    buttons_init();  // Need to use the push-button package so user can quit.
    int16_t sequenceLength = ONE;  // Start out with a sequence length of 1.
    verifySequence_printInstructions(sequenceLength, false);  // Tell the user what to do.
    utils_msDelay(MESSAGE_WAIT_MS);  // Give them a few seconds to read the instructions.
    simonDisplay_drawAllButtons()    // Now, draw the buttons.
    // Set the test sequence and it's length.
    globals_setSequence(verifySequence_testSequence, MAX_TEST_SEQUENCE_LENGTH);
    globals_setSequenceIterationLength(sequenceLength);
    // Enable the verifySequence state machine.
    verifySequence_enable();           // Everything is interlocked, so first enable the machine.
    while (!(buttons_read() & BTN0))// Need to hold button until it quits as you might be stuck in a delay.
    {
        // verifySequence uses the buttonHandler state machine so you need to "tick" both of them.
        verifySequence_tick();  // Advance the verifySequence state machine.
        simonbuttonHandler_tick();   // Advance the buttonHandler state machine.
        utils_msDelay(ONE_MS);       // Wait 1 ms.
        // If the verifySequence state machine has finished, check the result, otherwise just keep ticking both machines.
    if (verifySequence_isComplete())
    {
      if (verifySequence_isTimeOutError())
      {                      // Was the user too slow?
        verifySequence_printInfoMessage(user_time_out_e);         // Yes, tell the user that they were too slow.
      }
      else if (verifySequence_isUserInputError())
      {             // Did the user tap the wrong color?
        verifySequence_printInfoMessage(user_wrong_sequence_e);   // Yes, tell them so.
      }
      else
      {
        verifySequence_printInfoMessage(user_correct_sequence_e); // User was correct if you get here.
      }
      utils_msDelay(MESSAGE_WAIT_MS);                            // Allow the user to read the message.
      sequenceLength = incrementSequenceLength(sequenceLength);  // Increment the sequence.
      globals_setSequenceIterationLength(sequenceLength);  // Set the length for the verifySequence state machine.
      verifySequence_printInstructions(sequenceLength, V_ENABLED);    // Print the instructions.
      utils_msDelay(MESSAGE_WAIT_MS);                            // Let the user read the instructions.
      verifySequence_drawButtons();                              // Draw the buttons.
      verifySequence_disable();                                  // Interlock: first step of handshake.
      verifySequence_tick();                                     // Advance the verifySequence machine.
      utils_msDelay(ONE_MS);                                          // Wait for 1 ms.
      verifySequence_enable();                                   // Interlock: second step of handshake.
      utils_msDelay(ONE_MS);                                          // Wait 1 ms.
    }
  }
  verifySequence_printInfoMessage(user_quit_e);  // Quitting, print out an informational message.
}
Exemplo n.º 8
0
int main(void)
{

	SetupHardware();

	data_init(&data, &calib_params); //put some values into structure for testing
	ahrs_init(&data, &u8g, &calib_params);

	GlobalInterruptEnable();

	for (;;)
	{
		//time between updates
		timer_old = timer;
		timer = get_timer_ms();
		if (timer > timer_old) {
			t_period = (timer - timer_old) / 1000.0; //in seconds
		}
		else
			t_period = 0;
		data.time_period = t_period;

		//read data - sensors
		adxl345_read(&data); //accelerometer read
		l3g4200d_read_seq(&data); //gyroscope read
		hmc5883l_read(&data); //magnetometer read

		//buttons
		buttons_read(&data);

		//compute
		//ahrs_orientation_from_gyro(&data);
		ahrs_orientation(&data);
		//ahrs_orientation_from_accel_mag(&data);

		HID_Task();
		USB_USBTask();
	}
}
Exemplo n.º 9
0
void ticTacToeControl_tick() //actions and transitions of state machine
{
    debugStatePrint(); //print state for debugging

    switch (TTT_State) //state machine actions
    {
    case TTT_init_st: //inital entry state
        readTimer = 0; //initialize read timer
        firstTouchTimer = 0; //set to zero
        adTimer = 0; //set to zerio
        break;
    case TTT_draw_instructions_st:
        //draw print the instructions
        display_setTextSize(TEXT_SIZE); //how big
        display_setTextColor(DISPLAY_WHITE);//set the color
        display_setCursor(INSTRUCTIONS_LOCATION_X, INSTRUCTIONS_LOCATION_Y);
        display_println(INSTRUCTIONS);//print instructions
        break;
    case TTT_let_user_read_st:
        readTimer++; //increase read timer
        break;
    case TTT_wait_first_touch_st:
        firstTouchTimer++; //increment first touch wait timer
        break;
    case TTT_wait_for_settle_st:
        adTimer++; //increment timer for settling
        break;
    case TTT_computer_play_st:
        if (playerX) //computer is O
        {
            minimax_computeNextMove(&currentBoard, false, &controlTouchRow, &controlTouchColumn); //its always computing computers move, so just set the bool to false
            ticTacToeDisplay_drawO(controlTouchRow, controlTouchColumn);
            //mark that board space
            currentBoard.squares[controlTouchRow][controlTouchColumn] = MINIMAX_OPPONENT_SQUARE;
        }

        else //computer went first, is X
        {
            minimax_computeNextMove(&currentBoard, false, &controlTouchRow, &controlTouchColumn); //its always computing computers move, so just set the bool to false
            ticTacToeDisplay_drawX(controlTouchRow, controlTouchColumn);
            //mark that board space
            currentBoard.squares[controlTouchRow][controlTouchColumn] = MINIMAX_OPPONENT_SQUARE;
        }

        break;
    case TTT_user_play_st:
        //read button value here, and check in transitions
        newBTNValue = buttons_read();

        invalidMoveFlag = false; // reset the flag

        //reset wait for settle timer
        adTimer = 0;

        if (playerX) //player went first, is X
        {
            ticTacToeDisplay_touchScreenComputeBoardRowColumn(&controlTouchRow, &controlTouchColumn);
            if(currentBoard.squares[controlTouchRow][controlTouchColumn] == MINIMAX_EMPTY_SQUARE) //check square is empty
            {
                ticTacToeDisplay_drawX(controlTouchRow, controlTouchColumn); //draw the x
                //mark that board space
                currentBoard.squares[controlTouchRow][controlTouchColumn] = MINIMAX_PLAYER_SQUARE; //mark move in board
            }
            else
                invalidMoveFlag = true; //player tried to go in occupied square
        }

        else //player is O
        {
            ticTacToeDisplay_touchScreenComputeBoardRowColumn(&controlTouchRow, &controlTouchColumn);
            if(currentBoard.squares[controlTouchRow][controlTouchColumn] == MINIMAX_EMPTY_SQUARE) //check square is empty
            {
                ticTacToeDisplay_drawO(controlTouchRow, controlTouchColumn); //draw the O
                //mark that board space
                currentBoard.squares[controlTouchRow][controlTouchColumn] = MINIMAX_PLAYER_SQUARE; //mark move in board
            }
            else
                invalidMoveFlag = true; //player tried to go in occupied square
        }
        break;
    case TTT_wait_touch_st:
    //just wait
    case TTT_end_st:
        //read button value here, and check in transitions
        //only reset at end game
        newBTNValue = buttons_read();

    default:
        break;
    }



    //////////////////////////////////////////////////////////////////////////////////////////////////



    switch (TTT_State) //state machine transitions
    {
    case TTT_init_st: //inital entry state
        TTT_State = TTT_draw_instructions_st; //move to instructions state
        break;
    case TTT_draw_instructions_st:
        TTT_State = TTT_let_user_read_st; //go straight to reading after instructions are drawn
        break;
    case TTT_let_user_read_st:
        if (readTimer == TTT_READ_EXPIRED)
        {
            TTT_State = TTT_wait_first_touch_st; //wait for touching
            ticTacToeDisplay_reset();//draw empty board. mealey action
        }
        break;
    case TTT_wait_first_touch_st:
    {
        if (firstTouchTimer == TTT_FIRST_TOUCH_EXPIRED) //if the wait is expired
        {
            //computer goes first. computer is X
            TTT_State = TTT_computer_play_st;
            playerX = false;
        }
        else if (display_isTouched()) //human touched a spot
        {
            //human goes first. is X
            TTT_State = TTT_wait_for_settle_st;
            playerX = true;
        }
    }
    break;
    case TTT_wait_for_settle_st:
        if (adTimer == ADTIMER_EXPIRE) //gave touch screen time to settle
        {
            TTT_State = TTT_user_play_st; //go to user play
        }
        break;
    case TTT_computer_play_st:
        // if board full, go to end game
        if (ticTacToeControl_checkEndGame(&currentBoard, false)) //pass in the board, does matter what the bool is, just need an endgame score
            TTT_State = TTT_end_st;
        else
            TTT_State = TTT_wait_touch_st; //go to place to wait for player to touch
        break;
    case TTT_user_play_st:
        if (ticTacToeControl_checkEndGame(&currentBoard, true)) //pass in the board, does matter what the bool is, just need an endgame score
            TTT_State = TTT_end_st;

        else if(invalidMoveFlag) //player tried to go in occupied space
        {
            TTT_State = TTT_wait_touch_st; //wait for another touch
        }

        else
            TTT_State = TTT_computer_play_st; //go to computer move


        break;
    case TTT_wait_touch_st:
        if (ticTacToeControl_checkEndGame(&currentBoard, playerX)) //pass in the board, does matter what the bool is, just need an endgame score
            TTT_State = TTT_end_st;
        else if (display_isTouched()) //done waiting
        {
            TTT_State = TTT_wait_for_settle_st; //go settle state
        }
        break;
    case TTT_end_st:
        ticTacToeControl_checkResetBTN(); //check if button has been pressed,
        break;
    default:
        printf("ERROR: missed transition\n\r");
        break;
    }
}
Exemplo n.º 10
0
void buttons_runTest() {
    buttons_init();
    // Initialize the display for writing.
    display_init();
    // Clear the screen; make the whole thing black.
    display_fillScreen(DISPLAY_BLACK);
    // Set up a var for storing the current value of the buttons.
    // This will be updated every time our while loop cycles.
    uint32_t newVal = 0;
    // Set up a var for storing the previous value of the buttons.
    // This will be updated every time our while loop cycles.
    uint32_t lastVal = 0;
    // Set the text size to a value of 2.
    display_setTextSize(BUTTONS_TEXT_SIZE);

    // As long as all four buttons are not all pressed at once, do this:
    while(newVal ^ BUTTONS_ARE_ALL_PRESSED) {
        // Copy newVal into lastVal because we're going to update newVal.
        lastVal = newVal;
        // Read the state of the buttons into newVal.
        newVal = buttons_read();
        // We need to check whether BUTTONS_BUTTON1's corresponding square has
        // already been drawn. We don't want to draw it again if it's
        // already there.
        if(!(lastVal & BUTTONS_BUTTON1) && (newVal & BUTTONS_BUTTON1)) {
            // Fill the far right square with yellow.
            display_fillRect(BUTTONS_BUTTON1_X_CORD, 0, BUTTONS_ALL_BUTTONS_X_LENGTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_YELLOW);
            // Set our text cursor to a good place in the center of the square.
            display_setCursor(BUTTONS_BUTTON1_CURSOR_X_CORD, BUTTONS_ALL_BUTTONS_CURSOR_Y_CORD);
            // Make the text color black.
            display_setTextColor(DISPLAY_BLACK);
            // Write BTN0 in the center of the square.
            display_println(BUTTONS_BUTTON1_TEXT);
        }
        // If the square is drawn, and button 1 is no longer pressed:
        else if((lastVal & BUTTONS_BUTTON1) && !(newVal & BUTTONS_BUTTON1)) {
            // Write a black square on top of the yellow square.
            display_fillRect(BUTTONS_BUTTON1_X_CORD, 0, BUTTONS_ALL_BUTTONS_X_LENGTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_BLACK);
        }
        // Repeat the process for BUTTONS_BUTTON1 for all other buttons:
        if(!(lastVal & BUTTONS_BUTTON2) && (newVal & BUTTONS_BUTTON2)) {
            // Draw a green square
            display_fillRect(BUTTONS_BUTTON2_X_CORD, 0, BUTTONS_ALL_BUTTONS_X_LENGTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_GREEN);
            // Set the cursor
            display_setCursor(BUTTONS_BUTTON2_CURSOR_X_CORD, BUTTONS_ALL_BUTTONS_CURSOR_Y_CORD);
            // Set text color to black
            display_setTextColor(DISPLAY_BLACK);
            // Write BTN1
            display_println(BUTTONS_BUTTON2_TEXT);
        }
        // If the BUTTONS_BUTTON2 square is there and BUTTONS_BUTTON2 is no longer pressed:
        else if((lastVal & BUTTONS_BUTTON2) && !(newVal & BUTTONS_BUTTON2)) {
            // Draw a black square over the top of the green one
            display_fillRect(BUTTONS_BUTTON2_X_CORD, 0, BUTTONS_ALL_BUTTONS_X_LENGTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_BLACK);
        }
        // If BUTTONS_BUTTON3 is pressed and the square is not already drawn:
        if(!(lastVal & BUTTONS_BUTTON3) && (newVal & BUTTONS_BUTTON3)) {
            // Draw a red rectangle
            display_fillRect(BUTTONS_BUTTON3_X_CORD, 0, BUTTONS_ALL_BUTTONS_X_LENGTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_RED);
            // Set the cursor
            display_setCursor(BUTTONS_BUTTON3_CURSOR_X_CORD, BUTTONS_ALL_BUTTONS_CURSOR_Y_CORD);
            // Set the text color to white
            display_setTextColor(DISPLAY_WHITE);
            // Write BTN2 to the screen
            display_println(BUTTONS_BUTTON3_TEXT);
        }
        // If BUTTONS_BUTTON3 is no longer pressed and the square is on the screen:
        else if((lastVal & BUTTONS_BUTTON3) && !(newVal & BUTTONS_BUTTON3)) {
            // Draw a black rectangle over the top of the red one
            display_fillRect(BUTTONS_BUTTON3_X_CORD, 0, BUTTONS_ALL_BUTTONS_X_LENGTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_BLACK);
        }
        // If BUTTONS_BUTTON4 is pressed and the square isn't on the screen:
        if(!(lastVal & BUTTONS_BUTTON4) && (newVal & BUTTONS_BUTTON4)) {
            // Draw a blue rectangle
            display_fillRect(0, 0, BUTTONS_ALL_BUTTONS_X_LENGTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_BLUE);
            // Set the cursor
            display_setCursor(BUTTONS_BUTTON4_CURSOR_X_CORD, BUTTONS_ALL_BUTTONS_CURSOR_Y_CORD);
            // Set the text to be white
            display_setTextColor(DISPLAY_WHITE);
            // Write BTN3 to the screen
            display_println(BUTTONS_BUTTON4_TEXT);
        }
        // If BUTTONS_BUTTON4 is no longer pressed and the square is on the screen:
        else if((lastVal & BUTTONS_BUTTON4) && !(newVal & BUTTONS_BUTTON4)) {
            // Draw a black square over the blue one
            display_fillRect(0, 0, BUTTONS_ALL_BUTTONS_X_LENGTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_BLACK);
        }
    }
    // Once all 4 buttons are pressed simultaneously,
    // Draw a black square over the top part of the screen
    // To reset it.
    display_fillRect(0, 0, BUTTONS_SCREEN_WIDTH, BUTTONS_ALL_BUTTONS_Y_LENGTH, DISPLAY_BLACK);
}
Exemplo n.º 11
0
int main(void) {
  /* Early system initialisation */
  board_init();
  system_init_early();
  leds_init();

  set_busy_led(1);
  set_dirty_led(0);

  /* Due to an erratum in the LPC17xx chips anything that may change */
  /* peripheral clock scalers must come before system_init_late()    */
  uart_init();
#ifndef SPI_LATE_INIT
  spi_init(SPI_SPEED_SLOW);
#endif
  timer_init();
  bus_interface_init();
  i2c_init();

  /* Second part of system initialisation, switches to full speed on ARM */
  system_init_late();
  enable_interrupts();

  /* Internal-only initialisation, called here because it's faster */
  buffers_init();
  buttons_init();

  /* Anything that does something which needs the system clock */
  /* should be placed after system_init_late() */
  bus_init();    // needs delay
  rtc_init();    // accesses I2C
  disk_init();   // accesses card
  read_configuration();

  fatops_init(0);
  change_init();

  uart_puts_P(PSTR("\r\nsd2iec " VERSION " #"));
  uart_puthex(device_address);
  uart_putcrlf();

#ifdef CONFIG_REMOTE_DISPLAY
  /* at this point all buffers should be free, */
  /* so just use the data area of the first to build the string */
  uint8_t *strbuf = buffers[0].data;
  ustrcpy_P(strbuf, versionstr);
  ustrcpy_P(strbuf+ustrlen(strbuf), longverstr);
  if (display_init(ustrlen(strbuf), strbuf)) {
    display_address(device_address);
    display_current_part(0);
  }
#endif

  set_busy_led(0);

#if defined(HAVE_SD) && BUTTON_PREV != 0
  /* card switch diagnostic aid - hold down PREV button to use */
  if (!(buttons_read() & BUTTON_PREV)) {
    while (buttons_read() & BUTTON_NEXT) {
      set_dirty_led(sdcard_detect());
# ifndef SINGLE_LED
      set_busy_led(sdcard_wp());
# endif
    }
    reset_key(0xff);
  }
#endif

  bus_mainloop();

  while (1);
}