我们找到这个函数,其调用了用户函数delay_decrement()。后者是由用户编写的一个应用程序。 /* brief delay decrement param[in] none param[out] none retval none */voiddelay_decrement(void){if(0U != delay){ delay--; } } 每次进入 SysTick 中断就调用一次 delay_decrement()函数,使全局变量delay 自减...
i2c_flag_get(I2Cx, I2C_FLAG_TBE)){if((I2C_Timeout--) == 0){Resume_IIC(I2C_LONG_TIMEOUT,I2Cx);return I2C_FAIL;}} /* point to the next location where the byte read will be saved */ write_Buffer++; /* decrement the read bytes counter */ number_Bytes--; } // while(!i2c_...
*/voiddelay_1ms(uint32_tcount){ delay = count *1000;while(0U!= delay) { } }/*! \brief delay decrement \param[in] none \param[out] none \retval none */voiddelay_decrement(void){if(0U!= delay) { delay--; } }voiddelay_1us(uint32_tcount){ delay = count;while(0U!= delay) ...
}voidSysTick_Handler(void){ delay_decrement(); } 然后编译: pio run -e genericGD32F103CB 效果 h:1492:13: warning:'enet_delay'declared'static'but never defined [-Wunused-function] 1492 | static void enet_delay(uint32_t ncount); | ^~~~ Archiving .pio/build/genericGD32F103CB/libFramewo...
/* decrement the read bytes counter */ number_Bytes--; } // while(!i2c_flag_get(I2C1, I2C_BTC)) // { // if((I2C_Timeout--) == 0) // { // Resume_IIC(I2C_LONG_TIMEOUT,I2Cx); // return I2C_FAIL; // } // }
在GD32 的应用中,使用 Cortex-M3 内核的 SysTick 作为定时时钟,设定每一毫秒产生一次中断,在中断处理函数里对 N 减一,在Delay(N) 函数中循环检测 N 是否为 0,不为 0 则进行循环等待;若为 0 则关闭 SysTick 时钟,退出函数。 注: 全局变量 TimingDelay , 必须定义为 volatile 类型 , 延迟时间将不随系统...
gpio_bit_reset(GPIO_SCL, GPIO_Pin_SCL); Delay_I2C(20); gpio_bit_reset(GPIO_SDA, GPIO_Pin_SDA); Delay_I2C(20); gpio_bit_set(GPIO_SCL, GPIO_Pin_SCL); Delay_I2C(20); gpio_bit_set(GPIO_SDA, GPIO_Pin_SDA); Delay_I2C(20); if(Timeout-- == 0) return; }while((!gpio_input_...
volatile static uint32_t delay; void delay_decrement(void) { if(0U != delay) { delay--; } } 那么,一旦重新使能SysTick定时器,给delay赋一个初值,那么每经过一次SysTick中断触发,就会递减,直到归零为止。 而我们的代码中,就可以通过判断delay的值,来检查是否经过了所需次数的Tick。因为系统时钟周期为1...
void delay_decrement(void){ if (0U != delay_count){ delay_count--; /* 系统滴答中断中每次减...
其中S 表示由主机的I2C接口产生的传输起始信号(S),这时连接到I2C总线上的所有从机都会接收到这个信号。 起始信号产生后,所有从机就开始等待主机紧接下来广播的从机地址信号(SLAVE_ADDRESS),在I2C总线上,每个设备的地址都是唯一的。当主机广播的地址与某个设备地址相同时,这个设备就被选中了,没被选中的设备将会忽略...