File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
bsp/stm32/libraries/HAL_Drivers Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,41 @@ void _Error_Handler(char *s, int num)
8686 /* USER CODE END Error_Handler */
8787}
8888
89+ /**
90+ * This function will delay for some us.
91+ *
92+ * @param us the delay time of us
93+ */
94+ void rt_hw_us_delay (rt_uint32_t us )
95+ {
96+ rt_uint32_t ticks ;
97+ rt_uint32_t told , tnow , tcnt = 0 ;
98+ rt_uint32_t reload = SysTick -> LOAD ;
99+
100+ ticks = us * reload / (1000000 / RT_TICK_PER_SECOND );
101+ told = SysTick -> VAL ;
102+ while (1 )
103+ {
104+ tnow = SysTick -> VAL ;
105+ if (tnow != told )
106+ {
107+ if (tnow < told )
108+ {
109+ tcnt += told - tnow ;
110+ }
111+ else
112+ {
113+ tcnt += reload - tnow + told ;
114+ }
115+ told = tnow ;
116+ if (tcnt >= ticks )
117+ {
118+ break ;
119+ }
120+ }
121+ }
122+ }
123+
89124/**
90125 * This function will initial STM32 board.
91126 */
You can’t perform that action at this time.
0 commit comments