Skip to content

Instantly share code, notes, and snippets.

@odbol
Created April 25, 2014 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save odbol/11274002 to your computer and use it in GitHub Desktop.
Save odbol/11274002 to your computer and use it in GitHub Desktop.
Test Updating Firmware on the BCM20732S via HCI UART
/**
BCM20732S HCI UART is connected to Serial RX/TX pins on the Arduino Due.
BCM20732S Reset pin is connected to BLE_RESET_PIN
**/
#include <Arduino.h>
#define BLE_RESET_PIN 31
#define PACKET_LEN 4
const uint8_t startPacket[] = {0x01, 0x2E, 0xFC, 0x00};
const uint8_t nextPacket[] = {0x01, 0x03, 0x0C, 0x00};
void writeToBle(const uint8_t* packet) {
Serial.write(startPacket, PACKET_LEN);
SerialUSB.print("\nWrite: ");
SerialUSB.write(startPacket, PACKET_LEN);
SerialUSB.println(" --");
}
void ble_reset() {
// reset the BLE
// (active low)
pinMode(BLE_RESET_PIN, OUTPUT);
digitalWrite(BLE_RESET_PIN, LOW);
delay(2); // 20uS to reset
digitalWrite(BLE_RESET_PIN, HIGH);
delay(7); // ~5ms to warm up and boot
}
void setup() {
Serial.begin(115200);
SerialUSB.begin(57600);
ble_reset();
// wait for serial monitor
delay(8000);
writeToBle(startPacket);
}
void loop() {
while(Serial.available()) {
SerialUSB.write(Serial.read());
writeToBle(nextPacket);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment