mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-09-30 13:58:57 +02:00
Squashed commit of the following:
commit d614bc5f62f3c2efc5c5cc0f38168a67681e6fb5 Author: Nick Brassel <nick@tzarc.org> Date: Sun Oct 16 13:17:03 2022 +1100 Remove old header generator. commit 08337b814cfcef57a1f6b41acf06b806ad4bb116 Author: Nick Brassel <nick@tzarc.org> Date: Sat Oct 15 11:47:20 2022 +1100 Restart jinja2 generation for firmware-side output.
This commit is contained in:
@@ -34,10 +34,10 @@ class {{ name }}(namedtuple('{{ name }}', '{{ members }}')):
|
||||
{{ loop(item.routes.values()) }}
|
||||
{%- endif -%}
|
||||
{% if item.request_struct_members %}
|
||||
# TODO: gen inbound object for {{ to_snake(item.define) }}
|
||||
# TODO: gen inbound object for {{ item.define | to_snake }}
|
||||
{%- endif -%}
|
||||
{% if item.return_struct_members %}
|
||||
# TODO: gen outbound object for {{ to_snake(item.define) }}
|
||||
# TODO: gen outbound object for {{ item.define | to_snake }}
|
||||
{%- endif -%}
|
||||
{%- endfor %}
|
||||
|
||||
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
{{ GPL2_HEADER_C_LIKE }}
|
||||
{{ GENERATED_HEADER_C_LIKE }}
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Versions and identifiers
|
||||
|
||||
#define XAP_BCD_VERSION UINT32_C({{ xap.version | triplet_to_bcd }})
|
||||
#define QMK_BCD_VERSION UINT32_C({{ qmk_version | triplet_to_bcd }})
|
||||
#define XAP_KEYBOARD_IDENTIFIER UINT32_C({{ keyboard | fnv1a_32 }})
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Response flag definitions
|
||||
|
||||
{% for bit,data in xap.response_flags.bits | dictsort -%}
|
||||
#define {{ xap.response_flags.define_prefix }}_{{ data.define | to_snake | upper }} (UINT32_C(1) << ({{ bit }}))
|
||||
{% endfor -%}
|
||||
#define {{ xap.response_flags.define_prefix }}_FAILED 0x00
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Broadcast message definitions
|
||||
|
||||
{% for message_id,data in xap.broadcast_messages.messages | dictsort -%}
|
||||
#define {{ xap.broadcast_messages.define_prefix }}_{{ data.define | to_snake | upper }} {{ message_id }}
|
||||
{% if 'return_type' in data -%}
|
||||
void {{ xap.broadcast_messages.define_prefix | lower }}_{{ data.define | to_snake | lower }}({{ data.return_type | type_to_c('value') }});
|
||||
{% else -%}
|
||||
void {{ xap.broadcast_messages.define_prefix | lower }}_{{ data.define | to_snake | lower }}(const void *data, size_t length);
|
||||
{% endif %}
|
||||
{% endfor -%}
|
||||
#define XAP_BROADCAST_TOKEN 0xFFFF
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Type definitions
|
||||
|
||||
{% for name,data in xap.type_definitions | dictsort -%}
|
||||
{% if data.type != 'struct' -%}
|
||||
typedef {{ data.type | type_to_c('xap_'+(name|to_snake|lower)+'_t') }};
|
||||
{% endif -%}
|
||||
{% endfor %}
|
||||
{%- for name,data in xap.type_definitions | dictsort %}
|
||||
{% if data.type == 'struct' -%}
|
||||
typedef struct {
|
||||
{%- for member in data.struct_members %}
|
||||
{{ member.type | type_to_c(member.name) }};
|
||||
{%- endfor %}
|
||||
} __attribute__((__packed__)) xap_{{ name | to_snake | lower }}_t{{ data.type | type_to_c_after }};
|
||||
_Static_assert(sizeof(xap_{{ name | to_snake | lower }}_t) == {{ data.struct_length }}, "xap_{{ name | to_snake | lower }}_t needs to be {{ data.struct_length }} bytes in size");
|
||||
{%- endif -%}
|
||||
{% endfor %}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Route definitions
|
||||
|
||||
{% macro export_route_types(prefix, container) -%}
|
||||
{%- if 'routes' in container -%}
|
||||
{% for route, data in container.routes | dictsort -%}
|
||||
{%- set this_prefix_uc = (prefix + '_' + data.define) | upper -%}
|
||||
{%- set this_prefix_lc = this_prefix_uc | lower -%}
|
||||
|
||||
{% if 'request_struct_members' in data -%}
|
||||
typedef struct {
|
||||
{%- for member in data.request_struct_members %}
|
||||
{{ member.type | type_to_c(member.name|lower) }};
|
||||
{%- endfor %}
|
||||
} __attribute__((__packed__)) {{ this_prefix_lc | to_snake | lower }}_arg_t;
|
||||
_Static_assert(sizeof({{ this_prefix_lc | to_snake | lower }}_arg_t) == {{ data.request_struct_length }}, "{{ this_prefix_lc | to_snake | lower }}_arg_t needs to be {{ data.request_struct_length }} bytes in size");
|
||||
{% elif 'request_type' in data -%}
|
||||
typedef {{ data.request_type | type_to_c(this_prefix_lc+'_arg_t') }};
|
||||
{%- endif -%}
|
||||
|
||||
{%- if 'return_struct_members' in data -%}
|
||||
typedef struct {
|
||||
{%- for member in data.return_struct_members %}
|
||||
{{ member.type | type_to_c(member.name|lower) }};
|
||||
{%- endfor %}
|
||||
} __attribute__((__packed__)) {{ this_prefix_lc | to_snake | lower }}_t;
|
||||
_Static_assert(sizeof({{ this_prefix_lc | to_snake | lower }}_t) == {{ data.return_struct_length }}, "{{ this_prefix_lc | to_snake | lower }}_t needs to be {{ data.return_struct_length }} bytes in size");
|
||||
{%- elif 'return_type' in data -%}
|
||||
{%- if '[' in data.return_type %}
|
||||
typedef struct __attribute__((__packed__)) { {{ data.return_type | type_to_c('x') }}; } {{ this_prefix_lc }}_t;
|
||||
{%- else -%}
|
||||
typedef {{ data.return_type | type_to_c(this_prefix_lc+'_t') }};
|
||||
{%- endif -%}
|
||||
|
||||
{%- endif %}
|
||||
{{ export_route_types(this_prefix_lc, data) }}
|
||||
{% endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{{ export_route_types('xap_route', xap) }}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Capabilities IDs
|
||||
|
||||
{% macro export_route_ids(prefix, container) -%}
|
||||
{%- if 'routes' in container -%}
|
||||
{% for route, data in container.routes | dictsort -%}
|
||||
{%- set this_prefix_uc = (prefix + '_' + data.define) | upper -%}
|
||||
{%- set this_prefix_lc = this_prefix_uc | lower -%}
|
||||
#define {{ this_prefix_uc }} {{ route }}
|
||||
{{ export_route_ids(this_prefix_uc, data) }}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{{ export_route_ids('XAP_ROUTE', xap) }}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Capabilities Masks
|
||||
|
||||
{% macro export_route_masks(prefix, container, preprocessor_condition) -%}
|
||||
{%- if 'routes' in container -%}
|
||||
{% for route, data in container.routes | dictsort -%}
|
||||
{%- set this_prefix_uc = (prefix + '_' + data.define) | upper -%}
|
||||
{%- set this_prefix_lc = this_prefix_uc | lower -%}
|
||||
{% if 'enable_if_preprocessor' in data %}
|
||||
{% if preprocessor_condition == 'TRUE' %}
|
||||
{%- set condition = "(" + data.enable_if_preprocessor + ")" -%}
|
||||
{% else %}
|
||||
{%- set condition = "(" + preprocessor_condition + " && (" + data.enable_if_preprocessor + "))" -%}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{%- set condition = preprocessor_condition -%}
|
||||
{% endif %}
|
||||
{% if condition == 'TRUE' %}
|
||||
#define {{ this_prefix_uc }}_MASK (UINT32_C(1) << ({{ this_prefix_uc }}))
|
||||
{% else %}
|
||||
#if ({{ condition }})
|
||||
#define {{ this_prefix_uc }}_MASK (UINT32_C(1) << ({{ this_prefix_uc }}))
|
||||
#else // ({{ condition }})
|
||||
#define {{ this_prefix_uc }}_MASK 0
|
||||
#endif // ({{ condition }})
|
||||
{% endif %}
|
||||
{{ export_route_masks(this_prefix_uc, data, condition) }}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{{ export_route_masks('XAP_ROUTE', xap, 'TRUE') }}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Capabilities Values
|
||||
|
||||
{% macro export_route_capabilities(prefix, container) -%}
|
||||
{%- if 'routes' in container -%}
|
||||
#define {{ prefix }}_CAPABILITIES (0 \
|
||||
{% for route, data in container.routes | dictsort -%}
|
||||
{%- set this_prefix_uc = (prefix + '_' + data.define) | upper -%}
|
||||
| ({{ this_prefix_uc }}_MASK) \
|
||||
{% endfor -%}
|
||||
)
|
||||
{% for route, data in container.routes | dictsort -%}
|
||||
{%- set this_prefix_uc = (prefix + '_' + data.define) | upper -%}
|
||||
{{ export_route_capabilities(this_prefix_uc, data) }}
|
||||
{% endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{{ export_route_capabilities('XAP_ROUTE', xap) }}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
{{ GPL2_HEADER_C_LIKE }}
|
||||
{{ GENERATED_HEADER_C_LIKE }}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Full XAP {{ xap.version }} definitions
|
||||
|
||||
#if 0
|
||||
{{ xap | tojson(4) }}
|
||||
#endif
|
||||
Reference in New Issue
Block a user