Move code to bootloader section and provide custom init code
This commit is contained in:
parent
98d6c9720f
commit
c46ba6bbb3
@ -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");
|
||||
}
|
||||
|
@ -93,6 +93,10 @@
|
||||
</ToolNumber>
|
||||
<ToolName xmlns="">Simulator</ToolName>
|
||||
</com_atmel_avrdbg_tool_simulator>
|
||||
<AAFDebugger>
|
||||
<AAFDebugFiles>
|
||||
</AAFDebugFiles>
|
||||
</AAFDebugger>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<ToolchainSettings>
|
||||
@ -138,17 +142,23 @@
|
||||
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
|
||||
<avrgcccpp.compiler.warnings.Pedantic>True</avrgcccpp.compiler.warnings.Pedantic>
|
||||
<avrgcccpp.compiler.miscellaneous.OtherFlags>-fno-threadsafe-statics -Wextra -std=c++17</avrgcccpp.compiler.miscellaneous.OtherFlags>
|
||||
<avrgcccpp.linker.general.NoStartupOrDefaultLibs>True</avrgcccpp.linker.general.NoStartupOrDefaultLibs>
|
||||
<avrgcccpp.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.linker.libraries.Libraries>
|
||||
<avrgcccpp.linker.memorysettings.Flash>
|
||||
<ListValues>
|
||||
<Value>.text=0x3800</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.linker.memorysettings.Flash>
|
||||
<avrgcccpp.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.assembler.general.IncludePaths>
|
||||
</AvrGccCpp>
|
||||
</AvrGccCpp>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
@ -191,24 +201,30 @@
|
||||
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.compiler.directories.IncludePaths>
|
||||
<avrgcccpp.compiler.optimization.level>Optimize (-O1)</avrgcccpp.compiler.optimization.level>
|
||||
<avrgcccpp.compiler.optimization.level>Optimize debugging experience (-Og)</avrgcccpp.compiler.optimization.level>
|
||||
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcccpp.compiler.optimization.DebugLevel>Maximum (-g3)</avrgcccpp.compiler.optimization.DebugLevel>
|
||||
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
|
||||
<avrgcccpp.compiler.warnings.Pedantic>True</avrgcccpp.compiler.warnings.Pedantic>
|
||||
<avrgcccpp.compiler.miscellaneous.OtherFlags>-fno-threadsafe-statics -Wextra -std=c++17</avrgcccpp.compiler.miscellaneous.OtherFlags>
|
||||
<avrgcccpp.linker.general.NoStartupOrDefaultLibs>True</avrgcccpp.linker.general.NoStartupOrDefaultLibs>
|
||||
<avrgcccpp.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.linker.libraries.Libraries>
|
||||
<avrgcccpp.linker.memorysettings.Flash>
|
||||
<ListValues>
|
||||
<Value>.text=0x3800</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.linker.memorysettings.Flash>
|
||||
<avrgcccpp.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.4.346\include</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.assembler.general.IncludePaths>
|
||||
<avrgcccpp.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcccpp.assembler.debugging.DebugLevel>
|
||||
</AvrGccCpp>
|
||||
</AvrGccCpp>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user