mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 05:03:35 +08:00
purge broken qurt support and atlflight boards
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
|
||||
set(SRCS)
|
||||
|
||||
if (NOT "${PX4_PLATFORM}" MATCHES "qurt" AND NOT "${PX4_BOARD}" MATCHES "io-v2" AND NOT "${PX4_BOARD_LABEL}" MATCHES "bootloader")
|
||||
if(NOT "${PX4_BOARD}" MATCHES "io-v2" AND NOT "${PX4_BOARD_LABEL}" MATCHES "bootloader")
|
||||
list(APPEND SRCS
|
||||
px4_log.cpp
|
||||
)
|
||||
|
||||
@@ -84,10 +84,6 @@ public:
|
||||
*/
|
||||
inline T load() const
|
||||
{
|
||||
#ifdef __PX4_QURT
|
||||
return _value;
|
||||
#else
|
||||
|
||||
#if defined(__PX4_NUTTX)
|
||||
|
||||
if (!__atomic_always_lock_free(sizeof(T), 0)) {
|
||||
@@ -101,8 +97,6 @@ public:
|
||||
{
|
||||
return __atomic_load_n(&_value, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,10 +104,6 @@ public:
|
||||
*/
|
||||
inline void store(T value)
|
||||
{
|
||||
#ifdef __PX4_QURT
|
||||
_value = value;
|
||||
#else
|
||||
|
||||
#if defined(__PX4_NUTTX)
|
||||
|
||||
if (!__atomic_always_lock_free(sizeof(T), 0)) {
|
||||
@@ -126,8 +116,6 @@ public:
|
||||
{
|
||||
__atomic_store(&_value, &value, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,11 +124,6 @@ public:
|
||||
*/
|
||||
inline T fetch_add(T num)
|
||||
{
|
||||
#ifdef __PX4_QURT
|
||||
// TODO: fix
|
||||
return _value++;
|
||||
#else
|
||||
|
||||
#if defined(__PX4_NUTTX)
|
||||
|
||||
if (!__atomic_always_lock_free(sizeof(T), 0)) {
|
||||
@@ -154,8 +137,6 @@ public:
|
||||
{
|
||||
return __atomic_fetch_add(&_value, num, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,13 +282,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
#ifdef __PX4_QURT
|
||||
// It seems that __atomic_store and __atomic_load are not supported on Qurt,
|
||||
// so the best that we can do is to use volatile.
|
||||
volatile T _value{};
|
||||
#else
|
||||
T _value {};
|
||||
#endif
|
||||
};
|
||||
|
||||
using atomic_int = atomic<int>;
|
||||
|
||||
@@ -89,33 +89,14 @@ constexpr bool PX4_ISFINITE(double x) { return __builtin_isfinite(x); }
|
||||
#define USEC_PER_TICK (1000000/PX4_TICKS_PER_SEC)
|
||||
#define USEC2TICK(x) (((x)+(USEC_PER_TICK/2))/USEC_PER_TICK)
|
||||
|
||||
#ifdef __PX4_QURT
|
||||
|
||||
// QURT specific
|
||||
# include "dspal_math.h"
|
||||
# define PX4_ROOTFSDIR "."
|
||||
# define PX4_TICKS_PER_SEC 1000L
|
||||
|
||||
#else // __PX4_QURT
|
||||
|
||||
// All POSIX except QURT.
|
||||
|
||||
__BEGIN_DECLS
|
||||
extern long PX4_TICKS_PER_SEC;
|
||||
__END_DECLS
|
||||
|
||||
# if defined(__PX4_POSIX_EAGLE) || defined(__PX4_POSIX_EXCELSIOR)
|
||||
# define PX4_ROOTFSDIR "/home/linaro"
|
||||
# else
|
||||
# define PX4_ROOTFSDIR "."
|
||||
# endif
|
||||
|
||||
#endif // __PX4_QURT
|
||||
#define PX4_ROOTFSDIR "."
|
||||
|
||||
#define PX4_STORAGEDIR PX4_ROOTFSDIR
|
||||
#endif // __PX4_POSIX
|
||||
|
||||
#if defined(__PX4_POSIX)
|
||||
/****************************************************************************
|
||||
* Defines for POSIX and ROS
|
||||
****************************************************************************/
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015 Ramakrishna Kintada. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <parameters/param.h>
|
||||
|
||||
#define MAX_SHMEM_PARAMS 2000 //MAP_SIZE - (LOCK_SIZE - sizeof(struct shmem_info))
|
||||
|
||||
#define PARAM_BUFFER_SIZE (MAX_SHMEM_PARAMS / 8 + 1)
|
||||
|
||||
struct shmem_info {
|
||||
union param_value_u params_val[MAX_SHMEM_PARAMS];
|
||||
unsigned char krait_changed_index[MAX_SHMEM_PARAMS / 8 + 1]; /*bit map of all params changed by krait*/
|
||||
unsigned char adsp_changed_index[MAX_SHMEM_PARAMS / 8 + 1]; /*bit map of all params changed by adsp*/
|
||||
|
||||
#ifdef __PX4_NUTTX
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
#if (defined(__PX4_POSIX_EXCELSIOR) || defined(__PX4_QURT_EXCELSIOR))
|
||||
#define MAP_ADDRESS 0x861FC000
|
||||
#else
|
||||
#define MAP_ADDRESS 0xfbfc000
|
||||
#endif
|
||||
#define MAP_SIZE 16384
|
||||
#define MAP_MASK (MAP_SIZE - 1)
|
||||
|
||||
#define LOCK_OFFSET 0
|
||||
#define LOCK_SIZE 4
|
||||
#define LOCK_MEM 1
|
||||
#define UNLOCK_MEM 2
|
||||
|
||||
#define TYPE_MASK 0x1
|
||||
|
||||
extern bool handle_in_range(param_t);
|
||||
|
||||
#ifdef __PX4_QURT
|
||||
extern struct shmem_info *shmem_info_p;
|
||||
|
||||
int get_shmem_lock(const char *caller_file_name, int caller_line_number);
|
||||
void release_shmem_lock(const char *caller_file_name, int caller_line_number);
|
||||
void init_shared_memory(void);
|
||||
|
||||
void copy_params_to_shmem(const param_info_s *param_info_base);
|
||||
#endif
|
||||
|
||||
void update_to_shmem(param_t param, union param_value_u value);
|
||||
int update_from_shmem(param_t param, union param_value_u *value);
|
||||
void update_index_from_shmem(void);
|
||||
@@ -45,10 +45,6 @@
|
||||
#include <queue.h>
|
||||
#include <px4_platform_types.h>
|
||||
|
||||
#ifdef __PX4_QURT
|
||||
#include <dspal_types.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define HPWORK 0
|
||||
|
||||
@@ -49,7 +49,7 @@ WorkQueue::WorkQueue(const wq_config_t &config) :
|
||||
// set the threads name
|
||||
#ifdef __PX4_DARWIN
|
||||
pthread_setname_np(_config.name);
|
||||
#elif !defined(__PX4_QURT)
|
||||
#else
|
||||
pthread_setname_np(pthread_self(), _config.name);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,73 +25,46 @@ px4_posix_generate_alias(
|
||||
PREFIX ${PX4_SHELL_COMMAND_PREFIX}
|
||||
)
|
||||
|
||||
if (("${PX4_BOARD}" MATCHES "atlflight_eagle") OR ("${PX4_BOARD}" MATCHES "atlflight_excelsior"))
|
||||
include(fastrpc)
|
||||
include(linux_app)
|
||||
|
||||
FASTRPC_STUB_GEN(../qurt/px4muorb.idl)
|
||||
|
||||
LINUX_APP(
|
||||
APP_NAME px4
|
||||
IDL_NAME px4muorb
|
||||
APPS_DEST "/home/linaro"
|
||||
SOURCES
|
||||
px4muorb_stub.c
|
||||
src/px4/common/main.cpp
|
||||
apps.cpp
|
||||
LINK_LIBS
|
||||
-Wl,--start-group
|
||||
px4_layer
|
||||
parameters
|
||||
${module_libraries}
|
||||
${FASTRPC_ARM_LIBS}
|
||||
pthread m rt
|
||||
-Wl,--end-group
|
||||
)
|
||||
|
||||
else()
|
||||
add_executable(px4
|
||||
src/px4/common/main.cpp
|
||||
apps.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(px4
|
||||
PRIVATE
|
||||
${module_libraries}
|
||||
pthread m
|
||||
|
||||
# horrible circular dependencies that need to be teased apart
|
||||
px4_layer px4_platform
|
||||
work_queue
|
||||
parameters
|
||||
add_executable(px4
|
||||
src/px4/common/main.cpp
|
||||
apps.cpp
|
||||
)
|
||||
|
||||
if(NOT APPLE)
|
||||
target_link_libraries(px4 PRIVATE rt)
|
||||
endif()
|
||||
target_link_libraries(px4
|
||||
PRIVATE
|
||||
${module_libraries}
|
||||
pthread m
|
||||
|
||||
target_link_libraries(px4 PRIVATE uORB)
|
||||
|
||||
#=============================================================================
|
||||
# install
|
||||
#
|
||||
|
||||
# TODO: extend to snapdragon
|
||||
|
||||
# px4 dirs
|
||||
install(
|
||||
DIRECTORY
|
||||
${PROJECT_SOURCE_DIR}/posix-configs
|
||||
${PROJECT_SOURCE_DIR}/test
|
||||
${CMAKE_BINARY_DIR}/etc
|
||||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
DESTINATION
|
||||
${PROJECT_NAME}
|
||||
USE_SOURCE_PERMISSIONS
|
||||
)
|
||||
# horrible circular dependencies that need to be teased apart
|
||||
px4_layer px4_platform
|
||||
work_queue
|
||||
parameters
|
||||
)
|
||||
|
||||
if(NOT APPLE)
|
||||
target_link_libraries(px4 PRIVATE rt)
|
||||
endif()
|
||||
|
||||
target_link_libraries(px4 PRIVATE uORB)
|
||||
|
||||
#=============================================================================
|
||||
# install
|
||||
#
|
||||
|
||||
# TODO: extend to snapdragon
|
||||
|
||||
# px4 dirs
|
||||
install(
|
||||
DIRECTORY
|
||||
${PROJECT_SOURCE_DIR}/posix-configs
|
||||
${PROJECT_SOURCE_DIR}/test
|
||||
${CMAKE_BINARY_DIR}/etc
|
||||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
DESTINATION
|
||||
${PROJECT_NAME}
|
||||
USE_SOURCE_PERMISSIONS
|
||||
)
|
||||
|
||||
# Module Symlinks
|
||||
px4_posix_generate_symlinks(
|
||||
MODULE_LIST ${module_libraries}
|
||||
|
||||
@@ -36,17 +36,6 @@ add_subdirectory(px4_daemon)
|
||||
add_subdirectory(lockstep_scheduler)
|
||||
|
||||
set(EXTRA_DEPENDS)
|
||||
if("${CONFIG_SHMEM}" STREQUAL "1")
|
||||
list(APPEND CMAKE_MODULE_PATH "${PX4_SOURCE_DIR}/boards/atlflight/cmake_hexagon")
|
||||
include(hexagon_sdk)
|
||||
include_directories(${HEXAGON_SDK_INCLUDES})
|
||||
include_directories(${PX4_BINARY_DIR}/platforms/posix)
|
||||
list(APPEND SHMEM_SRCS
|
||||
shmem_posix.cpp
|
||||
)
|
||||
add_definitions(-DCONFIG_SHMEM=1)
|
||||
set(EXTRA_DEPENDS generate_px4muorb_stubs)
|
||||
endif()
|
||||
|
||||
add_library(px4_layer
|
||||
px4_posix_impl.cpp
|
||||
@@ -57,7 +46,6 @@ add_library(px4_layer
|
||||
drv_hrt.cpp
|
||||
cpuload.cpp
|
||||
print_load.cpp
|
||||
${SHMEM_SRCS}
|
||||
)
|
||||
target_compile_definitions(px4_layer PRIVATE MODULE_NAME="px4")
|
||||
target_compile_options(px4_layer PRIVATE -Wno-cast-align) # TODO: fix and enable
|
||||
|
||||
@@ -317,15 +317,6 @@ int main(int argc, char **argv)
|
||||
pxh.run_pxh();
|
||||
}
|
||||
|
||||
// When we exit, we need to stop muorb on Snapdragon.
|
||||
|
||||
#ifdef __PX4_POSIX_EAGLE
|
||||
// Sending muorb stop is needed if it is running to exit cleanly.
|
||||
// TODO: we should check with px4_task_is_running("muorb") before stopping it.
|
||||
std::string muorb_stop_cmd("muorb stop");
|
||||
px4_daemon::Pxh::process_line(muorb_stop_cmd, true);
|
||||
#endif
|
||||
|
||||
std::string cmd("shutdown");
|
||||
px4_daemon::Pxh::process_line(cmd, true);
|
||||
|
||||
@@ -451,10 +442,7 @@ void sig_int_handler(int sig_num)
|
||||
|
||||
void set_cpu_scaling()
|
||||
{
|
||||
#ifdef __PX4_POSIX_EAGLE
|
||||
// On Snapdragon we miss updates in sdlog2 unless all 4 CPUs are run
|
||||
// at the maximum frequency all the time.
|
||||
// Interestingely, cpu0 and cpu3 set the scaling for all 4 CPUs on Snapdragon.
|
||||
#if 0
|
||||
system("echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor");
|
||||
system("echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor");
|
||||
|
||||
|
||||
@@ -73,19 +73,6 @@ FILE *get_stdout(bool *isatty_)
|
||||
return stdout;
|
||||
}
|
||||
|
||||
#ifdef __PX4_POSIX_EAGLE
|
||||
|
||||
// XXX FIXME: thread_data_ptr is set to 0x1 in the main thread on Snapdragon
|
||||
// even though the pthread_key has been created.
|
||||
// We can catch this using the check below but we have no clue why this happens.
|
||||
if (thread_data_ptr == (void *)0x1) {
|
||||
if (isatty_) { *isatty_ = isatty(1); }
|
||||
|
||||
return stdout;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (thread_data_ptr->thread_stdout == nullptr) {
|
||||
if (isatty_) { *isatty_ = isatty(1); }
|
||||
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015 Vijay Venkatraman. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <errno.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <parameters/param.h>
|
||||
|
||||
#include <px4_platform_common/shmem.h>
|
||||
#include "px4muorb.h"
|
||||
|
||||
//#define SHMEM_DEBUG
|
||||
|
||||
static uint64_t update_from_shmem_prev_time = 0, update_from_shmem_current_time = 0;
|
||||
extern unsigned char *adsp_changed_index;
|
||||
|
||||
struct param_wbuf_s {
|
||||
union param_value_u val;
|
||||
param_t param;
|
||||
bool unsaved;
|
||||
};
|
||||
|
||||
/*update value and param's change bit in shared memory*/
|
||||
void update_to_shmem(param_t param, union param_value_u value)
|
||||
{
|
||||
if (px4muorb_param_update_to_shmem(param, (unsigned char *) &value, sizeof(value))) {
|
||||
PX4_ERR("krait update param %u failed", param);
|
||||
}
|
||||
}
|
||||
|
||||
void update_index_from_shmem(void)
|
||||
{
|
||||
if (!adsp_changed_index) {
|
||||
PX4_ERR("%s no param buffer", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
px4muorb_param_update_index_from_shmem(adsp_changed_index, PARAM_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
static void update_value_from_shmem(param_t param, union param_value_u *value)
|
||||
{
|
||||
if (px4muorb_param_update_value_from_shmem(param, (unsigned char *) value, sizeof(union param_value_u))) {
|
||||
PX4_ERR("%s get param failed", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
int update_from_shmem(param_t param, union param_value_u *value)
|
||||
{
|
||||
unsigned int byte_changed, bit_changed;
|
||||
unsigned int retval = 0;
|
||||
|
||||
if (!adsp_changed_index) {
|
||||
PX4_ERR("%s no param buffer", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
update_from_shmem_current_time = hrt_absolute_time();
|
||||
|
||||
if ((update_from_shmem_current_time - update_from_shmem_prev_time)
|
||||
> 1000000) { //update every 1 second
|
||||
update_from_shmem_prev_time = update_from_shmem_current_time;
|
||||
update_index_from_shmem();
|
||||
}
|
||||
|
||||
byte_changed = param / 8;
|
||||
bit_changed = 1 << param % 8;
|
||||
|
||||
if (adsp_changed_index[byte_changed] & bit_changed) {
|
||||
update_value_from_shmem(param, value);
|
||||
adsp_changed_index[byte_changed] &= ~bit_changed; //clear the bit
|
||||
retval = 1;
|
||||
}
|
||||
|
||||
//else {PX4_INFO("no change to param %s", param_name(param));}
|
||||
|
||||
PX4_DEBUG("%s %d bit on adsp index[%d]",
|
||||
(retval) ? "cleared" : "unchanged", bit_changed, byte_changed);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
|
||||
px4_add_git_submodule(TARGET git_dspal PATH "${PX4_SOURCE_DIR}/platforms/qurt/dspal")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PX4_SOURCE_DIR}/platforms/qurt/dspal/cmake_hexagon")
|
||||
include(toolchain/Toolchain-qurt)
|
||||
include(fastrpc)
|
||||
include(qurt_lib)
|
||||
include(qurt_flags)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES)
|
||||
|
||||
px4_qurt_generate_builtin_commands(
|
||||
OUT ${PX4_BINARY_DIR}/apps
|
||||
MODULE_LIST ${module_libraries}
|
||||
)
|
||||
|
||||
FASTRPC_STUB_GEN(px4muorb.idl)
|
||||
|
||||
add_definitions(-D__QAIC_SKEL_EXPORT=__EXPORT)
|
||||
|
||||
# Enable build without HexagonSDK to check link dependencies
|
||||
if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
|
||||
|
||||
add_definitions(-D QURT_EXE_BUILD=1)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${FASTRPC_DSP_INCLUDES}
|
||||
)
|
||||
|
||||
add_executable(px4
|
||||
${PX4_BINARY_DIR}/apps.cpp
|
||||
${PX4_BINARY_DIR}/platforms/qurt/px4muorb_skel.c
|
||||
)
|
||||
|
||||
target_link_libraries(px4 PRIVATE ${module_libraries})
|
||||
|
||||
else()
|
||||
# Generate the DSP lib and stubs but not the apps side executable
|
||||
# The Apps side executable is generated via the posix_eagle_xxxx target
|
||||
QURT_LIB(LIB_NAME px4
|
||||
IDL_NAME px4muorb
|
||||
SOURCES
|
||||
${PX4_BINARY_DIR}/apps.cpp
|
||||
LINK_LIBS
|
||||
modules__muorb__adsp
|
||||
${module_libraries}
|
||||
m
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
# board defined upload helper
|
||||
if(EXISTS "${PX4_BOARD_DIR}/cmake/upload.cmake")
|
||||
include(${PX4_BOARD_DIR}/cmake/upload.cmake)
|
||||
endif()
|
||||
@@ -1,188 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2015 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# Defined functions in this file
|
||||
#
|
||||
# OS Specific Functions
|
||||
#
|
||||
# * px4_qurt_add_firmware
|
||||
# * px4_qurt_generate_builtin_commands
|
||||
# * px4_qurt_add_export
|
||||
# * px4_qurt_generate_romfs
|
||||
#
|
||||
# Required OS Inteface Functions
|
||||
#
|
||||
# * px4_os_add_flags
|
||||
# * px4_os_determine_build_chip
|
||||
# * px4_os_prebuild_targets
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# px4_qurt_generate_builtin_commands
|
||||
#
|
||||
# This function generates the builtin_commands.c src for qurt
|
||||
#
|
||||
# Usage:
|
||||
# px4_qurt_generate_builtin_commands(
|
||||
# MODULE_LIST <in-list>
|
||||
# OUT <file>)
|
||||
#
|
||||
# Input:
|
||||
# MODULE_LIST : list of modules
|
||||
#
|
||||
# Output:
|
||||
# OUT : stem of generated apps.cpp/apps.h ("apps").
|
||||
#
|
||||
# Example:
|
||||
# px4_qurt_generate_builtin_commands(
|
||||
# OUT <generated-src> MODULE_LIST px4_simple_app)
|
||||
#
|
||||
function(px4_qurt_generate_builtin_commands)
|
||||
px4_parse_function_args(
|
||||
NAME px4_qurt_generate_builtin_commands
|
||||
ONE_VALUE OUT
|
||||
MULTI_VALUE MODULE_LIST
|
||||
REQUIRED MODULE_LIST OUT
|
||||
ARGN ${ARGN})
|
||||
|
||||
set(builtin_apps_string)
|
||||
set(builtin_apps_decl_string)
|
||||
set(command_count 0)
|
||||
foreach(module ${MODULE_LIST})
|
||||
foreach(property MAIN STACK_MAIN PRIORITY)
|
||||
get_target_property(${property} ${module} ${property})
|
||||
endforeach()
|
||||
if (MAIN)
|
||||
set(builtin_apps_string
|
||||
"${builtin_apps_string}\tapps[\"${MAIN}\"] = ${MAIN}_main;\n")
|
||||
set(builtin_apps_decl_string
|
||||
"${builtin_apps_decl_string}int ${MAIN}_main(int argc, char *argv[]);\n")
|
||||
math(EXPR command_count "${command_count}+1")
|
||||
endif()
|
||||
endforeach()
|
||||
configure_file(${PX4_SOURCE_DIR}/platforms/common/apps.cpp.in ${OUT}.cpp)
|
||||
configure_file(${PX4_SOURCE_DIR}/platforms/common/apps.h.in ${OUT}.h)
|
||||
endfunction()
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# px4_os_add_flags
|
||||
#
|
||||
# Set the qurt build flags.
|
||||
#
|
||||
# Usage:
|
||||
# px4_os_add_flags()
|
||||
#
|
||||
function(px4_os_add_flags)
|
||||
|
||||
set(DSPAL_ROOT platforms/qurt/dspal)
|
||||
include_directories(
|
||||
${DSPAL_ROOT}/include
|
||||
${DSPAL_ROOT}/sys
|
||||
${DSPAL_ROOT}/sys/sys
|
||||
|
||||
platforms/posix/include
|
||||
platforms/qurt/include
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-D__PX4_POSIX
|
||||
-D__PX4_QURT
|
||||
)
|
||||
|
||||
add_compile_options(
|
||||
-fPIC
|
||||
-fmath-errno
|
||||
|
||||
-Wno-unknown-warning-option
|
||||
-Wno-cast-align
|
||||
)
|
||||
|
||||
# Clear -rdynamic flag which fails for hexagon
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
|
||||
|
||||
endfunction()
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# px4_os_determine_build_chip
|
||||
#
|
||||
# Sets PX4_CHIP and PX4_CHIP_MANUFACTURER.
|
||||
#
|
||||
# Usage:
|
||||
# px4_os_determine_build_chip()
|
||||
#
|
||||
function(px4_os_determine_build_chip)
|
||||
|
||||
# always use generic chip and chip manufacturer
|
||||
set(PX4_CHIP "generic" CACHE STRING "PX4 Chip" FORCE)
|
||||
set(PX4_CHIP_MANUFACTURER "generic" CACHE STRING "PX4 Chip Manufacturer" FORCE)
|
||||
|
||||
endfunction()
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# px4_os_prebuild_targets
|
||||
#
|
||||
# This function generates os dependent targets
|
||||
#
|
||||
# Usage:
|
||||
# px4_os_prebuild_targets(
|
||||
# OUT <out-list_of_targets>
|
||||
# BOARD <in-string>
|
||||
# )
|
||||
#
|
||||
# Input:
|
||||
# BOARD : board
|
||||
#
|
||||
# Output:
|
||||
# OUT : the target list
|
||||
#
|
||||
# Example:
|
||||
# px4_os_prebuild_targets(OUT target_list BOARD px4_fmu-v2)
|
||||
#
|
||||
function(px4_os_prebuild_targets)
|
||||
px4_parse_function_args(
|
||||
NAME px4_os_prebuild_targets
|
||||
ONE_VALUE OUT BOARD
|
||||
REQUIRED OUT
|
||||
ARGN ${ARGN})
|
||||
|
||||
add_library(prebuild_targets INTERFACE)
|
||||
add_dependencies(prebuild_targets DEPENDS uorb_headers)
|
||||
|
||||
endfunction()
|
||||
Submodule platforms/qurt/dspal deleted from 0322a4e345
@@ -1,83 +0,0 @@
|
||||
/****************************************************************************
|
||||
* include/crc.h
|
||||
*
|
||||
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_CRC32_H
|
||||
#define __INCLUDE_CRC32_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: crc32part
|
||||
*
|
||||
* Description:
|
||||
* Continue CRC calculation on a part of the buffer.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN uint32_t crc32part(const uint8_t *src, size_t len,
|
||||
uint32_t crc32val);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: crc32
|
||||
*
|
||||
* Description:
|
||||
* Return a 32-bit CRC of the contents of the 'src' buffer, length 'len'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN uint32_t crc32(const uint8_t *src, size_t len);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_CRC32_H */
|
||||
@@ -1,65 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <semaphore.h>
|
||||
#include <px4_platform_common/workqueue.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern sem_t _hrt_work_lock;
|
||||
extern struct wqueue_s g_hrt_work;
|
||||
|
||||
void hrt_work_queue_init(void);
|
||||
int hrt_work_queue(struct work_s *work, worker_t worker, void *arg, uint32_t usdelay);
|
||||
void hrt_work_cancel(struct work_s *work);
|
||||
|
||||
static inline void hrt_work_lock(void);
|
||||
static inline void hrt_work_unlock(void);
|
||||
|
||||
static inline void hrt_work_lock()
|
||||
{
|
||||
//PX4_INFO("hrt_work_lock");
|
||||
sem_wait(&_hrt_work_lock);
|
||||
}
|
||||
|
||||
static inline void hrt_work_unlock()
|
||||
{
|
||||
//PX4_INFO("hrt_work_unlock");
|
||||
sem_post(&_hrt_work_lock);
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
/************************************************************************
|
||||
* include/queue.h
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_QUEUE_H
|
||||
#define __INCLUDE_QUEUE_H
|
||||
|
||||
/************************************************************************
|
||||
* Included Files
|
||||
************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef> // NULL
|
||||
#else
|
||||
#include <stddef.h> // NULL
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************/
|
||||
|
||||
#define sq_init(q) do { (q)->head = NULL; (q)->tail = NULL; } while (0)
|
||||
#define dq_init(q) do { (q)->head = NULL; (q)->tail = NULL; } while (0)
|
||||
|
||||
#define sq_next(p) ((p)->flink)
|
||||
#define dq_next(p) ((p)->flink)
|
||||
#define dq_prev(p) ((p)->blink)
|
||||
|
||||
#define sq_empty(q) ((q)->head == NULL)
|
||||
#define dq_empty(q) ((q)->head == NULL)
|
||||
|
||||
#define sq_peek(q) ((q)->head)
|
||||
#define dq_peek(q) ((q)->head)
|
||||
|
||||
// Required for Linux
|
||||
#define FAR
|
||||
|
||||
/************************************************************************
|
||||
* Global Type Declarations
|
||||
************************************************************************/
|
||||
|
||||
struct sq_entry_s {
|
||||
FAR struct sq_entry_s *flink;
|
||||
};
|
||||
typedef struct sq_entry_s sq_entry_t;
|
||||
|
||||
struct dq_entry_s {
|
||||
FAR struct dq_entry_s *flink;
|
||||
FAR struct dq_entry_s *blink;
|
||||
};
|
||||
typedef struct dq_entry_s dq_entry_t;
|
||||
|
||||
struct sq_queue_s {
|
||||
FAR sq_entry_t *head;
|
||||
FAR sq_entry_t *tail;
|
||||
};
|
||||
typedef struct sq_queue_s sq_queue_t;
|
||||
|
||||
struct dq_queue_s {
|
||||
FAR dq_entry_t *head;
|
||||
FAR dq_entry_t *tail;
|
||||
};
|
||||
typedef struct dq_queue_s dq_queue_t;
|
||||
|
||||
/************************************************************************
|
||||
* Global Function Prototypes
|
||||
************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN void sq_addfirst(FAR sq_entry_t *node, sq_queue_t *queue);
|
||||
EXTERN void dq_addfirst(FAR dq_entry_t *node, dq_queue_t *queue);
|
||||
EXTERN void sq_addlast(FAR sq_entry_t *node, sq_queue_t *queue);
|
||||
EXTERN void dq_addlast(FAR dq_entry_t *node, dq_queue_t *queue);
|
||||
EXTERN void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node,
|
||||
sq_queue_t *queue);
|
||||
EXTERN void dq_addafter(FAR dq_entry_t *prev, FAR dq_entry_t *node,
|
||||
dq_queue_t *queue);
|
||||
EXTERN void dq_addbefore(FAR dq_entry_t *next, FAR dq_entry_t *node,
|
||||
dq_queue_t *queue);
|
||||
|
||||
EXTERN FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue);
|
||||
EXTERN void sq_rem(FAR sq_entry_t *node, sq_queue_t *queue);
|
||||
EXTERN void dq_rem(FAR dq_entry_t *node, dq_queue_t *queue);
|
||||
EXTERN FAR sq_entry_t *sq_remlast(sq_queue_t *queue);
|
||||
EXTERN FAR dq_entry_t *dq_remlast(dq_queue_t *queue);
|
||||
EXTERN FAR sq_entry_t *sq_remfirst(sq_queue_t *queue);
|
||||
EXTERN FAR dq_entry_t *dq_remfirst(dq_queue_t *queue);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_QUEUE_H_ */
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
__EXPORT extern uint64_t hrt_absolute_time(void);
|
||||
|
||||
//void qurt_log(int level, const char *file, int line, const char *format, ...);
|
||||
|
||||
// declaration to make the compiler happy. This symbol is part of the adsp static image.
|
||||
void HAP_debug(const char *msg, int level, const char *filename, int line);
|
||||
|
||||
#ifndef qurt_log_defined
|
||||
#define qurt_log_defined
|
||||
static __inline void qurt_log(int level, const char *file, int line,
|
||||
const char *format, ...)
|
||||
{
|
||||
char buf[256];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vsnprintf(buf, sizeof(buf), format, args);
|
||||
va_end(args);
|
||||
HAP_debug(buf, level, file, line);
|
||||
}
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
@@ -1,184 +0,0 @@
|
||||
//=======================================================================
|
||||
// Copyright (c) 2016, Mark Charlebois. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
// * Neither the name of The Linux Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//=========================================================================
|
||||
|
||||
#include "AEEStdDef.idl"
|
||||
|
||||
interface px4muorb{
|
||||
|
||||
/**
|
||||
* interface method to start the uorb service and initialize the muorb
|
||||
*/
|
||||
AEEResult orb_initialize();
|
||||
|
||||
/**
|
||||
* Interface to set an offset to hrt_absolute_time on the DSP.
|
||||
*
|
||||
* @param time_diff_us: time difference of the DSP clock to Linux clock.
|
||||
* A positive number means the Linux clock is ahead of the DSP one.
|
||||
*/
|
||||
AEEResult set_absolute_time_offset( in long time_diff_us );
|
||||
|
||||
/**
|
||||
* Interface to request hrt_absolute_time on the DSP.
|
||||
* @param time_us: pointer to time in us
|
||||
*/
|
||||
AEEResult get_absolute_time(rout unsigned long long time_us);
|
||||
|
||||
/**
|
||||
* Interface to update param for krait.
|
||||
*
|
||||
* @param param: param index.
|
||||
* @param value: param value.
|
||||
*/
|
||||
AEEResult param_update_to_shmem( in unsigned long param, in sequence<octet> value);
|
||||
|
||||
/**
|
||||
* Interface to update index for krait.
|
||||
* @param data: param index array.
|
||||
*/
|
||||
AEEResult param_update_index_from_shmem( rout sequence<octet> data);
|
||||
|
||||
/**
|
||||
* Interface to get param value for krait.
|
||||
*
|
||||
* @param param: param index.
|
||||
* @param value: param value.
|
||||
*/
|
||||
AEEResult param_update_value_from_shmem( in unsigned long param, rout sequence<octet> value);
|
||||
|
||||
/**
|
||||
* Interface called from krait to inform of a published topic.
|
||||
* @param topic_name: name of the topic being advertised
|
||||
*/
|
||||
AEEResult topic_advertised(in string topic_name);
|
||||
|
||||
/**
|
||||
* Interface called from krait to inform of a published topic.
|
||||
* @param topic_name: name of the topic being advertised
|
||||
*/
|
||||
AEEResult topic_unadvertised(in string topic_name);
|
||||
|
||||
/**
|
||||
* Interface to add a subscriber to the identified topic
|
||||
* @param topic_name
|
||||
* @return status
|
||||
* 0 == success
|
||||
* all others is a failure.
|
||||
*/
|
||||
AEEResult add_subscriber( in string topic_name );
|
||||
|
||||
/**
|
||||
* Interface to remove a subscriber for the identified topic.
|
||||
* @param topic_name
|
||||
* @return status
|
||||
* 0 == success
|
||||
* all others is a failure.
|
||||
*/
|
||||
AEEResult remove_subscriber( in string topic_name );
|
||||
|
||||
/**
|
||||
* Interface called from krait for topic data.
|
||||
* @param topic_name
|
||||
* @param data
|
||||
* a sequence of bytes for the passed data stream.
|
||||
* as per the HExagon Documention, the max size of this stream is 255 bytes.
|
||||
* @return status
|
||||
* 0 == success
|
||||
* all others is a failure.
|
||||
*/
|
||||
AEEResult send_topic_data( in string topic_name, in sequence<octet> data );
|
||||
|
||||
/**
|
||||
* Inteface to check if there are subscribers on the remote adsp client
|
||||
* This inteface is required as the krait app can be restarted without adsp
|
||||
* being re-started. In this scenario the krait app does not know if there
|
||||
* is subscriber on the remote end(ie adsp).
|
||||
* @param topic_name
|
||||
* The name of the topic for which the subscription needs to be checked.
|
||||
* @param rout int status
|
||||
* The status of the subscription, 0=no-subscribers, 1 = more than one subscriber.
|
||||
* @return status
|
||||
* 0 == success
|
||||
* all others is a failure.
|
||||
*/
|
||||
AEEResult is_subscriber_present( in string topic_name, rout long status );
|
||||
|
||||
/**
|
||||
* Interface to receive data from adsp. Since there is only one interface, the different message
|
||||
* types are identified by the msg_type field.
|
||||
* @param msg_type
|
||||
* The possible values are:
|
||||
* 1 ==> add_subscriber
|
||||
* 2 ==> remove_subscriber
|
||||
* 3 ==> recieve_topic_data
|
||||
* 4 ==> advertised_topic
|
||||
* @note: for message types, 1 & 2, the data pointer returned is null with length of 0.
|
||||
* @param topic_name
|
||||
* The topic being returned.
|
||||
* @param data
|
||||
* the data stream
|
||||
* @param bytes_returned
|
||||
* The number of bytes returned in the byte buffer.
|
||||
* @return status
|
||||
* 0 == success
|
||||
* all others is a failure.
|
||||
*/
|
||||
AEEResult receive_msg( rout long msg_type, rout string topic_name, rout sequence<octet> data, rout long bytes_returned );
|
||||
|
||||
/**
|
||||
* Since the receive_msg is a blocking call, the client will not be able to peform a clean shutdown. Calling this
|
||||
* function will unblock the receive msg an return an error code.
|
||||
* Ideally this should be implemented as a timeout for the #receive_msg call.
|
||||
* @param none
|
||||
* @return status
|
||||
* 0 = success
|
||||
* all others is a failure.
|
||||
**/
|
||||
AEEResult unblock_recieve_msg();
|
||||
|
||||
/**
|
||||
* This interface will perform a bulk read from the adsp and return the data buffer.
|
||||
* The structure of the messages is as follows
|
||||
* +----------------+-----------+---------------+----------+----------------+
|
||||
* | Topic Name Len | datal_len |TopicName(nullterminated) | data bytes |
|
||||
* +----------------+-----------+---------------+----------+----------------+
|
||||
* |<-- 2 bytes -->|<-2bytes-> |<-- topicnamelen bytes -->|<-datalenbytes->|
|
||||
* +----------------+---------------------------+----------+----------------+
|
||||
* @param data
|
||||
* The output buffer where the data needs to be copied
|
||||
* @param bytes_returned
|
||||
* The number of bytes the buffer is filled up by.
|
||||
* @param topic_count
|
||||
* The numbe of topics filled in the buffer.
|
||||
* @return status
|
||||
* 0 = success
|
||||
* all others is a failure.
|
||||
**/
|
||||
AEEResult receive_bulk_data( rout sequence<octet> data, rout long bytes_returned, rout long topic_count );
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
add_subdirectory(common)
|
||||
|
||||
add_subdirectory(${PX4_CHIP_MANUFACTURER})
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2015 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PX4_SOURCE_DIR}/boards/atlflight/cmake_hexagon")
|
||||
include(hexagon_sdk)
|
||||
|
||||
include_directories(${HEXAGON_8074_INCLUDES})
|
||||
|
||||
set(QURT_LAYER_SRCS
|
||||
px4_qurt_impl.cpp
|
||||
tasks.cpp
|
||||
lib_crc32.c
|
||||
drv_hrt.cpp
|
||||
qurt_stubs.c
|
||||
main.cpp
|
||||
shmem_qurt.cpp
|
||||
px4_init.cpp
|
||||
)
|
||||
|
||||
if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
|
||||
list(APPEND QURT_LAYER_SRCS
|
||||
stubs/posix.c
|
||||
stubs/qurt.c
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(px4_layer
|
||||
${QURT_LAYER_SRCS}
|
||||
${CONFIG_SRC}
|
||||
)
|
||||
target_link_libraries(px4_layer PRIVATE work_queue)
|
||||
add_dependencies(px4_layer uorb_msgs) # dataman requires mission
|
||||
@@ -1,107 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
/**
|
||||
* @file commands_muorb_test.c
|
||||
* Commands to run for the "qurt_muorb_test" config
|
||||
*
|
||||
* @author Mark Charlebois <charlebm@gmail.com>
|
||||
*/
|
||||
|
||||
const char *get_commands(void);
|
||||
const char *get_commands()
|
||||
{
|
||||
|
||||
static const char *commands =
|
||||
"param set CAL_GYRO0_ID 2293760\n"
|
||||
"param set CAL_ACC0_ID 1310720\n"
|
||||
"param set CAL_ACC1_ID 1376256\n"
|
||||
"param set CAL_MAG0_ID 196608\n"
|
||||
// "rgbled start\n"
|
||||
// "tone_alarm start\n"
|
||||
"rc_update start\n"
|
||||
"commander start --hil\n"
|
||||
"sensors start\n"
|
||||
"ekf2 start\n"
|
||||
"mc_hover_thrust_estimator start\n"
|
||||
"flight_mode_manager start\n"
|
||||
"mc_pos_control start\n"
|
||||
"mc_att_control start\n"
|
||||
"mc_rate_control start\n"
|
||||
"sleep 1\n"
|
||||
"pwm_out_sim start\n"
|
||||
"param set RC1_MAX 2015\n"
|
||||
"param set RC1_MIN 996\n"
|
||||
"param set RC1_TRIM 1502\n"
|
||||
"param set RC1_REV -1\n"
|
||||
"param set RC2_MAX 2016 \n"
|
||||
"param set RC2_MIN 995\n"
|
||||
"param set RC2_TRIM 1500\n"
|
||||
"param set RC3_MAX 2003\n"
|
||||
"param set RC3_MIN 992\n"
|
||||
"param set RC3_TRIM 992\n"
|
||||
"param set RC4_MAX 2011\n"
|
||||
"param set RC4_MIN 997\n"
|
||||
"param set RC4_TRIM 1504\n"
|
||||
"param set RC4_REV -1\n"
|
||||
"param set RC6_MAX 2016\n"
|
||||
"param set RC6_MIN 992\n"
|
||||
"param set RC6_TRIM 1504\n"
|
||||
"param set RC_CHAN_CNT 8\n"
|
||||
"param set RC_MAP_MODE_SW 5\n"
|
||||
"param set RC_MAP_POSCTL_SW 7\n"
|
||||
"param set RC_MAP_RETURN_SW 8\n"
|
||||
"param set MC_YAW_P 1.5\n"
|
||||
"param set MC_PITCH_P 3.0\n"
|
||||
"param set MC_ROLL_P 3.0\n"
|
||||
"param set MC_YAWRATE_P 0.2\n"
|
||||
"param set MC_PITCHRATE_P 0.03\n"
|
||||
"param set MC_ROLLRATE_P 0.03\n"
|
||||
"param set ATT_W_ACC 0.0002\n"
|
||||
"param set ATT_W_MAG 0.002\n"
|
||||
"param set ATT_W_GYRO_BIAS 0.05\n"
|
||||
"sleep 1\n"
|
||||
|
||||
|
||||
"param set MAV_TYPE 2\n"
|
||||
"mixer load /dev/pwm_output0 /startup/quad_x.main.mix\n"
|
||||
"list_files\n"
|
||||
"list_tasks\n"
|
||||
"sleep 10\n"
|
||||
"list_tasks\n"
|
||||
"sleep 10\n"
|
||||
|
||||
;
|
||||
|
||||
return commands;
|
||||
|
||||
}
|
||||
@@ -1,477 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 - 2018 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file drv_hrt.cpp
|
||||
*
|
||||
* High-resolution timer with callouts and timekeeping.
|
||||
*/
|
||||
|
||||
#include <px4_platform_common/time.h>
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <px4_platform_common/workqueue.h>
|
||||
#include <px4_platform_common/tasks.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "hrt_work.h"
|
||||
|
||||
// Intervals in usec
|
||||
static constexpr unsigned HRT_INTERVAL_MIN = 50;
|
||||
static constexpr unsigned HRT_INTERVAL_MAX = 50000000;
|
||||
|
||||
/*
|
||||
* Queue of callout entries.
|
||||
*/
|
||||
static struct sq_queue_s callout_queue;
|
||||
|
||||
/* latency baseline (last compare value applied) */
|
||||
static uint64_t latency_baseline;
|
||||
|
||||
/* timer count at interrupt (for latency purposes) */
|
||||
static uint64_t latency_actual;
|
||||
|
||||
/* latency histogram */
|
||||
const uint16_t latency_bucket_count = LATENCY_BUCKET_COUNT;
|
||||
const uint16_t latency_buckets[LATENCY_BUCKET_COUNT] = { 1, 2, 5, 10, 20, 50, 100, 1000 };
|
||||
__EXPORT uint32_t latency_counters[LATENCY_BUCKET_COUNT + 1];
|
||||
|
||||
static px4_sem_t _hrt_lock;
|
||||
static struct work_s _hrt_work;
|
||||
|
||||
static int32_t dsp_offset = 0;
|
||||
|
||||
static void hrt_latency_update();
|
||||
|
||||
static void hrt_call_reschedule();
|
||||
static void hrt_call_invoke();
|
||||
|
||||
hrt_abstime hrt_absolute_time_offset()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hrt_lock()
|
||||
{
|
||||
px4_sem_wait(&_hrt_lock);
|
||||
}
|
||||
|
||||
static void hrt_unlock()
|
||||
{
|
||||
px4_sem_post(&_hrt_lock);
|
||||
}
|
||||
|
||||
#include "dspal_time.h"
|
||||
|
||||
int px4_clock_settime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
/* do nothing right now */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
return clock_gettime(clk_id, tp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get absolute time.
|
||||
*/
|
||||
hrt_abstime hrt_absolute_time()
|
||||
{
|
||||
struct timespec ts;
|
||||
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return ts_to_abstime(&ts) + dsp_offset;
|
||||
}
|
||||
|
||||
int hrt_set_absolute_time_offset(int32_t time_diff_us)
|
||||
{
|
||||
dsp_offset = time_diff_us;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a timespec to absolute time.
|
||||
*/
|
||||
hrt_abstime ts_to_abstime(const struct timespec *ts)
|
||||
{
|
||||
hrt_abstime result;
|
||||
|
||||
result = (hrt_abstime)(ts->tv_sec) * 1000000;
|
||||
result += ts->tv_nsec / 1000;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the delta between a timestamp taken in the past
|
||||
* and now.
|
||||
*
|
||||
* This function is safe to use even if the timestamp is updated
|
||||
* by an interrupt during execution.
|
||||
*/
|
||||
hrt_abstime hrt_elapsed_time_atomic(const volatile hrt_abstime *then)
|
||||
{
|
||||
// This is not atomic as the value on the application layer of POSIX is limited.
|
||||
hrt_abstime delta = hrt_absolute_time() - *then;
|
||||
return delta;
|
||||
}
|
||||
|
||||
/*
|
||||
* Store the absolute time in an interrupt-safe fashion.
|
||||
*
|
||||
* This function ensures that the timestamp cannot be seen half-written by an interrupt handler.
|
||||
*/
|
||||
void hrt_store_absolute_time(volatile hrt_abstime *t)
|
||||
{
|
||||
*t = hrt_absolute_time();
|
||||
}
|
||||
|
||||
/*
|
||||
* If this returns true, the entry has been invoked and removed from the callout list,
|
||||
* or it has never been entered.
|
||||
*
|
||||
* Always returns false for repeating callouts.
|
||||
*/
|
||||
bool hrt_called(struct hrt_call *entry)
|
||||
{
|
||||
return (entry->deadline == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the entry from the callout list.
|
||||
*/
|
||||
void hrt_cancel(struct hrt_call *entry)
|
||||
{
|
||||
hrt_lock();
|
||||
sq_rem(&entry->link, &callout_queue);
|
||||
entry->deadline = 0;
|
||||
|
||||
/* if this is a periodic call being removed by the callout, prevent it from
|
||||
* being re-entered when the callout returns.
|
||||
*/
|
||||
entry->period = 0;
|
||||
hrt_unlock();
|
||||
// endif
|
||||
}
|
||||
|
||||
static void hrt_latency_update()
|
||||
{
|
||||
uint16_t latency = latency_actual - latency_baseline;
|
||||
unsigned index;
|
||||
|
||||
/* bounded buckets */
|
||||
for (index = 0; index < LATENCY_BUCKET_COUNT; index++) {
|
||||
if (latency <= latency_buckets[index]) {
|
||||
latency_counters[index]++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* catch-all at the end */
|
||||
latency_counters[index]++;
|
||||
}
|
||||
|
||||
/*
|
||||
* initialise a hrt_call structure
|
||||
*/
|
||||
void hrt_call_init(struct hrt_call *entry)
|
||||
{
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
}
|
||||
|
||||
/*
|
||||
* delay a hrt_call_every() periodic call by the given number of
|
||||
* microseconds. This should be called from within the callout to
|
||||
* cause the callout to be re-scheduled for a later time. The periodic
|
||||
* callouts will then continue from that new base time at the
|
||||
* previously specified period.
|
||||
*/
|
||||
void hrt_call_delay(struct hrt_call *entry, hrt_abstime delay)
|
||||
{
|
||||
entry->deadline = hrt_absolute_time() + delay;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the HRT.
|
||||
*/
|
||||
void hrt_init()
|
||||
{
|
||||
sq_init(&callout_queue);
|
||||
|
||||
int sem_ret = px4_sem_init(&_hrt_lock, 0, 1);
|
||||
|
||||
if (sem_ret) {
|
||||
PX4_ERR("SEM INIT FAIL: %s", strerror(errno));
|
||||
}
|
||||
|
||||
memset(&_hrt_work, 0, sizeof(_hrt_work));
|
||||
}
|
||||
|
||||
static void
|
||||
hrt_call_enter(struct hrt_call *entry)
|
||||
{
|
||||
struct hrt_call *call, *next;
|
||||
|
||||
call = (struct hrt_call *)sq_peek(&callout_queue);
|
||||
|
||||
if ((call == nullptr) || (entry->deadline < call->deadline)) {
|
||||
sq_addfirst(&entry->link, &callout_queue);
|
||||
//if (call != nullptr) PX4_INFO("call enter at head, reschedule (%lu %lu)", entry->deadline, call->deadline);
|
||||
/* we changed the next deadline, reschedule the timer event */
|
||||
hrt_call_reschedule();
|
||||
|
||||
} else {
|
||||
do {
|
||||
next = (struct hrt_call *)sq_next(&call->link);
|
||||
|
||||
if ((next == nullptr) || (entry->deadline < next->deadline)) {
|
||||
//lldbg("call enter after head\n");
|
||||
sq_addafter(&call->link, &entry->link, &callout_queue);
|
||||
break;
|
||||
}
|
||||
} while ((call = next) != nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Timer interrupt handler
|
||||
*
|
||||
* This routine simulates a timer interrupt handler
|
||||
*/
|
||||
static void
|
||||
hrt_tim_isr(void *p)
|
||||
{
|
||||
/* grab the timer for latency tracking purposes */
|
||||
latency_actual = hrt_absolute_time();
|
||||
|
||||
/* do latency calculations */
|
||||
hrt_latency_update();
|
||||
|
||||
/* run any callouts that have met their deadline */
|
||||
hrt_call_invoke();
|
||||
|
||||
hrt_lock();
|
||||
|
||||
/* and schedule the next interrupt */
|
||||
hrt_call_reschedule();
|
||||
|
||||
hrt_unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reschedule the next timer interrupt.
|
||||
*
|
||||
* This routine must be called with interrupts disabled.
|
||||
*/
|
||||
static void
|
||||
hrt_call_reschedule()
|
||||
{
|
||||
hrt_abstime now = hrt_absolute_time();
|
||||
hrt_abstime delay = HRT_INTERVAL_MAX;
|
||||
struct hrt_call *next = (struct hrt_call *)sq_peek(&callout_queue);
|
||||
hrt_abstime deadline = now + HRT_INTERVAL_MAX;
|
||||
|
||||
/*
|
||||
* Determine what the next deadline will be.
|
||||
*
|
||||
* Note that we ensure that this will be within the counter
|
||||
* period, so that when we truncate all but the low 16 bits
|
||||
* the next time the compare matches it will be the deadline
|
||||
* we want.
|
||||
*
|
||||
* It is important for accurate timekeeping that the compare
|
||||
* interrupt fires sufficiently often that the base_time update in
|
||||
* hrt_absolute_time runs at least once per timer period.
|
||||
*/
|
||||
if (next != nullptr) {
|
||||
//lldbg("entry in queue\n");
|
||||
if (next->deadline <= (now + HRT_INTERVAL_MIN)) {
|
||||
//lldbg("pre-expired\n");
|
||||
/* set a minimal deadline so that we call ASAP */
|
||||
delay = HRT_INTERVAL_MIN;
|
||||
|
||||
} else if (next->deadline < deadline) {
|
||||
//lldbg("due soon\n");
|
||||
delay = next->deadline - now;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the new compare value and remember it for latency tracking */
|
||||
latency_baseline = now + delay;
|
||||
|
||||
// There is no timer ISR, so simulate one by putting an event on the
|
||||
// high priority work queue
|
||||
|
||||
// Remove the existing expiry and update with the new expiry
|
||||
hrt_work_cancel(&_hrt_work);
|
||||
|
||||
hrt_work_queue(&_hrt_work, (worker_t)&hrt_tim_isr, nullptr, delay);
|
||||
}
|
||||
|
||||
static void
|
||||
hrt_call_internal(struct hrt_call *entry, hrt_abstime deadline, hrt_abstime interval, hrt_callout callout, void *arg)
|
||||
{
|
||||
PX4_DEBUG("hrt_call_internal deadline=%lu interval = %lu", deadline, interval);
|
||||
hrt_lock();
|
||||
|
||||
//PX4_INFO("hrt_call_internal after lock");
|
||||
/* if the entry is currently queued, remove it */
|
||||
/* note that we are using a potentially uninitialised
|
||||
entry->link here, but it is safe as sq_rem() doesn't
|
||||
dereference the passed node unless it is found in the
|
||||
list. So we potentially waste a bit of time searching the
|
||||
queue for the uninitialised entry->link but we don't do
|
||||
anything actually unsafe.
|
||||
*/
|
||||
if (entry->deadline != 0) {
|
||||
sq_rem(&entry->link, &callout_queue);
|
||||
}
|
||||
|
||||
entry->deadline = deadline;
|
||||
entry->period = interval;
|
||||
entry->callout = callout;
|
||||
entry->arg = arg;
|
||||
|
||||
hrt_call_enter(entry);
|
||||
hrt_unlock();
|
||||
}
|
||||
|
||||
/*
|
||||
* Call callout(arg) after delay has elapsed.
|
||||
*
|
||||
* If callout is nullptr, this can be used to implement a timeout by testing the call
|
||||
* with hrt_called().
|
||||
*/
|
||||
void hrt_call_after(struct hrt_call *entry, hrt_abstime delay, hrt_callout callout, void *arg)
|
||||
{
|
||||
//printf("hrt_call_after\n");
|
||||
hrt_call_internal(entry,
|
||||
hrt_absolute_time() + delay,
|
||||
0,
|
||||
callout,
|
||||
arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Call callout(arg) after delay, and then after every interval.
|
||||
*
|
||||
* Note thet the interval is timed between scheduled, not actual, call times, so the call rate may
|
||||
* jitter but should not drift.
|
||||
*/
|
||||
void hrt_call_every(struct hrt_call *entry, hrt_abstime delay, hrt_abstime interval, hrt_callout callout, void *arg)
|
||||
{
|
||||
hrt_call_internal(entry,
|
||||
hrt_absolute_time() + delay,
|
||||
interval,
|
||||
callout,
|
||||
arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Call callout(arg) at absolute time calltime.
|
||||
*/
|
||||
void hrt_call_at(struct hrt_call *entry, hrt_abstime calltime, hrt_callout callout, void *arg)
|
||||
{
|
||||
hrt_call_internal(entry, calltime, 0, callout, arg);
|
||||
}
|
||||
|
||||
static void
|
||||
hrt_call_invoke()
|
||||
{
|
||||
struct hrt_call *call;
|
||||
hrt_abstime deadline;
|
||||
|
||||
hrt_lock();
|
||||
|
||||
while (true) {
|
||||
/* get the current time */
|
||||
hrt_abstime now = hrt_absolute_time();
|
||||
|
||||
call = (struct hrt_call *)sq_peek(&callout_queue);
|
||||
|
||||
if (call == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (call->deadline > now) {
|
||||
break;
|
||||
}
|
||||
|
||||
sq_rem(&call->link, &callout_queue);
|
||||
//PX4_INFO("call pop");
|
||||
|
||||
/* save the intended deadline for periodic calls */
|
||||
deadline = call->deadline;
|
||||
|
||||
/* zero the deadline, as the call has occurred */
|
||||
call->deadline = 0;
|
||||
|
||||
/* invoke the callout (if there is one) */
|
||||
if (call->callout) {
|
||||
// Unlock so we don't deadlock in callback
|
||||
hrt_unlock();
|
||||
|
||||
//PX4_INFO("call %p: %p(%p)", call, call->callout, call->arg);
|
||||
call->callout(call->arg);
|
||||
|
||||
hrt_lock();
|
||||
}
|
||||
|
||||
/* if the callout has a non-zero period, it has to be re-entered */
|
||||
if (call->period != 0) {
|
||||
// re-check call->deadline to allow for
|
||||
// callouts to re-schedule themselves
|
||||
// using hrt_call_delay()
|
||||
if (call->deadline <= now) {
|
||||
call->deadline = deadline + call->period;
|
||||
//PX4_INFO("call deadline set to %lu now=%lu", call->deadline, now);
|
||||
}
|
||||
|
||||
hrt_call_enter(call);
|
||||
}
|
||||
}
|
||||
|
||||
hrt_unlock();
|
||||
}
|
||||
|
||||
void abstime_to_ts(struct timespec *ts, hrt_abstime abstime)
|
||||
{
|
||||
ts->tv_sec = abstime / 1000000;
|
||||
abstime -= ts->tv_sec * 1000000;
|
||||
ts->tv_nsec = abstime * 1000;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
/**
|
||||
* @file get_commands.cpp
|
||||
* functions to call to run the set of startup commands
|
||||
*
|
||||
* @author Mark Charlebois <charlebm@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
__BEGIN_DECLS
|
||||
// The commands to run are specified in a target file: commands_<target>.c
|
||||
extern const char *get_commands(void);
|
||||
|
||||
// Enable external library hook
|
||||
void qurt_external_hook(void) __attribute__((weak));
|
||||
__END_DECLS
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <px4_platform/micro_hal.h>
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
/************************************************************************************************
|
||||
* libc/misc/lib_crc32.c
|
||||
*
|
||||
* This file is a part of NuttX:
|
||||
*
|
||||
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
|
||||
*
|
||||
* The logic in this file was developed by Gary S. Brown:
|
||||
*
|
||||
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or code or tables
|
||||
* extracted from it, as desired without restriction.
|
||||
*
|
||||
* First, the polynomial itself and its table of feedback terms. The polynomial is:
|
||||
*
|
||||
* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
|
||||
*
|
||||
* Note that we take it "backwards" and put the highest-order term in the lowest-order bit.
|
||||
* The X^32 term is "implied"; the LSB is the X^31 term, etc. The X^0 term (usually shown
|
||||
* as "+1") results in the MSB being 1
|
||||
*
|
||||
* Note that the usual hardware shift register implementation, which is what we're using
|
||||
* (we're merely optimizing it by doing eight-bit chunks at a time) shifts bits into the
|
||||
* lowest-order term. In our implementation, that means shifting towards the right. Why
|
||||
* do we do it this way? Because the calculated CRC must be transmitted in order from
|
||||
* highest-order term to lowest-order term. UARTs transmit characters in order from LSB
|
||||
* to MSB. By storing the CRC this way we hand it to the UART in the order low-byte to
|
||||
* high-byte; the UART sends each low-bit to hight-bit; and the result is transmission bit
|
||||
* by bit from highest- to lowest-order term without requiring any bit shuffling on our
|
||||
* part. Reception works similarly
|
||||
*
|
||||
* The feedback terms table consists of 256, 32-bit entries. Notes
|
||||
*
|
||||
* - The table can be generated at runtime if desired; code to do so is shown later. It
|
||||
* might not be obvious, but the feedback terms simply represent the results of eight
|
||||
* shift/xor operations for all combinations of data and CRC register values
|
||||
*
|
||||
* - The values must be right-shifted by eight bits by the updcrc logic; the shift must
|
||||
* be u_(bring in zeroes). On some hardware you could probably optimize the shift in
|
||||
* assembler by using byte-swap instructions polynomial $edb88320
|
||||
************************************************************************************************/
|
||||
|
||||
/************************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <crc32.h>
|
||||
|
||||
// Needed for Linux
|
||||
#define FAR
|
||||
|
||||
/************************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************************/
|
||||
|
||||
static const uint32_t crc32_tab[] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
||||
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
||||
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
||||
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
||||
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
||||
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
||||
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
||||
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
||||
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
||||
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
||||
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
||||
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
||||
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
||||
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
||||
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
||||
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
||||
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||
};
|
||||
|
||||
/************************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************************/
|
||||
/************************************************************************************************
|
||||
* Name: crc32part
|
||||
*
|
||||
* Description:
|
||||
* Continue CRC calculation on a part of the buffer.
|
||||
*
|
||||
************************************************************************************************/
|
||||
|
||||
uint32_t crc32part(FAR const uint8_t *src, size_t len, uint32_t crc32val)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
crc32val = crc32_tab[(crc32val ^ src[i]) & 0xff] ^ (crc32val >> 8);
|
||||
}
|
||||
|
||||
return crc32val;
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* Name: crc32
|
||||
*
|
||||
* Description:
|
||||
* Return a 32-bit CRC of the contents of the 'src' buffer, length 'len'
|
||||
*
|
||||
************************************************************************************************/
|
||||
|
||||
uint32_t crc32(FAR const uint8_t *src, size_t len)
|
||||
{
|
||||
return crc32part(src, len, 0);
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015-2016 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
/**
|
||||
* @file main.cpp
|
||||
*
|
||||
* Basic shell to execute builtin "apps" on QURT.
|
||||
*
|
||||
* @author Mark Charlebois <charlebm@gmail.com>
|
||||
* @author Julian Oes <julian@oes.ch>
|
||||
*/
|
||||
|
||||
#include <px4_platform_common/tasks.h>
|
||||
#include <px4_platform_common/time.h>
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include <px4_platform_common/init.h>
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <dspal_platform.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "get_commands.h"
|
||||
#include "apps.h"
|
||||
|
||||
#define MAX_ARGS 8 // max number of whitespace separated args after app name
|
||||
|
||||
|
||||
static px4_task_t g_dspal_task = -1;
|
||||
|
||||
__BEGIN_DECLS
|
||||
// The commands to run are specified in a target file: commands_<target>.c
|
||||
extern const char *get_commands(void);
|
||||
|
||||
// Enable external library hook
|
||||
void qurt_external_hook(void) __attribute__((weak));
|
||||
__END_DECLS
|
||||
|
||||
void qurt_external_hook(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void run_cmd(apps_map_type &apps, const std::vector<std::string> &appargs)
|
||||
{
|
||||
// command is appargs[0]
|
||||
std::string command = appargs[0];
|
||||
|
||||
//replaces app.find with iterator code to avoid null pointer exception
|
||||
for (apps_map_type::iterator it = apps.begin(); it != apps.end(); ++it)
|
||||
if (it->first == command) {
|
||||
// one for command name, one for null terminator
|
||||
const char *arg[MAX_ARGS + 2];
|
||||
|
||||
unsigned int i = 0;
|
||||
|
||||
if (appargs.size() > MAX_ARGS + 1) {
|
||||
PX4_ERR("%d too many arguments in run_cmd", appargs.size() - (MAX_ARGS + 1));
|
||||
return;
|
||||
}
|
||||
|
||||
while (i < appargs.size() && appargs[i].c_str()[0] != '\0') {
|
||||
arg[i] = (char *)appargs[i].c_str();
|
||||
PX4_DEBUG(" arg%d = '%s'\n", i, arg[i]);
|
||||
++i;
|
||||
}
|
||||
|
||||
arg[i] = (char *)0;
|
||||
|
||||
//PX4_DEBUG_PRINTF(i);
|
||||
if (apps[command] == NULL) {
|
||||
PX4_ERR("Null function !!\n");
|
||||
|
||||
} else {
|
||||
apps[command](i, (char **)arg);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void eat_whitespace(const char *&b, int &i)
|
||||
{
|
||||
// Eat whitespace
|
||||
while (b[i] == ' ' || b[i] == '\t') { ++i; }
|
||||
|
||||
b = &b[i];
|
||||
i = 0;
|
||||
}
|
||||
|
||||
static void process_commands(apps_map_type &apps, const char *cmds)
|
||||
{
|
||||
std::vector<std::string> appargs;
|
||||
int i = 0;
|
||||
const char *b = cmds;
|
||||
char arg[256];
|
||||
|
||||
// Eat leading whitespace
|
||||
eat_whitespace(b, i);
|
||||
|
||||
for (;;) {
|
||||
// End of command line
|
||||
if (b[i] == '\n' || b[i] == '\0') {
|
||||
strncpy(arg, b, i);
|
||||
arg[i] = '\0';
|
||||
appargs.push_back(arg);
|
||||
|
||||
// If we have a command to run
|
||||
if (appargs.size() > 0) {
|
||||
PX4_DEBUG("Processing command: %s", appargs[0].c_str());
|
||||
|
||||
for (int ai = 1; ai < (int)appargs.size(); ai++) {
|
||||
PX4_DEBUG(" > arg: %s", appargs[ai].c_str());
|
||||
}
|
||||
|
||||
run_cmd(apps, appargs);
|
||||
}
|
||||
|
||||
appargs.clear();
|
||||
|
||||
if (b[i] == '\n') {
|
||||
eat_whitespace(b, ++i);
|
||||
continue;
|
||||
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// End of arg
|
||||
else if (b[i] == ' ') {
|
||||
strncpy(arg, b, i);
|
||||
arg[i] = '\0';
|
||||
appargs.push_back(arg);
|
||||
eat_whitespace(b, ++i);
|
||||
continue;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
namespace px4
|
||||
{
|
||||
extern void init_once(void);
|
||||
};
|
||||
|
||||
__BEGIN_DECLS
|
||||
int dspal_main(int argc, char *argv[]);
|
||||
__END_DECLS
|
||||
|
||||
|
||||
const char *get_commands()
|
||||
{
|
||||
// All that needs to be started automatically on the DSP side
|
||||
// are uorb and qshell. After that, everything else can get
|
||||
// started from the main startup script on the Linux side.
|
||||
static const char *commands = "qshell start\n";
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
|
||||
int dspal_entry(int argc, char *argv[])
|
||||
{
|
||||
PX4_INFO("In dspal_entry");
|
||||
apps_map_type apps;
|
||||
init_app_map(apps);
|
||||
px4::init_once();
|
||||
px4::init(argc, (char **)argv, "px4");
|
||||
process_commands(apps, get_commands());
|
||||
sleep(1); // give time for all commands to execute before starting external function
|
||||
|
||||
if (qurt_external_hook) {
|
||||
qurt_external_hook();
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void usage()
|
||||
{
|
||||
PX4_INFO("Usage: dspal {start |stop}");
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
int dspal_main(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (argc == 2 && strcmp(argv[1], "start") == 0) {
|
||||
g_dspal_task = px4_task_spawn_cmd("dspal",
|
||||
SCHED_DEFAULT,
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
1500,
|
||||
dspal_entry,
|
||||
argv);
|
||||
|
||||
} else if (argc == 2 && strcmp(argv[1], "stop") == 0) {
|
||||
if (g_dspal_task < 0) {
|
||||
PX4_WARN("start up thread not running");
|
||||
|
||||
} else {
|
||||
px4_task_delete(g_dspal_task);
|
||||
g_dspal_task = -1;
|
||||
}
|
||||
|
||||
} else {
|
||||
usage();
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <px4_platform_common/init.h>
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <lib/parameters/param.h>
|
||||
#include <px4_platform_common/px4_work_queue/WorkQueueManager.hpp>
|
||||
|
||||
int px4_platform_init()
|
||||
{
|
||||
hrt_init();
|
||||
|
||||
param_init();
|
||||
|
||||
px4::WorkQueueManagerStart();
|
||||
|
||||
uorb_start();
|
||||
|
||||
//px4_log_initialize();
|
||||
|
||||
return PX4_OK;
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file px4_linux_impl.cpp
|
||||
*
|
||||
* PX4 Middleware Wrapper Linux Implementation
|
||||
*/
|
||||
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <px4_platform_common/init.h>
|
||||
#include <px4_platform_common/tasks.h>
|
||||
#include <px4_platform_common/workqueue.h>
|
||||
#include <dataman/dataman.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
#include <parameters/param.h>
|
||||
#include "hrt_work.h"
|
||||
|
||||
//extern pthread_t _shell_task_id;
|
||||
|
||||
|
||||
__BEGIN_DECLS
|
||||
extern uint64_t get_ticks_per_us();
|
||||
|
||||
//long PX4_TICKS_PER_SEC = 1000L;
|
||||
|
||||
unsigned int sleep(unsigned int sec)
|
||||
{
|
||||
for (unsigned int i = 0; i < sec; i++) {
|
||||
usleep(1000000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern void hrt_init(void);
|
||||
|
||||
#if 0
|
||||
void qurt_log(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printf(fmt, args);
|
||||
printf("n");
|
||||
va_end(args);
|
||||
}
|
||||
#endif
|
||||
|
||||
//extern int _posix_init(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
extern struct wqueue_s gwork[NWORKERS];
|
||||
|
||||
|
||||
namespace px4
|
||||
{
|
||||
|
||||
void init_once(void);
|
||||
|
||||
void init_once(void)
|
||||
{
|
||||
// Required for QuRT
|
||||
//_posix_init();
|
||||
|
||||
// _shell_task_id = pthread_self();
|
||||
// PX4_INFO("Shell id is %lu", _shell_task_id);
|
||||
|
||||
work_queues_init();
|
||||
hrt_work_queue_init();
|
||||
|
||||
px4_platform_init();
|
||||
}
|
||||
|
||||
void init(int argc, char *argv[], const char *app_name)
|
||||
{
|
||||
PX4_DEBUG("App name: %s\n", app_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Retrieve from the data manager store */
|
||||
ssize_t
|
||||
dm_read(
|
||||
dm_item_t item, /* The item type to retrieve */
|
||||
unsigned index, /* The index of the item */
|
||||
void *buffer, /* Pointer to caller data buffer */
|
||||
size_t buflen /* Length in bytes of data to retrieve */
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** write to the data manager store */
|
||||
ssize_t
|
||||
dm_write(
|
||||
dm_item_t item, /* The item type to store */
|
||||
unsigned index, /* The index of the item */
|
||||
dm_persitence_t persistence, /* The persistence level of this item */
|
||||
const void *buffer, /* Pointer to caller data buffer */
|
||||
size_t buflen /* Length in bytes of data to retrieve */
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t strnlen(const char *s, size_t maxlen)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
while (s[i] != '\0' && i < maxlen) {
|
||||
++i;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
PX4_ERR("Error: Calling unresolved symbol stub:[%s(%s,...)]", __FUNCTION__, format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fputc(int c, FILE *stream)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
int putchar(int character)
|
||||
{
|
||||
return character;
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
void block_indefinite(void);
|
||||
void _Read_uleb(void);
|
||||
void _Parse_fde_instr(void);
|
||||
void _Parse_csd(void);
|
||||
void _Valbytes(void);
|
||||
void _Get_eh_data(void);
|
||||
void _Parse_lsda(void);
|
||||
void __cxa_guard_release(void);
|
||||
void _Read_enc_ptr(void);
|
||||
void _Read_sleb(void);
|
||||
void __cxa_guard_acquire(void);
|
||||
void __cxa_pure_virtual(void);
|
||||
|
||||
void block_indefinite(void)
|
||||
{
|
||||
sem_t forever;
|
||||
sem_init(&forever, 0, 0);
|
||||
sem_wait(&forever);
|
||||
}
|
||||
|
||||
void _Read_uleb(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void _Parse_fde_instr(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void _Parse_csd(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void _Valbytes(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void _Get_eh_data(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void _Parse_lsda(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void __cxa_guard_release(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void _Read_enc_ptr(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void _Read_sleb(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void __cxa_guard_acquire(void)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
void __cxa_pure_virtual()
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
}
|
||||
|
||||
float _Stof(const char *p0, char **p1, long p2)
|
||||
{
|
||||
PX4_WARN("Error: Calling unresolved symbol stub[%s]", __FUNCTION__);
|
||||
block_indefinite();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *bsearch(const void *key, const void *ptr, size_t count, size_t size, int (*comp)(const void *, const void *))
|
||||
{
|
||||
const char *first = (const char *)ptr;
|
||||
|
||||
while (count > 1) {
|
||||
size_t m = count / 2;
|
||||
const char *middle_element = first + m * size;
|
||||
int cmp_res = comp(middle_element, key);
|
||||
|
||||
if (cmp_res > 0) {
|
||||
count = m;
|
||||
|
||||
} else if (cmp_res == 0) {
|
||||
return (void *)middle_element;
|
||||
|
||||
} else {
|
||||
first = middle_element + size;
|
||||
count = count - m - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (count && comp(first, key) == 0) {
|
||||
return (void *)first;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,344 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015 Vijay Venkatraman. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <atomic_ops.h>
|
||||
|
||||
#include <parameters/param.h>
|
||||
|
||||
#include <px4_platform_common/shmem.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
|
||||
//#define SHMEM_DEBUG
|
||||
//#define PARAM_LOCK_DEBUG
|
||||
|
||||
static atomic_word_t mem_lock;
|
||||
|
||||
static unsigned char *map_base, *virt_addr;
|
||||
static uint64_t update_from_shmem_prev_time = 0, update_from_shmem_current_time = 0;
|
||||
static unsigned char krait_changed_index[MAX_SHMEM_PARAMS / 8 + 1];
|
||||
|
||||
struct shmem_info *shmem_info_p;
|
||||
|
||||
// Small helper to get log2 for ints
|
||||
static unsigned log2_for_int(unsigned v)
|
||||
{
|
||||
unsigned r = 0;
|
||||
|
||||
while (v >>= 1) {
|
||||
++r;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
struct param_wbuf_s {
|
||||
union param_value_u val;
|
||||
param_t param;
|
||||
bool unsaved;
|
||||
};
|
||||
extern struct param_wbuf_s *param_find_changed(param_t param);
|
||||
|
||||
int get_shmem_lock(const char *caller_file_name, int caller_line_number)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
#ifdef PARAM_LOCK_DEBUG
|
||||
PX4_INFO("lock value %d before get from %s, line: %d\n", mem_lock.value, strrchr(caller_file_name, '/'),
|
||||
caller_line_number);
|
||||
#endif
|
||||
|
||||
while (!atomic_compare_and_set(&mem_lock, 1, 0)) {
|
||||
i++;
|
||||
usleep(1000);
|
||||
|
||||
if (i > 100) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 100) {
|
||||
PX4_INFO("Could not get lock, file name: %s, line number: %d.\n",
|
||||
strrchr(caller_file_name, '/'), caller_line_number);
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
PX4_DEBUG("Lock acquired, file name: %s, line number: %d\n",
|
||||
caller_file_name, caller_line_number);
|
||||
}
|
||||
|
||||
return 0; //got the lock
|
||||
|
||||
}
|
||||
|
||||
void release_shmem_lock(const char *caller_file_name, int caller_line_number)
|
||||
{
|
||||
atomic_set(&mem_lock, 1);
|
||||
|
||||
#ifdef PARAM_LOCK_DEBUG
|
||||
PX4_INFO("release lock, file name: %s, line number: %d.\n",
|
||||
strrchr(caller_file_name, '/'), caller_line_number);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void init_shared_memory(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (shmem_info_p) {
|
||||
return;
|
||||
}
|
||||
|
||||
//virt_addr = map_memory(MAP_ADDRESS);
|
||||
map_base = (unsigned char *)calloc(MAP_SIZE, 1); //16KB
|
||||
|
||||
if (map_base == NULL) {
|
||||
PX4_INFO("adsp memory malloc failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
virt_addr = map_base;
|
||||
shmem_info_p = (struct shmem_info *) virt_addr;
|
||||
|
||||
atomic_init(&mem_lock, 1);
|
||||
|
||||
for (i = 0; i < MAX_SHMEM_PARAMS / 8 + 1; i++) {
|
||||
shmem_info_p->krait_changed_index[i] = 0;
|
||||
}
|
||||
|
||||
PX4_INFO("adsp memory mapped\n");
|
||||
}
|
||||
|
||||
void copy_params_to_shmem(const param_info_s *param_info_base)
|
||||
{
|
||||
param_t param;
|
||||
unsigned int i;
|
||||
|
||||
if (get_shmem_lock(__FILE__, __LINE__) != 0) {
|
||||
PX4_INFO("Could not get shmem lock\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//else PX4_INFO("Got lock\n");
|
||||
|
||||
for (param = 0; param < param_count(); param++) {
|
||||
//{PX4_INFO("writing to offset %d\n", (unsigned char*)(shmem_info_p->adsp_params[param].name)-(unsigned char*)shmem_info_p);}
|
||||
struct param_wbuf_s *s = param_find_changed(param);
|
||||
|
||||
if (s == NULL) {
|
||||
shmem_info_p->params_val[param] = param_info_base[param].val;
|
||||
}
|
||||
|
||||
else {
|
||||
shmem_info_p->params_val[param] = s->val;
|
||||
}
|
||||
|
||||
#ifdef SHMEM_DEBUG
|
||||
|
||||
if (param_type(param) == PARAM_TYPE_INT32) {
|
||||
PX4_INFO("%d: written %d for param %s to shared mem", param, shmem_info_p->params_val[param].i, param_name(param));
|
||||
|
||||
} else if (param_type(param) == PARAM_TYPE_FLOAT) {
|
||||
PX4_INFO("%d: written %f for param %s to shared mem", param, shmem_info_p->params_val[param].f, param_name(param));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SHMEM_PARAMS / 8 + 1; i++) {
|
||||
shmem_info_p->adsp_changed_index[i] = 0;
|
||||
krait_changed_index[i] = 0;
|
||||
}
|
||||
|
||||
release_shmem_lock(__FILE__, __LINE__);
|
||||
//PX4_INFO("Released lock\n");
|
||||
|
||||
}
|
||||
|
||||
/*update value and param's change bit in shared memory*/
|
||||
void update_to_shmem(param_t param, union param_value_u value)
|
||||
{
|
||||
unsigned int byte_changed, bit_changed;
|
||||
|
||||
if (!handle_in_range(param)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_shmem_lock(__FILE__, __LINE__) != 0) {
|
||||
PX4_ERR("Could not get shmem lock\n");
|
||||
return;
|
||||
}
|
||||
|
||||
shmem_info_p->params_val[param] = value;
|
||||
|
||||
byte_changed = param / 8;
|
||||
bit_changed = 1 << param % 8;
|
||||
shmem_info_p->adsp_changed_index[byte_changed] |= bit_changed;
|
||||
|
||||
//PX4_INFO("set %d bit on adsp index[%d] to %d\n", bit_changed, byte_changed, shmem_info_p->adsp_changed_index[byte_changed]);
|
||||
|
||||
#ifdef SHMEM_DEBUG
|
||||
|
||||
if (param_type(param) == PARAM_TYPE_INT32) {
|
||||
PX4_INFO("Set value %d for param %s to shmem, set adsp index %d:%d\n", value.i, param_name(param), byte_changed,
|
||||
bit_changed);
|
||||
}
|
||||
|
||||
else if (param_type(param) == PARAM_TYPE_FLOAT) {
|
||||
PX4_INFO("Set value %f for param %s to shmem, set adsp index %d:%d\n", value.f, param_name(param), byte_changed,
|
||||
bit_changed);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
release_shmem_lock(__FILE__, __LINE__);
|
||||
|
||||
}
|
||||
|
||||
void update_index_from_shmem(void)
|
||||
{
|
||||
unsigned int i;
|
||||
param_t params[MAX_SHMEM_PARAMS / 8 + 1];
|
||||
|
||||
if (get_shmem_lock(__FILE__, __LINE__) != 0) {
|
||||
PX4_ERR("Could not get shmem lock\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SHMEM_PARAMS / 8 + 1; i++) {
|
||||
// Check if any param has been changed.
|
||||
if (krait_changed_index[i] != shmem_info_p->krait_changed_index[i]) {
|
||||
|
||||
// If a param has changed, we need to find out which one.
|
||||
// From the byte and bit that is different, we can resolve the param number.
|
||||
unsigned bit = log2_for_int(
|
||||
krait_changed_index[i]
|
||||
^ shmem_info_p->krait_changed_index[i]);
|
||||
param_t param_to_get = i * 8 + bit;
|
||||
|
||||
// Update our krait_changed_index as well.
|
||||
krait_changed_index[i] = shmem_info_p->krait_changed_index[i];
|
||||
params[i] = param_to_get;
|
||||
|
||||
} else {
|
||||
params[i] = 0xFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
release_shmem_lock(__FILE__, __LINE__);
|
||||
|
||||
// FIXME: this is a hack but it gets the param so that it gets added
|
||||
// to the local list param_values in param_shmem.c.
|
||||
for (i = 0; i < MAX_SHMEM_PARAMS / 8 + 1; i++) {
|
||||
if (params[i] != 0xFFFF) {
|
||||
int32_t dummy;
|
||||
param_get(params[i], &dummy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void update_value_from_shmem(param_t param, union param_value_u *value)
|
||||
{
|
||||
unsigned int byte_changed, bit_changed;
|
||||
|
||||
if (get_shmem_lock(__FILE__, __LINE__) != 0) {
|
||||
PX4_ERR("Could not get shmem lock\n");
|
||||
return;
|
||||
}
|
||||
|
||||
*value = shmem_info_p->params_val[param];
|
||||
|
||||
/*also clear the index since we are holding the lock*/
|
||||
byte_changed = param / 8;
|
||||
bit_changed = 1 << param % 8;
|
||||
shmem_info_p->krait_changed_index[byte_changed] &= ~bit_changed;
|
||||
|
||||
release_shmem_lock(__FILE__, __LINE__);
|
||||
|
||||
#ifdef SHMEM_DEBUG
|
||||
|
||||
if (param_type(param) == PARAM_TYPE_INT32) {
|
||||
PX4_INFO("Got value %d for param %s from shmem, cleared krait index %d:%d\n", value->i, param_name(param), byte_changed,
|
||||
bit_changed);
|
||||
}
|
||||
|
||||
else if (param_type(param) == PARAM_TYPE_FLOAT) {
|
||||
PX4_INFO("Got value %f for param %s from shmem, cleared krait index %d:%d\n", value->f, param_name(param), byte_changed,
|
||||
bit_changed);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int update_from_shmem(param_t param, union param_value_u *value)
|
||||
{
|
||||
unsigned int byte_changed, bit_changed;
|
||||
unsigned int retval = 0;
|
||||
|
||||
if (!handle_in_range(param) || value == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
update_from_shmem_current_time = hrt_absolute_time();
|
||||
|
||||
if ((update_from_shmem_current_time - update_from_shmem_prev_time)
|
||||
> 1000000) { //update every 1 second
|
||||
update_from_shmem_prev_time = update_from_shmem_current_time;
|
||||
update_index_from_shmem();
|
||||
}
|
||||
|
||||
byte_changed = param / 8;
|
||||
bit_changed = 1 << param % 8;
|
||||
|
||||
if (krait_changed_index[byte_changed] & bit_changed) {
|
||||
update_value_from_shmem(param, value);
|
||||
krait_changed_index[byte_changed] &= ~bit_changed;
|
||||
retval = 1;
|
||||
}
|
||||
|
||||
//else {PX4_INFO("no change to param %s\n", param_name(param));}
|
||||
|
||||
PX4_DEBUG("%s %d bit on krait changed index[%d]\n",
|
||||
(retval) ? "cleared" : "unchanged", bit_changed, byte_changed);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
#include <semaphore.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
int sem_init(sem_t *sem, int pshared, unsigned int value)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sem_wait(sem_t *sem)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sem_destroy(sem_t *sem)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sem_post(sem_t *sem)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sem_getvalue(sem_t *sem, int *sval)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int usleep(useconds_t usec)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
pthread_t pthread_self(void)
|
||||
{
|
||||
pthread_t x = 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
int pthread_kill(pthread_t thread, int sig)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void pthread_exit(void *retval)
|
||||
{
|
||||
}
|
||||
|
||||
int pthread_join(pthread_t thread, void **retval)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_cancel(pthread_t thread)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int pthread_attr_init(pthread_attr_t *attr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_attr_destroy(pthread_attr_t *attr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_cond_signal(pthread_cond_t *cond)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int pthread_condattr_init(pthread_condattr_t *attr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fsync(int fd)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <dlfcn.h>
|
||||
#include <qurt_log.h>
|
||||
#include <dspal_platform.h>
|
||||
|
||||
// This code is never run. It is used solely to test linking in the
|
||||
// TravisCI build test to make sure all symbols are resolved.
|
||||
__EXPORT int _start_main(void);
|
||||
|
||||
void HAP_debug(const char *msg, int level, const char *filename, int line)
|
||||
{
|
||||
}
|
||||
|
||||
void HAP_power_request(int a, int b, int c)
|
||||
{
|
||||
}
|
||||
|
||||
int dlinit(int a, char **b)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int _start_main()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file px4_qurt_tasks.c
|
||||
* Implementation of existing task API for QURT.
|
||||
*
|
||||
* @author Mark Charlebois <charlebm@gmail.com>
|
||||
*/
|
||||
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include <px4_platform_common/workqueue.h>
|
||||
#include <px4_platform_common/time.h>
|
||||
#include <hrt_work.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if !defined(__PX4_QURT)
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <string>
|
||||
|
||||
#include <px4_platform_common/tasks.h>
|
||||
#include <systemlib/err.h>
|
||||
|
||||
#define MAX_CMD_LEN 100
|
||||
|
||||
#define PX4_MAX_TASKS 50
|
||||
#define SHELL_TASK_ID (PX4_MAX_TASKS+1)
|
||||
|
||||
pthread_t _shell_task_id = 0;
|
||||
|
||||
struct task_entry {
|
||||
pthread_t pid;
|
||||
std::string name;
|
||||
bool isused;
|
||||
task_entry() : isused(false) {}
|
||||
};
|
||||
|
||||
static task_entry taskmap[PX4_MAX_TASKS];
|
||||
|
||||
typedef struct {
|
||||
px4_main_t entry;
|
||||
int argc;
|
||||
char *argv[];
|
||||
// strings are allocated after the
|
||||
} pthdata_t;
|
||||
|
||||
static void *entry_adapter(void *ptr)
|
||||
{
|
||||
pthdata_t *data;
|
||||
data = (pthdata_t *) ptr;
|
||||
|
||||
data->entry(data->argc, data->argv);
|
||||
//PX4_WARN("Before waiting infinte busy loop");
|
||||
//for( ;; )
|
||||
//{
|
||||
// volatile int x = 0;
|
||||
// ++x;
|
||||
// }
|
||||
free(ptr);
|
||||
px4_task_exit(0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_size, px4_main_t entry,
|
||||
char *const argv[])
|
||||
{
|
||||
struct sched_param param;
|
||||
pthread_attr_t attr;
|
||||
pthread_t task;
|
||||
int rv;
|
||||
int argc = 0;
|
||||
int i;
|
||||
unsigned int len = 0;
|
||||
unsigned long offset;
|
||||
unsigned long structsize;
|
||||
char *p = (char *)argv;
|
||||
|
||||
PX4_DEBUG("Creating %s\n", name);
|
||||
PX4_DEBUG("attr address: 0x%X, param address: 0x%X", &attr, ¶m);
|
||||
|
||||
// Calculate argc
|
||||
while (p != (char *)0) {
|
||||
p = argv[argc];
|
||||
|
||||
if (p == (char *)0) {
|
||||
break;
|
||||
}
|
||||
|
||||
++argc;
|
||||
len += strlen(p) + 1;
|
||||
}
|
||||
|
||||
structsize = sizeof(pthdata_t) + (argc + 1) * sizeof(char *);
|
||||
pthdata_t *taskdata = nullptr;
|
||||
|
||||
// not safe to pass stack data to the thread creation
|
||||
taskdata = (pthdata_t *)malloc(structsize + len);
|
||||
|
||||
if (taskdata == nullptr) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
offset = ((unsigned long)taskdata) + structsize;
|
||||
|
||||
taskdata->entry = entry;
|
||||
taskdata->argc = argc;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
PX4_DEBUG("arg %d %s\n", i, argv[i]);
|
||||
taskdata->argv[i] = (char *)offset;
|
||||
strcpy((char *)offset, argv[i]);
|
||||
offset += strlen(argv[i]) + 1;
|
||||
}
|
||||
|
||||
// Must add NULL at end of argv
|
||||
taskdata->argv[argc] = (char *)0;
|
||||
|
||||
rv = pthread_attr_init(&attr);
|
||||
|
||||
if (rv != 0) {
|
||||
PX4_WARN("px4_task_spawn_cmd: failed to init thread attrs");
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
PX4_DEBUG("stack address after pthread_attr_init: 0x%X", attr.stackaddr);
|
||||
PX4_DEBUG("attr address: 0x%X, param address: 0x%X", &attr, ¶m);
|
||||
rv = pthread_attr_getschedparam(&attr, ¶m);
|
||||
PX4_DEBUG("stack address after pthread_attr_getschedparam: 0x%X", attr.stackaddr);
|
||||
|
||||
if (rv != 0) {
|
||||
PX4_WARN("px4_task_spawn_cmd: failed to get thread sched param");
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
#if 0
|
||||
rv = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
|
||||
if (rv != 0) {
|
||||
PX4_WARN("px4_task_spawn_cmd: failed to set inherit sched");
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
rv = pthread_attr_setschedpolicy(&attr, scheduler);
|
||||
|
||||
if (rv != 0) {
|
||||
PX4_WARN("px4_task_spawn_cmd: failed to set sched policy");
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
#endif
|
||||
size_t fixed_stacksize = -1;
|
||||
pthread_attr_getstacksize(&attr, &fixed_stacksize);
|
||||
PX4_DEBUG("stack size: %d passed stacksize(%d)", fixed_stacksize, stack_size);
|
||||
fixed_stacksize = 8 * 1024;
|
||||
fixed_stacksize = (fixed_stacksize < (size_t)stack_size) ? (size_t)stack_size : fixed_stacksize;
|
||||
|
||||
PX4_DEBUG("setting the thread[%s] stack size to[%d]", name, fixed_stacksize);
|
||||
pthread_attr_setstacksize(&attr, PX4_STACK_ADJUSTED(fixed_stacksize));
|
||||
|
||||
PX4_DEBUG("stack address after pthread_attr_setstacksize: 0x%X", attr.stackaddr);
|
||||
param.sched_priority = priority;
|
||||
|
||||
rv = pthread_attr_setschedparam(&attr, ¶m);
|
||||
|
||||
if (rv != 0) {
|
||||
PX4_ERR("px4_task_spawn_cmd: failed to set sched param");
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
rv = pthread_create(&task, &attr, &entry_adapter, (void *) taskdata);
|
||||
|
||||
if (rv != 0) {
|
||||
PX4_ERR("px4_task_spawn_cmd: pthread_create failed, error: %d", rv);
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
for (i = 0; i < PX4_MAX_TASKS; ++i) {
|
||||
if (taskmap[i].isused == false) {
|
||||
taskmap[i].pid = task;
|
||||
taskmap[i].name = name;
|
||||
taskmap[i].isused = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= PX4_MAX_TASKS) {
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int px4_task_delete(px4_task_t id)
|
||||
{
|
||||
int rv = 0;
|
||||
pthread_t pid;
|
||||
PX4_WARN("Called px4_task_delete");
|
||||
|
||||
if (id < PX4_MAX_TASKS && taskmap[id].isused) {
|
||||
pid = taskmap[id].pid;
|
||||
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// If current thread then exit, otherwise cancel
|
||||
if (pthread_self() == pid) {
|
||||
taskmap[id].isused = false;
|
||||
pthread_exit(0);
|
||||
|
||||
} else {
|
||||
rv = pthread_cancel(pid);
|
||||
}
|
||||
|
||||
taskmap[id].isused = false;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void px4_task_exit(int ret)
|
||||
{
|
||||
int i;
|
||||
pthread_t pid = pthread_self();
|
||||
|
||||
// Get pthread ID from the opaque ID
|
||||
for (i = 0; i < PX4_MAX_TASKS; ++i) {
|
||||
if (taskmap[i].pid == pid) {
|
||||
taskmap[i].isused = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= PX4_MAX_TASKS) {
|
||||
PX4_ERR("px4_task_exit: self task not found!");
|
||||
|
||||
} else {
|
||||
PX4_DEBUG("px4_task_exit: %s", taskmap[i].name.c_str());
|
||||
}
|
||||
|
||||
//pthread_exit((void *)(unsigned long)ret);
|
||||
}
|
||||
|
||||
int px4_task_kill(px4_task_t id, int sig)
|
||||
{
|
||||
int rv = 0;
|
||||
pthread_t pid;
|
||||
PX4_DEBUG("Called px4_task_kill %d, taskname %s", sig, taskmap[id].name.c_str());
|
||||
|
||||
if (id < PX4_MAX_TASKS && taskmap[id].pid != 0) {
|
||||
pid = taskmap[id].pid;
|
||||
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// If current thread then exit, otherwise cancel
|
||||
rv = pthread_kill(pid, sig);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void px4_show_tasks()
|
||||
{
|
||||
int idx;
|
||||
int count = 0;
|
||||
|
||||
PX4_INFO("Active Tasks:");
|
||||
|
||||
for (idx = 0; idx < PX4_MAX_TASKS; idx++) {
|
||||
if (taskmap[idx].isused) {
|
||||
PX4_INFO(" %-10s %d", taskmap[idx].name.c_str(), taskmap[idx].pid);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
PX4_INFO(" No running tasks");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
px4_task_t px4_getpid()
|
||||
{
|
||||
pthread_t pid = pthread_self();
|
||||
//
|
||||
// if (pid == _shell_task_id)
|
||||
// return SHELL_TASK_ID;
|
||||
|
||||
// Get pthread ID from the opaque ID
|
||||
for (int i = 0; i < PX4_MAX_TASKS; ++i) {
|
||||
if (taskmap[i].isused && taskmap[i].pid == pid) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return ~0;
|
||||
}
|
||||
|
||||
|
||||
const char *px4_get_taskname()
|
||||
{
|
||||
pthread_t pid = pthread_self();
|
||||
|
||||
for (int i = 0; i < PX4_MAX_TASKS; i++) {
|
||||
if (taskmap[i].isused && taskmap[i].pid == pid) {
|
||||
return taskmap[i].name.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
return "Unknown App";
|
||||
}
|
||||
|
||||
static void timer_cb(void *data)
|
||||
{
|
||||
px4_sem_t *sem = reinterpret_cast<px4_sem_t *>(data);
|
||||
|
||||
sem_post(sem);
|
||||
}
|
||||
|
||||
int px4_sem_timedwait(px4_sem_t *sem, const struct timespec *ts)
|
||||
{
|
||||
work_s _hpwork = {};
|
||||
|
||||
// Get the current time.
|
||||
struct timespec ts_now;
|
||||
px4_clock_gettime(CLOCK_MONOTONIC, &ts_now);
|
||||
|
||||
// We get an absolute time but want to calculate a timeout in us.
|
||||
hrt_abstime timeout_us = ts_to_abstime((struct timespec *)ts) - ts_to_abstime(&ts_now);
|
||||
|
||||
// Create a timer to unblock.
|
||||
hrt_work_queue(&_hpwork, (worker_t)&timer_cb, (void *)sem, timeout_us);
|
||||
sem_wait(sem);
|
||||
hrt_work_cancel(&_hpwork);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int px4_prctl(int option, const char *arg2, px4_task_t pid)
|
||||
{
|
||||
int rv;
|
||||
|
||||
switch (option) {
|
||||
case PR_SET_NAME:
|
||||
// set the threads name - Not supported
|
||||
// rv = pthread_setname_np(pthread_self(), arg2);
|
||||
rv = -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = -1;
|
||||
PX4_WARN("FAILED SETTING TASK NAME");
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
|
||||
add_subdirectory(${PX4_CHIP})
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <px4_platform_common/i2c.h>
|
||||
|
||||
|
||||
static inline constexpr px4_i2c_bus_t initI2CBusInternal(int bus)
|
||||
{
|
||||
px4_i2c_bus_t ret{};
|
||||
ret.bus = bus;
|
||||
ret.is_external = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline constexpr px4_i2c_bus_t initI2CBusExternal(int bus)
|
||||
{
|
||||
px4_i2c_bus_t ret{};
|
||||
ret.bus = bus;
|
||||
ret.is_external = true;
|
||||
return ret;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <px4_platform/micro_hal.h>
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <px4_platform_common/spi.h>
|
||||
|
||||
static inline constexpr px4_spi_bus_device_t initSPIDevice(uint8_t devid_driver)
|
||||
{
|
||||
px4_spi_bus_device_t ret{};
|
||||
ret.cs_gpio = 1; // set to some non-zero value to indicate this is used
|
||||
ret.devid = PX4_SPIDEV_ID(PX4_SPI_DEVICE_ID, 0);
|
||||
ret.devtype_driver = devid_driver;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline constexpr px4_spi_bus_t initSPIBus(int bus, const px4_spi_bus_devices_t &devices)
|
||||
{
|
||||
px4_spi_bus_t ret{};
|
||||
|
||||
for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) {
|
||||
ret.devices[i] = devices.devices[i];
|
||||
}
|
||||
|
||||
ret.bus = bus;
|
||||
ret.is_external = false; // all buses are marked internal on QuRT
|
||||
ret.requires_locking = false;
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user