1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| ...
s_I2C_ADRR : // Slave Address (0x40) + Read
begin
if (!i2c_busy) begin
i2c_start = 0;
i2c_write = 1;
i2c_data_in = I2C_ADRSi7021_Read;
r_I2C_State_Next = s_I2C_MEASURE_CHECK;
end
end
s_I2C_MEASURE_CHECK :
begin
if (!i2c_busy) begin
if (i2c_ack_write) begin // si NAK
i2c_write = 0;
i2c_start = 1;
r_I2C_State_Next = s_I2C_ADRR; // si NAK, la conversion n'est pas terminée, on retourne à l'étape précédente
end else
begin // si AK
r_I2C_State_Next = s_I2C_MEASURE; // si AK, fin de la conversion, il faut récupérer les données de température à l'étape suivante
end
end
end
s_I2C_MEASURE : // conversion terminée
begin
if (!i2c_busy) begin
i2c_write = 0;
i2c_read = 1;
i2c_ack_read = 1;
r_I2C_State_Next = s_I2C_READ_MSB;
end
end
s_I2C_READ_MSB :
begin
... |
Partager