Test Updating Firmware on the BCM20732S via HCI UART
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
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