{% macro type_map(type) %}
{%- if type.lower()=="uint8" -%}
uint8_t
{%- elif type.lower()=="int8" -%}
int8_t
{%- elif type.lower()=="uint16" -%}
uint16_t
{%- elif type.lower()=="int16" -%}
int16_t
{%- elif type.lower()=="uint32" -%}
uint32_t
{%- elif type.lower()=="int32" -%}
int32_t
{%- elif type.lower()=="uint64" -%}
uint64_t
{%- elif type.lower()=="int64" -%}
int64_t
{%- elif type.lower()=="float" -%}
float
{%- elif type.lower()=="double" -%}
double
{%- elif type.lower()=="bool" -%}
bool
{% else -%}
{{type.lower()}}_t
{%- endif%}
{% endmacro %}
// Generated with umsg_gen on {{ date }}
#pragma once
#include <umsg_types.h>

// msg structure typedefs
{%if topic_dict.enums %}

{% for enum in topic_dict.enums%}
typedef enum
{
    {%for val in enum.enumerators%}
    {{val.upper()}}{{ "," if not loop.last else "" }}
    {%endfor%}
} {{enum.name}}_t;

{%endfor%}
{% endif %}
{% for msg_dict in topic_dict.msgs %}
typedef struct
{
    {% for field in msg_dict.fields %}
    {%+ if not field.bitfield %}{{type_map(field.type)}} {{field.name}}{% if field.length %}[{{field.length}}]{% endif %};{% endif %}
    {% if field.bitfield %}{{type_map(field.type)}} {%for bitfield in field.bitfield %}{{bitfield.name}} : {{bitfield.bits}}{{ ", " if not loop.last else ";" }}{%endfor%}{% endif +%}
    {% endfor %}
} umsg_{{topic_dict.name}}_{{msg_dict.name}}_t;

{% endfor -%}

// api function headers
{% for msg_dict in topic_dict.msgs %}
{% set prefix = topic_dict.name+'_'+msg_dict.name %}
umsg_sub_handle_t umsg_{{prefix}}_subscribe(uint32_t prescaler, uint8_t length);
void umsg_{{prefix}}_publish(umsg_{{prefix}}_t* data);
uint8_t umsg_{{prefix}}_receive(umsg_sub_handle_t queue, umsg_{{prefix}}_t* data, uint32_t timeout);
uint8_t umsg_{{prefix}}_peek(umsg_{{prefix}}_t* data);

{% endfor %}

