Move code to bootloader section and provide custom init code

This commit is contained in:
2020-04-11 16:51:09 +02:00
parent 98d6c9720f
commit c46ba6bbb3
2 changed files with 138 additions and 112 deletions

View File

@@ -3,6 +3,7 @@
#include "uart/uart.hpp"
#include <avr/boot.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "command.hpp"
@@ -282,7 +283,7 @@ static inline void formatErrorAnswer(Message &msg)
static inline void handleMessage(Message &msg)
{
static uint32_t s_address = 0;
static uint32_t s_address;
if (isSignOn(msg))
formatSignOnAnswer(msg);
@@ -328,14 +329,23 @@ int main()
{
serial.init();
Message msg;
static Message s_msg;
while (true) {
if (receiveMessage(msg)) {
handleMessage(msg);
transmitMessage(msg);
if (receiveMessage(s_msg)) {
handleMessage(s_msg);
transmitMessage(s_msg);
}
}
return 0;
}
void startup() __attribute__((naked, section(".vectors")));
void startup()
{
asm volatile("clr __zero_reg__");
// SP = RAMEND;
SREG = 0;
asm volatile("jmp main");
}