Skip to content

Commit

Permalink
wip multiple targets
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossless committed Feb 7, 2024
1 parent 0bf0918 commit 3748c2b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
- name: Build release
run: nix develop --command make all
- name: Archive code coverage results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: firmware.hex
path: bin/main.hex
name: firmware
path: bin/*.hex

lint:
runs-on: ubuntu-latest
Expand Down
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ BINDIR = bin
FAMILY = mcs51
PROC = mcs51

FREQ_SYS ?= 24000000
FREQ_SYS ?= 24000000 # 24Mhz, could be keyboard specific
WATHCDOG_ENABLE ?= 1 # could be keyboard specific
XRAM_SIZE ?= 0x1000
XRAM_LOC ?= 0x0000
CODE_SIZE ?= 0xf000 # 61440 bytes (leaving the remaining 4096 for bootloader)
Expand All @@ -32,7 +33,7 @@ CFLAGS := -V -mmcs51 --model-small \
-I$(ROOT_DIR)../include \
-DDEBUG=$(DEBUG) \
-DFREQ_SYS=$(FREQ_SYS) \
-DWATCHDOG_ENABLE=1 \
-DWATCHDOG_ENABLE=$(WATHCDOG_ENABLE) \
-DUSB_VID=$(USB_VID) \
-DUSB_PID=$(USB_PID) \
-DSMK_VERSION=$(SMK_VERSION)
Expand All @@ -53,15 +54,18 @@ LIBSINO8051_OBJECTS := $(LIBSINO8051_SOURCES:$(SRCDIR)/lib/sh68f90a/%.c=$(OBJDIR
OVERRIDABLE_SOURCES := $(wildcard $(SRCDIR)/overridable/*.c)
OVERRIDABLE_OBJECTS := $(OVERRIDABLE_SOURCES:$(SRCDIR)/overridable/%.c=$(OBJDIR)/overridable/%.rel)

.PHONY: all clean flash
KEYBOARDS_LAYOUTS = nuphy-air60_default

all: $(BINDIR)/main.hex
.PHONY: all
all: $(KEYBOARDS_LAYOUTS:%=$(BINDIR)/%.hex)

.PHONY: clean
clean:
rm -rf $(BINDIR) $(OBJDIR)

flash: $(BINDIR)/main.hex
$(FLASHER) $(BINDIR)/main.hex
.PHONY: %_flash
%_flash: $(BINDIR)/%.hex
$(FLASHER) $(BINDIR)/%.hex

$(OBJDIR)/%.rel: $(SRCDIR)/%.c
@mkdir -p $(@D)
Expand All @@ -75,12 +79,12 @@ $(BINDIR)/sino8051.lib: $(LIBSINO8051_OBJECTS)
@mkdir -p $(@D)
$(SDAR) $@ $^

$(BINDIR)/main.ihx: $(MAIN_OBJECTS) $(BINDIR)/sino8051.lib $(BINDIR)/overridable.lib
$(BINDIR)/%.ihx: $(MAIN_OBJECTS) $(BINDIR)/sino8051.lib $(BINDIR)/overridable.lib
@mkdir -p $(@D)
$(CC) -m$(FAMILY) -l$(PROC) $(LFLAGS) -o $@ $(MAIN_OBJECTS) -L$(BINDIR) -loverridable -lsino8051

$(BINDIR)/%.hex: $(BINDIR)/%.ihx
${PACKIHX} < $< > $@

$(BINDIR)/%.bin: $(BINDIR)/%.ihx
$(BINDIR)/%.bin: $(BINDIR)/%.hex
$(OBJCOPY) -I ihex -O binary $< $@
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = "github:carlossless/nixpkgs/fixups"; # latest patches to get astyle 4.3.10 & sdcc 4.3.0 working
nixpkgs.url = "github:carlossless/nixpkgs/fixups"; # latest patches to get sdcc 4.3.0 working
utils.url = "github:numtide/flake-utils";
sinowealth-kb-tool.url = "github:carlossless/sinowealth-kb-tool";
};
Expand All @@ -23,6 +23,7 @@
sinowealth-kb-tool.packages."${system}".default
uhubctl
srecord
cmake
];
};
}
Expand Down
23 changes: 12 additions & 11 deletions src/lib/sh68f90a/delay.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>

// very naive implementation, not very accurate or optimized
// hardcoded for F_SYS = 12Mhz
// hardcoded for F_SYS = 24Mhz

void delay_ms(uint16_t cnt)
{
Expand All @@ -13,24 +13,25 @@ void delay_ms(uint16_t cnt)
}
}

void delay_us(uint16_t cnt)
void delay_us(uint16_t cnt) __naked
{
for (uint16_t i = 0; i < cnt; i++) {
// 4*6 = 24 instructions
// @ 12 Mhz one cycle should be 1us
// @ 24 Mhz one cycle should be 1us
// unverified

#ifdef WATCHDOG_ENABLE
CLR_WDT();
_nop_3_();
CLR_WDT(); // 2c
_nop_3_(); // 3c
#else
_nop_4_();
_nop_4_(); // 4c
#endif

_nop_4_();
_nop_4_();
_nop_4_();
_nop_4_();
_nop_4_();
_nop_4_(); // 4c
_nop_4_(); // 4c
_nop_4_(); // 4c
_nop_4_(); // 4c
_nop_4_(); // 4c
// =
}
}

0 comments on commit 3748c2b

Please sign in to comment.