void FReportMotorStatus(char dataIn[]) { char message[8]; message[7] = dataIn[0]; Soft_I2C_Start(); // Write to motors: Address Soft_I2C_Write(dataIn[0] | 0x01); // Current address message[0] = (Soft_I2C_Read(1) & 0xFE); // Status Byte // 7 6 5 4 3 2 1 bits // 7-4 Software Revision // 3-2 Future Growth // 1 Motor type // - 0-Brushed // - 1-Brushless // 0 Current Limitation // - 0-Limited // - 1-Unlimited message[1] = Soft_I2C_Read(1); // Fault Byte // 7-5 Future Growth // 4 Water Detect (0 none, 1 water) // 3 Ground Fault // 2 Hall Sensor error // 1 Stalled Motor // 0 Over Temperature message[2] = Soft_I2C_Read(1); // Current Byte // 0x00-0xFF If 12 in decimal, current is 1.2A message[3] = Soft_I2C_Read(1); // SPEED, current speed message[4] = Soft_I2C_Read(1); // Temperature, in Celcius message[5] = Soft_I2C_Read(1); // Checksum message[6] = Soft_I2C_Read(0); // End I2C communication Soft_I2C_Stop(); TxPacketBytes(reportMotorStatus, message[0],message[2], message[3],message[5]); }
//--------------------- Reads time and date information from RTC (PCF8563) void rtc_r(void) { unsigned char tmp; Soft_I2C_Start(); Soft_I2C_Write(0xA2); Soft_I2C_Write(2); Soft_I2C_Start(); Soft_I2C_Write(0xA3); tmp= 0x7F & Soft_I2C_Read(1); //segundos time[5]=':'; time[6]=getd(tmp); time[7]=getu(tmp); time[8]=0; tmp= 0x7F & Soft_I2C_Read(1); //minutos time[2]=':'; time[3]=getd(tmp); time[4]=getu(tmp); tmp= 0x3F & Soft_I2C_Read(1); //horas time[0]=getd(tmp); time[1]=getu(tmp); tmp= 0x3F & Soft_I2C_Read(1); //dia date[0]=getd(tmp); date[1]=getu(tmp); Soft_I2C_Read(1); //dia semana tmp= 0x1F & Soft_I2C_Read(1); //mes date[2]='/'; date[3]=getd(tmp); date[4]=getu(tmp); tmp= Soft_I2C_Read(1); //ano date[5]='/'; date[6]=getd(tmp); date[7]=getu(tmp); date[8]=0; Soft_I2C_Stop(); }