ec_timet osal_current_time(void) { struct timeval current_time; ec_timet return_value; osal_gettimeofday(¤t_time, 0); return_value.sec = current_time.tv_sec; return_value.usec = current_time.tv_usec; return return_value; }
boolean osal_timer_is_expired (osal_timert * self) { struct timeval current_time; struct timeval stop_time; int is_not_yet_expired; osal_gettimeofday(¤t_time, 0); stop_time.tv_sec = self->stop_time.sec; stop_time.tv_usec = self->stop_time.usec; is_not_yet_expired = timercmp(¤t_time, &stop_time, <); return is_not_yet_expired == FALSE; }
void osal_timer_start(osal_timert * self, uint32 timeout_usec) { struct timeval start_time; struct timeval timeout; struct timeval stop_time; osal_gettimeofday(&start_time, 0); timeout.tv_sec = timeout_usec / USECS_PER_SEC; timeout.tv_usec = timeout_usec % USECS_PER_SEC; timeradd(&start_time, &timeout, &stop_time); self->stop_time.sec = stop_time.tv_sec; self->stop_time.usec = stop_time.tv_usec; }
static INT32 stp_dbg_fill_hdr (struct stp_dbg_pkt_hdr *hdr, INT32 type, INT32 ack, INT32 seq, INT32 crc, INT32 dir, INT32 len, INT32 dbg_type) { INT32 sec = 0; INT32 usec = 0; if (!hdr){ STP_DBG_ERR_FUNC("function invalid\n"); return -22; } else { osal_gettimeofday(&sec,&usec); hdr->dbg_type = dbg_type; hdr->ack = ack; hdr->seq = seq; hdr->sec = sec; hdr->usec = usec; hdr->crc = crc; hdr->dir = dir;//rx hdr->dmy = 0xffffffff; hdr->len = len; hdr->type = type; return 0; } }