Add a generic hrt driver userspace interface

This adds a nuttx userspace interface for hrt driver, communicating with
the actual px4 hrt driver via BOARDCTL IOCTLs

This is be used when running PX4 in NuttX protected or kernel builds

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen
2022-02-25 13:35:14 +01:00
committed by Beat Küng
parent 9f049b4dca
commit 77f71e61d2
4 changed files with 373 additions and 0 deletions
+37
View File
@@ -47,6 +47,10 @@
#include <px4_platform_common/time.h>
#include <queue.h>
#if defined(__PX4_NUTTX) && !defined(CONFIG_BUILD_FLAT)
#include <px4_platform/board_ctrl.h>
#endif
__BEGIN_DECLS
/**
@@ -76,6 +80,10 @@ typedef struct hrt_call {
hrt_abstime period;
hrt_callout callout;
void *arg;
#if defined(__PX4_NUTTX) && !defined(CONFIG_BUILD_FLAT)
hrt_callout usr_callout;
void *usr_arg;
#endif
} *hrt_call_t;
@@ -89,6 +97,35 @@ typedef struct latency_info {
uint32_t counter;
} latency_info_t;
#if defined(__PX4_NUTTX) && !defined(CONFIG_BUILD_FLAT)
typedef struct hrt_boardctl {
hrt_call_t entry;
hrt_abstime time; /* delay or calltime */
hrt_abstime interval;
hrt_callout callout;
void *arg;
} hrt_boardctl_t;
typedef struct latency_boardctl {
uint16_t bucket_idx;
uint16_t counter_idx;
latency_info_t latency;
} latency_boardctl_t;
#define _HRTIOC(_n) (_PX4_IOC(_HRTIOCBASE, _n))
#define HRT_WAITEVENT _HRTIOC(1)
#define HRT_ABSOLUTE_TIME _HRTIOC(2)
#define HRT_CALL_AFTER _HRTIOC(3)
#define HRT_CALL_AT _HRTIOC(4)
#define HRT_CALL_EVERY _HRTIOC(5)
#define HRT_CANCEL _HRTIOC(6)
#define HRT_GET_LATENCY _HRTIOC(7)
#define HRT_RESET_LATENCY _HRTIOC(8)
#endif
/**
* Get absolute time in [us] (does not wrap).
*/