git-svn-id: http://moon:8086/svn/projects/HendiControl@165 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-03-30 01:04:04 +00:00
parent 54ac3a2834
commit ef0daf1143
8 changed files with 0 additions and 0 deletions
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">
<ProjectComponents>
<ProjectComponent z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<CApiVersion></CApiVersion>
<CBundle></CBundle>
<CClass>Device</CClass>
<CGroup>Startup</CGroup>
<CSub></CSub>
<CVariant></CVariant>
<CVendor>Atmel</CVendor>
<CVersion>1.2.0</CVersion>
<DefaultRepoPath>D:/Program Files (x86)\Atmel\Studio\7.0\Packs</DefaultRepoPath>
<DependentComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<Description></Description>
<Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\include</AbsolutePath>
<Attribute></Attribute>
<Category>include</Category>
<Condition>C</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>include</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\include\avr\iom328p.h</AbsolutePath>
<Attribute></Attribute>
<Category>header</Category>
<Condition>C</Condition>
<FileContentHash>UMk4QUzkkuShabuoYtNl/Q==</FileContentHash>
<FileVersion></FileVersion>
<Name>include/avr/iom328p.h</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\templates\main.c</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>GD1k8YYhulqRs6FD1B2Hog==</FileContentHash>
<FileVersion></FileVersion>
<Name>templates/main.c</Name>
<SelectString>Main file (.c)</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\templates\main.cpp</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>YXFphlh0CtZJU+ebktABgQ==</FileContentHash>
<FileVersion></FileVersion>
<Name>templates/main.cpp</Name>
<SelectString>Main file (.cpp)</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\gcc\dev\atmega328p</AbsolutePath>
<Attribute></Attribute>
<Category>libraryPrefix</Category>
<Condition>GCC</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>gcc/dev/atmega328p</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>ATmega_DFP</PackName>
<PackPath>D:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/Atmel.ATmega_DFP.pdsc</PackPath>
<PackVersion>1.2.150</PackVersion>
<PresentInProject>true</PresentInProject>
<ReferenceConditionId>ATmega328P</ReferenceConditionId>
<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:string></d4p1:string>
</RteComponents>
<Status>Resolved</Status>
<VersionMode>Fixed</VersionMode>
<IsComponentInAtProject>true</IsComponentInAtProject>
</ProjectComponent>
</ProjectComponents>
</Store>
@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>{c77f8c5d-b585-42ee-bf03-003a6350cd7a}</ProjectGuid>
<avrdevice>ATmega328P</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
<OutputFileExtension>.elf</OutputFileExtension>
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
<AssemblyName>Bootloader</AssemblyName>
<Name>Bootloader</Name>
<RootNamespace>Bootloader</RootNamespace>
<ToolchainFlavour>Native</ToolchainFlavour>
<KeepTimersRunning>true</KeepTimersRunning>
<OverrideVtor>false</OverrideVtor>
<CacheFlash>true</CacheFlash>
<ProgFlashFromRam>true</ProgFlashFromRam>
<RamSnippetAddress>0x20000000</RamSnippetAddress>
<UncachedRange />
<preserveEEPROM>true</preserveEEPROM>
<OverrideVtorValue>exception_table</OverrideVtorValue>
<BootSegment>2</BootSegment>
<ResetRule>0</ResetRule>
<eraseonlaunchrule>1</eraseonlaunchrule>
<EraseKey />
<AsfFrameworkConfig>
<framework-data>
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.26.0" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
<avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
<avrtoolserialnumber>J41800089261</avrtoolserialnumber>
<avrdeviceexpectedsignature>0x1E950F</avrdeviceexpectedsignature>
<com_atmel_avrdbg_tool_atmelice>
<ToolOptions>
<InterfaceProperties>
</InterfaceProperties>
<InterfaceName>debugWIRE</InterfaceName>
</ToolOptions>
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
<ToolNumber>J41800089261</ToolNumber>
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<avrtoolinterface>debugWIRE</avrtoolinterface>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
<Value>ARDUINO_NANO=0</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.linker.memorysettings.Flash>
<ListValues>
<Value>.text=0x3800</Value>
</ListValues>
</avrgcc.linker.memorysettings.Flash>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>ARDUINO_NANO=0</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize debugging experience (-Og)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.linker.memorysettings.Flash>
<ListValues>
<Value>.text=0x3800</Value>
</ListValues>
</avrgcc.linker.memorysettings.Flash>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
<Compile Include="machine.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="main.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="srec.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="srec.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="uart.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="uart.h">
<SubType>compile</SubType>
</Compile>
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>
+21
View File
@@ -0,0 +1,21 @@
/*
* machine.h
*
* Created: 03.03.2019 09:21:56
* Author: Jens
*/
#ifndef MACHINE_H_
#define MACHINE_H_
#if ARDUINO_NANO
#define F_CPU (16000000UL) // MHz
#else
#define F_CPU (18432000UL) // MHz
#endif
#endif /* MACHINE_H_ */
+264
View File
@@ -0,0 +1,264 @@
/*
* Bootloader.c
*
* Created: 03.03.2019 09:55:52
* Author : Jens
*/
#include "machine.h"
#include <ctype.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/boot.h>
#include <util/delay.h>
#include "uart.h"
#include "srec.h"
typedef void(fp_t)(void);
fp_t *startApplication = (fp_t*)0x0000; /* Funktionspointer auf 0x0000 */
fp_t *startBootloader = (fp_t*)0x7000; /* Funktionspointer auf 0x7000 */
#define SPM_PAGESIZE_MASK 0x7FUL
inline void bootloader_enter()
{
/* Interrupt Vektoren verbiegen */
char sregtemp = SREG;
char temp = MCUCR;
MCUCR = temp | (1<<IVCE);
MCUCR = temp | (1<<IVSEL);
SREG = sregtemp;
}
inline void bootloader_exit()
{
/* Interrupt Vektoren wieder gerade biegen */
char temp = MCUCR;
MCUCR = temp | (1<<IVCE);
MCUCR = temp & ~(1<<IVSEL);
}
typedef enum _eState
{
StateIdle = 0,
StateHex,
} State;
void erase_page(uint16_t page_addr);
void write_page(uint16_t page_addr, uint8_t *buf);
void program_page (uint32_t page, uint8_t *buf);
void init_page(uint8_t *pPageBuffer, size_t size)
{
for (int i=0; i < size; i++)
{
pPageBuffer[i] = 0xFF;
}
}
void port_init()
{
DDRB = 0x00;
DDRD = 0x40;
PORTD = 0x40;
}
int is_bsel()
{
return ((PINB & 1) == 0);
}
void led_bsel(int enable)
{
if (enable)
{
PORTD = 0x00;
}
else
{
PORTD = 0x40;
}
}
int main(void)
{
uint8_t page_buffer[SPM_PAGESIZE];
uint8_t hex_buffer[64];
State state = StateIdle;
State state_next;
srec_t srec;
port_init();
cli();
if (is_bsel())
{
bootloader_enter();
led_bsel(1);
uart_init(9600);
uart_puts("Hendi-Control Bootloader v1.2\n");
size_t image_size = 0;
uint16_t page_addr = 0xFFFF;
size_t hex_buffer_size = 0;
int leave_loop = 0;
int page_is_dirty = 0;
int force_page_erase = 1;
do
{
char c;
if ((c = uart_getc()))
{
char C = toupper(c);
state_next = state;
switch(state)
{
case StateIdle:
if (C == 'S')
{
hex_buffer_size = 0;
state_next = StateHex;
hex_buffer[hex_buffer_size++] = C;
}
if (C == 'R')
{
startBootloader();
}
if (C == 'Q')
{
leave_loop = 1;
}
break;
case StateHex:
if(((C != 0x0D) && (C != 0x0A)))
{
hex_buffer[hex_buffer_size++] = C;
}
else
{
int srec_state = srec_decode(&srec, hex_buffer, hex_buffer_size);
hex_buffer_size = 0;
switch(srec_state)
{
case srec_sob:
image_size = 0;
init_page(page_buffer, SPM_PAGESIZE);
page_is_dirty = 0;
break;
case srec_data:
{
uint16_t new_page_addr = srec.addr & ~SPM_PAGESIZE_MASK;
if ((new_page_addr != page_addr) || force_page_erase)
{
page_addr = new_page_addr;
force_page_erase = 0;
erase_page(page_addr);
}
uint16_t start = srec.addr & SPM_PAGESIZE_MASK;
uint16_t i = 0;
for (; i < srec.size; i++)
{
if (start == SPM_PAGESIZE)
{
break;
}
page_is_dirty = 1;
page_buffer[start++] = srec.data[i];
}
// Page buffer is complete -> write to flash
if (start == SPM_PAGESIZE)
{
page_is_dirty = 0;
write_page(page_addr, page_buffer);
init_page(page_buffer, SPM_PAGESIZE);
}
if (i < srec.size)
{
page_addr += SPM_PAGESIZE;
page_is_dirty = 1;
force_page_erase = 1;
start=0;
}
// Copy remaining data to start of page buffer
for (; i < srec.size; i++)
{
page_buffer[start++] = srec.data[i];
}
image_size += srec.size;
uart_putc('.');
}
break;
case srec_rec:
break;
case srec_eob:
state_next = StateIdle;
if (page_is_dirty)
{
if (force_page_erase)
{
erase_page(page_addr);
}
write_page(page_addr, page_buffer);
page_is_dirty = 0;
}
uart_puts("\nImage size: 0x"); print_word(image_size); uart_puts("\n");
/* Reenable RWW-section again. We need this if we want to jump back */
/* to the application after bootloading. */
boot_rww_enable ();
break;
case srec_err:
startBootloader();
break;
}
}
break;
default:
break;
}
state = state_next;
}
} while (!leave_loop);
uart_puts("Exit bootloader!\n\n");
bootloader_exit();
}
/* Return to address 0x0000 */
startApplication();
}
void erase_page(uint16_t page_addr)
{
// uart_puts("ErasePage: "); print_word(page_addr); uart_puts("\n");
eeprom_busy_wait ();
boot_spm_busy_wait ();
boot_page_erase (page_addr);
}
void write_page(uint16_t page_addr, uint8_t *pPageBuffer)
{
uint16_t i;
// uart_puts("Write page 0x"); print_word(page_addr); uart_puts("\n");
boot_spm_busy_wait (); /* Wait until the memory is erased. */
for (i=0; i<SPM_PAGESIZE; i+=2)
{
/* Set up little-endian word. */
uint16_t w = *(pPageBuffer++);
uint16_t v = *(pPageBuffer++);
w += v << 8;
boot_page_fill (page_addr + i, w);
}
boot_page_write (page_addr); /* Store buffer in flash page. */
}
+78
View File
@@ -0,0 +1,78 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
#include "srec.h"
uint8_t h2i(uint8_t *c)
{
int i;
uint8_t t, b = 0;
for (i=0; i < 2; i++)
{
t = c[i];
if (t >= 'A')
t = t - 'A' + 10;
else
t -= '0';
b = (b << 4) | t;
}
return b;
}
int srec_decode(srec_t *pRec, uint8_t *pBuf, int buflen)
{
uint8_t chksum, byte;
int alen, i;
if (!buflen)
return srec_err;
pRec->type = srec_rec;
alen = 0;
if ((pBuf[1] > '0') && (pBuf[1] < '4'))
{
alen = pBuf[1] - '0' + 1;
pRec->type = srec_data;
}
else if ((pBuf[1] >= '7') && (pBuf[1] <= '9'))
{
alen = 11 - (pBuf[1] - '0');
pRec->type = srec_eob;
}
else if (pBuf[1] == '0')
{
alen = 2;
pRec->type = srec_sob;
}
byte = h2i(&pBuf[2]);
pRec->size = byte;
chksum = byte;
pRec->addr = 0;
for (i=0; i < alen; i++)
{
byte = h2i(&pBuf[4+2*i]);
pRec->addr = pRec->addr << 8 | byte;
chksum += byte;
}
pRec->size -= (alen+1);
pRec->data = (uint8_t*) &pBuf[4 + 2*alen];
for (i=0; i < (int)pRec->size; i++)
{
byte = h2i(&pRec->data[2*i]);
pRec->data[i] = byte;
chksum += byte;
}
chksum = ~chksum;
byte = h2i(&pRec->data[2*i]);
if (chksum != byte)
return srec_err;
return pRec->type;
}
+45
View File
@@ -0,0 +1,45 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: srec.h
* Author: jens
*
* Created on 22. Januar 2017, 14:10
*/
#ifndef SREC_H
#define SREC_H
#include <stdint.h>
typedef struct _ssrec_t
{
uint32_t addr;
uint16_t size;
uint8_t type;
uint8_t *data;
} srec_t;
enum srec_type
{
srec_err, srec_sob, srec_data, srec_rec, srec_eob
};
#ifdef __cplusplus
extern "C" {
#endif
int srec_decode(srec_t *pRec, uint8_t *pBuf, int buflen);
int srec_getline(uint8_t *pLine);
#ifdef __cplusplus
}
#endif
#endif /* SREC_H */
+100
View File
@@ -0,0 +1,100 @@
/*
* uart.c
*
* Created: 20.02.2019 20:50:13
* Author: jens
*/
#include <stdlib.h>
#include <avr/io.h>
#include "uart.h"
void uart_init(uint32_t baudrate)
{
uint16_t prescale8 = UART_PRESCALE(baudrate, 8UL);
uint16_t prescale16 = UART_PRESCALE(baudrate, 16UL);
uint32_t baud8 = ((prescale8+1) * 8);
uint32_t baud16 = ((prescale16+1) * 16);
uint32_t err8 = abs(baudrate - baud8);
uint32_t err16 = abs(baudrate - baud16);
uint16_t prescale = prescale16;
if (err8 < err16)
{
prescale = prescale8;
// Double UART speed
UCSR0A |= 1 << U2X0;
}
// Set baud rate
UBRR0L = (uint8_t)prescale;
UBRR0H = (uint8_t)(prescale >> 8);
// Enable receiver and transmitter
UCSR0B = (1<<TXEN0)|(1<<RXEN0);
}
void uart_putc(char c)
{
while((UCSR0A & (1<<UDRE0)) == 0)
{
}
UDR0 = c;
}
char uart_getc()
{
while ((UCSR0A & (1 << RXC0)) == 0)
{
}
return UDR0;
}
void uart_puts(char const *str)
{
while(*str)
{
char c = *(str++);
uart_putc(c);
if (c == 0x0A)
{
uart_putc(0x0D);
}
}
}
void print_byte(char byte)
{
int i;
unsigned char c, nibble;
for (i=0; i < 2; i++)
{
nibble = (char)((byte >> 4) & 0xF);
byte <<= 4;
if (nibble < 10)
c = nibble + '0';
else
c = nibble + 'A' - 10;
uart_putc(c);
}
}
void print_word(uint16_t word)
{
int i;
unsigned char c;
for (i=0; i < 2; i++)
{
c = (char) (word >> 8);
print_byte(c);
word <<= 8;
}
}
+26
View File
@@ -0,0 +1,26 @@
/*
* uart.h
*
* Created: 20.02.2019 20:50:01
* Author: jens
*/
#ifndef UART_H_
#define UART_H_
#include "machine.h"
#define XON 17 /* XON Zeichen */
#define XOFF 19 /* XOFF Zeichen */
#define UART_PRESCALE(baudrate, smpPerBit) ((5+ 10*F_CPU / (baudrate*smpPerBit) - 1)/10)
void uart_init(uint32_t baudrate);
void uart_putc(char c);
char uart_getc(void);
void uart_puts(char const *str);
void print_byte(char byte);
void print_word(uint16_t word);
#endif /* UART_H_ */