-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial_load.hpp
83 lines (66 loc) · 1.39 KB
/
serial_load.hpp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <cstdint>
#include "maple/maple_bus_commands.hpp"
#include "serial_protocol.hpp"
namespace serial_load {
void init(uint32_t speed);
void recv(struct maple_poll_state& poll_state, uint8_t c);
void tick(struct maple_poll_state& poll_state);
enum struct fsm_state {
idle,
write,
read,
jump,
speed,
maple_raw__command,
maple_raw__maple_dma,
maple_raw__response,
};
struct state_arglen_reply {
uint32_t command;
uint32_t reply;
enum fsm_state fsm_state;
};
struct incremental_crc {
uint32_t value;
uint32_t offset;
};
struct state {
union command_reply buf;
uint32_t len;
enum fsm_state fsm_state;
struct incremental_crc reply_crc;
uint32_t speed;
};
extern struct state state;
struct lm {
struct maple::device_id device_id;
};
struct maple_port {
struct maple::device_id device_id;
uint8_t ap__lm;
struct lm lm[5];
};
enum struct step {
IDLE = 0,
DEVICE_STATUS,
EXTENSION__DEVICE_STATUS,
EXTENSION__DEVICE_STATUS__DEVICE_REPLY,
RAW,
};
struct maple_command_parameters {
uint8_t port;
uint8_t lm;
};
struct maple_poll_state {
uint32_t send_length;
uint32_t recv_length;
bool want_start;
bool want_raw;
enum step step;
struct serial_load::maple_port port[4];
struct maple_command_parameters command_parameters;
};
}
extern "C" uint32_t __send_buf __asm("__send_buf");
extern "C" uint32_t __recv_buf __asm("__recv_buf");