-
Notifications
You must be signed in to change notification settings - Fork 7
/
moat_backend.c
82 lines (71 loc) · 2.04 KB
/
moat_backend.c
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
/*
* Copyright © 2014-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.
*/
/* This file implements the data structures required to hook individual
* MoaT features (which can be dynamically updated) to the main code
* (which cannot be).
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include "pgm.h"
#include <string.h>
#include "onewire.h"
#include "features.h"
#include "moat.h"
#include "dev_data.h"
#include "debug.h"
#include "moat_internal.h"
#include "port.h"
#include "pwm.h"
#include "count.h"
#include "console.h"
#include "timer.h"
#include "moat_dummy.c"
#define _1W_READ_GENERIC 0xF2
#define _1W_WRITE_GENERIC 0xF4
#define TC_DEFINE(_s) ALIASDEFS(_s)
#include "_def.h"
#undef TC_DEFINE
#define TC_DEFINE(_s) FUNCPTRS(_s),
const moat_call_t moat_calls[TC_MAX] __attribute__((progmem)) = {
#include "_def.h"
};
#undef ALERT_DEF
#undef TC_DEFINE
const uint8_t moat_sizes[] __attribute__ ((progmem)) = {
#include "_nums.h"
};
#ifdef USE_BOOTLOADER
extern uint8_t __mdata_start;
extern uint8_t __mdata_end;
extern uint8_t __mdata_load_start;
extern uint8_t __mbss_start;
extern uint8_t __mbss_end;
void moat_backend_init(void)
{
uint8_t *dsrc = &__mdata_load_start;
uint8_t *ddst = &__mdata_load_start;
while (ddst != &__mdata_end)
*ddst++ = *dsrc++;
ddst = &__mbss_start;
while (ddst != &__mbss_end)
*ddst++ = 0;
}
const moat_loader_t moat_loader __attribute__ ((progmem,section(".progmem.first"))) = {
{'M','T'},
&moat_backend_init,
moat_calls,
TC_MAX,
};
#endif