#include "zport.h" #include #include #include "zboard.h" static uint32_t sys_haspassedms(uint32_t ticket) { uint32_t nowticket = HAL_GetTick(); if (nowticket >= ticket) { return nowticket - ticket; } return UINT32_MAX - ticket + nowticket; } ///********************************************************************************************************************** // * ===================================================printf重定向=================================================== * // **********************************************************************************************************************/ int fputc(int ch, FILE *stream) { uint8_t c = ch; HAL_UART_Transmit(&DEBUG_UART, &c, 1, 100); return ch; } ///*********************************************************************************************************************** // * ====================================================调试指示灯===================================================== * // ***********************************************************************************************************************/ void port_do_debug_light_state(void) { static uint32_t lastprocess = 0; if (sys_haspassedms(lastprocess) > 300) { lastprocess = HAL_GetTick(); HAL_GPIO_TogglePin(DEBUG_LIGHT_PORT, DEBUG_LIGHT_PIN); } }