mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-03-12 18:16:55 -04:00
PoC: Integrate spi and flash code
This commit is contained in:
parent
12c23cc149
commit
cbc7adf706
@ -128,7 +128,9 @@ FIRMWARE_OBJS = \
|
|||||||
$(P)/fw/tk1/assert.o \
|
$(P)/fw/tk1/assert.o \
|
||||||
$(P)/fw/tk1/led.o \
|
$(P)/fw/tk1/led.o \
|
||||||
$(P)/fw/tk1/blake2s/blake2s.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 = \
|
FIRMWARE_SOURCES = \
|
||||||
$(P)/fw/tk1/main.c \
|
$(P)/fw/tk1/main.c \
|
||||||
@ -137,7 +139,9 @@ FIRMWARE_SOURCES = \
|
|||||||
$(P)/fw/tk1/assert.c \
|
$(P)/fw/tk1/assert.c \
|
||||||
$(P)/fw/tk1/led.c \
|
$(P)/fw/tk1/led.c \
|
||||||
$(P)/fw/tk1/blake2s/blake2s.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 = \
|
TESTFW_OBJS = \
|
||||||
$(P)/fw/testfw/main.o \
|
$(P)/fw/testfw/main.o \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Uses ../.clang-format
|
# Uses ../.clang-format
|
||||||
FMTFILES=main.c lib.h lib.c proto.h proto.c types.h assert.c assert.h led.c \
|
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
|
.PHONY: fmt
|
||||||
fmt:
|
fmt:
|
||||||
clang-format --dry-run --ferror-limit=0 $(FMTFILES)
|
clang-format --dry-run --ferror-limit=0 $(FMTFILES)
|
||||||
|
@ -2,12 +2,11 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
#include "../tk1/types.h"
|
||||||
#include "../tk1_mem.h"
|
#include "../tk1_mem.h"
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static volatile uint32_t *timer = (volatile uint32_t *)TK1_MMIO_TIMER_TIMER;
|
static volatile uint32_t *timer = (volatile uint32_t *)TK1_MMIO_TIMER_TIMER;
|
||||||
|
@ -2,11 +2,9 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
#include "../tk1/types.h"
|
||||||
#include "../tk1_mem.h"
|
#include "../tk1_mem.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static volatile uint32_t *spi_en = (volatile uint32_t *)(TK1_MMIO_TK1_BASE | 0x200);
|
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);
|
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.
|
// 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,
|
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)
|
uint8_t *rx_buf, size_t rx_size)
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#ifndef TKEY_SPI_H
|
#ifndef TKEY_SPI_H
|
||||||
#define TKEY_SPI_H
|
#define TKEY_SPI_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include "../tk1/types.h"
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
int spi_ready(void);
|
int spi_ready(void);
|
||||||
int spi_transfer(uint8_t *cmd, size_t cmd_size, uint8_t *tx_buf, size_t tx_size,
|
int spi_transfer(uint8_t *cmd, size_t cmd_size, uint8_t *tx_buf, size_t tx_size,
|
||||||
|
@ -14,7 +14,7 @@ typedef long long int64_t;
|
|||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned long size_t;
|
typedef unsigned long size_t;
|
||||||
|
|
||||||
#define NULL ((char *)0)
|
#define NULL ((void *)0)
|
||||||
|
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#define TRUE !FALSE
|
#define TRUE !FALSE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user