Skip to content

Commit

Permalink
Format code according to conventions (qmk#16322)
Browse files Browse the repository at this point in the history
  • Loading branch information
qmk-bot authored Feb 12, 2022
1 parent afcdd70 commit 63646e8
Show file tree
Hide file tree
Showing 345 changed files with 4,939 additions and 3,252 deletions.
26 changes: 16 additions & 10 deletions drivers/bluetooth/bluefruit_le.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif

#ifndef BLUEFRUIT_LE_SCK_DIVISOR
# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
#endif

#define SAMPLE_BATTERY
Expand Down Expand Up @@ -77,10 +77,10 @@ struct sdep_msg {
// information here.

enum queue_type {
QTKeyReport, // 1-byte modifier + 6-byte key report
QTConsumer, // 16-bit key code
QTKeyReport, // 1-byte modifier + 6-byte key report
QTConsumer, // 16-bit key code
#ifdef MOUSE_ENABLE
QTMouseMove, // 4-byte mouse report
QTMouseMove, // 4-byte mouse report
#endif
};

Expand Down Expand Up @@ -115,8 +115,8 @@ enum sdep_type {
SdepResponse = 0x20,
SdepAlert = 0x40,
SdepError = 0x80,
SdepSlaveNotReady = 0xFE, // Try again later
SdepSlaveOverflow = 0xFF, // You read more data than is available
SdepSlaveNotReady = 0xFE, // Try again later
SdepSlaveOverflow = 0xFF, // You read more data than is available
};

enum ble_cmd {
Expand Down Expand Up @@ -306,13 +306,15 @@ static bool ble_init(void) {
wait_ms(10);
writePinHigh(BLUEFRUIT_LE_RST_PIN);

wait_ms(1000); // Give it a second to initialize
wait_ms(1000); // Give it a second to initialize

state.initialized = true;
return state.initialized;
}

static inline uint8_t min(uint8_t a, uint8_t b) { return a < b ? a : b; }
static inline uint8_t min(uint8_t a, uint8_t b) {
return a < b ? a : b;
}

static bool read_response(char *resp, uint16_t resplen, bool verbose) {
char *dest = resp;
Expand Down Expand Up @@ -424,7 +426,9 @@ bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) {
return at_command(cmdbuf, resp, resplen, verbose);
}

bool bluefruit_le_is_connected(void) { return state.is_connected; }
bool bluefruit_le_is_connected(void) {
return state.is_connected;
}

bool bluefruit_le_enable_keyboard(void) {
char resbuf[128];
Expand Down Expand Up @@ -671,7 +675,9 @@ void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan,
}
#endif

uint32_t bluefruit_le_read_battery_voltage(void) { return state.vbat; }
uint32_t bluefruit_le_read_battery_voltage(void) {
return state.vbat;
}

bool bluefruit_le_set_mode_leds(bool on) {
if (!state.configured) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/bluetooth/outputselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ uint8_t auto_detect_output(void) {
#endif

#ifdef BLUETOOTH_ENABLE
return OUTPUT_BLUETOOTH; // should check if BT is connected here
return OUTPUT_BLUETOOTH; // should check if BT is connected here
#endif

return OUTPUT_NONE;
Expand Down
8 changes: 5 additions & 3 deletions drivers/bluetooth/rn42.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ static inline uint16_t rn42_consumer_usage_to_bitmap(uint16_t usage) {
}
}

void rn42_init(void) { uart_init(RN42_BAUD_RATE); }
void rn42_init(void) {
uart_init(RN42_BAUD_RATE);
}

void rn42_send_keyboard(report_keyboard_t *report) {
uart_write(0xFD);
Expand All @@ -81,8 +83,8 @@ void rn42_send_mouse(report_mouse_t *report) {
uart_write(report->buttons);
uart_write(report->x);
uart_write(report->y);
uart_write(report->v); // should try sending the wheel v here
uart_write(report->h); // should try sending the wheel h here
uart_write(report->v); // should try sending the wheel v here
uart_write(report->h); // should try sending the wheel h here
uart_write(0x00);
}

Expand Down
12 changes: 9 additions & 3 deletions drivers/eeprom/eeprom_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ uint32_t eeprom_read_dword(const uint32_t *addr) {
return ret;
}

void eeprom_write_byte(uint8_t *addr, uint8_t value) { eeprom_write_block(&value, addr, 1); }
void eeprom_write_byte(uint8_t *addr, uint8_t value) {
eeprom_write_block(&value, addr, 1);
}

void eeprom_write_word(uint16_t *addr, uint16_t value) { eeprom_write_block(&value, addr, 2); }
void eeprom_write_word(uint16_t *addr, uint16_t value) {
eeprom_write_block(&value, addr, 2);
}

void eeprom_write_dword(uint32_t *addr, uint32_t value) { eeprom_write_block(&value, addr, 4); }
void eeprom_write_dword(uint32_t *addr, uint32_t value) {
eeprom_write_block(&value, addr, 4);
}

void eeprom_update_block(const void *buf, void *addr, size_t len) {
uint8_t read_buf[len];
Expand Down
6 changes: 3 additions & 3 deletions drivers/eeprom/eeprom_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
# include "timer.h"
# include "debug.h"
#endif // DEBUG_EEPROM_OUTPUT
#endif // DEBUG_EEPROM_OUTPUT

static inline void fill_target_address(uint8_t *buffer, const void *addr) {
uintptr_t p = (uintptr_t)addr;
Expand Down Expand Up @@ -91,7 +91,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) {
dprintf(" %02X", (int)(((uint8_t *)buf)[i]));
}
dprintf("\n");
#endif // DEBUG_EEPROM_OUTPUT
#endif // DEBUG_EEPROM_OUTPUT
}

void eeprom_write_block(const void *buf, void *addr, size_t len) {
Expand Down Expand Up @@ -122,7 +122,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
dprintf(" %02X", (int)(read_buf[i]));
}
dprintf("\n");
#endif // DEBUG_EEPROM_OUTPUT
#endif // DEBUG_EEPROM_OUTPUT

i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE + write_length, 100);
wait_ms(EXTERNAL_EEPROM_WRITE_TIME);
Expand Down
12 changes: 8 additions & 4 deletions drivers/eeprom/eeprom_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
# define EXTERNAL_EEPROM_SPI_TIMEOUT 100
#endif

static bool spi_eeprom_start(void) { return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); }
static bool spi_eeprom_start(void) {
return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR);
}

static spi_status_t spi_eeprom_wait_while_busy(int timeout) {
uint32_t deadline = timer_read32() + timeout;
Expand Down Expand Up @@ -80,7 +82,9 @@ static void spi_eeprom_transmit_address(uintptr_t addr) {

//----------------------------------------------------------------------------------------------------------------------

void eeprom_driver_init(void) { spi_init(); }
void eeprom_driver_init(void) {
spi_init();
}

void eeprom_driver_erase(void) {
#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
Expand Down Expand Up @@ -135,7 +139,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) {
dprintf(" %02X", (int)(((uint8_t *)buf)[i]));
}
dprintf("\n");
#endif // DEBUG_EEPROM_OUTPUT
#endif // DEBUG_EEPROM_OUTPUT

spi_stop();
}
Expand Down Expand Up @@ -192,7 +196,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
dprintf(" %02X", (int)(uint8_t)(read_buf[i]));
}
dprintf("\n");
#endif // DEBUG_EEPROM_OUTPUT
#endif // DEBUG_EEPROM_OUTPUT

spi_write(CMD_WRITE);
spi_eeprom_transmit_address(target_addr);
Expand Down
8 changes: 6 additions & 2 deletions drivers/eeprom/eeprom_transient.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ size_t clamp_length(intptr_t offset, size_t len) {
return len;
}

void eeprom_driver_init(void) { eeprom_driver_erase(); }
void eeprom_driver_init(void) {
eeprom_driver_erase();
}

void eeprom_driver_erase(void) { memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE); }
void eeprom_driver_erase(void) {
memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE);
}

