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 ws63 HAL systick \n 16 * 17 * History: \n 18 * 2023-04-06, Create file. \n 19 */ 20 #include <stdint.h> 21 #include "systick_porting.h" 22 #include "hal_systick_ws63.h" 23 hal_systick_init(void)24void hal_systick_init(void) 25 { 26 return; 27 } 28 hal_systick_deinit(void)29void hal_systick_deinit(void) 30 { 31 return; 32 } 33 hal_systick_count_clear(void)34errcode_t hal_systick_count_clear(void) 35 { 36 return ERRCODE_SUCC; 37 } 38 rtc_read_once(void)39STATIC uint64_t rtc_read_once(void) 40 { 41 uint32_t low = (*(volatile uint32_t*)(uintptr_t)RTC_TIME_OUT_L); 42 uint32_t high = (*(volatile uint32_t*)(uintptr_t)(RTC_TIME_OUT_H)); 43 return low + (((uint64_t)((high & 0xFFFF))) << 32); // H Move right 32 bit 44 } 45 rtc_read_ts(void)46STATIC uint64_t rtc_read_ts(void) 47 { 48 uint64_t ts1 = rtc_read_once(); 49 uint64_t ts2 = rtc_read_once(); 50 51 return (ts1 == ts2) ? ts1 : ts2; 52 } 53 hal_systick_get_count(void)54uint64_t hal_systick_get_count(void) 55 { 56 return rtc_read_ts(); 57 }