Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 688 → Rev 689

/trunk/uart1.c
126,11 → 126,16
u8 UART1_ConfirmFrame = 0;
u8 UART1_Request_FTP = FALSE;
u8 UART1_Request_LicenseString = FALSE;
u8 UART1_Request_PPM_Channels = FALSE;
u8 LastTransmittedFCStatusFlags2 = 0;
u8 UART1_ExternalControlConfirmFrame = FALSE;
u8 Send_NMEA_RMC = FALSE;
u8 NaviData_Flags_SpeakHoTT_Processed = 0;
u8 NewExternalControlFrame = 0; // flag that sends the Frame to FC
 
SerialChannel_t SerialChannel;
u8 NewSerialChannelFrame = 0; // flag that sends the Frame to FC
 
UART_TypeDef *DebugUART = UART1;
 
#ifdef FOLLOW_ME
325,6 → 330,11
UART_VersionInfo.Flags = 0;
UART_VersionInfo.LabelTextCRC = CalculateDebugLableCrc();
NaviData.Version = NAVIDATA_VERSION;
 
PPM_In[PPM_IN_MAX] = +127;
PPM_In[PPM_IN_OFF] = -127;
PPM_In[PPM_IN_MID] = 0;
 
UART1_PutString("\r\n UART1 init...ok");
}
 
438,21 → 448,21
 
// analyze header first
MKProtocol_DecodeSerialFrameHeader(&UART1_rx_buffer, &SerialMsg);
/*
if( SerialMsg.Address == FC_ADDRESS )
{
switch(SerialMsg.CmdID)
{
// case 'v': // version
case 'b': // extern control
UART1_ExternalControlConfirmFrame = 1;
case 'y': // serial poti values
Buffer_Copy(&UART1_rx_buffer, &UART2_tx_buffer); //forward to FC
Buffer_Clear(&UART1_rx_buffer); // free rc buffer for next frame
return; //end process rx data
// case 'b': // extern control
// UART1_ExternalControlConfirmFrame = 1;
// case 'y': // serial poti values
// Buffer_Copy(&UART1_rx_buffer, &UART2_tx_buffer); //forward to FC
// Buffer_Clear(&UART1_rx_buffer); // free rc buffer for next frame
// return; //end process rx data
break;
}
}
 
*/
MKProtocol_DecodeSerialFrameData(&UART1_rx_buffer, &SerialMsg); // decode serial frame in rxd buffer
if(SerialMsg.CmdID != 'z') SerialLinkOkay = 250; // reset SerialTimeout, but not in case of the "ping"
switch(SerialMsg.Address) // check for Slave Address
635,12 → 645,27
UART1_Request_DebugLabel = SerialMsg.pData[0];
if(UART1_Request_DebugLabel > 31) UART1_Request_DebugLabel = 31;
break;
/*
case 'b': // submit extern control
memcpy(&ExternControl, SerialMsg.pData, sizeof(ExternControl));
UART1_ConfirmFrame = ExternControl.Frame;
NewExternalControlFrame = 1;
break;
*/
 
case 'y': // serial Channels
memcpy(&SerialChannel, SerialMsg.pData, sizeof(SerialChannel));
memcpy((u8 *) &(PPM_In[SERIAL_POTI_START]), (u8 *) &SerialChannel, 12); // copy the 12 Bytes Serial Channels into the PPM_In array
NewSerialChannelFrame = 1;
break;
 
case 'g':// request for the externalControl
UART1_Request_ExternalControl = TRUE;
break;
 
case 'p':// request for the PPM_In
UART1_Request_PPM_Channels = TRUE;
break;
case 'd': // request for debug data;
UART1_DebugData_Interval = (u32) SerialMsg.pData[0] * 10;
if(UART1_DebugData_Interval > 0) UART1_Request_DebugData = TRUE;
1376,21 → 1401,16
CreateNmeaRMC();
Send_NMEA_RMC = FALSE;
}
 
/*
else if(UART1_ConfirmFrame && (UART1_tx_buffer.Locked == FALSE))
{
MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'B', NC_ADDRESS, 1, &UART1_ConfirmFrame, sizeof(UART1_ConfirmFrame));
UART1_ConfirmFrame = 0;
}
*/
/*
else if(UART1_Request_ExternalControl && (UART1_tx_buffer.Locked == FALSE))
{
MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'G', NC_ADDRESS, 1, (u8 *)&ExternControl, sizeof(ExternControl));
UART1_Request_ExternalControl = FALSE;
}
*/
else if( (( (UART1_Display_Interval > 0) && CheckDelay(UART1_Display_Timer)) || UART1_Request_Display) && (UART1_tx_buffer.Locked == FALSE))
{
if(UART1_DisplayLine > 3)
1446,6 → 1466,11
MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG));
UART1_Request_ErrorMessage = FALSE;
}
else if(UART1_Request_PPM_Channels && (UART1_tx_buffer.Locked == FALSE))
{
MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'P', NC_ADDRESS, 1, (u8 *)&PPM_In, sizeof(PPM_In));
UART1_Request_PPM_Channels = FALSE;
}
else if(UART1_Request_LicenseString && (UART1_tx_buffer.Locked == FALSE))
{
u8 result = 1, cmd = 0;
/trunk/uart1.h
85,26 → 85,49
} __attribute__((packed)) ExternControl_t;
*/
 
// defines for ExternalControl.Config
#define EC_VALID 0x01 // only valid if this is 1
#define EC_GAS_ADD 0x02 // if 1 -> use the GAS Value not as MAX
#define EC_IGNORE_RC 0x80 // if 1 -> for Flying without RC-Control
#define EC_VALID 0x01 // only valid if this is 1
#define EC_GAS_ADD 0x02 // if 1 -> use the GAS Value not as MAX
#define EC_USE_SWITCH 0x20 // if 1 -> use the Switches for further control
#define EC_IGNORE_RC_STICK 0x40 // direct control (do nor add to RC-Stick)
#define EC_IGNORE_RC_LOST 0x80 // if 1 -> for Flying without RC-Control
 
// defines for ExternalControl.Switches -> control GPS Modes etc. if(Config & EC_USE_SWITCH)
#define EC2_PH 0x01 // GPS-Mode: PH
#define EC2_CH 0x02 // GPS-Mode: CH
#define EC2_CAREFREE 0x10 //
#define EC2_ALTITUDE 0x20 //
#define EC2_AUTOSTART 0x40 //
#define EC2_AUTOLAND 0x80 //
 
typedef struct
{
signed char Nick;
signed char Roll;
signed char Gier;
signed char Gas;
unsigned char Frame; // will return a confirm frame with this value
signed char Nick;
signed char Roll;
signed char Gier;
signed char Gas;
unsigned char Frame; // will return a confirm frame with this value
unsigned char Config;
unsigned char free;
unsigned char Switches;
unsigned char Free1; // these two don't need capacity in the ASCII data string
unsigned char Free2;
} __attribute__((packed)) ExternControl_t;
 
extern ExternControl_t ExternControl;
extern u8 NewExternalControlFrame; // flag that sends the Frame to FC
 
#define SERIAL_POTI_START 17
#define WP_EVENT_PPM_IN 29
#define PPM_IN_OFF 30
#define PPM_IN_MAX 31
#define PPM_IN_MID 32
typedef struct
{
signed char Ch[12];
} __attribute__((packed)) SerialChannel_t;
extern SerialChannel_t SerialChannel;
extern u8 NewSerialChannelFrame; // flag that sends the Frame to FC
 
typedef struct
{
s16 Nick;
s16 Roll;
s16 Compass; // angle between north and head of the MK