Code C
/*=----------------------------------------------------------------------=*\ Use :Lecture de la temp??rature du DS1621 : :Param??tres pour la macro Lect_Temp : : Adresse : MX_UINT8 : :Renvoie : MX_BOOL \*=----------------------------------------------------------------------=*/ MX_BOOL FCM_Lect_Temp(MX_UINT8 FCL_ADRESSE) { //Définitions des variables locales MX_UINT8 FCL_ACK; MX_UINT8 FCL_ADRESSE_L; MX_BOOL FCR_RETVAL;
// Nom: Calcul, Type: Calcul: // Old_MSB = MSB // Old_lsb = lsb // .Adresse = .Adresse AND 0b11111110 // .Adresse_L = .Adresse OR 0b00000001 FCV_OLD_MSB = FCV_MSB; FCV_OLD_LSB = FCV_LSB; FCL_ADRESSE = FCL_ADRESSE & 254; FCL_ADRESSE_L = FCL_ADRESSE | 1;
// Nom: Start_I2c, Type: Appel de la Routine Composant: I2C_Master1::Start() FCD_005f1_I2C_Master1__Start();
// Nom: Adresse I2C du DS1621, Type: Appel de la Routine Composant: .Ack=I2C_Master1::TransmitByte(.Adresse) FCL_ACK = FCD_005f1_I2C_Master1__TransmitByte(FCL_ADRESSE);
// Nom: Si Acknoledge est à 0, Type: Décision: .Ack = 0? if (FCL_ACK == 0) {
// Nom: Appel de la Routine Composant, Type: Appel de la Routine Composant: .Ack=I2C_Master1::TransmitByte(0xAA) FCL_ACK = FCD_005f1_I2C_Master1__TransmitByte(0xAA);
// Nom: Stop and Start I2C, Type: Appel de la Routine Composant: I2C_Master1::Restart() FCD_005f1_I2C_Master1__Restart();
// Nom: Adresse en Lecture du DS1621, Type: Appel de la Routine Composant: .Ack=I2C_Master1::TransmitByte(.Adresse_L) FCL_ACK = FCD_005f1_I2C_Master1__TransmitByte(FCL_ADRESSE_L);
// Nom: Appel de la Routine Composant, Type: Appel de la Routine Composant: MSB=I2C_Master1::ReceiveByte(0) FCV_MSB = FCD_005f1_I2C_Master1__ReceiveByte(0);
// Nom: Appel de la Routine Composant, Type: Appel de la Routine Composant: lsb=I2C_Master1::ReceiveByte(1) FCV_LSB = FCD_005f1_I2C_Master1__ReceiveByte(1);
// Nom: Décision, Type: Décision: MSB < 129? if (FCV_MSB < 129) {
//Commentaire: //Commentaire //Température positive
// Nom: Calcul, Type: Calcul: // Temp_s = "+" + ToString$ (MSB) FCI_SHEAD("+",2, FCI_TOSTRING(FCV_MSB, FCI_TMP_STR,20),20, FCV_TEMP_S,8);
// Nom: Décision, Type: Décision: lsb = 0? if (FCV_LSB == 0) {
} else {
//Commentaire: //Commentaire //lsb = 128
// Nom: Calcul, Type: Calcul: // Temp_s = Temp_s + ",5" FCI_SHEAD(FCV_TEMP_S,FCVsz_TEMP_S, ",5",3, FCV_TEMP_S,8);
}
} else {
// Nom: Calcul, Type: Calcul: // MSB2 = MSB FCV_MSB2 = FCV_MSB;
// Nom: Décision, Type: Décision: lsb = 0? if (FCV_LSB == 0) {
// Nom: Calcul complément à deux, Type: Calcul: // MSB2 = 256 - MSB FCV_MSB2 = 256 - FCV_MSB;
// Nom: Calcul, Type: Calcul: // Temp_s = "-" + ToString$ (MSB2) FCI_SHEAD("-",2, FCI_TOSTRING(FCV_MSB2, FCI_TMP_STR,20),20, FCV_TEMP_S,8);
} else {
// Nom: Calcul, Type: Calcul: // MSB2 = 255 - MSB FCV_MSB2 = 255 - FCV_MSB;
// Nom: Calcul, Type: Calcul: // Temp_s = "-" + ToString$ (MSB2) FCI_SHEAD("-",2, FCI_TOSTRING(FCV_MSB2, FCI_TMP_STR,20),20, FCV_TEMP_S,8);
// Nom: Calcul, Type: Calcul: // Temp_s = Temp_s + ",5" FCI_SHEAD(FCV_TEMP_S,FCVsz_TEMP_S, ",5",3, FCV_TEMP_S,8);
}
}
} else {
// Nom: Calcul, Type: Calcul: // Temp_s = "No DS1621 " FCI_SCOPY("No DS1621 ",11, FCV_TEMP_S,FCVsz_TEMP_S);
}
// Nom: Stop I2C, Type: Appel de la Routine Composant: I2C_Master1::Stop() FCD_005f1_I2C_Master1__Stop();
return (FCR_RETVAL);
}
|