-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug_lib.c
41 lines (34 loc) · 858 Bytes
/
debug_lib.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "stm8s.h"
#define PUTCHAR_PROTOTYPE void putchar (char c)
/**
* @brief Retargets the C library printf function to the UART.
* @param c Character to send
* @retval char Character sent
*/
PUTCHAR_PROTOTYPE
{
/* Write a character to the UART1 */
UART1_SendData8(c);
/* Loop until the end of transmission */
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
//return (c);
}
void debug_init(void)
{
UART1_DeInit();
UART1_Init((uint32_t)9600, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);
UART1_ITConfig(UART1_IT_RXNE, ENABLE);
}
void send_str(char c[]) {
char i;
//char len;
//len = sizeof(c);
//len = strlen(c);
i = 0;
while (c[i] > 0) {
UART1_SendData8(c[i]);
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
i++;
}
}