]> begriffs open source - cmsis-freertos/blob - Demo/RISC-V_RV32_SiFive_HiFive1-RevB_FreedomStudio/freedom-metal/src/drivers/sifive_test0.c
Update README.md - branch main is now the base branch
[cmsis-freertos] / Demo / RISC-V_RV32_SiFive_HiFive1-RevB_FreedomStudio / freedom-metal / src / drivers / sifive_test0.c
1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
3
4 #include <metal/machine/platform.h>
5
6 #ifdef METAL_SIFIVE_TEST0
7
8 #include <metal/machine.h>
9
10 #include <stdint.h>
11
12 #include <metal/drivers/sifive_test0.h>
13 #include <metal/io.h>
14
15 void __metal_driver_sifive_test0_exit(const struct __metal_shutdown *sd,
16                                       int code) __attribute__((noreturn));
17 void __metal_driver_sifive_test0_exit(const struct __metal_shutdown *sd,
18                                       int code) {
19     long base = __metal_driver_sifive_test0_base(sd);
20     uint32_t out = (code << 16) + (code == 0 ? 0x5555 : 0x3333);
21     while (1) {
22         __METAL_ACCESS_ONCE((
23             __metal_io_u32 *)(base + METAL_SIFIVE_TEST0_FINISHER_OFFSET)) = out;
24     }
25 }
26
27 __METAL_DEFINE_VTABLE(__metal_driver_vtable_sifive_test0) = {
28     .shutdown.exit = &__metal_driver_sifive_test0_exit,
29 };
30 #endif /* METAL_SIFIVE_TEST0 */
31
32 typedef int no_empty_translation_units;