Buenas tardes,
Como me has pedido te vuelvo a reenviar la imagen y esta dejo el codigo escrito. Espero podais ayudarme, no doy con el problema.
Below I show the unique changes that I have made as requested by the same code, add the functions that are writing and reading.
/***************************************************************************************/
s8 BMP180_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
{
s32 iError = BMP180_INIT_VALUE;
u8 array[I2C_BUFFER_LEN];
u8 stringpos = BMP180_INIT_VALUE;
array[BMP180_INIT_VALUE] = reg_addr;
int C_BMP180_ONE_U8X = -1;
for (stringpos = BMP180_INIT_VALUE; stringpos < cnt; stringpos++) {
array[stringpos + C_BMP180_ONE_U8X] = *(reg_data + stringpos);
}
I2C_IF_Write(dev_addr,&array[0],cnt,1);
return (s8)iError;
}
/***************************************************************************************/
s8 BMP180_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
{
s32 iError = BMP180_INIT_VALUE;
u8 array[22] = {BMP180_INIT_VALUE}; // FALLO SI NO ES DE 22, "array[I2C_BUFFER_LEN]"
u8 stringpos = BMP180_INIT_VALUE;
array[BMP180_INIT_VALUE] = reg_addr;
int iretval;
//
// Write the register address to be read from.
// Stop bit implicitly assumed to be 0.
//
iretval=I2C_IF_Write(dev_addr,®_addr,1,0);
if(iretval!=0)
UART_PRINT ("Fallo en ESCRITURA");
//
// Read the specified length of data
//
iretval=I2C_IF_Read(dev_addr,&array[0],cnt);
if(iretval!=0)
UART_PRINT ("Fallo en LECTURA");
/* Por favor, tenga la función de continuación como su referencia
* Para leer los datos utilizando la comunicación I2C
* Añadir su función rad I2C aquí.
* "IError = I2C_WRITE_READ_STRING (DEV_ADDR, Array, Array, C_BMP180_ONE_U8X, CNT)"
* IError es un valor de retorno de la función de escritura SPI
* Por favor seleccione su valor de retorno válida
* En el ÉXITO conductor definido como BMP180_INIT_VALUE
* Y FALLO define como -C_BMP180_ONE_U8X
*/
for (stringpos = BMP180_INIT_VALUE; stringpos < cnt; stringpos++) {
*(reg_data + stringpos) = array[stringpos];
}
return (s8)iError;
}
/***************************************************************************************/
void BMP180_delay_msek(u32 msek)
{
MAP_UtilsDelay(5000);
}
s8 I2C_routine()
{
bmp180.bus_write = BMP180_I2C_bus_write;
bmp180.bus_read = BMP180_I2C_bus_read;
bmp180.dev_addr = BMP180_I2C_ADDR;
bmp180.delay_msec = BMP180_delay_msek;
return BMP180_INIT_VALUE;
}
//*****************************************************************************
//
//! Main function handling the I2C example
//!
//! \param None
//!
//! \return None
//!
//*****************************************************************************
void main()
{
//
// Initialize board configurations
//
BoardInit();
//
// Configure the pinmux settings for the peripherals exercised
//
PinMuxConfig();
//
// Configuring UART
//
InitTerm();
//
// I2C Init
//
I2C_IF_Open(I2C_MASTER_MODE_STD);
/* result of communication results*/
u16 v_uncomp_temp_u16 = BMP180_INIT_VALUE;
u32 v_uncomp_press_u32 = BMP180_INIT_VALUE;
//s32 com_rslt = E_BMP_COMM_RES;
u16 TEMPERATURA;
u32 PRESION;
I2C_routine();
bmp180_init(&bmp180);
while(1)
{
v_uncomp_temp_u16 = bmp180_get_uncomp_temperature();
UART_PRINT ("Temp uncomp =");
UART_PRINT ("%d",v_uncomp_temp_u16);
UART_PRINT ("\n\r");
v_uncomp_press_u32 = bmp180_get_uncomp_pressure();
UART_PRINT ("Presion uncomp =");
UART_PRINT ("%d",v_uncomp_press_u32);
UART_PRINT ("\n\r");
TEMPERATURA = bmp180_get_temperature(v_uncomp_temp_u16);
UART_PRINT ("TEMPERATURE REAL=");
UART_PRINT ("%d",TEMPERATURA);
UART_PRINT ("\n\r");
PRESION = bmp180_get_pressure(v_uncomp_press_u32);
UART_PRINT ("PRESSURE REAL=");
UART_PRINT ("%d",PRESION);
UART_PRINT ("\n\r");
UART_PRINT ("\n\r");
}
}
/*****************************************************************************/
Thank you very much and I hope your answer.
Cheers