-
Notifications
You must be signed in to change notification settings - Fork 20
/
moat.h
66 lines (54 loc) · 1.87 KB
/
moat.h
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
#ifndef MOAT_H
#define MOAT_H
/*
* Copyright © 2010-2015, Matthias Urlichs <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License (included; see the file LICENSE)
* for more details.
*/
#include "jmp.h"
#include "features.h"
/* Setup */
/* Called before enabling interrupts */
#ifndef init_state
void init_state(void);
#endif
/* Your main loop. You need to poll_all() if you don't return. */
void mainloop(void);
EXTERN q_jmp_buf _go_out;
static inline void go_out(void) __attribute__((noreturn));
static inline void go_out(void) {
longjmp_q(_go_out);
}
/* Called to process commands. You implement this! */
void do_command(uint8_t cmd);
/*
Your code can do any one of:
* call xmit|recv_bit|byte, as required
* call next_command() (wait for next bus command, will not return)
* call next_idle() (wait for RESET pulse; will not return)
If you need to run any expensive computations, do it in update_idle().
Your steps need to be short enough to observe the timing requirements
of the state you're currently in.
Returning is equivalent to calling next_idle().
*/
/* Ditto, but called from idle / bit-wait context. You implement this! */
/* 'bits' says how many 1wire bit times are left. */
#ifndef update_idle
void update_idle(uint8_t bits);
#endif
void moat_init(void);
void moat_poll(void);
/* Implement if you need it. */
#ifdef CONDITIONAL_SEARCH
uint8_t condition_met(void);
#endif
#endif // moat.h