mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2024-12-25 07:29:25 -05:00
fw: Move LED defines and function to own files
Signed-off-by: Daniel Lublin <daniel@lublin.se>
This commit is contained in:
parent
ccc3b16569
commit
bbbe1e2f31
@ -74,6 +74,7 @@ FIRMWARE_DEPS = \
|
|||||||
$(P)/fw/tk1/lib.h \
|
$(P)/fw/tk1/lib.h \
|
||||||
$(P)/fw/tk1/proto.h \
|
$(P)/fw/tk1/proto.h \
|
||||||
$(P)/fw/tk1/assert.h \
|
$(P)/fw/tk1/assert.h \
|
||||||
|
$(P)/fw/tk1/led.h
|
||||||
|
|
||||||
FIRMWARE_OBJS = \
|
FIRMWARE_OBJS = \
|
||||||
$(P)/fw/tk1/main.o \
|
$(P)/fw/tk1/main.o \
|
||||||
@ -81,6 +82,7 @@ FIRMWARE_OBJS = \
|
|||||||
$(P)/fw/tk1/proto.o \
|
$(P)/fw/tk1/proto.o \
|
||||||
$(P)/fw/tk1/lib.o \
|
$(P)/fw/tk1/lib.o \
|
||||||
$(P)/fw/tk1/assert.o \
|
$(P)/fw/tk1/assert.o \
|
||||||
|
$(P)/fw/tk1/led.o \
|
||||||
$(P)/fw/tk1/blake2s/blake2s.o
|
$(P)/fw/tk1/blake2s/blake2s.o
|
||||||
|
|
||||||
TESTFW_OBJS = \
|
TESTFW_OBJS = \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Uses ../.clang-format
|
# Uses ../.clang-format
|
||||||
FMTFILES=main.c lib.h lib.c proto.h proto.c types.h assert.c assert.h
|
FMTFILES=main.c lib.h lib.c proto.h proto.c types.h assert.c assert.h led.c led.h
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt:
|
fmt:
|
||||||
clang-format --dry-run --ferror-limit=0 $(FMTFILES)
|
clang-format --dry-run --ferror-limit=0 $(FMTFILES)
|
||||||
|
@ -20,6 +20,5 @@ void __assert_fail(const char *__assertion, const char *__file,
|
|||||||
htif_lf();
|
htif_lf();
|
||||||
|
|
||||||
for (;;);
|
for (;;);
|
||||||
|
|
||||||
// Not reached
|
// Not reached
|
||||||
}
|
}
|
||||||
|
21
hw/application_fpga/fw/tk1/led.c
Normal file
21
hw/application_fpga/fw/tk1/led.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022, 2023 - Tillitis AB
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "led.h"
|
||||||
|
#include "../tk1_mem.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
void forever_redflash()
|
||||||
|
{
|
||||||
|
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
|
||||||
|
|
||||||
|
int led_on = 0;
|
||||||
|
for (;;) {
|
||||||
|
*led = led_on ? LED_RED : 0;
|
||||||
|
for (volatile int i = 0; i < 800000; i++) {
|
||||||
|
}
|
||||||
|
led_on = !led_on;
|
||||||
|
}
|
||||||
|
}
|
22
hw/application_fpga/fw/tk1/led.h
Normal file
22
hw/application_fpga/fw/tk1/led.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022, 2023 - Tillitis AB
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LED_H
|
||||||
|
#define LED_H
|
||||||
|
|
||||||
|
#include "../tk1_mem.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
#define LED_RED (1 << TK1_MMIO_TK1_LED_R_BIT)
|
||||||
|
#define LED_GREEN (1 << TK1_MMIO_TK1_LED_G_BIT)
|
||||||
|
#define LED_BLUE (1 << TK1_MMIO_TK1_LED_B_BIT)
|
||||||
|
#define LED_WHITE (LED_RED | LED_GREEN | LED_BLUE)
|
||||||
|
|
||||||
|
void forever_redflash();
|
||||||
|
#endif
|
@ -4,8 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "types.h"
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
#if NOCONSOLE
|
#if NOCONSOLE
|
||||||
void htif_putc(int ch)
|
void htif_putc(int ch)
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../tk1_mem.h"
|
#include "../tk1_mem.h"
|
||||||
|
#include "assert.h"
|
||||||
#include "blake2s/blake2s.h"
|
#include "blake2s/blake2s.h"
|
||||||
|
#include "led.h"
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "assert.h"
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static volatile uint32_t *uds = (volatile uint32_t *)TK1_MMIO_UDS_FIRST;
|
static volatile uint32_t *uds = (volatile uint32_t *)TK1_MMIO_UDS_FIRST;
|
||||||
@ -21,7 +22,6 @@ static volatile uint32_t *cdi = (volatile uint32_t *)TK1_MMIO_TK1_CD
|
|||||||
static volatile uint32_t *app_addr = (volatile uint32_t *)TK1_MMIO_TK1_APP_ADDR;
|
static volatile uint32_t *app_addr = (volatile uint32_t *)TK1_MMIO_TK1_APP_ADDR;
|
||||||
static volatile uint32_t *app_size = (volatile uint32_t *)TK1_MMIO_TK1_APP_SIZE;
|
static volatile uint32_t *app_size = (volatile uint32_t *)TK1_MMIO_TK1_APP_SIZE;
|
||||||
static volatile uint8_t *fw_ram = (volatile uint8_t *)TK1_MMIO_FW_RAM_BASE;
|
static volatile uint8_t *fw_ram = (volatile uint8_t *)TK1_MMIO_FW_RAM_BASE;
|
||||||
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
|
|
||||||
static volatile uint32_t *fw_blake2s_addr = (volatile uint32_t *)TK1_MMIO_TK1_BLAKE2S;
|
static volatile uint32_t *fw_blake2s_addr = (volatile uint32_t *)TK1_MMIO_TK1_BLAKE2S;
|
||||||
static volatile uint32_t *trng_status = (volatile uint32_t *)TK1_MMIO_TRNG_STATUS;
|
static volatile uint32_t *trng_status = (volatile uint32_t *)TK1_MMIO_TRNG_STATUS;
|
||||||
static volatile uint32_t *trng_entropy = (volatile uint32_t *)TK1_MMIO_TRNG_ENTROPY;
|
static volatile uint32_t *trng_entropy = (volatile uint32_t *)TK1_MMIO_TRNG_ENTROPY;
|
||||||
@ -29,11 +29,6 @@ static volatile uint32_t *timer = (volatile uint32_t *)TK1_MMIO_TIMER_
|
|||||||
static volatile uint32_t *timer_prescaler = (volatile uint32_t *)TK1_MMIO_TIMER_PRESCALER;
|
static volatile uint32_t *timer_prescaler = (volatile uint32_t *)TK1_MMIO_TIMER_PRESCALER;
|
||||||
static volatile uint32_t *timer_status = (volatile uint32_t *)TK1_MMIO_TIMER_STATUS;
|
static volatile uint32_t *timer_status = (volatile uint32_t *)TK1_MMIO_TIMER_STATUS;
|
||||||
static volatile uint32_t *timer_ctrl = (volatile uint32_t *)TK1_MMIO_TIMER_CTRL;
|
static volatile uint32_t *timer_ctrl = (volatile uint32_t *)TK1_MMIO_TIMER_CTRL;
|
||||||
|
|
||||||
#define LED_RED (1 << TK1_MMIO_TK1_LED_R_BIT)
|
|
||||||
#define LED_GREEN (1 << TK1_MMIO_TK1_LED_G_BIT)
|
|
||||||
#define LED_BLUE (1 << TK1_MMIO_TK1_LED_B_BIT)
|
|
||||||
#define LED_WHITE (LED_RED | LED_GREEN | LED_BLUE)
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
struct namever {
|
struct namever {
|
||||||
@ -141,17 +136,6 @@ static void compute_cdi(uint8_t digest[32], uint8_t use_uss, uint8_t uss[32])
|
|||||||
wordcpy_s((void *)cdi, 8, (void *)local_cdi, 8);
|
wordcpy_s((void *)cdi, 8, (void *)local_cdi, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void forever_redflash()
|
|
||||||
{
|
|
||||||
int led_on = 0;
|
|
||||||
for (;;) {
|
|
||||||
*led = led_on ? LED_RED : 0;
|
|
||||||
for (volatile int i = 0; i < 800000; i++) {
|
|
||||||
}
|
|
||||||
led_on = !led_on;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum state {
|
enum state {
|
||||||
FW_STATE_INITIAL,
|
FW_STATE_INITIAL,
|
||||||
FW_STATE_INIT_LOADING,
|
FW_STATE_INIT_LOADING,
|
||||||
|
Loading…
Reference in New Issue
Block a user