• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 #include <hi_types_base.h>
19 #include <hi_config.h>
20 
ms2systick(HI_IN hi_u32 ms,HI_IN hi_bool include0)21 hi_u32 ms2systick(HI_IN hi_u32 ms, HI_IN hi_bool include0)
22 {
23     hi_u32 tick;
24 
25     /* >10ms向下对齐 */
26     if (ms > HI_MILLISECOND_PER_TICK) {
27         tick = ms / HI_MILLISECOND_PER_TICK; /* convert from ms to ticks */
28     }
29     /* <10ms向上对齐 */
30     else {
31         if ((HI_TRUE == include0) && (0 == ms)) {
32             tick = 0;
33         } else {
34             tick = 1;
35         }
36     }
37 
38     return tick;
39 }
40