Пример #1
0
/**
 * Initialize the peripherals and state for this task.
 */
uint8_t
camera_task_setup() {
	/* Initialize I2C peripherals for this task. */
	ov5642_init();
	lps331_init();
	hts221_init();

	/* Intialize SPI peripherals for this task. */
	spi_take();
	arduCamInstalled = arducam_init();

	/* Try to mount the SD card. */
	if (fn_initvolume(mmc_spi_initfunc) != F_NO_ERROR) {
		trace_printf("sdcard: failed to mount volume\n");
		spi_give();
		return 0;
	}

#ifdef CLEAN_SD_CARD
	/* Delete DATA.LOG and JPG files from the SD card. */
	trace_printf("camera_task: cleaning SD card\n");
	f_delete("DATA.LOG");
	f_delete("file.txt");
	F_FIND xFindStruct;
	if (f_findfirst("*.JPG", &xFindStruct) == F_NO_ERROR) {
		do {
			f_delete(xFindStruct.filename);
		} while (f_findnext(&xFindStruct) == F_NO_ERROR);
	}
#endif

	spi_give();
	return 1; // OK
}
Пример #2
0
int main(void)
{
    printf("Init HTS221 on I2C_DEV(%i)\n", (int)hts221_params[0].i2c);
    if (hts221_init(&dev, &hts221_params[0]) != HTS221_OK) {
        puts("[FAILED]");
        return 1;
    }
    if (hts221_power_on(&dev) != HTS221_OK) {
        puts("[FAILED] to set power on!");
        return 2;
    }
    if (hts221_set_rate(&dev, dev.p.rate) != HTS221_OK) {
        puts("[FAILED] to set continuous mode!");
        return 3;
    }

    while(1) {
        uint16_t hum = 0;
        int16_t temp = 0;
        if (hts221_read_humidity(&dev, &hum) != HTS221_OK) {
            puts(" -- failed to humidity!");
        }
        if (hts221_read_temperature(&dev, &temp) != HTS221_OK) {
            puts(" -- failed to temperature!");
        }
        bool negative = (temp < 0);
        if (negative) {
            temp = -temp;
        }
        printf("H: %u.%u%%, T:%c%u.%u°C\n", (hum/10), (hum%10),
               (negative ? '-' : ' '), (temp/10), (temp%10));
        xtimer_sleep(SLEEP_S);
    }
    return 0;
}