// // Функция ожидания, с остановом при нажатой кнопке. // void wait (unsigned msec, int button) { unsigned t0 = timer_milliseconds (&timer); while (button_pressed (button) || timer_milliseconds (&timer) - t0 < msec) { // Если нажата указанная кнопка - ждём, // пока она не освободится. timer_delay (&timer, 10); } }
void hello (void *arg) { for (;;) { debug_printf ("Hello from `%s'! msec = %u\n", arg, timer_milliseconds (&timer)); mutex_wait (&timer.decisec); } }
void hello (void *arg) { for (;;) { debug_printf ("%s: msec = %d\n", arg, timer_milliseconds (&timer)); mutex_wait (&timer.decisec); } }
void udp_task (void *data) { int i; buf_t *p; unsigned old_count = 0; unsigned long start, end, elapsed; unsigned long long bytes; start = timer_milliseconds (&timer); debug_printf ("Press ENTER to start sending to %d.%d.%d.%d:%d\n", server_ip[0], server_ip[1], server_ip[2], server_ip[3], PORT); debug_getchar (); udp_socket (&sock, &ip, PORT); trace_udp.udps_ip = (unsigned)sock.ip; for (;;) { p = buf_alloc (&pool, BUF_SIZE * 4, 42); for (i = 0; i < BUF_SIZE; ++i) buf[i] = count++; memcpy (p->payload, buf, sizeof(buf)); if (!udp_sendto (&sock, p, server_ip, PORT)){ count -= BUF_SIZE; debug_printf ("Press ENTER to start sending to %@.4D:%d\n", server_ip, PORT); while (debug_peekchar () < 0) task_yield(); debug_getchar (); } if (timer_passed (&timer, start, 1000)) { end = timer_milliseconds (&timer); elapsed = end - start; bytes = (count - old_count) << 2; old_count = count; debug_printf ("snd rate: %lu (bytes/sec)\n", (unsigned) (bytes * 1000 / elapsed)); start = end; } } }
/* * Listener task. Get a lock group as an argument. * Waits for signals on the group, and prints them. */ void main_waiter (void *arg) { mutex_group_t *g = arg; mutex_t *m; void *msg; for (;;) { mutex_group_wait (g, &m, &msg); debug_printf ("Time %d, message %s\n", timer_milliseconds (&timer), msg ? msg : "Timer"); } }
static uint16_t Timer_Silence( void) { uint32_t delta_time = 0; delta_time = timer_milliseconds(TIMER_SILENCE); if (delta_time > 0xFFFF) { delta_time = 0xFFFF; } return (uint16_t) delta_time; }
/************************************************************************* * Description: Sets the timer counter to zero. * Returns: none * Notes: none *************************************************************************/ uint32_t timer_reset( unsigned index) { uint32_t timer_value = 0; if (index < MAX_MILLISECOND_TIMERS) { timer_value = timer_milliseconds(index); Millisecond_Counter[index] = timeGetTime(); } return timer_value; }
void hello (void *arg) { for (;;) { //debug_printf ("STATUS = %08x\n", mips_read_c0_register (C0_STATUS)); //debug_printf ("CAUSE = %08x\n", mips_read_c0_register (C0_CAUSE)); //debug_printf ("INTCTL = %08x\n", mips_read_c0_select (C0_INTCTL, 1)); //debug_printf ("EBASE = %08x\n", mips_read_c0_select (C0_EBASE, 1)); //debug_printf ("INTCON = %08x\n", INTCON); debug_printf ("Hello from `%s'! msec = %d\n", arg, timer_milliseconds (&timer)); mutex_wait (&timer.decisec); } }
void main_test () { buf_t *p; int i = 0; const unsigned delay = 20; mdelay(start_delay); data_pattern = mem_alloc (&pool, packet_size); memset (data_pattern, 0xa5, packet_size); if (packet_size >= 12) memcpy (data_pattern+6, eth.netif.ethaddr, 6); unsigned long time0 = timer_milliseconds(&timer); while (1) { //for (i = 0; i < nb_of_packets; ++i) { /* Check received data. */ p = netif_input (ð.netif); if (p) { if (memcmp (p->payload, data_pattern, packet_size) != 0) nerr++; nb_of_received++; buf_free (p); continue; } /* Send packets - make transmit queue full. */ if (i++ < nb_of_packets) { p = buf_alloc (&pool, packet_size, 16); if (p) { memcpy (p->payload, data_pattern, packet_size); netif_output (ð.netif, p, 0, 0); } else debug_printf("no mem\n"); } if ((nb_of_received == nb_of_packets) || timer_passed(&timer, time0, delay * nb_of_packets * 2)) break; timer_delay (&timer, delay); } nerr += nb_of_packets - nb_of_received; STOP; }
void display_refresh () { unsigned sec = timer_milliseconds (&timer) / 1000; unsigned min = sec / 60; unsigned hour = min / 60; sec -= min*60; min -= hour*60; gpanel_clear (&display, 0); puts (&display, "--Работает 5600ВГ1У--\r\n"); printf (&display, "Время теста:%3u:%02u:%02u\r\n", hour, min, sec); printf (&display, " TX пакетов:%9lu\r\n", eth.netif.out_packets); printf (&display, " ошибок:%9lu\r\n", eth.netif.out_errors); printf (&display, " RX пакетов:%9lu\r\n", eth.netif.in_packets); printf (&display, " ошибок:%9lu\r\n", eth.netif.in_errors); printf (&display, " Прерываний:%9lu\r\n", eth.intr); printf (&display, "Своб.байтов:%9u\r\n", mem_available (&pool)); }
/************************************************************************* * Description: compares the current time count with a value * Returns: true if the time has elapsed * Notes: none *************************************************************************/ bool timer_elapsed_minutes( unsigned index, unsigned long minutes) { return ((timer_milliseconds(index) / (1000UL * 60UL)) >= minutes); }
void test_arinc_main() { debug_printf("func_tx = %x, control1_tx = %x\n", func_tx, control1_tx); debug_printf("func_rx = %x, control1_rx = %x, control2_rx = %x\n", func_rx, control1_rx, control2_rx); debug_printf("channel out = %d, in = %d\n", MY_OUT_CHANNEL, MY_IN_CHANNEL); debug_printf("ssm data sdi label\n"); unsigned int counter = 0xee; ARINC_msg_t *const pCounter = (ARINC_msg_t *)&counter; pCounter->label = 0x30; pCounter->sdi = 1; pCounter->data = 0x1f; const int fifoCnt = 60; int i = 0; unsigned int data = 0; ARINC_msg_t *const pData = (ARINC_msg_t *)&data; int received = 0; unsigned long time0 = timer_milliseconds(&timer); for(;;) { // const ARINC_msg_t firstSentData = *pCounter; for (i=0; i<fifoCnt; ++i) { arinc_write(&atx, *pCounter); debug_printf("sent = %x = %x %x %x %x, status = %x\n", counter, pCounter->ssm, pCounter->data, pCounter->sdi, pCounter->label, ARM_ARINC429T->STATUS); ++counter; } for(;;) { if (arinc_read(&arx, pData)) { ++received; debug_printf("received=%08x (ssm=%x data=%x sdi=%x label=%x), status1 = %x, status2 = %x\n", data, pData->ssm, pData->data, pData->sdi, pData->label, ARM_ARINC429R->STATUS1, ARM_ARINC429R->STATUS2); // debug if (timer_passed(&timer, time0, 1000)) { static int ddd = 0; if (ddd == 0) debug_printf("received frames cnt = %d -------------\n", received); ddd = 1; } } else { if ((ARM_ARINC429R->STATUS1 & ARM_ARINC429R_STATUS1_ERR(MY_IN_CHANNEL)) > 0) { // Ошибка приёма debug_printf("rec error\n"); } else { debug_printf("no data received\n"); } break; } } timer_delay(&timer, 1000); // mdelay(1000); } }
/************************************************************************* * Description: compares the current time count with a value * Returns: true if the time has elapsed * Notes: none *************************************************************************/ bool timer_elapsed_milliseconds( unsigned index, unsigned long value) { return (timer_milliseconds(index) >= value); }
/************************************************************************* * Description: compares the current time count with a value * Returns: true if the time has elapsed * Notes: none *************************************************************************/ bool timer_elapsed_seconds( unsigned index, uint32_t seconds) { return ((timer_milliseconds(index) / 1000) >= seconds); }
/************************************************************************* * Description: compares the current time count with a value * Returns: true if the time has elapsed * Notes: none *************************************************************************/ bool timer_elapsed_minutes( unsigned index, uint32_t minutes) { return ((timer_milliseconds(index) / (1000 * 60)) >= minutes); }
static uint32_t Timer_Silence( void *pArg) { return timer_milliseconds(TIMER_SILENCE); }
/************************************************************************* * Description: compares the current time count with a value * Returns: true if the time has elapsed * Notes: none *************************************************************************/ bool timer_elapsed_seconds( unsigned index, unsigned long seconds) { return ((timer_milliseconds(index) / 1000UL) >= seconds); }