Example #1
0
/**
 *
 * @brief The test main function
 *
 * @return 0 on success
 */
int nanoIntLatency(void)
{
	PRINT_FORMAT(" 1- Measure time to switch from fiber to ISR execution");
	TICK_SYNCH();
	task_fiber_start(&fiberStack[0], STACKSIZE,
					 (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
	PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
				 timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
	return 0;
}
Example #2
0
/**
 *
 * @brief The test main function
 *
 * @return 0 on success
 */
int int_to_thread_evt(void)
{
	PRINT_FORMAT(" 2 - Measure time from ISR to executing a different thread"
		     " (rescheduled)");
	TICK_SYNCH();
	k_sem_give(&INTSEMA);
	k_alert_recv(&EVENT0, K_FOREVER);
	timestamp = TIME_STAMP_DELTA_GET(timestamp);
	PRINT_FORMAT(" switch time is %u tcs = %u nsec",
		     timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
	return 0;
}
Example #3
0
/**
 *
 * @brief The test main function
 *
 * @return 0 on success
 */
int nanoIntToFiber(void)
{
	PRINT_FORMAT(" 2- Measure time to switch from ISR back to interrupted"
				 " fiber");
	TICK_SYNCH();
	task_fiber_start(&fiberStack[0], STACKSIZE,
					 (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
	if (flagVar == 1) {
		PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
					 timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
	}
	return 0;
}
Example #4
0
/**
 *
 * @brief The test main function
 *
 * @return 0 on success
 */
int nanoIntToFiberSem(void)
{
	PRINT_FORMAT(" 3- Measure time from ISR to executing a different fiber"
		     " (rescheduled)");
	nano_sem_init(&testSema);

	TICK_SYNCH();
	task_fiber_start(&waiterStack[0], STACKSIZE,
			 (nano_fiber_entry_t) fiberWaiter, 0, 0, 5, 0);
	task_fiber_start(&intStack[0], STACKSIZE,
			 (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);

	PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
		     timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
	return 0;
}
Example #5
0
/**
 *
 * @brief Interrupt preparation fiber
 *
 * Fiber makes all the test preparations: registers the interrupt handler,
 * gets the first timestamp and invokes the software interrupt.
 *
 * @return N/A
 */
static void fiberInt(void)
{
	flagVar = 0;
	irq_offload(latencyTestIsr, NULL);
	if (flagVar != 1) {
		PRINT_FORMAT(" Flag variable has not changed. FAILED");
	} else {
		timestamp = TIME_STAMP_DELTA_GET(timestamp);
	}
}
Example #6
0
/**
 *
 * @brief The test main function
 *
 * @return 0 on success
 */
int nanoIntLockUnlock(void)
{
	int i;
	unsigned int mask;

	PRINT_FORMAT(" 5- Measure average time to lock then unlock interrupts");
	bench_test_start();
	timestamp = TIME_STAMP_DELTA_GET(0);
	for (i = 0; i < NTESTS; i++) {
		mask = irq_lock();
		irq_unlock(mask);
	}
	timestamp = TIME_STAMP_DELTA_GET(timestamp);
	if (bench_test_end() == 0) {
		PRINT_FORMAT(" Average time for lock then unlock "
			"is %lu tcs = %lu nsec",
			timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS));
	} else {
		errorCount++;
		PRINT_OVERFLOW_ERROR();
	}
	return 0;
}
Example #7
0
static void print_one_field(mavlink_message_t *msg, const mavlink_field_info_t *f, int idx)
{
#define PRINT_FORMAT(f, def) (f->print_format?f->print_format:def)
	switch (f->type) {
	case MAVLINK_TYPE_CHAR:
		printf(PRINT_FORMAT(f, "%c"), _MAV_RETURN_char(msg, f->wire_offset+idx*1));
		break;
	case MAVLINK_TYPE_UINT8_T:
		printf(PRINT_FORMAT(f, "%u"), _MAV_RETURN_uint8_t(msg, f->wire_offset+idx*1));
		break;
	case MAVLINK_TYPE_INT8_T:
		printf(PRINT_FORMAT(f, "%d"), _MAV_RETURN_int8_t(msg, f->wire_offset+idx*1));
		break;
	case MAVLINK_TYPE_UINT16_T:
		printf(PRINT_FORMAT(f, "%u"), _MAV_RETURN_uint16_t(msg, f->wire_offset+idx*2));
		break;
	case MAVLINK_TYPE_INT16_T:
		printf(PRINT_FORMAT(f, "%d"), _MAV_RETURN_int16_t(msg, f->wire_offset+idx*2));
		break;
	case MAVLINK_TYPE_UINT32_T:
		printf(PRINT_FORMAT(f, "%lu"), (unsigned long)_MAV_RETURN_uint32_t(msg, f->wire_offset+idx*4));
		break;
	case MAVLINK_TYPE_INT32_T:
		printf(PRINT_FORMAT(f, "%ld"), (long)_MAV_RETURN_int32_t(msg, f->wire_offset+idx*4));
		break;
	case MAVLINK_TYPE_UINT64_T:
		printf(PRINT_FORMAT(f, "%llu"), (unsigned long long)_MAV_RETURN_uint64_t(msg, f->wire_offset+idx*8));
		break;
	case MAVLINK_TYPE_INT64_T:
		printf(PRINT_FORMAT(f, "%lld"), (long long)_MAV_RETURN_int64_t(msg, f->wire_offset+idx*8));
		break;
	case MAVLINK_TYPE_FLOAT:
		printf(PRINT_FORMAT(f, "%f"), (double)_MAV_RETURN_float(msg, f->wire_offset+idx*4));
		break;
	case MAVLINK_TYPE_DOUBLE:
		printf(PRINT_FORMAT(f, "%f"), _MAV_RETURN_double(msg, f->wire_offset+idx*8));
		break;
	}
}