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 pwm \n 16 * 17 * History: \n 18 * 2022-09-16, Create file. \n 19 */ 20 21 #include "common_def.h" 22 #include "hal_pwm.h" 23 24 uintptr_t g_pwm_regs = NULL; 25 hal_pwm_funcs_t *g_hal_pwm_funcs = NULL; 26 hal_pwm_regs_init(void)27errcode_t hal_pwm_regs_init(void) 28 { 29 if (pwm_porting_base_addr_get() == 0) { 30 return ERRCODE_PWM_REG_ADDR_INVALID; 31 } 32 33 g_pwm_regs = pwm_porting_base_addr_get(); 34 35 return ERRCODE_SUCC; 36 } 37 hal_pwm_regs_deinit(void)38void hal_pwm_regs_deinit(void) 39 { 40 g_pwm_regs = NULL; 41 } 42 hal_pwm_register_funcs(hal_pwm_funcs_t * funcs)43errcode_t hal_pwm_register_funcs(hal_pwm_funcs_t *funcs) 44 { 45 if (funcs == NULL) { 46 return ERRCODE_INVALID_PARAM; 47 } 48 49 g_hal_pwm_funcs = funcs; 50 51 return ERRCODE_SUCC; 52 } 53 hal_pwm_unregister_funcs(void)54errcode_t hal_pwm_unregister_funcs(void) 55 { 56 g_hal_pwm_funcs = NULL; 57 return ERRCODE_SUCC; 58 } 59 hal_pwm_get_funcs(void)60hal_pwm_funcs_t *hal_pwm_get_funcs(void) 61 { 62 return g_hal_pwm_funcs; 63 }