void eeprom_read_block(void *buf, const void *addr, size_t len) {
intptr_t offset = (intptr_t)addr;
Expand Down
2 changes: 1 addition & 1 deletion drivers/eeprom/eeprom_transient.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
*/
#ifndef TRANSIENT_EEPROM_SIZE
# include "eeconfig.h"
# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
#endif
12 changes: 8 additions & 4 deletions drivers/flash/flash_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

// #define DEBUG_FLASH_SPI_OUTPUT

static bool spi_flash_start(void) { return spi_start(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN, EXTERNAL_FLASH_SPI_LSBFIRST, EXTERNAL_FLASH_SPI_MODE, EXTERNAL_FLASH_SPI_CLOCK_DIVISOR); }
static bool spi_flash_start(void) {
return spi_start(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN, EXTERNAL_FLASH_SPI_LSBFIRST, EXTERNAL_FLASH_SPI_MODE, EXTERNAL_FLASH_SPI_CLOCK_DIVISOR);
}

static flash_status_t spi_flash_wait_while_busy(void) {
uint32_t deadline = timer_read32() + EXTERNAL_FLASH_SPI_TIMEOUT;
Expand Down Expand Up @@ -160,7 +162,9 @@ static flash_status_t spi_flash_transaction(uint8_t cmd, uint32_t addr, uint8_t
return response;
}

void flash_init(void) { spi_init(); }
void flash_init(void) {
spi_init();
}

flash_status_t flash_erase_chip(void) {
flash_status_t response = FLASH_STATUS_SUCCESS;
Expand Down Expand Up @@ -304,7 +308,7 @@ flash_status_t flash_read_block(uint32_t addr, void *buf, size_t len) {
dprintf(" %02X", (int)(((uint8_t *)read_buf)[i]));
}
dprintf("\n");
#endif // DEBUG_FLASH_SPI_OUTPUT
#endif // DEBUG_FLASH_SPI_OUTPUT

return response;
}
Expand Down Expand Up @@ -340,7 +344,7 @@ flash_status_t flash_write_block(uint32_t addr, const void *buf, size_t len) {
dprintf(" %02X", (int)(uint8_t)(write_buf[i]));
}
dprintf("\n");
#endif // DEBUG_FLASH_SPI_OUTPUT
#endif // DEBUG_FLASH_SPI_OUTPUT

/* Perform the write. */
response = spi_flash_transaction(FLASH_CMD_PP, addr, write_buf, write_length);
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpio/mcp23018.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#define TIMEOUT 100

enum {
CMD_IODIRA = 0x00, // i/o direction register
CMD_IODIRA = 0x00, // i/o direction register
CMD_IODIRB = 0x01,
CMD_GPPUA = 0x0C, // GPIO pull-up resistor register
CMD_GPPUA = 0x0C, // GPIO pull-up resistor register
CMD_GPPUB = 0x0D,
CMD_GPIOA = 0x12, // general purpose i/o port register (write modifies OLAT)
CMD_GPIOA = 0x12, // general purpose i/o port register (write modifies OLAT)
CMD_GPIOB = 0x13,
};

Expand Down
6 changes: 4 additions & 2 deletions drivers/haptic/DRV2605L.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ void DRV_init(void) {

void DRV_rtp_init(void) {
DRV_write(DRV_GO, 0x00);
DRV_write(DRV_RTP_INPUT, 20); // 20 is the lowest value I've found where haptics can still be felt.
DRV_write(DRV_RTP_INPUT, 20); // 20 is the lowest value I've found where haptics can still be felt.
DRV_write(DRV_MODE, 0x05);
DRV_write(DRV_GO, 0x01);
}

void DRV_amplitude(uint8_t amplitude) { DRV_write(DRV_RTP_INPUT, amplitude); }
void DRV_amplitude(uint8_t amplitude) {
DRV_write(DRV_RTP_INPUT, amplitude);
}

void DRV_pulse(uint8_t sequence) {
DRV_write(DRV_GO, 0x00);
Expand Down
20 changes: 15 additions & 5 deletions drivers/haptic/solenoid.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;

extern haptic_config_t haptic_config;

void solenoid_buzz_on(void) { haptic_set_buzz(1); }
void solenoid_buzz_on(void) {
haptic_set_buzz(1);
}

void solenoid_buzz_off(void) { haptic_set_buzz(0); }
void solenoid_buzz_off(void) {
haptic_set_buzz(0);
}

void solenoid_set_buzz(int buzz) { haptic_set_buzz(buzz); }
void solenoid_set_buzz(int buzz) {
haptic_set_buzz(buzz);
}

void solenoid_set_dwell(uint8_t dwell) { solenoid_dwell = dwell; }
void solenoid_set_dwell(uint8_t dwell) {
solenoid_dwell = dwell;
}

void solenoid_stop(void) {
SOLENOID_PIN_WRITE_INACTIVE();
Expand Down Expand Up @@ -89,4 +97,6 @@ void solenoid_setup(void) {
}
}

void solenoid_shutdown(void) { SOLENOID_PIN_WRITE_INACTIVE(); }
void solenoid_shutdown(void) {
SOLENOID_PIN_WRITE_INACTIVE();
}
25 changes: 17 additions & 8 deletions drivers/lcd/st7565.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Addressing Setting Commands
#define PAM_SETCOLUMN_LSB 0x00
#define PAM_SETCOLUMN_MSB 0x10
#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7

// Hardware Configuration Commands
#define DISPLAY_START_LINE 0x40
Expand Down Expand Up @@ -138,7 +138,9 @@ bool st7565_init(display_rotation_t rotation) {
return true;
}

__attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) { return rotation; }
__attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) {
return rotation;
}

void st7565_clear(void) {
memset(st7565_buffer, 0, sizeof(st7565_buffer));
Expand Down Expand Up @@ -212,7 +214,8 @@ void st7565_advance_page(bool clearPageRemainder) {
remaining = remaining / ST7565_FONT_WIDTH;

// Write empty character until next line
while (remaining--) st7565_write_char(' ', false);
while (remaining--)
st7565_write_char(' ', false);
} else {
// Next page index out of bounds?
if (index + remaining >= ST7565_MATRIX_SIZE) {
Expand Down Expand Up @@ -263,7 +266,7 @@ void st7565_write_char(const char data, bool invert) {
_Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array");

// set the reder buffer data
uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) {
memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH);
} else {
Expand Down Expand Up @@ -389,7 +392,7 @@ void st7565_write_raw_P(const char *data, uint16_t size) {
st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE));
}
}
#endif // defined(__AVR__)
#endif // defined(__AVR__)

bool st7565_on(void) {
if (!st7565_initialized) {
Expand Down Expand Up @@ -429,7 +432,9 @@ bool st7565_off(void) {

__attribute__((weak)) void st7565_off_user(void) {}

bool st7565_is_on(void) { return st7565_active; }
bool st7565_is_on(void) {
return st7565_active;
}

bool st7565_invert(bool invert) {
if (!st7565_initialized) {
Expand All @@ -445,9 +450,13 @@ bool st7565_invert(bool invert) {
return st7565_inverted;
}

uint8_t st7565_max_chars(void) { return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; }
uint8_t st7565_max_chars(void) {
return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH;
}

uint8_t st7565_max_lines(void) { return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; }
uint8_t st7565_max_lines(void) {
return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT;
}

void st7565_task(void) {
if (!st7565_initialized) {
Expand Down
Loading

0 comments on commit 63646e8

Please sign in to comment.