工具/软件:
您好、
我尝试在 WKUP 域中启用 uart_callback 模式、但我发现这里没有这种示例工程。 因此、我创建了一个空的 WKUP 工程并将“uart_echo_callback.c"复制“复制到这个工程中。 我选择的 UART 通道是 WKUP_UART0、我发现程序在第 50 行被阻止、断点不能插入到函数“uart_echo_write_callback “中。 我只想仔细检查 WKUP 域中的 UART_callback 模式是可行的、还是这种 现象导致了我的编码错误。
我附上了下面的相关代码和数字。
BR、
Bomiao


#include <string.h>
#include <kernel/dpl/DebugP.h>
#include "ti_drivers_config.h"
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"
#define APP_UART_BUFSIZE (200U)
#define APP_UART_RECEIVE_BUFSIZE (8U)
uint8_t gUartBuffer[APP_UART_BUFSIZE];
uint8_t gUartReceiveBuffer[APP_UART_RECEIVE_BUFSIZE];
volatile uint32_t gNumBytesRead = 0U, gNumBytesWritten = 0U;
/* Semaphore to indicate Write/Read completion used in callback api's */
static SemaphoreP_Object gUartWriteDoneSem;
static SemaphoreP_Object gUartReadDoneSem;
#define APP_UART_ASSERT_ON_FAILURE(transferOK, transaction) \
do { \
if((SystemP_SUCCESS != (transferOK)) || (UART_TRANSFER_STATUS_SUCCESS != transaction.status)) \
{ \
DebugP_assert(FALSE); /* UART TX/RX failed!! */ \
} \
} while(0) \
void uart_echo_callback(void *args)
{
int32_t transferOK, status;
UART_Transaction trans;
DebugP_log("[UART] Echo callback example started ...\r\n");
status = SemaphoreP_constructBinary(&gUartWriteDoneSem, 0);
DebugP_assert(SystemP_SUCCESS == status);
status = SemaphoreP_constructBinary(&gUartReadDoneSem, 0);
DebugP_assert(SystemP_SUCCESS == status);
UART_Transaction_init(&trans);
/* Send entry string */
gNumBytesWritten = 0U;
trans.buf = &gUartBuffer[0U];
strncpy(trans.buf,"This is uart echo test callback mode\r\nReceives 8 characters then echo's back. Please input..\r\n", APP_UART_BUFSIZE);
trans.count = strlen(trans.buf);
transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
/* Wait for write completion */
SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
DebugP_assert(gNumBytesWritten == strlen(trans.buf));
/* Read 8 chars */
gNumBytesRead = 0U;
trans.buf = &gUartReceiveBuffer[0U];
trans.count = APP_UART_RECEIVE_BUFSIZE;
transferOK = UART_read(gUartHandle[CONFIG_UART_CONSOLE], &trans);
APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
/* Wait for read completion */
SemaphoreP_pend(&gUartReadDoneSem, SystemP_WAIT_FOREVER);
DebugP_assert(gNumBytesRead == APP_UART_RECEIVE_BUFSIZE);
/* Echo chars entered */
gNumBytesWritten = 0U;
trans.buf = &gUartReceiveBuffer[0U];
trans.count = APP_UART_RECEIVE_BUFSIZE;
transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
/* Wait for write completion */
SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
DebugP_assert(gNumBytesWritten == APP_UART_RECEIVE_BUFSIZE);
/* Send exit string */
gNumBytesWritten = 0U;
trans.buf = &gUartBuffer[0U];
strncpy(trans.buf, "\r\nAll tests have passed!!\r\n", APP_UART_BUFSIZE);
trans.count = strlen(trans.buf);
transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
/* Wait for write completion */
SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
DebugP_assert(gNumBytesWritten == strlen(trans.buf));
SemaphoreP_destruct(&gUartWriteDoneSem);
SemaphoreP_destruct(&gUartReadDoneSem);
DebugP_log("All tests have passed!!\r\n");
return;
}
void uart_echo_write_callback(UART_Handle handle, UART_Transaction *trans)
{
DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
gNumBytesWritten = trans->count;
SemaphoreP_post(&gUartWriteDoneSem);
return;
}
void uart_echo_read_callback(UART_Handle handle, UART_Transaction *trans)
{
DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
gNumBytesRead = trans->count;
SemaphoreP_post(&gUartReadDoneSem);
return;
}