Update .clang-format and apply

Update .clang-format for LLVM 14.0, available on Ubuntu 22.04.

There is still plenty that clang-format sucks at or does wrong, so
either add some more blocks to disable it, or just put up with it.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2023-01-06 13:47:21 -07:00
committed by Jeremy Soller
parent c3267fc4ad
commit e032c5f0f2
99 changed files with 1766 additions and 1517 deletions

View File

@@ -2,54 +2,64 @@
#include <common/i2c.h>
int16_t i2c_recv(struct I2C * i2c, uint8_t addr, uint8_t* data, uint16_t length) __reentrant {
int16_t i2c_recv(struct I2C *i2c, uint8_t addr, uint8_t *data, uint16_t length) __reentrant {
int16_t res = 0;
res = i2c_start(i2c, addr, true);
if (res < 0) return res;
if (res < 0)
return res;
res = i2c_read(i2c, data, length);
if (res < 0) return res;
if (res < 0)
return res;
i2c_stop(i2c);
return res;
}
int16_t i2c_send(struct I2C * i2c, uint8_t addr, uint8_t* data, uint16_t length) __reentrant {
int16_t i2c_send(struct I2C *i2c, uint8_t addr, uint8_t *data, uint16_t length) __reentrant {
int16_t res = 0;
res = i2c_start(i2c, addr, false);
if (res < 0) return res;
if (res < 0)
return res;
res = i2c_write(i2c, data, length);
if (res < 0) return res;
if (res < 0)
return res;
i2c_stop(i2c);
return res;
}
int16_t i2c_get(struct I2C * i2c, uint8_t addr, uint8_t reg, uint8_t* data, uint16_t length) __reentrant {
int16_t i2c_get(struct I2C *i2c, uint8_t addr, uint8_t reg, uint8_t *data, uint16_t length)
__reentrant {
int16_t res = 0;
res = i2c_start(i2c, addr, false);
if (res < 0) return res;
if (res < 0)
return res;
res = i2c_write(i2c, &reg, 1);
if (res < 0) return res;
if (res < 0)
return res;
return i2c_recv(i2c, addr, data, length);
}
int16_t i2c_set(struct I2C * i2c, uint8_t addr, uint8_t reg, uint8_t* data, uint16_t length) __reentrant {
int16_t i2c_set(struct I2C *i2c, uint8_t addr, uint8_t reg, uint8_t *data, uint16_t length)
__reentrant {
int16_t res = 0;
res = i2c_start(i2c, addr, false);
if (res < 0) return res;
if (res < 0)
return res;
res = i2c_write(i2c, &reg, 1);
if (res < 0) return res;
if (res < 0)
return res;
return i2c_send(i2c, addr, data, length);
}

View File

@@ -14,37 +14,37 @@
// This is the user-configurable log level
#ifndef LEVEL
#define LEVEL LEVEL_INFO
#define LEVEL LEVEL_INFO
#endif
#if LEVEL >= LEVEL_TRACE
#define TRACE(...) printf(__VA_ARGS__)
#define TRACE(...) printf(__VA_ARGS__)
#else
#define TRACE(...)
#define TRACE(...)
#endif
#if LEVEL >= LEVEL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#define DEBUG(...)
#endif
#if LEVEL >= LEVEL_INFO
#define INFO(...) printf(__VA_ARGS__)
#define INFO(...) printf(__VA_ARGS__)
#else
#define INFO(...)
#define INFO(...)
#endif
#if LEVEL >= LEVEL_WARN
#define WARN(...) printf(__VA_ARGS__)
#define WARN(...) printf(__VA_ARGS__)
#else
#define WARN(...)
#define WARN(...)
#endif
#if LEVEL >= LEVEL_ERROR
#define ERROR(...) printf(__VA_ARGS__)
#define ERROR(...) printf(__VA_ARGS__)
#else
#define ERROR(...)
#define ERROR(...)
#endif
#endif // _COMMON_DEBUG_H

View File

@@ -8,7 +8,7 @@
// Prevent failures to compile on AVR
#ifndef __SDCC
#define __reentrant
#define __reentrant
#endif
// I2C bus, should be defined elsewhere
@@ -16,30 +16,34 @@ struct I2C;
// Start i2c transaction
// Must be defined by arch, board, or ec
int16_t i2c_start(struct I2C * i2c, uint8_t addr, bool read) __reentrant;
int16_t i2c_start(struct I2C *i2c, uint8_t addr, bool read) __reentrant;
// Stop i2c transaction
// Must be defined by arch, board, or ec
void i2c_stop(struct I2C * i2c) __reentrant;
void i2c_stop(struct I2C *i2c) __reentrant;
// Send a byte on i2c bus
// Must be defined by arch, board, or ec
int16_t i2c_write(struct I2C * i2c, uint8_t * data, uint16_t length) __reentrant;
int16_t i2c_write(struct I2C *i2c, uint8_t *data, uint16_t length) __reentrant;
// Read bytes from bus
// Must be defined by arch, board, or ec
int16_t i2c_read(struct I2C * i2c, uint8_t * data, uint16_t length) __reentrant;
int16_t i2c_read(struct I2C *i2c, uint8_t *data, uint16_t length) __reentrant;
// Read multiple bytes from address in one transaction
int16_t i2c_recv(struct I2C * i2c, uint8_t addr, uint8_t* data, uint16_t length) __reentrant;
int16_t i2c_recv(struct I2C *i2c, uint8_t addr, uint8_t *data, uint16_t length) __reentrant;
// Write multiple bytes to address in one transaction
int16_t i2c_send(struct I2C * i2c, uint8_t addr, uint8_t* data, uint16_t length) __reentrant;
int16_t i2c_send(struct I2C *i2c, uint8_t addr, uint8_t *data, uint16_t length) __reentrant;
// clang-format off
// Read multiple bytes from a register in one transaction
int16_t i2c_get(struct I2C * i2c, uint8_t addr, uint8_t reg, uint8_t* data, uint16_t length) __reentrant;
int16_t i2c_get(struct I2C *i2c, uint8_t addr, uint8_t reg, uint8_t *data, uint16_t length) __reentrant;
// Write multiple bytes to a register in one transaction
int16_t i2c_set(struct I2C * i2c, uint8_t addr, uint8_t reg, uint8_t* data, uint16_t length) __reentrant;
int16_t i2c_set(struct I2C *i2c, uint8_t addr, uint8_t reg, uint8_t *data, uint16_t length) __reentrant;
// clang-format on
#endif // _COMMON_I2C_H

View File

@@ -8,28 +8,28 @@
// Keymap defined by board
#if defined(KM_LAY) && defined(KM_OUT) && defined(KM_IN)
extern uint16_t __code KEYMAP[KM_LAY][KM_OUT][KM_IN];
extern uint16_t __xdata DYNAMIC_KEYMAP[KM_LAY][KM_OUT][KM_IN];
#define HAVE_KEYMAP 1
extern uint16_t __code KEYMAP[KM_LAY][KM_OUT][KM_IN];
extern uint16_t __xdata DYNAMIC_KEYMAP[KM_LAY][KM_OUT][KM_IN];
#define HAVE_KEYMAP 1
#else
#define HAVE_KEYMAP 0
#define HAVE_KEYMAP 0
#endif
#if HAVE_KEYMAP
// Initialize the dynamic keymap
void keymap_init(void);
// Set the dynamic keymap to the default keymap
void keymap_load_default(void);
// Erase dynamic keymap in flash
bool keymap_erase_config(void);
// Load dynamic keymap from flash
bool keymap_load_config(void);
// Save dynamic keymap to flash
bool keymap_save_config(void);
// Get a keycode from the dynamic keymap
bool keymap_get(uint8_t layer, uint8_t output, uint8_t input, uint16_t * value);
// Set a keycode in the dynamic keymap
bool keymap_set(uint8_t layer, uint8_t output, uint8_t input, uint16_t value);
// Initialize the dynamic keymap
void keymap_init(void);
// Set the dynamic keymap to the default keymap
void keymap_load_default(void);
// Erase dynamic keymap in flash
bool keymap_erase_config(void);
// Load dynamic keymap from flash
bool keymap_load_config(void);
// Save dynamic keymap to flash
bool keymap_save_config(void);
// Get a keycode from the dynamic keymap
bool keymap_get(uint8_t layer, uint8_t output, uint8_t input, uint16_t *value);
// Set a keycode in the dynamic keymap
bool keymap_set(uint8_t layer, uint8_t output, uint8_t input, uint16_t value);
#endif
// Translate a keycode from PS/2 set 2 to PS/2 set 1

View File

@@ -4,7 +4,7 @@
#define _COMMON_MACRO_H
#define xconcat(a, b) concat(a, b)
#define concat(a, b) a ## b
#define concat(a, b) a##b
#define xstr(s) str(s)
#define str(s) #s

View File

@@ -3,7 +3,7 @@
#ifndef _COMMON_VERSION_H
#define _COMMON_VERSION_H
const char * board();
const char * version();
const char *board();
const char *version();
#endif // _COMMON_VERSION_H

View File

@@ -5,7 +5,7 @@
// Prevent failures to compile on AVR
//TODO: move to a driver included only on platforms needing it
#ifndef __SDCC
#define __code
#define __code
#endif
// https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html#ss10.3

View File

@@ -4,7 +4,7 @@
// Prevent failures to compile on AVR
#ifndef __SDCC
#define __code
#define __code
#endif
// clang-format off
@@ -17,10 +17,10 @@ static const char __code VERSION[] =
xstr(__FIRMWARE_VERSION__);
// clang-format on
const char * board() {
const char *board() {
return &BOARD[11];
}
const char * version() {
const char *version() {
return &VERSION[13];
}