Subversion Repositories MK3Mag

Compare Revisions

Regard whitespace Rev 36 → Rev 37

/trunk/main.h
32,7 → 32,3
 
#endif //_MAIN_H_
 
 
 
 
 
/trunk/timer0.c
165,6 → 165,3
while (!CheckDelay(t_stop));
}
 
 
 
 
/trunk/timer0.h
15,8 → 15,3
 
#endif //_TIMER0_H
 
 
 
 
 
 
/trunk/twislave.c
153,7 → 153,7
case TW_SR_DATA_ACK: // data has been received and ack has been returned
data = TWDR;
if (Rx_Idx == 0xFF)
{ // if the fisrt byte after slave addressing was received
{ // if the first byte after slave addressing was received
switch(data)
{
case I2C_CMD_VERSION:
/trunk/uart.c
62,6 → 62,10
#include "timer0.h"
#include "twislave.h"
 
// slave addresses
#define FC_ADDRESS 1
#define NC_ADDRESS 2
#define MK3MAG_ADDRESS 3
 
#define FALSE 0
#define TRUE 1
76,11 → 80,14
volatile uint8_t txd_complete = TRUE;
volatile uint8_t ReceivedBytes = 0;
 
#define VERSION_INFO 0x01
#define DEBUG_DATA 0x02
#define DEBUG_LABEL 0x04
#define COMPASS_HEADING 0x08
// send flags
#define RQST_VERSION_INFO 0x01
#define RQST_DEBUG_DATA 0x02
#define RQST_DEBUG_LABEL 0x04
#define RQST_COMPASS_HEADING 0x08
#define RQST_EXTERN_CTRL 0x10
 
 
uint8_t RequestFlags = 0x00;
uint8_t RequestDebugLabel = 0;
 
87,7 → 94,7
uint8_t PC_Connected = 0;
uint8_t FC_Connected = 0;
 
uint8_t MySlaveAddr = 0;
uint8_t MySlaveAddr = MK3MAG_ADDRESS;
 
 
DebugOut_t DebugOut;
203,6 → 210,7
VersionInfo.Minor = VERSION_MINOR;
VersionInfo.PCCompatible = VERSION_COMPATIBLE;
 
MySlaveAddr = MK3MAG_ADDRESS;
 
// Version beim Start ausgeben (nicht schön, aber geht... )
USART0_putchar ('\n');
420,14 → 428,15
 
switch(rxd_buffer[2])
{
case 'w':// Attitude
case 'w':// Attitude info from FC
Decode64((uint8_t *) &ExternData, sizeof(ExternData), 3, ReceivedBytes);
RequestFlags |= COMPASS_HEADING;
RequestFlags |= RQST_COMPASS_HEADING;
AttitudeSource = ATTITUDE_SOURCE_UART;
Orientation = ExternData.Orientation;
FC_Connected = 255;
break;
 
// used only for debug proposes at serial port
case 'b': // extern control
case 'c': // extern control with debug request
Decode64((uint8_t *) &ExternControl,sizeof(ExternControl), 3,ReceivedBytes);
442,17 → 451,22
ExternData.CalState++;
if(ExternData.CalState == 6) ExternData.CalState = 0;
}
//ExternData.Attitude[0] = ExternControl.Par1;
//ExternData.Attitude[1] = ExternControl.Par2;
PC_Connected = 255;
break;
 
// get debug values
case 'f':
RequestFlags |= RQST_DEBUG_DATA;
PC_Connected = 255;
break;
 
// no reaction for display line request
case 'h':// x-1 display columns
PC_Connected = 255;
break;
 
case 'v': // get version and board release
RequestFlags |= VERSION_INFO;
RequestFlags |= RQST_VERSION_INFO;
PC_Connected = 255;
break;
 
459,12 → 473,12
case 'a':// Labels of the Analog Debug outputs
Decode64((uint8_t *) &tmp_char_arr2[0], sizeof(tmp_char_arr2), 3, ReceivedBytes);
RequestDebugLabel = tmp_char_arr2[0];
RequestFlags |= DEBUG_LABEL;
RequestFlags |= RQST_DEBUG_LABEL;
PC_Connected = 255;
break;
 
case 'g':// get debug data
RequestFlags |= DEBUG_DATA;
case 'g':// get extern control data
RequestFlags |= RQST_EXTERN_CTRL;
PC_Connected = 255;
break;
}
481,38 → 495,39
 
if(!txd_complete) return;
 
if(CheckDelay(Debug_Timer))
if(CheckDelay(Debug_Timer) || (RequestFlags & RQST_DEBUG_DATA))
{
SetDebugValues();
SendOutData('D',MySlaveAddr,(uint8_t *) &DebugOut,sizeof(DebugOut));
Debug_Timer = SetDelay(250);
RequestFlags &= ~RQST_DEBUG_DATA;
}
 
if(RequestFlags & DEBUG_LABEL)
if(RequestFlags & RQST_DEBUG_LABEL)
{
SendOutData('A',RequestDebugLabel + '0',(uint8_t *) ANALOG_LABEL[RequestDebugLabel],16);
RequestDebugLabel = 255;
RequestFlags &= ~DEBUG_LABEL;
RequestFlags &= ~RQST_DEBUG_LABEL;
Debug_Timer = SetDelay(500);
}
 
if(RequestFlags & VERSION_INFO)
if(RequestFlags & RQST_VERSION_INFO)
{
SendOutData('V',MySlaveAddr,(uint8_t *) &VersionInfo, sizeof(VersionInfo));
RequestFlags &= ~VERSION_INFO;
RequestFlags &= ~RQST_VERSION_INFO;
}
 
if(RequestFlags & DEBUG_DATA)
if(RequestFlags & RQST_EXTERN_CTRL)
{
SetDebugValues();
SendOutData('G',MySlaveAddr,(uint8_t *) &ExternControl,sizeof(ExternControl));
RequestFlags &= ~DEBUG_DATA;
RequestFlags &= ~RQST_EXTERN_CTRL;
}
 
if(RequestFlags & COMPASS_HEADING)
if(RequestFlags & RQST_COMPASS_HEADING)
{
SendOutData('K',MySlaveAddr,(uint8_t *) &I2C_Heading, sizeof(I2C_Heading));
RequestFlags &= ~COMPASS_HEADING;
RequestFlags &= ~RQST_COMPASS_HEADING;
}
}