Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Keil project template
- *
- * Before you start, select your target, on the right of the "Load" button
- *
- * @author Tilen Majerle
- * @email tilen@majerle.eu
- * @website http://stm32f4-discovery.com
- * @ide Keil uVision 5
- * @conf PLL parameters are set in "Options for Target" -> "C/C++" -> "Defines"
- * @packs STM32F4xx Keil packs version 2.4.0 or greater required
- * @stdperiph STM32F4xx Standard peripheral drivers version 1.5.0 or greater required
- */
- /* Include core modules */
- #include "stm32f4xx.h"
- /* Include my libraries here */
- #include "defines.h"
- #include "tm_stm32f4_delay.h"
- #include "tm_stm32f4_disco.h"
- #include "tm_stm32f4_usart.h"
- #include "tm_stm32f4_stdio.h"
- int main(void) {
- /* Initialize system */
- SystemInit();
- /* Initialize delay */
- TM_DELAY_Init();
- TM_USART_Init(USART2, TM_USART_PinsPack_1, 9600);
- while (1) {
- int a,b;
- a=b=10;
- printf("a=");
- scanf("%d", &a);
- printf("b=");
- scanf("%d", &b);
- printf("a*b=%d", a*b);
- Delayms(1000);
- }
- }
- /* Handle stdout actions */
- int TM_STDIO_StdoutHandler(int ch, FILE* f) {
- /* Send data to USART1 */
- TM_USART_Putc(USART2, (char) ch);
- /* Return ch, it means OK */
- return ch;
- /* If you want to return error, then you have to send EOF (-1) */
- //return -1;
- }
- /* Handle stdin actions */
- int TM_STDIO_StdinHandler(FILE* f) {
- /* If any data at USART, return them */
- /* Do your custom implementation here when string ends */
- if (!TM_USART_BufferEmpty(USART2)) {
- return (int)TM_USART_Getc(USART2);
- }
- /* End of data, string is valid */
- /* You have to send -1 at the end of string */
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement