1 /** 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * 15 * Description: Provides hal watchdog \n 16 * 17 * History: \n 18 * 2022-07-26, Create file. \n 19 */ 20 #include <stdint.h> 21 #include <stdio.h> 22 #include "hal_watchdog.h" 23 24 uintptr_t g_watchdog_regs; 25 hal_watchdog_funcs_t *g_hal_watchdogs_funcs = NULL; 26 hal_watchdog_register_funcs(hal_watchdog_funcs_t * funcs)27errcode_t hal_watchdog_register_funcs(hal_watchdog_funcs_t *funcs) 28 { 29 if (funcs == NULL) { 30 return ERRCODE_INVALID_PARAM; 31 } 32 g_hal_watchdogs_funcs = funcs; 33 return ERRCODE_SUCC; 34 } 35 hal_watchdog_unregister_funcs(void)36errcode_t hal_watchdog_unregister_funcs(void) 37 { 38 g_hal_watchdogs_funcs = NULL; 39 return ERRCODE_SUCC; 40 } 41 hal_watchdog_get_funcs(void)42hal_watchdog_funcs_t *hal_watchdog_get_funcs(void) 43 { 44 return g_hal_watchdogs_funcs; 45 } 46 hal_watchdog_regs_init(void)47errcode_t hal_watchdog_regs_init(void) 48 { 49 if (g_watchdog_base_addr == 0) { 50 return ERRCODE_WDT_REG_ADDR_INVALID; 51 } 52 53 g_watchdog_regs = g_watchdog_base_addr; 54 return ERRCODE_SUCC; 55 } 56 hal_watchdog_regs_deinit(void)57void hal_watchdog_regs_deinit(void) 58 { 59 g_watchdog_regs = 0; 60 } 61