ist alles in der Datei serial.c und retarget.c die in die Projekte bei
Keil mit eingebunden wird.
Hier meine Modifizierung:
#include "stm32f10x.h"
#include "my_types.h"
extern charfifo_t debugTx;
/*----------------------------------------------------------------------
------
Initialize UART pins, Baudrate
*-----------------------------------------------------------------------
-----*/
void SER_init (void) {
int i;
/* Configure UART2 for 115200 baud
*/
RCC->APB2ENR |= 1 << 0; /* Enable AFIO clock
*/
RCC->APB2ENR |= 1 << 5; /* Enable GPIOD clock
*/
AFIO->MAPR |= 0x00000008; /* Configure used Pins
*/
GPIOD->CRL &= 0xF00FFFFF;
GPIOD->CRL |= 0x04B00000;
RCC->APB1ENR |= 0x00020000; /* Enable USART#2 clock
*/
USART2->BRR = 0x0135; /* Configure 115200 baud,
*/
USART2->CR3 = 0x0000; /* 8 bit, 1 stop bit,
*/
USART2->CR2 = 0x0000; /* no parity
*/
for (i = 0; i < 0x1000; i++) __NOP();/* avoid unwanted output
*/
USART2->CR1 = 0x200C;
}
/*----------------------------------------------------------------------
------
Write character to Serial Port
*-----------------------------------------------------------------------
-----*/
int sendchar (int c) {
uint8_t dat;
#ifdef __DBG_ITM
ITM_SendChar(c);
dat=(uint8_t)c;
put_charfifo(&debugTx,&dat);
#else
dat=(uint8_t)c;
put_charfifo(&debugTx,&dat);
#endif
return (c);
}
/*----------------------------------------------------------------------
------
Read character from Serial Port (blocking read)
*-----------------------------------------------------------------------
-----*/
int getkey (void) {
while (!(USART2->SR & 0x0020));
return (USART2->DR);
}