지금 현재 “UART_VCOM_1_KIT_TC397_TFT” Aurix에서 제공해주는 프로젝트를 기본 예제로 하여
HostPC - TC397 보드 사이의 UART 통신을 하고 있음
일단 기본적으로 기본 예제에서는 고정된 문자열을 고정된 크기와 함께 Buffer에 저장하여, Tx를 통해 보내고 있음
최종적으로 조향 각도나 속도 값에 대해서, Host PC로 전달받은 다음에 이거를 Tc397 보드 내부에서 처리해야 함
그래서 우선, 고정된 숫자와 크기를 기반으로 UART 통신이 되는 것을 커스텀 해보겠음
void sendTest(void)
{
char txData[20];
int test_data = 30;
Ifx_SizeT count;
snprintf(txData, sizeof(txData), "%d", test_data);
count = (Ifx_SizeT)strlen(txData);
IfxAsclin_Asc_write(&g_asc, txData, &count, TIME_INFINITE);
}
테스트로 보낼 데이터에 대해서 sendTest() 함수를 만들고, 이 함수가 잘 동작을 하는지 확인해볼 예정
(당연히 새로 만든 함수에 대해서 헤더 파일에 추가)
이 함수를 동작시키기 위해, 아래 헤더들을 추가해야 함
#include <stdio.h>
#include <string.h>
이후 Cpu0_Main.c 코드로 가서
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#include "UART_VCOM.h"
IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;
void core0_main(void)
{
IfxCpu_enableInterrupts();
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
init_UART(); /* Initialize the module */
//send_UART_message(); /* Send the message "Hello World!" */
sendTest();
while(1)
{
}
}