mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 15:11:36 +08:00
QuRT: Added HRT workqueues as per POSIX
A high rate workqueue is required that acts like an interrupt handler for a HW timer. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
#
|
#
|
||||||
MODULES += drivers/device
|
MODULES += drivers/device
|
||||||
MODULES += drivers/blinkm
|
MODULES += drivers/blinkm
|
||||||
MODULES += drivers/buzzer
|
|
||||||
MODULES += drivers/hil
|
MODULES += drivers/hil
|
||||||
MODULES += drivers/rgbled
|
MODULES += drivers/rgbled
|
||||||
MODULES += drivers/led
|
MODULES += drivers/led
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#define MAX_CMD_LEN 100
|
#define MAX_CMD_LEN 100
|
||||||
|
|
||||||
#define PX4_MAX_TASKS 100
|
#define PX4_MAX_TASKS 50
|
||||||
#define SHELL_TASK_ID (PX4_MAX_TASKS+1)
|
#define SHELL_TASK_ID (PX4_MAX_TASKS+1)
|
||||||
|
|
||||||
pthread_t _shell_task_id = 0;
|
pthread_t _shell_task_id = 0;
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ SRCDIR=$(dir $(MODULE_MK))
|
|||||||
SRCS = \
|
SRCS = \
|
||||||
px4_qurt_impl.cpp \
|
px4_qurt_impl.cpp \
|
||||||
px4_qurt_tasks.cpp \
|
px4_qurt_tasks.cpp \
|
||||||
|
hrt_thread.c \
|
||||||
|
hrt_queue.c \
|
||||||
|
hrt_work_cancel.c \
|
||||||
work_thread.c \
|
work_thread.c \
|
||||||
work_queue.c \
|
work_queue.c \
|
||||||
work_lock.c \
|
work_lock.c \
|
||||||
|
|||||||
@@ -49,8 +49,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include "systemlib/param/param.h"
|
#include "systemlib/param/param.h"
|
||||||
|
#include "hrt_work.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern pthread_t _shell_task_id;
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
// FIXME - sysconf(_SC_CLK_TCK) not supported
|
// FIXME - sysconf(_SC_CLK_TCK) not supported
|
||||||
@@ -92,7 +95,10 @@ void init_once(void)
|
|||||||
// Required for QuRT
|
// Required for QuRT
|
||||||
//_posix_init();
|
//_posix_init();
|
||||||
|
|
||||||
|
_shell_task_id = pthread_self();
|
||||||
|
PX4_INFO("Shell id is %lu", _shell_task_id);
|
||||||
work_queues_init();
|
work_queues_init();
|
||||||
|
hrt_work_queue_init();
|
||||||
hrt_init();
|
hrt_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,11 @@
|
|||||||
|
|
||||||
#define MAX_CMD_LEN 100
|
#define MAX_CMD_LEN 100
|
||||||
|
|
||||||
#define PX4_MAX_TASKS 100
|
#define PX4_MAX_TASKS 50
|
||||||
|
#define SHELL_TASK_ID (PX4_MAX_TASKS+1)
|
||||||
|
|
||||||
|
pthread_t _shell_task_id = 0;
|
||||||
|
|
||||||
struct task_entry
|
struct task_entry
|
||||||
{
|
{
|
||||||
pthread_t pid;
|
pthread_t pid;
|
||||||
@@ -269,13 +273,16 @@ int px4_getpid()
|
|||||||
{
|
{
|
||||||
pthread_t pid = pthread_self();
|
pthread_t pid = pthread_self();
|
||||||
|
|
||||||
|
if (pid == _shell_task_id)
|
||||||
|
return SHELL_TASK_ID;
|
||||||
|
|
||||||
// Get pthread ID from the opaque ID
|
// Get pthread ID from the opaque ID
|
||||||
for (int i=0; i<PX4_MAX_TASKS; ++i) {
|
for (int i=0; i<PX4_MAX_TASKS; ++i) {
|
||||||
if (taskmap[i].pid == pid) {
|
if (taskmap[i].isused && taskmap[i].pid == pid) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PX4_ERR("px4_getpid() called from non-thread context!");
|
PX4_ERR("px4_getpid() called from unknown thread context!");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user