///lcdCmd(0xC0);2行目の先頭に移動
///lcdCmd(0x80);1行目の先頭に移動
void lcdCmd(unsigned char cmd) {
    Soft_I2C_Start();
    Soft_I2C_Write(0x7C);
    Soft_I2C_Write(0x80);
    Soft_I2C_Write(cmd);
    Soft_I2C_Stop();
}
void lcd_str_byCode(char cmd) {
    Soft_I2C_Start();
    Soft_I2C_Write(0x7C);
    Soft_I2C_Write(0xC0);
    Soft_I2C_Write(cmd);
    Soft_I2C_Stop();
}
void lcdData(unsigned char str) {
    Soft_I2C_Start();
    Soft_I2C_Write(0x7C);
    Soft_I2C_Write(0xC0);
    Soft_I2C_Write(str);
    Soft_I2C_Stop();
}
Example #4
0
//--------------------- 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();

}
Example #5
0
void FSetMotorAddress(char dataIn[])
{
    // Send start
    Soft_I2C_Start();
    // Write to motors: Address
    Soft_I2C_Write(dataIn[0]);
    // Write to motors: Speed
    Soft_I2C_Write(0x06);
    // Write to motors: Info
    Soft_I2C_Write(0x72);
    // Write to motors: Checksum
    //checkSum = dataIn[0] + 0x06 + 0x72;
    Soft_I2C_Write(dataIn[0] + 0x06 + 0x72);
    // Stop
    Soft_I2C_Stop();

    //Delay_ms(100);

    Soft_I2C_Start();
    // Write to motors: Address
    Soft_I2C_Write(dataIn[0]);
    // Write to motors: Speed
    Soft_I2C_Write(dataIn[1]);
    // Write to motors: Checksum
    //checkSum = dataIn[0] + dataIn[1];
    Soft_I2C_Write(dataIn[0] + dataIn[1]);
    //Soft_I2C_Write(dataIn[0]+dataIn[0]+dataIn[1]+0x06+0x72 + dataIn[1]);
    // Stop
    Soft_I2C_Stop();
}
Example #6
0
void FCommandMotors(char address, char command)
{
    // Send START
    Soft_I2C_Start();

    // Write to motors: Address
    Soft_I2C_Write(address);

    // Write to motors: Speed
    Soft_I2C_Write(command);

    // Write to motors: Info
    Soft_I2C_Write(MOTORFUTUREGROWTH);

    // Write to motors: Checksum
    Soft_I2C_Write(address + command + MOTORFUTUREGROWTH);

    // Stop
    Soft_I2C_Stop();
}
Example #7
0
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]);
}