static void test_lifo_get_two(void) { lifo_insert(lifo, 0); lifo_insert(lifo, 1); TEST_ASSERT_EQUAL_INT(1, lifo_get(lifo)); TEST_ASSERT_EQUAL_INT(0, lifo_get(lifo)); }
int main() { int array[5]; lifo_init(array, 4); lifo_insert(array, 2); lifo_insert(array, 1); lifo_insert(array, 3); lifo_insert(array, 0); lifo_insert(array, 3); printf("get: %i\n", lifo_get(array)); printf("get: %i\n", lifo_get(array)); printf("get: %i\n", lifo_get(array)); printf("get: %i\n", lifo_get(array)); printf("get: %i\n", lifo_get(array)); printf("get: %i\n", lifo_get(array)); printf("get: %i\n", lifo_get(array)); printf("get: %i\n", lifo_get(array)); printf("get: %i\n", lifo_get(array)); return 0; }
static int _hwtimer_set(unsigned long offset, void (*callback)(void*), void *ptr, bool absolute) { DEBUG("_hwtimer_set: offset=%lu callback=%p ptr=%p absolute=%d\n", offset, callback, ptr, absolute); if (!inISR()) { dINT(); } int n = lifo_get(lifo); if (n == -1) { if (!inISR()) { eINT(); } puts("No hwtimer left."); return -1; } timer[n].callback = callback; timer[n].data = ptr; if (absolute) { DEBUG("hwtimer_arch_set_absolute n=%d\n", n); hwtimer_arch_set_absolute(offset, n); } else { DEBUG("hwtimer_arch_set n=%d\n", n); hwtimer_arch_set(offset, n); } lpm_prevent_sleep++; if (!inISR()) { eINT(); } return n; }
static void test_lifo_get_one(void) { lifo_insert(lifo, 0); TEST_ASSERT_EQUAL_INT(0, lifo_get(lifo)); }