I tried to send the data and receive through the uart but i am unable finish this can someone help meProgram:
#include <stdint.h>
#include "tx_api.h"
#include "hal_data.h"
#include "r_sci_uart.h"
#include "rfid.h"
#include "SEGGER_RTT/SEGGER_RTT.h"
#define TRANSFER_LENGTH 128
uint8_t g_rfid_src[TRANSFER_LENGTH];
uint8_t g_rfid_dest[TRANSFER_LENGTH];
uint32_t g_rfid_transfer_complete = 0;
uint32_t g_rfid_receive_complete = 0;
void rfid_entry(void)
{
fsp_err_t err = R_SCI_UART_Open(&g_uart_ctrl, &g_uart_cfg);
SEGGER_RTT_printf(0, "Err: %d\n",err);
assert(FSP_SUCCESS == err);
err=0;
SEGGER_RTT_printf(0, "ErrR: %d\n",err);
char single_char = 'A';
err = R_SCI_UART_Write(&g_uart_ctrl, (uint8_t *)&single_char, 1);
SEGGER_RTT_printf(0, "Err1: %d\n",err);
// Wait for transfer to complete
uint32_t timeout = 10000000;
while (g_rfid_transfer_complete == 0 && timeout > 0)
timeout--;
}
if (timeout == 0)
SEGGER_RTT_printf(0, "Transfer timeout occurred\n");
// Handle the timeout situation
SEGGER_RTT_printf(0, "Transmitted: %d\n", g_rfid_transfer_complete);
// Reset the transfer complete flag
g_rfid_transfer_complete = 0;
// Start the read operation
err = R_SCI_UART_Read(&g_uart_ctrl, g_rfid_dest, TRANSFER_LENGTH);
SEGGER_RTT_printf(0, "Err2: %d\n",err);
// Wait for receive to complete
SEGGER_RTT_printf(0, "Received: %d\n", g_rfid_dest);
// Reset the receive complete flag
g_rfid_receive_complete = 0;
void rfid_callback(uart_callback_args_t * p_args)
switch (p_args->event)
case UART_EVENT_TX_COMPLETE:
g_rfid_transfer_complete = 1;
break;
case UART_EVENT_RX_COMPLETE:
g_rfid_receive_complete = 1;
default:
}}Output:00> Err: 000> ErrR: 000> Err1: 000> Transmitted: 100> Err2: 000> Received: 536744216