Subversion Repositories MK3Mag

Compare Revisions

Ignore whitespace Rev 26 → Rev 25

/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,7 → 185,9
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;
203,27 → 205,16
{
// fill receiver buffer with the byte that has been received
// if buffer exist and there is still some free space
if(Rx_Idx < I2C_RxBufferSize)
if((I2C_RxBuffer != 0) && (Rx_Idx < I2C_RxBufferSize))
{
I2C_PrimRxBuffer[Rx_Idx] = data;
I2C_RxBuffer[Rx_Idx] = data;
crc += data;
}
else if (Rx_Idx == I2C_RxBufferSize) // crc byte was transfered
{ // if checksum matched
else if (Rx_Idx == I2C_RxBufferSize) // crc byte was transferred
{
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
{
DebugOut.Analog[30]++;
// copy primary rx buffer to target
}
}
// else ignore data