char _kbhit(void) { // make sure we're ready for this if (!first_pass_complete) retarget_init(); return RI; } // _kbhit()
/** * @brief Main program * @param None * @retval None */ int main(void) { float data = 2.555; /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 168 MHz */ SystemClock_Config(); /* Configure USART console*/ retarget_init(); Led_Config(); /* Add your application code here */ /* Infinite loop */ while (1) { HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12); /* Insert delay 100 ms */ HAL_Delay(delayTime); HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13); /* Insert delay 100 ms */ HAL_Delay(delayTime); HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_14); /* Insert delay 100 ms */ HAL_Delay(delayTime); HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_15); /* Insert delay 100 ms */ HAL_Delay(delayTime); delayTime = delayTime +1; printf("hello %f \r\n", 1.55); } }
char putchar(char c) { // make sure we're ready for this if (!first_pass_complete) retarget_init(); // move the byte into the transmit butter SBUF = c; // for now, this blocks until a byte gets sent while (!TI) { // loop until it gets set } // clear it TI = 0; // a byte was successfully moved into the transmit buffer return c; } // putchar()
char _getkey(void) { char c; // make sure we're ready for this if (!first_pass_complete) retarget_init(); // wait for RI while (!RI) { // loop until RI set } // get the byte c = SBUF; // clear RI RI = 0; // return the byte return c; } // _getkey()