diff --git a/hw/application_fpga/Makefile b/hw/application_fpga/Makefile index 3dafab6..1281b35 100644 --- a/hw/application_fpga/Makefile +++ b/hw/application_fpga/Makefile @@ -128,7 +128,9 @@ FIRMWARE_OBJS = \ $(P)/fw/tk1/assert.o \ $(P)/fw/tk1/led.o \ $(P)/fw/tk1/blake2s/blake2s.o \ - $(P)/fw/tk1/syscall.o + $(P)/fw/tk1/syscall.o \ + $(P)/fw/tk1/spi.o \ + $(P)/fw/tk1/flash.o FIRMWARE_SOURCES = \ $(P)/fw/tk1/main.c \ @@ -137,7 +139,9 @@ FIRMWARE_SOURCES = \ $(P)/fw/tk1/assert.c \ $(P)/fw/tk1/led.c \ $(P)/fw/tk1/blake2s/blake2s.c \ - $(P)/fw/tk1/syscall.c + $(P)/fw/tk1/syscall.c \ + $(P)/fw/tk1/spi.c \ + $(P)/fw/tk1/flash.c TESTFW_OBJS = \ $(P)/fw/testfw/main.o \ diff --git a/hw/application_fpga/fw/tk1/Makefile b/hw/application_fpga/fw/tk1/Makefile index 3c1cd5f..2ac03fa 100644 --- a/hw/application_fpga/fw/tk1/Makefile +++ b/hw/application_fpga/fw/tk1/Makefile @@ -1,6 +1,6 @@ # Uses ../.clang-format FMTFILES=main.c lib.h lib.c proto.h proto.c types.h assert.c assert.h led.c \ - led.h syscall.c + led.h syscall.c spi.c spi.h flash.c flash.h .PHONY: fmt fmt: clang-format --dry-run --ferror-limit=0 $(FMTFILES) diff --git a/hw/application_fpga/fw/tk1/flash.c b/hw/application_fpga/fw/tk1/flash.c index 3be9431..efa8c47 100644 --- a/hw/application_fpga/fw/tk1/flash.c +++ b/hw/application_fpga/fw/tk1/flash.c @@ -2,12 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-only #include "flash.h" +#include "../tk1/types.h" #include "../tk1_mem.h" #include "spi.h" #include -#include -#include // clang-format off static volatile uint32_t *timer = (volatile uint32_t *)TK1_MMIO_TIMER_TIMER; diff --git a/hw/application_fpga/fw/tk1/spi.c b/hw/application_fpga/fw/tk1/spi.c index 4246ccb..ba50e35 100644 --- a/hw/application_fpga/fw/tk1/spi.c +++ b/hw/application_fpga/fw/tk1/spi.c @@ -2,11 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-only #include "spi.h" +#include "../tk1/types.h" #include "../tk1_mem.h" -#include -#include - // clang-format off static volatile uint32_t *spi_en = (volatile uint32_t *)(TK1_MMIO_TK1_BASE | 0x200); static volatile uint32_t *spi_xfer = (volatile uint32_t *)(TK1_MMIO_TK1_BASE | 0x204); @@ -64,7 +62,6 @@ static void _spi_read(uint8_t *buf, size_t size) } } - // Function to both read and write data to the connected SPI flash. int spi_transfer(uint8_t *cmd, size_t cmd_size, uint8_t *tx_buf, size_t tx_size, uint8_t *rx_buf, size_t rx_size) diff --git a/hw/application_fpga/fw/tk1/spi.h b/hw/application_fpga/fw/tk1/spi.h index 2c59f4c..0db6555 100644 --- a/hw/application_fpga/fw/tk1/spi.h +++ b/hw/application_fpga/fw/tk1/spi.h @@ -4,8 +4,7 @@ #ifndef TKEY_SPI_H #define TKEY_SPI_H -#include -#include +#include "../tk1/types.h" int spi_ready(void); int spi_transfer(uint8_t *cmd, size_t cmd_size, uint8_t *tx_buf, size_t tx_size, diff --git a/hw/application_fpga/fw/tk1/types.h b/hw/application_fpga/fw/tk1/types.h index 9a1fcff..2ed09d5 100644 --- a/hw/application_fpga/fw/tk1/types.h +++ b/hw/application_fpga/fw/tk1/types.h @@ -14,7 +14,7 @@ typedef long long int64_t; typedef unsigned char uint8_t; typedef unsigned long size_t; -#define NULL ((char *)0) +#define NULL ((void *)0) #define FALSE 0 #define TRUE !FALSE