This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

setup HTS221 with nrf52832

I am trying to integrate code on hts221 with an nrf52832. I am using sdk15a for referring the .h and .c of hts221.

NRF_TWI_MNGR_DEF(m_nrf_twi_mngr, MAX_PENDING_TRANSACTIONS, TWI_INSTANCE_ID);
NRF_TWI_SENSOR_DEF(m_twi_sensor, &m_nrf_twi_mngr, 128);
HTS221_INSTANCE_DEF(m_hts221, &m_twi_sensor, HTS221_ADDR ); 

how to call this macros( in hts221.c) into the main file

I am not sure this is correct ?

HTS221_WRITE(m_hts221, msg);

also problem in how to call this function into main file

ret_code_t hts221_temp_read(hts221_instance_t *       p_instance,
                            hts221_data_callback_t    user_callback,
                            int16_t *                 p_temp)
{
    ASSERT(p_instance != NULL);
    return nrf_twi_sensor_reg_read(p_instance->p_sensor_data,
                                   p_instance->sensor_addr,
                                   HTS221_REG_TEMP_OUT_L | HTS221_INCR_REG_MASK,
                                   (nrf_twi_sensor_reg_cb_t) user_callback,
                                   (uint8_t *) p_temp,
                                   2);
}

i am trying but getting errror.

 If anyone knows please help me.(anyone having code hts221 twi interfacing please provide)

Parents
  • Hi,

    Which error are you getting? There is no example of using this driver in the SDK, but maybe the code in this post may provide you with a starting-point.

    There is also a driver for this sensor in the Thingy:52 FW.

    Best regards,
    Jørgen

  • which parameter need t pass to this function(nrf_twi_sensor)?

    ret_code_t hts221_temp_read(hts221_instance_t *       p_instance,
                                hts221_data_callback_t    user_callback,
                                int16_t *                 p_temp)
    {
        ASSERT(p_instance != NULL);
        return nrf_twi_sensor_reg_read(p_instance->p_sensor_data,
                                       p_instance->sensor_addr,
                                       HTS221_REG_TEMP_OUT_L | HTS221_INCR_REG_MASK,
                                       (nrf_twi_sensor_reg_cb_t) user_callback,
                                       (uint8_t *) p_temp,
                                       2);
    }

    above error occured while calling this function in main file.

Reply
  • which parameter need t pass to this function(nrf_twi_sensor)?

    ret_code_t hts221_temp_read(hts221_instance_t *       p_instance,
                                hts221_data_callback_t    user_callback,
                                int16_t *                 p_temp)
    {
        ASSERT(p_instance != NULL);
        return nrf_twi_sensor_reg_read(p_instance->p_sensor_data,
                                       p_instance->sensor_addr,
                                       HTS221_REG_TEMP_OUT_L | HTS221_INCR_REG_MASK,
                                       (nrf_twi_sensor_reg_cb_t) user_callback,
                                       (uint8_t *) p_temp,
                                       2);
    }

    above error occured while calling this function in main file.

Children
No Data
Related