-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSelfProgram.h
More file actions
49 lines (38 loc) · 1.49 KB
/
SelfProgram.h
File metadata and controls
49 lines (38 loc) · 1.49 KB
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
/*
* Copyright (C) 2015-2017 Erin Tomson <erin@rgba.net>
* Copyright (C) 2017-2025 3devo (http://www.3devo.eu)
*
* 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, version 3.
*
* 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SELFPROGRAM_H_
#define SELFPROGRAM_H_
#include <stdint.h>
#include "Config.h"
class SelfProgram {
public:
static void readFlash(uint16_t address, uint8_t *data, uint16_t len);
static uint8_t readByte(uint16_t address);
static uint8_t writePage(uint16_t address, uint8_t *data, uint16_t len);
#if defined(NEED_TRAMPOLINE)
static void writeTrampoline(uint16_t instruction);
static uint16_t offsetRelativeJump(uint16_t instruction, int16_t offset);
static uint16_t trampolineStart;
// Use a reference to make this an alias to trampolineStart for
// readability
static constexpr const uint16_t& applicationSize = trampolineStart;
#else
static constexpr const uint16_t applicationSize = APPLICATION_SIZE;
#endif // defined(NEED_TRAMPOLINE)
static uint8_t eraseCount;
};
#endif /* SELFPROGRAM_H_ */