hw/drivers/sensors/lps22hb/src/lps22hb.c
int
lps22hb_init(struct os_dev *dev, void *arg)
{
    struct lps22hb *lhb;
    struct sensor *sensor;
    int rc;

    if (!arg || !dev) {
        return SYS_ENODEV;
    }

    lhb = (struct lps22hb *) dev;

    lhb->cfg.mask = SENSOR_TYPE_ALL;

    log_register((char*)dev->od_name, &_log, &log_console_handler, NULL, LOG_SYSLEVEL);

    sensor = &lhb->sensor;

    rc = sensor_init(sensor, dev);
    if (rc) {
        return rc;
    }

    /* Add the accelerometer/gyroscope driver */
    rc = sensor_set_driver(sensor, (SENSOR_TYPE_PRESSURE | SENSOR_TYPE_TEMPERATURE),
         (struct sensor_driver *) &g_lps22hb_sensor_driver);
    if (rc) {
        return rc;
    }

    rc = sensor_set_interface(sensor, arg);
    if (rc) {
        return rc;
    }

    return sensor_mgr_register(sensor);
}
/**
 * Expects to be called back through os_dev_create().
 *
 * @param The device object associated with this accellerometer
 * @param Argument passed to OS device init, unused
 *
 * @return 0 on success, non-zero error on failure.
 */
Expects to be called back through os_dev_create().
@param The device object associated with this accellerometer
@param Argument passed to OS device init, unused

@return 0 on success, non-zero error on failure.
Expects to be called back through os_dev_create () . @param The device object associated with this accellerometer @param Argument passed to OS device init unused @return 0 on success non - zero error on failure .
int
lps22hb_init(struct os_dev *dev, void *arg)
{
    struct lps22hb *lhb;
    struct sensor *sensor;
    int rc;
    if (!arg || !dev) {
        return SYS_ENODEV;
    }
    lhb = (struct lps22hb *) dev;
    lhb->cfg.mask = SENSOR_TYPE_ALL;
    log_register((char*)dev->od_name, &_log, &log_console_handler, NULL, LOG_SYSLEVEL);
    sensor = &lhb->sensor;
    rc = sensor_init(sensor, dev);
    if (rc) {
        return rc;
    }
    rc = sensor_set_driver(sensor, (SENSOR_TYPE_PRESSURE | SENSOR_TYPE_TEMPERATURE),
         (struct sensor_driver *) &g_lps22hb_sensor_driver);
    if (rc) {
        return rc;
    }
    rc = sensor_set_interface(sensor, arg);
    if (rc) {
        return rc;
    }
    return sensor_mgr_register(sensor);
}
int lps22hb_init ( struct os_dev * dev , void * arg ) { struct lps22hb * lhb ; struct sensor * sensor ; int rc ; if ( ! arg || ! dev ) { return SYS_ENODEV ; } lhb = ( struct lps22hb * ) dev ; lhb -> cfg . mask = SENSOR_TYPE_ALL ; log_register ( ( char * ) dev -> od_name , & _log , & log_console_handler , NULL , LOG_SYSLEVEL ) ; sensor = & lhb -> sensor ; rc = sensor_init ( sensor , dev ) ; if ( rc ) { return rc ; } rc = sensor_set_driver ( sensor , ( SENSOR_TYPE_PRESSURE | SENSOR_TYPE_TEMPERATURE ) , ( struct sensor_driver * ) & g_lps22hb_sensor_driver ) ; if ( rc ) { return rc ; } rc = sensor_set_interface ( sensor , arg ) ; if ( rc ) { return rc ; } return sensor_mgr_register ( sensor ) ; }
Expects to be called back through os_dev_create().
Expects to be called back through os_dev_create () .
/* Add the accelerometer/gyroscope driver */