tillitis-key/hw/application_fpga/fw/tk1/assert.c

31 lines
561 B
C
Raw Normal View History

/*
* Copyright (C) 2022, 2023 - Tillitis AB
* SPDX-License-Identifier: GPL-2.0-only
*/
#include "assert.h"
#include "led.h"
#include "lib.h"
void assert_fail(const char *assertion, const char *file, unsigned int line,
const char *function)
{
htif_puts("assert: ");
htif_puts(assertion);
htif_puts(" ");
htif_puts(file);
htif_puts(":");
htif_putinthex(line);
htif_puts(" ");
htif_puts(function);
htif_lf();
#ifndef S_SPLINT_S
2024-03-14 10:07:42 -04:00
// Force illegal instruction to halt CPU
asm volatile("unimp");
#endif
2024-03-14 10:07:42 -04:00
// Not reached
2024-03-14 10:07:42 -04:00
__builtin_unreachable();
}