Add compiler_support.h (#25274)
This commit is contained in:
parent
fa24b0fcce
commit
955809bd5a
36 changed files with 142 additions and 81 deletions
|
|
@ -44,7 +44,7 @@ typedef struct __attribute__((packed)) qff_font_descriptor_v1_t {
|
|||
uint8_t compression_scheme; // compression scheme, see below.
|
||||
uint8_t transparency_index; // palette index used for transparent pixels (not yet implemented)
|
||||
} qff_font_descriptor_v1_t;
|
||||
// _Static_assert(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF");
|
||||
// STATIC_ASSERT(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF");
|
||||
```
|
||||
|
||||
The values for `format`, `flags`, `compression_scheme`, and `transparency_index` match [QGF's frame descriptor block](quantum_painter_qgf#qgf-frame-descriptor), with the exception that the `delta` flag is ignored by QFF.
|
||||
|
|
@ -66,7 +66,7 @@ typedef struct __attribute__((packed)) qff_ascii_glyph_table_v1_t {
|
|||
qgf_block_header_v1_t header; // = { .type_id = 0x01, .neg_type_id = (~0x01), .length = 285 }
|
||||
uint24_t glyph[95]; // 95 glyphs, 0x20..0x7E, see bits/masks above for values
|
||||
} qff_ascii_glyph_table_v1_t;
|
||||
// _Static_assert(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1_t) + 285), "qff_ascii_glyph_table_v1_t must be 290 bytes in v1 of QFF");
|
||||
// STATIC_ASSERT(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1_t) + 285), "qff_ascii_glyph_table_v1_t must be 290 bytes in v1 of QFF");
|
||||
```
|
||||
|
||||
## Unicode glyph table {#qff-unicode-table}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ typedef struct __attribute__((packed)) qgf_block_header_v1_t {
|
|||
uint8_t neg_type_id; // Negated type ID, used for detecting parsing errors
|
||||
uint24_t length; // 24-bit blob length, allowing for block sizes of a maximum of 16MB
|
||||
} qgf_block_header_v1_t;
|
||||
// _Static_assert(sizeof(qgf_block_header_v1_t) == 5, "qgf_block_header_v1_t must be 5 bytes in v1 of QGF");
|
||||
// STATIC_ASSERT(sizeof(qgf_block_header_v1_t) == 5, "qgf_block_header_v1_t must be 5 bytes in v1 of QGF");
|
||||
```
|
||||
The _length_ describes the number of octets in the data following the block header -- a block header may specify a _length_ of `0` if no blob is specified.
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ typedef struct __attribute__((packed)) qgf_graphics_descriptor_v1_t {
|
|||
uint16_t image_height; // in pixels
|
||||
uint16_t frame_count; // minimum of 1
|
||||
} qgf_graphics_descriptor_v1_t;
|
||||
// _Static_assert(sizeof(qgf_graphics_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 18), "qgf_graphics_descriptor_v1_t must be 23 bytes in v1 of QGF");
|
||||
// STATIC_ASSERT(sizeof(qgf_graphics_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 18), "qgf_graphics_descriptor_v1_t must be 23 bytes in v1 of QGF");
|
||||
```
|
||||
|
||||
## Frame offset block {#qgf-frame-offset-descriptor}
|
||||
|
|
@ -95,7 +95,7 @@ typedef struct __attribute__((packed)) qgf_frame_v1_t {
|
|||
uint8_t transparency_index; // palette index used for transparent pixels (not yet implemented)
|
||||
uint16_t delay; // frame delay time for animations (in units of milliseconds)
|
||||
} qgf_frame_v1_t;
|
||||
// _Static_assert(sizeof(qgf_frame_v1_t) == (sizeof(qgf_block_header_v1_t) + 6), "qgf_frame_v1_t must be 11 bytes in v1 of QGF");
|
||||
// STATIC_ASSERT(sizeof(qgf_frame_v1_t) == (sizeof(qgf_block_header_v1_t) + 6), "qgf_frame_v1_t must be 11 bytes in v1 of QGF");
|
||||
```
|
||||
|
||||
If this frame is grayscale, the _frame descriptor block_ (or _frame delta block_ if flags denote a delta frame) is immediately followed by this frame's corresponding _frame data block_.
|
||||
|
|
@ -160,7 +160,7 @@ typedef struct __attribute__((packed)) qgf_delta_v1_t {
|
|||
uint16_t right; // The right pixel location to to draw the delta image
|
||||
uint16_t bottom; // The bottom pixel location to to draw the delta image
|
||||
} qgf_delta_v1_t;
|
||||
// _Static_assert(sizeof(qgf_delta_v1_t) == 13, "qgf_delta_v1_t must be 13 bytes in v1 of QGF");
|
||||
// STATIC_ASSERT(sizeof(qgf_delta_v1_t) == 13, "qgf_delta_v1_t must be 13 bytes in v1 of QGF");
|
||||
```
|
||||
|
||||
## Frame data block {#qgf-frame-data-descriptor}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "keyboard.h"
|
||||
#include "progmem.h"
|
||||
#include "timer.h"
|
||||
|
|
@ -265,7 +266,7 @@ void st7565_write_char(const char data, bool invert) {
|
|||
static uint8_t st7565_temp_buffer[ST7565_FONT_WIDTH];
|
||||
memcpy(&st7565_temp_buffer, st7565_cursor, ST7565_FONT_WIDTH);
|
||||
|
||||
_Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array");
|
||||
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
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
# include "keyboard.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "oled_driver.h"
|
||||
#include OLED_FONT_H
|
||||
#include "timer.h"
|
||||
|
|
@ -601,7 +603,7 @@ void oled_write_char(const char data, bool invert) {
|
|||
static uint8_t oled_temp_buffer[OLED_FONT_WIDTH];
|
||||
memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH);
|
||||
|
||||
_Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array");
|
||||
STATIC_ASSERT(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array");
|
||||
|
||||
// set the reder buffer data
|
||||
uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "i2c_master.h"
|
||||
#include "pointing_device.h"
|
||||
#include "util.h"
|
||||
|
|
@ -79,7 +80,7 @@ typedef struct {
|
|||
azoteq_iqs5xx_relative_xy_t y;
|
||||
} azoteq_iqs5xx_base_data_t;
|
||||
|
||||
_Static_assert(sizeof(azoteq_iqs5xx_base_data_t) == 10, "azoteq_iqs5xx_basic_report_t should be 10 bytes");
|
||||
STATIC_ASSERT(sizeof(azoteq_iqs5xx_base_data_t) == 10, "azoteq_iqs5xx_basic_report_t should be 10 bytes");
|
||||
|
||||
typedef struct {
|
||||
uint8_t number_of_fingers;
|
||||
|
|
@ -87,7 +88,7 @@ typedef struct {
|
|||
azoteq_iqs5xx_relative_xy_t y;
|
||||
} azoteq_iqs5xx_report_data_t;
|
||||
|
||||
_Static_assert(sizeof(azoteq_iqs5xx_report_data_t) == 5, "azoteq_iqs5xx_report_data_t should be 5 bytes");
|
||||
STATIC_ASSERT(sizeof(azoteq_iqs5xx_report_data_t) == 5, "azoteq_iqs5xx_report_data_t should be 5 bytes");
|
||||
|
||||
typedef struct PACKED {
|
||||
bool sw_input : 1;
|
||||
|
|
@ -159,7 +160,7 @@ typedef struct PACKED {
|
|||
uint16_t zoom_consecutive_distance;
|
||||
} azoteq_iqs5xx_gesture_config_t;
|
||||
|
||||
_Static_assert(sizeof(azoteq_iqs5xx_gesture_config_t) == 24, "azoteq_iqs5xx_gesture_config_t should be 24 bytes");
|
||||
STATIC_ASSERT(sizeof(azoteq_iqs5xx_gesture_config_t) == 24, "azoteq_iqs5xx_gesture_config_t should be 24 bytes");
|
||||
|
||||
typedef struct {
|
||||
uint16_t x_resolution;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "keyboard.h"
|
||||
#include <stdint.h>
|
||||
#include "spi_master.h"
|
||||
|
|
@ -39,8 +40,8 @@ typedef struct __attribute__((packed)) {
|
|||
int16_t delta_y; // displacement on y directions.
|
||||
} pmw33xx_report_t;
|
||||
|
||||
_Static_assert(sizeof(pmw33xx_report_t) == 6, "pmw33xx_report_t must be 6 bytes in size");
|
||||
_Static_assert(sizeof((pmw33xx_report_t){0}.motion) == 1, "pmw33xx_report_t.motion must be 1 byte in size");
|
||||
STATIC_ASSERT(sizeof(pmw33xx_report_t) == 6, "pmw33xx_report_t must be 6 bytes in size");
|
||||
STATIC_ASSERT(sizeof((pmw33xx_report_t){0}.motion) == 1, "pmw33xx_report_t.motion must be 1 byte in size");
|
||||
|
||||
#if !defined(PMW33XX_CLOCK_SPEED)
|
||||
# define PMW33XX_CLOCK_SPEED 2000000
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
// Copyright 2022 Nick Brassel (@tzarc)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#include "fnv.h"
|
||||
#include "compiler_support.h"
|
||||
|
||||
// This library was originally sourced from:
|
||||
// http://www.isthe.com/chongo/tech/comp/fnv/index.html
|
||||
//
|
||||
// Version at the time of retrieval on 2022-06-26: v5.0.3
|
||||
|
||||
_Static_assert(sizeof(long long) == 8, "long long should be 64 bits");
|
||||
_Static_assert(sizeof(unsigned long long) == 8, "unsigned long long should be 64 bits");
|
||||
STATIC_ASSERT(sizeof(long long) == 8, "long long should be 64 bits");
|
||||
STATIC_ASSERT(sizeof(unsigned long long) == 8, "unsigned long long should be 64 bits");
|
||||
|
||||
_Static_assert(sizeof(Fnv32_t) == 4, "Fnv32_t should be 32 bits");
|
||||
_Static_assert(sizeof(Fnv64_t) == 8, "Fnv64_t should be 64 bits");
|
||||
STATIC_ASSERT(sizeof(Fnv32_t) == 4, "Fnv32_t should be 32 bits");
|
||||
STATIC_ASSERT(sizeof(Fnv64_t) == 8, "Fnv64_t should be 64 bits");
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ def _render_keycodes(module_jsons):
|
|||
lines.append('')
|
||||
lines.append(' LAST_COMMUNITY_MODULE_KEY')
|
||||
lines.append('};')
|
||||
lines.append('_Static_assert((int)LAST_COMMUNITY_MODULE_KEY <= (int)(QK_COMMUNITY_MODULE_MAX+1), "Too many community module keycodes");')
|
||||
lines.append('STATIC_ASSERT((int)LAST_COMMUNITY_MODULE_KEY <= (int)(QK_COMMUNITY_MODULE_MAX+1), "Too many community module keycodes");')
|
||||
return lines
|
||||
|
||||
|
||||
|
|
@ -215,9 +215,11 @@ def generate_community_modules_h(cli):
|
|||
'#include <stdbool.h>',
|
||||
'#include <keycodes.h>',
|
||||
'',
|
||||
'#include "compiler_support.h"',
|
||||
'',
|
||||
'#define COMMUNITY_MODULES_API_VERSION_BUILDER(ver_major,ver_minor,ver_patch) (((((uint32_t)(ver_major))&0xFF) << 24) | ((((uint32_t)(ver_minor))&0xFF) << 16) | (((uint32_t)(ver_patch))&0xFF))',
|
||||
f'#define COMMUNITY_MODULES_API_VERSION COMMUNITY_MODULES_API_VERSION_BUILDER({ver_major},{ver_minor},{ver_patch})',
|
||||
f'#define ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(ver_major,ver_minor,ver_patch) _Static_assert(COMMUNITY_MODULES_API_VERSION_BUILDER(ver_major,ver_minor,ver_patch) <= COMMUNITY_MODULES_API_VERSION, "Community module requires a newer version of QMK modules API -- needs: " #ver_major "." #ver_minor "." #ver_patch ", current: {api_version}.")',
|
||||
f'#define ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(ver_major,ver_minor,ver_patch) STATIC_ASSERT(COMMUNITY_MODULES_API_VERSION_BUILDER(ver_major,ver_minor,ver_patch) <= COMMUNITY_MODULES_API_VERSION, "Community module requires a newer version of QMK modules API -- needs: " #ver_major "." #ver_minor "." #ver_patch ", current: {api_version}.")',
|
||||
'',
|
||||
'typedef struct keyrecord_t keyrecord_t; // forward declaration so we don\'t need to include quantum.h',
|
||||
'',
|
||||
|
|
|
|||
|
|
@ -15,17 +15,19 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
// Macro to help make GPIO and other controls atomic.
|
||||
|
||||
#ifndef IGNORE_ATOMIC_BLOCK
|
||||
# if __has_include_next("atomic_util.h")
|
||||
# include_next "atomic_util.h" /* Include the platforms atomic.h */
|
||||
# else
|
||||
# define ATOMIC_BLOCK _Static_assert(0, "ATOMIC_BLOCK not implemented")
|
||||
# define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented")
|
||||
# define ATOMIC_BLOCK_FORCEON _Static_assert(0, "ATOMIC_BLOCK_FORCEON not implemented")
|
||||
# define ATOMIC_FORCEON _Static_assert(0, "ATOMIC_FORCEON not implemented")
|
||||
# define ATOMIC_RESTORESTATE _Static_assert(0, "ATOMIC_RESTORESTATE not implemented")
|
||||
# define ATOMIC_BLOCK STATIC_ASSERT(0, "ATOMIC_BLOCK not implemented")
|
||||
# define ATOMIC_BLOCK_RESTORESTATE STATIC_ASSERT(0, "ATOMIC_BLOCK_RESTORESTATE not implemented")
|
||||
# define ATOMIC_BLOCK_FORCEON STATIC_ASSERT(0, "ATOMIC_BLOCK_FORCEON not implemented")
|
||||
# define ATOMIC_FORCEON STATIC_ASSERT(0, "ATOMIC_FORCEON not implemented")
|
||||
# define ATOMIC_RESTORESTATE STATIC_ASSERT(0, "ATOMIC_RESTORESTATE not implemented")
|
||||
# endif
|
||||
#else /* do nothing atomic macro */
|
||||
# define ATOMIC_BLOCK(t) for (uint8_t __ToDo = 1; __ToDo; __ToDo = 0)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
#ifndef I2C_SLAVE_REG_COUNT
|
||||
|
||||
# if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS)
|
||||
|
|
@ -33,7 +35,7 @@
|
|||
|
||||
#endif // I2C_SLAVE_REG_COUNT
|
||||
|
||||
_Static_assert(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte");
|
||||
STATIC_ASSERT(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte");
|
||||
|
||||
extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT];
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "pin_defs.h"
|
||||
|
||||
typedef uint8_t pin_t;
|
||||
|
|
@ -24,9 +26,9 @@ typedef uint8_t pin_t;
|
|||
|
||||
#define gpio_set_pin_input(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
|
||||
#define gpio_set_pin_input_high(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||
#define gpio_set_pin_input_low(pin) _Static_assert(0, "GPIO pulldowns in input mode are not available on AVR")
|
||||
#define gpio_set_pin_input_low(pin) STATIC_ASSERT(0, "GPIO pulldowns in input mode are not available on AVR")
|
||||
#define gpio_set_pin_output_push_pull(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||
#define gpio_set_pin_output_open_drain(pin) _Static_assert(0, "Open-drain outputs are not available on AVR")
|
||||
#define gpio_set_pin_output_open_drain(pin) STATIC_ASSERT(0, "Open-drain outputs are not available on AVR")
|
||||
#define gpio_set_pin_output(pin) gpio_set_pin_output_push_pull(pin)
|
||||
|
||||
#define gpio_write_pin_high(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
#ifndef USB_VBUS_PIN
|
||||
# define SPLIT_USB_DETECT // Force this on when dedicated pin is not used
|
||||
#endif
|
||||
|
|
@ -26,7 +28,7 @@
|
|||
# define REALTIME_COUNTER_CLOCK 1000000
|
||||
|
||||
# define USE_GPIOV1
|
||||
# define PAL_OUTPUT_TYPE_OPENDRAIN _Static_assert(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible");
|
||||
# define PAL_OUTPUT_TYPE_OPENDRAIN STATIC_ASSERT(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible");
|
||||
|
||||
/* Aliases for GPIO PWM channels - every pin has at least one PWM channel
|
||||
* assigned */
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@
|
|||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "pico/bootrom.h"
|
||||
#include "hardware/flash.h"
|
||||
#include "hardware/sync.h"
|
||||
#include "hardware/structs/ssi.h"
|
||||
#include "hardware/structs/ioqspi.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "compiler_support.h"
|
||||
#include "timer.h"
|
||||
#include "wear_leveling.h"
|
||||
#include "wear_leveling_rp2040_flash_config.h"
|
||||
|
|
@ -178,7 +180,7 @@ bool backing_store_erase(void) {
|
|||
#endif
|
||||
|
||||
// Ensure the backing size can be cleanly subtracted from the flash size without alignment issues.
|
||||
_Static_assert((WEAR_LEVELING_BACKING_SIZE) % (FLASH_SECTOR_SIZE) == 0, "Backing size must be a multiple of FLASH_SECTOR_SIZE");
|
||||
STATIC_ASSERT((WEAR_LEVELING_BACKING_SIZE) % (FLASH_SECTOR_SIZE) == 0, "Backing size must be a multiple of FLASH_SECTOR_SIZE");
|
||||
|
||||
interrupts = save_and_disable_interrupts();
|
||||
flash_range_erase((WEAR_LEVELING_RP2040_FLASH_BASE), (WEAR_LEVELING_BACKING_SIZE));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "musical_notes.h"
|
||||
#include "song_list.h"
|
||||
#include "voices.h"
|
||||
|
|
@ -38,7 +40,7 @@ typedef union audio_config_t {
|
|||
};
|
||||
} audio_config_t;
|
||||
|
||||
_Static_assert(sizeof(audio_config_t) == sizeof(uint8_t), "Audio EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(audio_config_t) == sizeof(uint8_t), "Audio EECONFIG out of spec.");
|
||||
|
||||
/*
|
||||
* a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
#ifndef BACKLIGHT_LEVELS
|
||||
# define BACKLIGHT_LEVELS 3
|
||||
#elif BACKLIGHT_LEVELS > 31
|
||||
|
|
@ -44,7 +46,7 @@ typedef union backlight_config_t {
|
|||
};
|
||||
} backlight_config_t;
|
||||
|
||||
_Static_assert(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec.");
|
||||
|
||||
void backlight_init(void);
|
||||
void backlight_toggle(void);
|
||||
|
|
|
|||
15
quantum/compiler_support.h
Normal file
15
quantum/compiler_support.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2025 QMK Contributors
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
/**
|
||||
* @brief Perfom an assertion at compile time.
|
||||
*
|
||||
* `_Static_assert` is C<23, while `static_assert` is C++/C23.
|
||||
*/
|
||||
#if !defined(STATIC_ASSERT)
|
||||
# ifdef __cplusplus
|
||||
# define STATIC_ASSERT static_assert
|
||||
# else
|
||||
# define STATIC_ASSERT _Static_assert
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "util.h"
|
||||
|
||||
/**
|
||||
|
|
@ -29,7 +31,7 @@ typedef union connection_config_t {
|
|||
connection_host_t desired_host : 8;
|
||||
} PACKED connection_config_t;
|
||||
|
||||
_Static_assert(sizeof(connection_config_t) == sizeof(uint8_t), "Connection EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(connection_config_t) == sizeof(uint8_t), "Connection EECONFIG out of spec.");
|
||||
|
||||
/**
|
||||
* \brief Initialize the subsystem.
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
#ifndef HAPTIC_DEFAULT_FEEDBACK
|
||||
# define HAPTIC_DEFAULT_FEEDBACK 0
|
||||
#endif
|
||||
|
|
@ -42,7 +44,7 @@ typedef union haptic_config_t {
|
|||
};
|
||||
} haptic_config_t;
|
||||
|
||||
_Static_assert(sizeof(haptic_config_t) == sizeof(uint32_t), "Haptic EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(haptic_config_t) == sizeof(uint32_t), "Haptic EECONFIG out of spec.");
|
||||
|
||||
typedef enum HAPTIC_FEEDBACK {
|
||||
KEY_PRESS,
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define _Static_assert static_assert
|
||||
#endif
|
||||
#include "compiler_support.h"
|
||||
|
||||
#include "eeconfig.h"
|
||||
#include "keycode.h"
|
||||
|
|
@ -47,6 +45,6 @@ typedef union keymap_config_t {
|
|||
};
|
||||
} keymap_config_t;
|
||||
|
||||
_Static_assert(sizeof(keymap_config_t) == sizeof(uint16_t), "Keycode (magic) EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(keymap_config_t) == sizeof(uint16_t), "Keycode (magic) EECONFIG out of spec.");
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
# include INTROSPECTION_KEYMAP_C
|
||||
#endif // INTROSPECTION_KEYMAP_C
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "keymap_introspection.h"
|
||||
#include "util.h"
|
||||
|
||||
|
|
@ -30,9 +31,9 @@ __attribute__((weak)) uint8_t keymap_layer_count(void) {
|
|||
}
|
||||
|
||||
#ifdef DYNAMIC_KEYMAP_ENABLE
|
||||
_Static_assert(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT");
|
||||
STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT");
|
||||
#else
|
||||
_Static_assert(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT");
|
||||
STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT");
|
||||
#endif
|
||||
|
||||
uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column) {
|
||||
|
|
@ -61,7 +62,7 @@ __attribute__((weak)) uint8_t encodermap_layer_count(void) {
|
|||
return encodermap_layer_count_raw();
|
||||
}
|
||||
|
||||
_Static_assert(NUM_KEYMAP_LAYERS_RAW == NUM_ENCODERMAP_LAYERS_RAW, "Number of encoder_map layers doesn't match the number of keymap layers");
|
||||
STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW == NUM_ENCODERMAP_LAYERS_RAW, "Number of encoder_map layers doesn't match the number of keymap layers");
|
||||
|
||||
uint16_t keycode_at_encodermap_location_raw(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) {
|
||||
if (layer_num < NUM_ENCODERMAP_LAYERS_RAW && encoder_idx < NUM_ENCODERS) {
|
||||
|
|
@ -106,7 +107,7 @@ __attribute__((weak)) uint16_t combo_count(void) {
|
|||
return combo_count_raw();
|
||||
}
|
||||
|
||||
_Static_assert(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?");
|
||||
STATIC_ASSERT(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?");
|
||||
|
||||
combo_t* combo_get_raw(uint16_t combo_idx) {
|
||||
if (combo_idx >= combo_count_raw()) {
|
||||
|
|
@ -133,7 +134,7 @@ __attribute__((weak)) uint16_t tap_dance_count(void) {
|
|||
return tap_dance_count_raw();
|
||||
}
|
||||
|
||||
_Static_assert(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?");
|
||||
STATIC_ASSERT(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?");
|
||||
|
||||
tap_dance_action_t* tap_dance_get_raw(uint16_t tap_dance_idx) {
|
||||
if (tap_dance_idx >= tap_dance_count_raw()) {
|
||||
|
|
@ -161,7 +162,7 @@ __attribute__((weak)) uint16_t key_override_count(void) {
|
|||
return key_override_count_raw();
|
||||
}
|
||||
|
||||
_Static_assert(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?");
|
||||
STATIC_ASSERT(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?");
|
||||
|
||||
const key_override_t* key_override_get_raw(uint16_t key_override_idx) {
|
||||
if (key_override_idx >= key_override_count_raw()) {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue