aboutsummaryrefslogtreecommitdiff
path: root/center_fw/protocol.h
blob: 89c93e239b0e11081bf536d5910ead7d3f53f3e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef __PROTOCOL_H__
#define __PROTOCOL_H__

#include <stdint.h>
#include <stdbool.h>

#define PKT_TYPE_BULK_FLAG 0x80

struct proto_rx_st {
    int packet_type;
    int is_bulk;
    int rxpos;
    int address;
    uint8_t argbuf[8];
    int offset;
    const struct command_if_def *cmd_if;
};

struct command_if_def {
    int packet_type_max;
    int payload_len[0];
};

extern volatile uint32_t decoding_error_cnt, protocol_error_cnt;
extern volatile bool backchannel_frame;

/* Callback */
void handle_command(int command, uint8_t *args);

void receive_symbol(struct proto_rx_st *st, int symbol);
void reset_receiver(struct proto_rx_st *st, const struct command_if_def *cmd_if);

#endif