Hi,
I need to transmit data over CAN, but i am really struggling to organize the software flow. The below is the prototype function to transmit
Code:
void CanTransmit(uint8_t *TxData)
{
}
The above function transmits 8 bytes of data in a cyclic manner every 10ms and i have to fill the TxData[8] array.
Code:
uint8 TxData[8];
uint8_t current;
int main(void)
{
while(1)
{
}
}
The problem is the data comes from different functions ex:
Code:
void CalculateCurrent(void)
{
  current = 12; 
}
void CalVoltage(void)
{
 voltage = 15;
}
How do i organize the filling of array of TxData[8], define global variables for each data and fill it in each function or define a common function and fill the data. The problem is multiple people work on the software.
Like for example
Code:
void CalculateCurrent(void)
{
  current = 12; 
  TxData[0] = current ;
}
void CalVoltage(void)
{
 voltage = 15;
 TxData[1] = voltage;
}
or
Code:
void FillBuffer(void)
{
TxData[0] = current ;
TxData[1] = voltage;
}
Call the FillBuffer code periodically. Please advise.