Subversion Repositories MK3Mag

Compare Revisions

Ignore whitespace Rev 25 → Rev 26

/branches/MK3Mag V0.14 Code Redesign Killagreg/main.c
217,7 → 217,7
break;
 
case 3: // 3rd step of calibration
// used to change the orietation of the MK3MAG vertical to the horizontal plane
// used to change the orientation of the MK3MAG vertical to the horizontal plane
break;
 
case 4:
/branches/MK3Mag V0.14 Code Redesign Killagreg/twislave.c
68,8 → 68,8
volatile uint8_t *I2C_TxBuffer = 0, *I2C_RxBuffer = 0;
volatile uint8_t Tx_Idx = 0, Rx_Idx = 0;
 
volatile uint8_t I2C_PrimRxBuffer[10];
 
 
struct I2C_Heading_t I2C_Heading;
struct I2C_WriteAttitude_t I2C_WriteAttitude;
struct I2C_Mag_t I2C_Mag;
185,9 → 185,7
I2C_TxBufferSize = sizeof(I2C_Heading);
I2C_RxBuffer = (uint8_t *)&I2C_WriteAttitude;
I2C_RxBufferSize = sizeof(I2C_WriteAttitude);
// update heading from global variable
I2C_Heading.Heading = Heading;
// copy current attitude from I2C rx buffer to uart rx buffer (this is used for the calulation of the heading)
ExternData.Attitude[NICK] = I2C_WriteAttitude.Nick;
ExternData.Attitude[ROLL] = I2C_WriteAttitude.Roll;
break;
205,16 → 203,27
{
// fill receiver buffer with the byte that has been received
// if buffer exist and there is still some free space
if((I2C_RxBuffer != 0) && (Rx_Idx < I2C_RxBufferSize))
if(Rx_Idx < I2C_RxBufferSize)
{
I2C_RxBuffer[Rx_Idx] = data;
I2C_PrimRxBuffer[Rx_Idx] = data;
crc += data;
}
else if (Rx_Idx == I2C_RxBufferSize) // crc byte was transferred
{
else if (Rx_Idx == I2C_RxBufferSize) // crc byte was transfered
{ // if checksum matched
if(crc == data)
{ // and RxBuffer exist
if(I2C_RxBuffer != 0)
{ // copy data to rx buffer
for(data = 0; data < I2C_RxBufferSize; data++)
{
I2C_RxBuffer[data] = I2C_PrimRxBuffer[data];
}
}
DebugOut.Analog[31]++;
}
else
{
// copy primary rx buffer to target
DebugOut.Analog[30]++;
}
}
// else ignore data
/branches/MK3Mag V0.14 Code Redesign Killagreg/uart.c
127,8 → 127,8
"Analog27 ",
"Analog28 ",
"Analog29 ",
"Analog30 ", //30
"Analog31 "
"I2C Error ", //30
"I2C Okay "
};
 
 
435,8 → 435,8
ExternData.CalState++;
if(ExternData.CalState == 6) ExternData.CalState = 0;
}
ExternData.Attitude[0] = ExternControl.Par1;
ExternData.Attitude[1] = ExternControl.Par2;
//ExternData.Attitude[0] = ExternControl.Par1;
//ExternData.Attitude[1] = ExternControl.Par2;
PC_Connected = 255;
break;
 
/branches/MK3Mag V0.14 Code Redesign Killagreg/uart.h
34,7 → 34,7
 
struct ExternData_t
{
int16_t Attitude[2]; // nock and roll angle in 0.1 deg
int16_t Attitude[2]; // nick and roll angle in 0.1 deg
uint8_t UserParam[2];
uint8_t CalState;
uint8_t Orientation;