- must be defined in da14580_config.h
#define CFG_PRINTF
#define CFG_DISABLE_RTS_CTS
- 添加文件夹app_console.c的项目from DA14580_SDK_3.0.2.1\DA14580_SDK_3.0.2.1\dk_apps\src\modules\app\src\app_utils\app_console
- Include the path of app_console folder from Options for target -> C/C++ tab -> Include paths.
- In the periph_init, add:
SetBits16(CLK_PER_REG, UART1_ENABLE, 1); // enable clock for UART 1
SetWord16(UART_LCR_REG, 0x80); // set bit to access DLH and DLL register
// divisor = 1000000 / 115200 = 9
SetWord16(UART_IER_DLH_REG,(9&0xFF>>8));//set high byte
SetWord16(UART_RBR_THR_DLL_REG,9&0xFF);//set low byte
SetWord16(UART_LCR_REG,3); // no parity, 1 stop bit 8 data length and clear bit 8
SetBits16(UART_MCR_REG, UART_SIRE, 0); // mode 0 for normal , 1 for IRDA
SetWord16(UART_IIR_FCR_REG,1); // enable fifo
SetBits16(UART_IER_DLH_REG,ERBFI_dlh0,0); // IER access, disable interrupt for available data
- In the GPIO_reservations function, add:
RESERVE_GPIO( UART1_TX, GPIO_PORT_0, GPIO_PIN_4, PID_UART1_TX);
RESERVE_GPIO( UART1_RX, GPIO_PORT_0, GPIO_PIN_5, PID_UART1_RX);
- In the set_pad_function add:
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_4, OUTPUT, PID_UART1_TX, false );
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_5, INPUT, PID_UART1_RX, false );
- Add: #include "app_console.h" in the file where the printf command has to be used
To printf 1 byte:
char ch = 0xFF;
arch_puts(&ch);
To printf 1 string:
arch_printf("test")
arch_printf(" actual_triming_value= %Lx",actual_triming_value);
arch_printf(" reason= %Lx",param ->reason);