Skip to content

Commit

Permalink
More linter format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fpb committed Jan 27, 2024
1 parent b75d870 commit f20307d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 76 deletions.
4 changes: 2 additions & 2 deletions drivers/bluetooth/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 22 additions & 21 deletions drivers/bluetooth/iton_bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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:
Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -246,15 +247,15 @@ 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);
}

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);
Expand Down
106 changes: 53 additions & 53 deletions drivers/bluetooth/iton_bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit f20307d

Please sign in to comment.