2022-11-12 00:31:10 +08:00
|
|
|
/*
|
|
|
|
* @Author: jiejie
|
|
|
|
* @Github: https://github.com/jiejieTop
|
|
|
|
* @Date: 2019-12-10 22:18:32
|
|
|
|
* @LastEditTime: 2020-10-17 14:17:55
|
2022-11-12 13:55:15 +08:00
|
|
|
* @Description: the code belongs to jiejie, please keep the author information
|
|
|
|
* and source code according to the license.
|
2022-11-12 00:31:10 +08:00
|
|
|
*/
|
|
|
|
#ifndef _PLATFORM_TIMER_H_
|
|
|
|
#define _PLATFORM_TIMER_H_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2022-11-13 13:41:05 +08:00
|
|
|
#include "PikaObj.h"
|
2022-11-12 14:02:43 +08:00
|
|
|
#ifdef __linux
|
2022-11-12 15:20:51 +08:00
|
|
|
#include <sys/time.h>
|
|
|
|
typedef struct platform_timer {
|
|
|
|
struct timeval time;
|
|
|
|
} platform_timer_t;
|
|
|
|
#elif PIKA_FREERTOS_ENABLE
|
2022-11-13 13:41:05 +08:00
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/semphr.h"
|
2022-11-12 15:20:51 +08:00
|
|
|
typedef struct platform_timer {
|
|
|
|
uint32_t time;
|
|
|
|
} platform_timer_t;
|
2022-11-12 14:02:43 +08:00
|
|
|
#else
|
2022-11-12 15:20:51 +08:00
|
|
|
/*
|
|
|
|
You need to create the __platform_timer.h for your platform.
|
|
|
|
*/
|
|
|
|
#include "__platform_time.h"
|
2022-11-12 14:02:43 +08:00
|
|
|
#endif
|
2022-11-12 00:31:10 +08:00
|
|
|
#include <time.h>
|
2022-11-12 13:55:15 +08:00
|
|
|
#include <unistd.h>
|
2022-11-12 00:31:10 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void platform_timer_init(platform_timer_t* timer);
|
|
|
|
void platform_timer_cutdown(platform_timer_t* timer, unsigned int timeout);
|
|
|
|
char platform_timer_is_expired(platform_timer_t* timer);
|
|
|
|
int platform_timer_remain(platform_timer_t* timer);
|
|
|
|
unsigned long platform_timer_now(void);
|
|
|
|
void platform_timer_usleep(unsigned long usec);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|