Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions example/echodw/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

#MCU=attiny13
#F_CPU = 9600000
MCU=attiny84
F_CPU = 8000000
#MCU=attiny85
#F_CPU = 1000000

CFLAGS =
CFLAGS += -Wno-deprecated-declarations
CFLAGS += -Wl,--gc-sections
CFLAGS += -fdata-sections -ffunction-sections
COMPILE = avr-gcc -Wall -Os --std=c++11 -save-temps=obj -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(MCU)

BASENAME = $(notdir $(PWD))
OBJECTS = $(addsuffix .o, $(basename $(wildcard *.cpp)))

all: $(BASENAME).elf

dwload:
dwdebug l $(BASENAME).elf ,qr

clean:
rm -f *.elf *.map *.o *.i *.ii *.s *.lss

.cpp.o:
$(COMPILE) -c $< -o $@

%.i: %.cpp
$(COMPILE) -E -c $< -o $@

$(BASENAME).elf: $(OBJECTS)
$(COMPILE) -Wl,-Map,$(BASENAME).map -o $(BASENAME).elf $(OBJECTS)

disasm: $(BASENAME).elf
avr-objdump -d $(BASENAME).elf > $(BASENAME).lss
20 changes: 20 additions & 0 deletions example/echodw/core.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// items used in assembler as well as C
#ifndef MUAPK_EXP
#define MUAPK_EXP(A) A
#define MUAPK_INT(A0,A1) A0##A1
#define MUAPK_CAT(A0,A1) MUAPK_INT(A0,A1)
#define MUAPK_2_0(A0,A1) A0
#define MUAPK_2_1(A0,A1) A1
#define MUAPK_3_0(A0,A1,A2) A0
#define MUAPK_3_1(A0,A1,A2) A1
#define MUAPK_3_2(A0,A1,A2) A2
#define MUAPK_4_0(A0,A1,A2,A3) A0
#define MUAPK_4_1(A0,A1,A2,A3) A1
#define MUAPK_4_2(A0,A1,A2,A3) A2
#define MUAPK_4_3(A0,A1,A2,A3) A3
#define MUAPK_5_0(A0,A1,A2,A3,A4) A0
#define MUAPK_5_1(A0,A1,A2,A3,A4) A1
#define MUAPK_5_2(A0,A1,A2,A3,A4) A2
#define MUAPK_5_3(A0,A1,A2,A3,A4) A3
#define MUAPK_5_4(A0,A1,A2,A3,A4) A4
#endif // MUAPK_EXP
27 changes: 27 additions & 0 deletions example/echodw/echodw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

#include "uartsoft.hpp"

#include <avr/wdt.h>
#include <string.h>
#include <util/delay.h>

int main() {
uartSoft.begin();

for (;;) {
wdt_reset();
_delay_ms(100);

// get the data
char* s;
uint8_t n = uartSoft.read(&s);
if (!n) continue;

// send it back
char buf[32] = "got: ";
strcat(buf, s);
strcat(buf, "\n");
_delay_ms(100);
uartSoft.write(buf, strlen(buf));
}
}
19 changes: 19 additions & 0 deletions example/echodw/rpc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef rpc_hpp
#define rpc_hpp

#ifdef CORE_RPC_HPP
#include "../core/rpc.hpp"
#else

#include <stdint.h>

const uint8_t RpcPayloadMax = 0;
const uint8_t RpcNumber = 0;
struct RpcSend { };
struct Rpc {
inline uint8_t Size(uint8_t i) { return 0; }
inline void VtAct(uint8_t i) { }
};

#endif // CORE_RPC_HPP
#endif
Loading