void bt_reset(void) { // Perform hardware reset. This function has some relatively long // delays in it and so should probably only be called during application // initialisation and termination. Calling it at other times may cause // problems for other real time tasks. // If power is currently off to the BC4 do not reset it! if ((*AT91C_PIOA_ODSR & BT_RST_PIN) == 0) return; //display_goto_xy(0, 1); //display_string("BT Reset...."); //display_update(); //systick_wait_ms(10000); // Ask for command mode bt_clear_arm7_cmd(); // BC4 reset sequence. First take the reset line low for 100ms bt_set_reset_low(); // Wait and discard any packets that may be around int cnt = 100; U8 *buf = out_buf[0]; while (cnt-- > 0) { bt_receive(buf); systick_wait_ms(1); } bt_set_reset_high(); // Now wait either for 5000ms or for the BC4 chip to signal reset // complete. Note we use the out buffer as a scratch area here // this id safe since we are forcing a reset. cnt = 5000; while (cnt-- > 0) { bt_receive(buf); // Look for the reset indication and the checksum if ((buf[0] == 3) && (buf[1] == MSG_RESET_INDICATION) && (buf[2] == 0xff) && (buf[3] == 0xe9)) break; systick_wait_ms(1); } // Force command mode bt_clear_arm7_cmd(); //display_goto_xy(10, 1); //display_int(cnt, 5); //display_update(); //systick_wait_ms(10000); }
static int bt_rec_transfer(struct voss_backend *pbe, void *ptr, int len) { return (bt_receive(pbe->arg, ptr, len, 1)); }