PoC: Integrate spi and flash code

This commit is contained in:
Mikael Ågren 2025-02-03 17:46:25 +01:00
parent 12c23cc149
commit cbc7adf706
No known key found for this signature in database
GPG Key ID: E02DA3D397792C46
6 changed files with 11 additions and 12 deletions

View File

@ -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 \

View File

@ -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)

View File

@ -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 <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// clang-format off
static volatile uint32_t *timer = (volatile uint32_t *)TK1_MMIO_TIMER_TIMER;

View File

@ -2,11 +2,9 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "spi.h"
#include "../tk1/types.h"
#include "../tk1_mem.h"
#include <stddef.h>
#include <stdint.h>
// 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)

View File

@ -4,8 +4,7 @@
#ifndef TKEY_SPI_H
#define TKEY_SPI_H
#include <stddef.h>
#include <stdint.h>
#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,

View File

@ -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