V1.9
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
|
||||
static uint8_t p_us = 0;
|
||||
static uint16_t p_ms = 0;
|
||||
|
||||
#define DEBUG_DATA0_ADDRESS ((volatile uint32_t*)0xE0000380)
|
||||
#define DEBUG_DATA1_ADDRESS ((volatile uint32_t*)0xE0000384)
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Delay_Init
|
||||
*
|
||||
@@ -139,6 +143,22 @@ void USART_Printf_Init(uint32_t baudrate)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SDI_Printf_Enable
|
||||
*
|
||||
* @brief Initializes the SDI printf Function.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void SDI_Printf_Enable(void)
|
||||
{
|
||||
*(DEBUG_DATA0_ADDRESS) = 0;
|
||||
Delay_Init();
|
||||
Delay_Ms(1);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn _write
|
||||
*
|
||||
@@ -152,8 +172,44 @@ void USART_Printf_Init(uint32_t baudrate)
|
||||
__attribute__((used))
|
||||
int _write(int fd, char *buf, int size)
|
||||
{
|
||||
int i;
|
||||
int i = 0;
|
||||
|
||||
#if (SDI_PRINT == SDI_PR_OPEN)
|
||||
int writeSize = size;
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
/**
|
||||
* data0 data1 8 byte
|
||||
* data0 The storage length of the lowest byte, with a maximum of 7 bytes.
|
||||
*/
|
||||
|
||||
while( (*(DEBUG_DATA0_ADDRESS) != 0u))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(writeSize>7)
|
||||
{
|
||||
*(DEBUG_DATA1_ADDRESS) = (*(buf+i+3)) | (*(buf+i+4)<<8) | (*(buf+i+5)<<16) | (*(buf+i+6)<<24);
|
||||
*(DEBUG_DATA0_ADDRESS) = (7u) | (*(buf+i)<<8) | (*(buf+i+1)<<16) | (*(buf+i+2)<<24);
|
||||
|
||||
i += 7;
|
||||
writeSize -= 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(DEBUG_DATA1_ADDRESS) = (*(buf+i+3)) | (*(buf+i+4)<<8) | (*(buf+i+5)<<16) | (*(buf+i+6)<<24);
|
||||
*(DEBUG_DATA0_ADDRESS) = (writeSize) | (*(buf+i)<<8) | (*(buf+i+1)<<16) | (*(buf+i+2)<<24);
|
||||
|
||||
writeSize = 0;
|
||||
}
|
||||
|
||||
} while (writeSize);
|
||||
|
||||
|
||||
#else
|
||||
for(i = 0; i < size; i++){
|
||||
#if(DEBUG == DEBUG_UART1)
|
||||
while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
|
||||
@@ -166,7 +222,7 @@ int _write(int fd, char *buf, int size)
|
||||
USART_SendData(USART3, *buf++);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* File Name : debug.h
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2021/06/06
|
||||
* Date : 2023/10/24
|
||||
* Description : This file contains all the functions prototypes for UART
|
||||
* Printf , Delay functions.
|
||||
*********************************************************************************
|
||||
@@ -30,10 +30,20 @@ extern "C" {
|
||||
#define DEBUG DEBUG_UART1
|
||||
#endif
|
||||
|
||||
/* SDI Printf Definition */
|
||||
#define SDI_PR_CLOSE 0
|
||||
#define SDI_PR_OPEN 1
|
||||
|
||||
#ifndef SDI_PRINT
|
||||
#define SDI_PRINT SDI_PR_CLOSE
|
||||
#endif
|
||||
|
||||
|
||||
void Delay_Init(void);
|
||||
void Delay_Us(uint32_t n);
|
||||
void Delay_Ms(uint32_t n);
|
||||
void USART_Printf_Init(uint32_t baudrate);
|
||||
void SDI_Printf_Enable(void);
|
||||
|
||||
#if(DEBUG)
|
||||
#define PRINT(format, ...) printf(format, ##__VA_ARGS__)
|
||||
|
||||
Reference in New Issue
Block a user