Hi awneil,
You said:
Thanks for your help. But all managers never want to throw away what they spent for, that’s why I’m trying to manage existant first before new ones to come (It is a particular chapter for it is to come, be sure). but I did progress. while jumping some pins on my cards I am receiving data on my Uart2. This is my code:
#include "adl_global.h"
#include "generated.h"
#define UART_2 ADL_AT_PORT_TYPE(ADL_PORT_UART2,ADL_AT_RSP) /* refer to ADL User Guide pag 67, rspflag */
/* --- UART Config enums --- */
/* Data format */
enum UART_FORMAT{
NO_USE,
DATA8_STOP2,
DATA8_STOP1_PARITY1,
DATA8_STOP1,
DATA7_STOP2,
DATA7_STOP1_PARITY1,
DATA7_STOP1
};
/* parity bit config */
enum UART_PARITY{
ODD,
EVEN,
MARK,
SPACE,
NONE_PARITY
};
/* flow control */
enum UART_FLOW_CONTROL{
CTS_RTS,
NO_CTS_RTS
};
/* UART mode type */
enum UART_TYPE{
DATAMODE,
ATMODE
};
/* can anybody help me with stack size???? */
s8 handle_uart2; /* UART1 handler */
u8 mode_uart2; /* UART1 mode type */
s32 GreenHandle;
s32 BlueHandle;
ascii result;
adl_ioDefs_t GreenLED [ 1 ] = { ADL_IO_GPIO | 20 | ADL_IO_DIR_OUT };
adl_ioDefs_t BlueLED [ 1 ] = { ADL_IO_GPIO | 22 | ADL_IO_DIR_OUT };
/* functions prototypes */
int initUART2(u8 mode, int speed, u8 format, u8 parity, u8 flow_control);
static bool EvhCrtlUart2(adl_fcmEvent_e evnt);
static bool EvhDataUart2(u16 datalength, u8 *data);
static void EvhConfUartx(adl_atResponse_t *Rsp);
void GreenLEDHandle( u8 ID, void * Context );
void BlueLEDHandle( u8 ID, void * Context );
void GreenLEDHandle( u8 ID, void * Context ){
static int toggle = 1;
adl_ioDefs_t Gpio_to_write1 = ADL_IO_GPIO | 20 ;
adl_ioWriteSingle ( GreenHandle, &Gpio_to_write1, toggle);
toggle = !toggle;
}
void BlueLEDHandle( u8 ID, void * Context ){
static int toggle = 1;
adl_ioDefs_t Gpio_to_write1 = ADL_IO_GPIO | 22 ;
adl_ioWriteSingle ( BlueHandle, &Gpio_to_write1, toggle);
toggle = !toggle;
}
int initUART2(u8 mode, int speed, u8 format, u8 parity, u8 flow_control){
char comand[15];
/* Check if port available*/
if(adl_fcmIsAvailable(ADL_FCM_FLOW_V24_UART2))
{
/* Save UART operation mode: DATA o AT*/
mode_uart2=mode;
/* subscribe to FCM uart service */
handle_uart2=adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART2, EvhCrtlUart2,EvhDataUart2);
/* config parity with AT Command*/
wm_sprintf(comand,"AT+ICF=%d,%d", format, parity);
adl_atCmdCreate(comand, UART_2, EvhConfUartx, NULL);
/* speed with AT Command*/
wm_sprintf(comand,"AT+IPR=%d", speed);
adl_atCmdCreate(comand, UART_2, EvhConfUartx, NULL);
/* flow control with AT Command*/
switch(flow_control){
/* hardware flow control */
case CTS_RTS:
adl_atCmdCreate("AT+IFC=2,2",UART_2,EvhConfUartx,NULL);
break;
/* no hardware flow control */
case NO_CTS_RTS:
adl_atCmdCreate("AT+IFC=0,0",UART_2,EvhConfUartx,NULL);
break;
}
/* save configuration */
adl_atCmdCreate("AT&W", UART_2, (adl_atRspHandler_t)EvhConfUartx,NULL);
return 0;
}
return -1;
}/*initUART2*/
static bool EvhCrtlUart2(adl_fcmEvent_e evnt){
switch (evnt)
{
/* when com is open, operation mode is defined */
case ADL_FCM_EVENT_FLOW_OPENNED:
/* DATA MODE */
if(mode_uart2 == DATAMODE){
adl_atSendResponse(ADL_AT_RSP, "\r\nUART2: Data Mode");
adl_fcmSwitchV24State(handle_uart2,ADL_FCM_V24_STATE_DATA);
}
/* AT MODE */
else if(mode_uart2 == ATMODE){
adl_atSendResponse(ADL_AT_RSP, "\r\nUART2: AT Mode");
adl_fcmSwitchV24State(handle_uart2,ADL_FCM_V24_STATE_AT);
}
break;
case ADL_FCM_EVENT_V24_DATA_MODE:
/* DATA MODE OK */
adl_atSendResponse(ADL_AT_RSP, "\r\nUART2: Data Mode OK");
break;
case ADL_FCM_EVENT_V24_AT_MODE:
/* AT MODE OK */
adl_atSendResponse(ADL_AT_RSP, "\r\nUART2: Returned to AT Mode");
break;
case ADL_FCM_EVENT_RESUME:
adl_atSendResponse(ADL_AT_RSP, "\r\nUART2: Event resume");
break;
case ADL_FCM_EVENT_MEM_RELEASE:
adl_atSendResponse(ADL_AT_RSP, "\r\nUART2: Memory Released");
break;
default:
return FALSE;
break;
}
return TRUE;
}/*EvhCrtlUart2*/
static bool EvhDataUart2(u16 datalength, u8 *data){
/* when data recived echo it */
ascii NewText [ 20 ],txt[20];
u16 i;
result=*data;
for ( i = 0 ; i < datalength ; i++ )
{
GreenHandle = adl_ioSubscribe ( 1, GreenLED, 0, 0, 0 );
adl_tmrSubscribe ( TRUE, 5, ADL_TMR_TYPE_100MS, GreenLEDHandle );
if ( data [ i ] == '~' )
{
adl_fcmUnsubscribe(handle_uart2);
}else
{
txt[i]=data[i];
wm_sprintf ( NewText, "%d", txt[i] );
adl_atSendResponse(ADL_AT_UNS, NewText);//to send received data and display using uart1.
}
}
//adl_atSendResponse(ADL_AT_RSP,data[0]);
return TRUE;
}/*EvhDataUart2*/
static void EvhConfUartx(adl_atResponse_t *Rsp){
}/*EvhConfUartx*/
void main_task ( void )
{
// TODO Insert your task initialization code here
initUART2(DATAMODE, 9600 , DATA8_STOP1 , NONE_PARITY , NO_CTS_RTS);
}
And I am receiving some integer I don’t exactly understand. Here are some.
UART2: Data Mode
UART2: Data Mode OK1818022518214012915528064201680656080642016812819340160128152080646420806420806464208064208064642080642080646420806420806474218064208074662080821326537516512813120166131151489110118717217719723253
+WIND: 13
+CREG: 0
+CGREG: 0
UART2: Data Mode
UART2: Data Mode OK6920209169208080642080642080819020806421801042080806420806420808064208064208080642080642080806420806420808064208064202116012815528264518811869104532271925280832080806414817692366363232
+WIND: 13
+CREG: 0
+CGREG: 0
UART2: Data Mode
UART2: Data Mode OK18180971821341520806420806464201440160144112047160128152080642020806420806420208064208064202080642080642020806420806420211281520809064202081932120889165130352857242020872148252148121228246
+WIND: 13
+CREG: 0
+CGREG: 0
UART2: Data Mode
UART2: Data Mode OK1818097182140152080642080806420144016014411204516012815208064642080642080646420806420806464208064208064642080642080646421128152016806420208193212088916512821113318212064208021211218416862249132255
+WIND: 13
+WIND: 1
+CREG: 2
+WIND: 16
+CGREG: 0
+WIND: 15,3,"+04",4,"11/08/10,00:44:22+04",6,"0"
Can somebody help me in understanding this?
Is this my PVT data that I should decode? while receiving data from my data handler as ascii, I have some cryptograms characters. So I’ùm oblige to receive it as intergers.
I will apreciate your helps.
Thanks more