2025-11-10 18:05:11 +08:00
|
|
|
#include "ti_msp_dl_config.h"
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ARM Compiler 6 半主机模式禁用声明 */
|
|
|
|
|
#if (__ARMCC_VERSION >= 6010050)
|
2025-11-12 21:26:40 +08:00
|
|
|
__asm(".global __use_no_semihosting\n\t");
|
|
|
|
|
__asm(".global __ARM_use_no_argv \n\t");
|
2025-11-10 18:05:11 +08:00
|
|
|
#else
|
2025-11-12 21:26:40 +08:00
|
|
|
#pragma import(__use_no_semihosting)
|
2025-11-10 18:05:11 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
FILE __stdout;
|
|
|
|
|
|
|
|
|
|
/* 系统退出函数实现 */
|
|
|
|
|
void _sys_exit(int x)
|
|
|
|
|
{
|
|
|
|
|
x = x;
|
2025-11-12 21:26:40 +08:00
|
|
|
while(1)
|
2025-11-10 18:05:11 +08:00
|
|
|
; /* 死循环防止程序异常退出 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ARM Compiler 6 printf重定向实现 */
|
|
|
|
|
int fputc(int c, FILE *stream)
|
|
|
|
|
{
|
|
|
|
|
/* 等待UART发送缓冲区就绪 */
|
2025-11-12 21:26:40 +08:00
|
|
|
while(DL_UART_Main_isBusy(UART_0_INST))
|
2025-11-10 18:05:11 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
/* 发送字符 */
|
|
|
|
|
DL_UART_Main_transmitData(UART_0_INST, (uint8_t)c);
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int fputs(const char *restrict s, FILE *restrict stream)
|
|
|
|
|
{
|
|
|
|
|
uint16_t i, len;
|
|
|
|
|
len = strlen(s);
|
2025-11-12 21:26:40 +08:00
|
|
|
for(i = 0; i < len; i++)
|
2025-11-10 18:05:11 +08:00
|
|
|
{
|
|
|
|
|
fputc(s[i], stream);
|
|
|
|
|
}
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int puts(const char *_ptr)
|
|
|
|
|
{
|
|
|
|
|
int count = fputs(_ptr, stdout);
|
|
|
|
|
count += fputc('\n', stdout); /* 自动添加换行 */
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|