123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /********************************* (C) РОТЕК ***********************************
- * @module usart
- * @file usart.c
- * @version 1.0.0
- * @date XX.XX.XXXX
- * $brief Template
- *******************************************************************************
- * @history Version Author Comment
- * XX.XX.XXXX 1.0.0 Telenkov D.A. First release.
- *******************************************************************************
- */
- #include "stm32f4xx.h"
- #include "usart.h"
- #include "tinystdio.h"
-
- #ifdef __GNUC__
- #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
- #else
- #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
- #endif
- PUTCHAR_PROTOTYPE
- {
- //ITM_SendChar((u8) ch);
- return ch;
- }
- void putchar_(uint8_t c) {
- while (!(USER_USART->SR & USART_FLAG_TXE));
- USER_USART->DR = (uint16_t)c;
- }
- void putc_(void* p, char c) {
- (void)p;
- putchar_(c);
- }
- /**
- * @brief
- * @retval
- */
- void InitUSART( void) {
- USART_InitTypeDef USART_InitStructure;
-
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
- USART_InitStructure.USART_BaudRate = 115200;
- USART_InitStructure.USART_WordLength = USART_WordLength_8b;
- USART_InitStructure.USART_StopBits = USART_StopBits_1;
- USART_InitStructure.USART_Parity = USART_Parity_No;
- USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
- USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
- USART_Init(USER_USART, &USART_InitStructure);
- USART_Cmd(USER_USART, ENABLE);
-
-
- USART_ITConfig(USER_USART, USART_IT_RXNE, DISABLE);
- USART_ITConfig(USER_USART, USART_IT_TXE, DISABLE);
- init_printf(NULL, putc_);
- }
- /********************************* (C) РОТЕК **********************************/
|