|
@@ -15,11 +15,12 @@
|
|
|
#include "tinystdio.h"
|
|
|
|
|
|
|
|
|
-#ifdef __GNUC__
|
|
|
+
|
|
|
+#ifdef __GNUC__
|
|
|
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
|
|
|
-#else
|
|
|
+#else
|
|
|
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
PUTCHAR_PROTOTYPE
|
|
@@ -29,11 +30,8 @@ PUTCHAR_PROTOTYPE
|
|
|
}
|
|
|
|
|
|
void putchar_(uint8_t c) {
|
|
|
- //while (!(USER_USART->SR & USART_FLAG_TXE));
|
|
|
- //USER_USART->DR = (uint16_t)c;
|
|
|
-#ifdef SWOTRACE
|
|
|
- ITM_SendChar(c);
|
|
|
-#endif
|
|
|
+ while (!(USER_USART->SR & USART_FLAG_TXE));
|
|
|
+ USER_USART->DR = (uint16_t)c;
|
|
|
}
|
|
|
|
|
|
void putc_(void* p, char c) {
|
|
@@ -50,23 +48,23 @@ void InitUSART( void) {
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
USART_InitTypeDef USART_InitStructure;
|
|
|
|
|
|
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
|
|
|
+ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
|
|
|
|
|
|
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
|
|
|
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
|
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
|
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
|
|
- GPIO_Init(GPIOB, &GPIO_InitStructure);
|
|
|
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
|
|
|
|
|
|
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1);
|
|
|
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1);
|
|
|
+ GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
|
|
|
+ GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
|
|
|
|
|
|
USART_InitStructure.USART_BaudRate = 115200;
|
|
|
- USART_InitStructure.USART_WordLength = USART_WordLength_9b;
|
|
|
+ USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
|
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
|
|
- USART_InitStructure.USART_Parity = USART_Parity_Even;
|
|
|
+ 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);
|