kos_sys/arch/
wdt.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Rust for KallistiOS/Dreamcast
// Copyright (C) 2024 Eric Fradella
// https://dreamcast.rs/

use crate::prelude::*;

#[repr(C)]
pub enum WDT_CLK_DIV {
    WDT_CLK_DIV_32,
    WDT_CLK_DIV_64,
    WDT_CLK_DIV_128,
    WDT_CLK_DIV_256,
    WDT_CLK_DIV_512,
    WDT_CLK_DIV_1024,
    WDT_CLK_DIV_2048,
    WDT_CLK_DIV_4096,
}

#[repr(C)]
pub enum WDT_RST {
    WDT_RST_POWER_ON,
    WDT_RST_MANUAL,
}

pub type wdt_callback = Option<unsafe extern "C" fn(user_data: *mut c_void)>;

#[link(name = "kallisti")]
extern "C" {
    pub fn wdt_enable_timer(initial_count: u8, microsec_period: u32, irq_prio: u8,
                            callback: wdt_callback, user_data: *mut c_void);
    pub fn wdt_enable_watchdog(initial_count: u8, clk_config: WDT_CLK_DIV,
                               reset_select: WDT_RST);
    pub fn wdt_get_counter() -> u8;
    pub fn wdt_set_counter(value: u8);
    pub fn wdt_pet();
    pub fn wdt_disable();
    pub fn wdt_is_enabled() -> c_int;
}