Ejemplo n.º 1
0
static uint32_t aon_counter_qmsi_read(struct device *dev)
{
	uint32_t value;

	qm_aonc_get_value(QM_AONC_0, &value);

	return value;
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: jeez/qmsi
int main(void)
{
	uint32_t c_val = 0, pt_val = 0;
	qm_aonpt_config_t cfg;

	QM_PUTS("Starting: Always-on Counter");

	/* Always-on Counter enable and read value. */
	qm_aonc_enable(QM_AONC_0);

	if (qm_aonc_get_value(QM_AONC_0, &c_val) == 0) {
		QM_PRINTF("Always-on Counter value: %u\n", c_val);
	} else {
		QM_PUTS("Error: Could not read aonc value.");
	}

	/* Request an IRQ and write the Always-on Periodic Timer config. */
	cfg.count = 0x1000; /* 0.125 seconds. */
	cfg.int_en = true;  /* Interrupts enabled. */
	cfg.callback = aonpt_example_callback;

	qm_irq_request(QM_IRQ_AONPT_0_INT, qm_aonpt_0_isr);

	qm_aonpt_set_config(QM_AONC_0, &cfg);

	/* Wait for the defined number of callbacks be invoked. */
	while (NUM_CALLBACKS > callback_count)
		;

	QM_PRINTF("Periodic Timer callback fired %d times.\n", callback_count);

	/* Get the value of the Always-on Periodic Timer. */
	if (qm_aonpt_get_value(QM_AONC_0, &c_val) == 0) {
		QM_PRINTF("Always-on Periodic Timer value: %u\n", pt_val);
	} else {
		QM_PUTS("Error: Could not read Periodic timer value");
	}

	/* Disable the always-on periodic timer interrupt. */
	cfg.int_en = false;
	qm_aonpt_set_config(QM_AONC_0, &cfg);

	QM_PUTS("Finished: Always-on counter");

	return 0;
}
Ejemplo n.º 3
0
int main(void)
{
	volatile uint32_t delay;
	uint32_t c_val = 0, pt_val = 0;
	qm_aonpt_config_t cfg;

	QM_PUTS("\nAlways-on Counter example app\n");

	/* Always-on Counter enable, disable and read value */
	qm_aonc_disable(QM_SCSS_AON_0);
	qm_aonc_enable(QM_SCSS_AON_0);

	c_val = qm_aonc_get_value(QM_SCSS_AON_0);
	if (c_val) {
		QM_PRINTF("Always-on Counter value: %lu\n", c_val);
	} else {
		QM_PRINTF("ERROR: Could not read aonc value\n");
	}

	/* Request an IRQ and write the Always-on Periodic Timer config */
	cfg.count = 0x10000;
	cfg.int_en = true;
	cfg.callback = aonpt_example_callback;

	qm_irq_request(QM_IRQ_AONPT_0, qm_aonpt_isr_0);

	qm_aonpt_set_config(QM_SCSS_AON_0, &cfg);

	/* The AON Periodic Timer runs from the RTC clock at 32KHz (rather than
	 * the system clock which is 32MHz) so we need to spin for a few cycles
	 * allow the register change to propagate */
	for (delay = 500; delay--;) {
	}

	/* Get the value of the Always-on Periodic Timer */
	pt_val = qm_aonpt_get_value(QM_SCSS_AON_0);
	if (pt_val) {
		QM_PRINTF("Always-on Periodic Timer value: %lu\n", pt_val);
	} else {
		QM_PRINTF("ERROR: Could not read Periodic timer value\n\n");
	}

	QM_PUTS("Always-on counter example app complete\n");
	return 0;
}