Ejemplo n.º 1
0
Archivo: ft5x06.c Proyecto: sktwj/var
static void ft5x06_check_mode()
{
	i2c_block_read(TS_I2CBUS_NUM, FT5X06_SLAVE_ADDR, &info.id, sizeof(struct ts_id), ID_G_AUTO_CLB_MODE);

	switch (info.id.auto_calibration_mode) {
	case 0:
		printf("enable auto calibration\n");
		break;
	case 0xff:
		printf("disable auto calibration\n");
		break;
	default:
		printf("unknown value of auto_calibration_mode 0x%x\n", info.id.auto_calibration_mode);
		break;
	}

	if (info.id.interrupt_mode) {
		printf("Trigger mode\n");
	} else {
		printf("Polling mode\n");
	}

	printf("lib_version = 0x%x, chip_id = 0x%x\n", info.id.firmware_lib_ver_H << 8 | info.id.firmware_lib_ver_L, info.id.chip_vendor_ID);
}
Ejemplo n.º 2
0
int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
    int rv;
    int pid = ONLP_OID_ID_GET(id);
    *info = psus__[pid];
    const char* dir = psu_info[pid].path;
    uint8_t buffer[ONLP_CONFIG_INFO_STR_MAX];
	int value = -1;

	rv = pca953x_gpio_value_get(psu_info[pid].present, &value);
	if(rv < 0) {
        return rv;
    }
	else if(value == GPIO_HIGH) {
        info->status &= ~1;
        return 0;
	}

    if(onlp_file_read_int(&info->mvin, "%s/in1_input", dir) == 0 && info->mvin >= 0) {
        info->caps |= ONLP_PSU_CAPS_VIN;
    }

    /* PSU is present and powered. */
    info->status |= 1;

    memset(buffer, 0, sizeof(buffer));
    rv = i2c_block_read(psu_info[pid].busno, psu_info[pid].addr, PMBUS_MFR_MODEL, PMBUS_MFR_MODEL_LEN, buffer, ONLP_I2C_F_FORCE);
    if(rv >= 0)
        strncpy(info->model, (char *) (buffer+1), buffer[0]);
    else
        strcpy(info->model, "Missing");

    memset(buffer, 0, sizeof(buffer));
    rv = i2c_block_read(psu_info[pid].busno, psu_info[pid].addr, PMBUS_MFR_SERIAL, PMBUS_MFR_SERIAL_LEN, buffer, ONLP_I2C_F_FORCE);
    if(rv >= 0)
        strncpy(info->serial, (char *) (buffer+1), buffer[0]);
    else
        strcpy(info->serial, "Missing");

    info->caps |= ONLP_PSU_CAPS_AC;

    if(onlp_file_read_int(&info->miin, "%s/curr1_input", dir) == 0 && info->miin >= 0) {
        info->caps |= ONLP_PSU_CAPS_IIN;
    }
    if(onlp_file_read_int(&info->miout, "%s/curr2_input", dir) == 0 && info->miout >= 0) {
        info->caps |= ONLP_PSU_CAPS_IOUT;
    }
    if(onlp_file_read_int(&info->mvout, "%s/in2_input", dir) == 0 && info->mvout >= 0) {
        info->caps |= ONLP_PSU_CAPS_VOUT;
        /* Empirical */
        info->mvout /= 500;
    }
    if(onlp_file_read_int(&info->mpin, "%s/power1_input", dir) == 0 && info->mpin >= 0) {
        info->caps |= ONLP_PSU_CAPS_PIN;
        /* The pmbus driver reports power in micro-units */
        info->mpin /= 1000;
    }
    if(onlp_file_read_int(&info->mpout, "%s/power2_input", dir) == 0 && info->mpout >= 0) {
        info->caps |= ONLP_PSU_CAPS_POUT;
        /* the pmbus driver reports power in micro-units */
        info->mpout /= 1000;
    }
    return ONLP_STATUS_OK;
}