diff --git a/drivers/bluetooth/bluetooth.c b/drivers/bluetooth/bluetooth.c index 81673c0c6ad6..dc8532b9730e 100644 --- a/drivers/bluetooth/bluetooth.c +++ b/drivers/bluetooth/bluetooth.c @@ -53,9 +53,9 @@ void bluetooth_send_keyboard(report_keyboard_t *report) { void bluetooth_nkro_send(report_nkro_t *report) { #if defined(BLUETOOTH_BLUEFRUIT_LE) - //bluefruit_le_send_keyboard(report); + return; #elif defined(BLUETOOTH_RN42) - //rn42_send_keyboard(report); + return; #elif defined(BLUETOOTH_ITON_BT) iton_bt_send_nkro(report); #endif diff --git a/drivers/bluetooth/iton_bt.c b/drivers/bluetooth/iton_bt.c index 51aace9a6684..6c78c32ffe12 100644 --- a/drivers/bluetooth/iton_bt.c +++ b/drivers/bluetooth/iton_bt.c @@ -32,8 +32,8 @@ /** * Driver Macros */ -#define HIGH_BITS(x) ((uint8_t)(x >> 8)) -#define LOW_BITS(x) ((uint8_t)(x & 0x00FF)) +#define HIGH_BITS(x) ((uint8_t)(x >> 8)) +#define LOW_BITS(x) ((uint8_t)(x & 0x00FF)) /** * Function definitions @@ -56,14 +56,14 @@ __attribute__((weak)) void iton_bt_enters_connection_state(void) {} /** * Driver variables */ -bool iton_bt_is_connected = false; -uint8_t iton_bt_led_state = 0x00; +bool iton_bt_is_connected = false; +uint8_t iton_bt_led_state = 0x00; static uint8_t iton_bt_buffer[ITON_BT_BUFFER_LEN]; -uint8_t iton_bt_send_kb_last_key = 0x00; +uint8_t iton_bt_send_kb_last_key = 0x00; const SPIConfig iton_bt_spicfg = { - .slave = true, + .slave = true, .data_cb = iton_bt_data_cb, // SN32 specific .ctrl0 = SPI_DATA_LENGTH(8), @@ -90,14 +90,14 @@ static inline void iton_bt_rx_battery_notif(uint8_t data) { iton_bt_battery_level(data); break; case batt_wake_mcu: - #ifdef ITON_BT_ENABLE_ACK +# ifdef ITON_BT_ENABLE_ACK iton_bt_send_ack(control_bt, wake_ack); - #endif +# endif break; case batt_unknown: - #ifdef ITON_BT_ENABLE_ACK +# ifdef ITON_BT_ENABLE_ACK iton_bt_send_ack(control_bt, unknown_ack); - #endif +# endif break; case query_working_mode: break; @@ -111,9 +111,9 @@ static inline void iton_bt_rx_bluetooth_notif(uint8_t data) { case bt_connection_success: iton_bt_is_connected = true; - #ifdef ITON_BT_ENABLE_ACK +# ifdef ITON_BT_ENABLE_ACK iton_bt_send_ack(control_bt, connect_ack); - #endif +# endif iton_bt_connection_successful(); break; @@ -123,9 +123,9 @@ static inline void iton_bt_rx_bluetooth_notif(uint8_t data) { case bt_disconected: iton_bt_is_connected = false; - #ifdef ITON_BT_ENABLE_ACK +# ifdef ITON_BT_ENABLE_ACK iton_bt_send_ack(control_bt, disconnect_ack); - #endif +# endif iton_bt_disconnected(); break; @@ -145,10 +145,10 @@ static void iton_bt_rx_cb(void *arg) { spiStopTransferI(&ITON_BT_SPI_PORT, NULL); chSysUnlockFromISR(); - #ifdef ITON_BT_ENABLE_ACK +# ifdef ITON_BT_ENABLE_ACK // hack to make sure irq is low since acks messes with stuff writePinLow(ITON_BT_IRQ_LINE); - #endif +# endif switch (iton_bt_buffer[0]) { case led_state: @@ -169,7 +169,6 @@ static void iton_bt_rx_cb(void *arg) { } #endif - void iton_bt_data_cb(SPIDriver *spip) { writePinLow(ITON_BT_IRQ_LINE); } @@ -192,7 +191,8 @@ void iton_bt_init(void) { } void iton_bt_send(uint8_t cmd, uint8_t *data, uint8_t len) { - while (readPin(ITON_BT_IRQ_LINE)); + while (readPin(ITON_BT_IRQ_LINE)) + ; writePinHigh(ITON_BT_IRQ_LINE); iton_bt_buffer[0] = cmd; @@ -201,7 +201,8 @@ void iton_bt_send(uint8_t cmd, uint8_t *data, uint8_t len) { } void iton_bt_send2(uint8_t cmd, uint8_t b1, uint8_t b2) { - while (readPin(ITON_BT_IRQ_LINE)); + while (readPin(ITON_BT_IRQ_LINE)) + ; writePinHigh(ITON_BT_IRQ_LINE); iton_bt_buffer[0] = cmd; @@ -246,7 +247,7 @@ void iton_bt_send_keyboard(report_keyboard_t *report) { // return iton_bt_send(report_nkro, &nkro_report[0], 15); // } -// iton_bt_send(report_hid, &report->raw[HID_REPORT_OFFSET], 8); + // iton_bt_send(report_hid, &report->raw[HID_REPORT_OFFSET], 8); iton_bt_send(report_hid, &report->mods, 8); } @@ -254,7 +255,7 @@ void iton_bt_send_nkro(report_nkro_t *report) { report_keyboard_t rep; rep.report_id = report_hid; - rep.mods = report->mods; + rep.mods = report->mods; rep.keys[0] = rep.keys[1] = rep.keys[2] = rep.keys[3] = rep.keys[4] = rep.keys[5] = 0; iton_bt_send_keyboard(&rep); iton_bt_send(report_nkro, &report->bits[0], 15); diff --git a/drivers/bluetooth/iton_bt.h b/drivers/bluetooth/iton_bt.h index d90ebb066c7f..99e6cc508778 100644 --- a/drivers/bluetooth/iton_bt.h +++ b/drivers/bluetooth/iton_bt.h @@ -20,44 +20,44 @@ enum iton_bt_cmd { set_alarm_volt = 0xA8, // iton to mcu - led_state = 0xB1, - notification = 0xB6, + led_state = 0xB1, + notification = 0xB6, }; enum iton_bt_control_cmd { - control_power = 0x25, - control_usb = 0x58, - control_bt = 0x51, - control_pins = 0x52, + control_power = 0x25, + control_usb = 0x58, + control_bt = 0x51, + control_pins = 0x52, }; enum iton_bt_control_param { // control_power - sleep_idle_10m = 0x01, - sleep_idle_20m = 0x02, - sleep_idle_30m = 0x03, + sleep_idle_10m = 0x01, + sleep_idle_20m = 0x02, + sleep_idle_30m = 0x03, // control_usb - mode_usb = 0x01, + mode_usb = 0x01, // control_bt - mode_bt = 0x62, - reset_pairing = 0x70, - enter_pairing = 0x89, - switch_profile = 0x81, // + 0-5 profiles - os_mac = 0x74, - os_win = 0x75, - - connect_ack = 0x50, - disconnect_ack = 0x51, - wake_ack = 0x60, - unknown_ack = 0x52, - - query_voltage = 0x66, + mode_bt = 0x62, + reset_pairing = 0x70, + enter_pairing = 0x89, + switch_profile = 0x81, // + 0-5 profiles + os_mac = 0x74, + os_win = 0x75, + + connect_ack = 0x50, + disconnect_ack = 0x51, + wake_ack = 0x60, + unknown_ack = 0x52, + + query_voltage = 0x66, query_battery_level = 0x61, - disable_sleep = 0x65, - enable_sleep = 0x68, + disable_sleep = 0x65, + enable_sleep = 0x68, }; enum iton_bt_notification_type { @@ -67,34 +67,34 @@ enum iton_bt_notification_type { enum iton_bt_notification_param { // notif_battery - batt_voltage_low = 0x06, - batt_exit_low_battery_mode = 0x0A, - batt_low_power_shutdown = 0x07, + batt_voltage_low = 0x06, + batt_exit_low_battery_mode = 0x0A, + batt_low_power_shutdown = 0x07, - batt_above_70 = 0x04, - batt_between_30_70 = 0x02, - batt_below_30 = 0x01, + batt_above_70 = 0x04, + batt_between_30_70 = 0x02, + batt_below_30 = 0x01, - query_working_mode = 0xA0, - query_bt_name = 0xA1, + query_working_mode = 0xA0, + query_bt_name = 0xA1, // Wake from batt_low_power_shutdown - batt_wake_mcu = 0x0B, + batt_wake_mcu = 0x0B, - batt_unknown = 0x08, + batt_unknown = 0x08, // notif_bluetooth - bt_connection_success = 0x76, - bt_entered_pairing = 0x77, - bt_disconected = 0x78, - bt_enters_connection = 0x79, + bt_connection_success = 0x76, + bt_entered_pairing = 0x77, + bt_disconected = 0x78, + bt_enters_connection = 0x79, }; /** * Exported Variables */ uint8_t iton_bt_led_state; -bool iton_bt_is_connected; +bool iton_bt_is_connected; /** * Driver Callbacks @@ -130,18 +130,18 @@ void iton_bt_send_nkro(report_nkro_t *report); * Driver Macros */ #define iton_bt_control(cmd, param) iton_bt_send2(control, cmd, param) -#define iton_bt_control_bt(param) iton_bt_control(control_bt, param) -#define iton_bt_control_usb(param) iton_bt_control(control_usb, param) - -#define iton_bt_mode_usb() iton_bt_control_usb(mode_usb) -#define iton_bt_mode_bt() iton_bt_control_bt(mode_bt) -#define iton_bt_reset_pairing() iton_bt_control_bt(reset_pairing) -#define iton_bt_enter_pairing() iton_bt_control_bt(enter_pairing) -#define iton_bt_switch_profile(x) iton_bt_control_bt(switch_profile + x) -#define iton_bt_os_mac() iton_bt_control_bt(os_mac) -#define iton_bt_os_win() iton_bt_control_bt(os_win) -#define iton_bt_query_voltage() iton_bt_control_bt(query_voltage) +#define iton_bt_control_bt(param) iton_bt_control(control_bt, param) +#define iton_bt_control_usb(param) iton_bt_control(control_usb, param) + +#define iton_bt_mode_usb() iton_bt_control_usb(mode_usb) +#define iton_bt_mode_bt() iton_bt_control_bt(mode_bt) +#define iton_bt_reset_pairing() iton_bt_control_bt(reset_pairing) +#define iton_bt_enter_pairing() iton_bt_control_bt(enter_pairing) +#define iton_bt_switch_profile(x) iton_bt_control_bt(switch_profile + x) +#define iton_bt_os_mac() iton_bt_control_bt(os_mac) +#define iton_bt_os_win() iton_bt_control_bt(os_win) +#define iton_bt_query_voltage() iton_bt_control_bt(query_voltage) #define iton_bt_query_battery_level() iton_bt_control_bt(query_battery_level) -#define iton_bt_disable_sleep() iton_bt_control_bt(disable_sleep) -#define iton_bt_enable_sleep() iton_bt_control_bt(enable_sleep) +#define iton_bt_disable_sleep() iton_bt_control_bt(disable_sleep) +#define iton_bt_enable_sleep() iton_bt_control_bt(enable_sleep)