#include "adl_global.h"
#include "adl_OpenDevice.h"
#include "wm_uart.h"
#include "adl_TimerHandler.h"
//#include "uart_read.c"
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024;
adl_tmr_t *tt;// pointer to a structure returned by adl_tmrsubscribeExt
u16 timeout_period = 5;// Indicates the timervalue
static psGItfCont_t uart_if;// Operation parameter.
static u32 uart2_hdl;// Pointer to device opened.
static u8 rx_buf[256];// Memory area where the received data is stored.
u8* p_rx_buf;// Pointer to area where received data is stored.
u32 nb_tb_read;// Number of bytes to be read.
u32 nb_read;// Number of bytes read.
sUartSettings_t settings;// Settings for the uart.
sUartLc_t line_coding;// Line coding parameters.
/***************************************************************************/
/* Local variables */
/***************************************************************************/
/***************************************************************************/
/* Local functions */
/***************************************************************************/
void a_generic_handler(u8 id, void * context)
{
// Open UART DEVICE.
uart2_hdl=adl_OpenDevice(DF_UART_CLID, &settings);
LOGIC TO READ DATA.
}
/***************************************************************************/
/* Function : uartread */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialisation */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
//This is the entry point for uart_read.
void UartRead ( adl_InitType_e InitType )
{
TRACE (( 1, "Embedded Application : Main" ));
// TO DO : Add your initialization code here
// Set the line coding parameters.
line_coding.valid_fields=UART_LC_ALL;
line_coding.rate=(eUartRate_t) (UART_RATE_USER_DEF | 57600);
line_coding.stop=UART_STOP_BIT_1;
line_coding.data=UART_DATALENGTH_8;
line_coding.parity=UART_PARITY_NONE;
//UART2 will be opened in NULL MODEM role/ with synchronus read.
settings.identity="UART2";
settings.role= UART_ROLE_NM;
settings.capabilities=NULL;
settings.event_handlers=NULL;
// settings.interface=&uart_if;
settings.line_coding=&line_coding;
// Here settings and configurations of uart are finished.
tt=adl_tmrSubscribeExt(ADL_TMR_CYCLIC_OPT_ON_RECEIVE,timeout_period,ADL_TMR_TYPE_100MS,a_generic_handler,NULL,FALSE);
// THE ABOVE FUNCTION IS USED TO SUBSCRIBE A TIMER WITH THE GIVEN VALUES .
}
HI,
Can u guys please suggest whether the above code is sufficient to read data from uart in sychronous mode.
I regret unconditionally if my mail annoys you.
Thanks in advance.