Doing simulation I2C when, Software delay is required, Be ignorant of W801 Is there any similar STM32 the_nop Easy software delay for operation
There are nop
#include "wm_hal. h"
#include "assert. h"
//160MZH 53 a nop exactly 1us
//240Mhz 80 a nop exactly 1us
//Can be realized 1ms Following delay, Much more Don't use it. forbid.
//5u The following delays are subject to error Look out.
static void Delay_Us (uint8_t freq, uint32_t time)
{
uint32_t i;
uint16_t num = 90;
if (time " 1000)
{
printf ("delay time is too lager than 1000, please use HAL_Delay () \r\n") ;
}
switch (freq)
{
case 240: num = 80; break;
case 160: num = 53; break;
default: printf ("delay input freq err. . . default set 240MHZ us time \r\n ") ; break;
}
for (i = 0; i " (num) *time; i++)
{
__NOP () ;
}
}