platform: restructure (NuttX) architecture-specific code

updated: tone_alarm, px4io_serial, px4_micro_hal
This commit is contained in:
Beat Küng 2019-08-23 16:04:22 +02:00
parent 2fa3ee9336
commit ab43a83bed
111 changed files with 1640 additions and 404 deletions

View File

@ -347,6 +347,17 @@ else()
px4_find_python_module(jinja2 REQUIRED)
endif()
#=============================================================================
# get chip and chip manufacturer
#
px4_os_determine_build_chip()
if(NOT PX4_CHIP_MANUFACTURER)
message(FATAL_ERROR "px4_os_determine_build_chip() needs to set PX4_CHIP_MANUFACTURER")
endif()
if(NOT PX4_CHIP)
message(FATAL_ERROR "px4_os_determine_build_chip() needs to set PX4_CHIP")
endif()
#=============================================================================
# build flags
#
@ -451,6 +462,7 @@ add_library(parameters_interface INTERFACE)
include(px4_add_library)
add_subdirectory(src/lib EXCLUDE_FROM_ALL)
add_subdirectory(platforms/${PX4_PLATFORM}/src/px4)
add_subdirectory(src/platforms EXCLUDE_FROM_ALL)
add_subdirectory(src/modules/uORB EXCLUDE_FROM_ALL) # TODO: platform layer
add_subdirectory(src/drivers/boards EXCLUDE_FROM_ALL)

View File

@ -42,7 +42,6 @@ px4_add_board(
rc_input
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -48,7 +48,6 @@ px4_add_board(
roboclaw
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -49,7 +49,6 @@ px4_add_board(
#roboclaw
stm32
stm32/adc
#stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -27,7 +27,6 @@ px4_add_board(
rc_input
stm32
stm32/adc
stm32/tone_alarm
telemetry
tone_alarm
osd

View File

@ -51,7 +51,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -32,7 +32,6 @@ px4_add_board(
irlock
kinetis
kinetis/adc
kinetis/tone_alarm
lights/blinkm
lights/oreoled
lights/rgbled

View File

@ -37,7 +37,6 @@ px4_add_board(
rc_input
stm32
stm32/adc
#stm32/tone_alarm
#tap_esc
#telemetry # all available telemetry drivers
telemetry/frsky_telemetry

View File

@ -57,7 +57,6 @@ px4_add_board(
#roboclaw
stm32
stm32/adc
stm32/tone_alarm
#tap_esc
#telemetry # all available telemetry drivers
#test_ppm

View File

@ -37,7 +37,6 @@ px4_add_board(
px4io
stm32
stm32/adc
stm32/tone_alarm
#telemetry # all available telemetry drivers
telemetry/iridiumsbd
tone_alarm

View File

@ -53,7 +53,6 @@ px4_add_board(
px4io
stm32
stm32/adc
stm32/tone_alarm
#tap_esc
#telemetry # all available telemetry drivers
#test_ppm

View File

@ -37,7 +37,6 @@ px4_add_board(
px4io
stm32
stm32/adc
stm32/tone_alarm
tone_alarm
MODULES

View File

@ -33,7 +33,6 @@ px4_add_board(
px4io
stm32
stm32/adc
stm32/tone_alarm
tone_alarm
MODULES

View File

@ -53,7 +53,6 @@ px4_add_board(
px4io
stm32
stm32/adc
stm32/tone_alarm
#tap_esc
#telemetry # all available telemetry drivers
#test_ppm

View File

@ -56,7 +56,6 @@ px4_add_board(
roboclaw
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -55,7 +55,6 @@ px4_add_board(
roboclaw
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -55,7 +55,6 @@ px4_add_board(
roboclaw
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -41,7 +41,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -43,7 +43,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -41,7 +41,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -54,7 +54,6 @@ px4_add_board(
roboclaw
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -53,7 +53,6 @@ px4_add_board(
roboclaw
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -55,7 +55,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -55,7 +55,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -39,7 +39,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
telemetry # all available telemetry drivers
tone_alarm
uavcan

View File

@ -55,7 +55,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -43,7 +43,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
tone_alarm

View File

@ -43,7 +43,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
telemetry # all available telemetry drivers
tone_alarm
uavcan

View File

@ -53,7 +53,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -53,7 +53,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -55,7 +55,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -49,7 +49,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
telemetry # all available telemetry drivers
tone_alarm
uavcan

View File

@ -50,7 +50,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
tone_alarm

View File

@ -53,7 +53,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
telemetry # all available telemetry drivers
tone_alarm
uavcan

View File

@ -55,7 +55,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -55,7 +55,6 @@ px4_add_board(
safety_button
stm32
stm32/adc
stm32/tone_alarm
tap_esc
telemetry # all available telemetry drivers
test_ppm

View File

@ -17,7 +17,6 @@ px4_add_board(
#magnetometer # all available magnetometer drivers
pwm_out_sim
#telemetry # all available telemetry drivers
sim/tone_alarm
tone_alarm
#uavcan

View File

@ -17,7 +17,6 @@ px4_add_board(
#magnetometer # all available magnetometer drivers
pwm_out_sim
#telemetry # all available telemetry drivers
sim/tone_alarm
tone_alarm
#uavcan

View File

@ -17,7 +17,6 @@ px4_add_board(
#magnetometer # all available magnetometer drivers
pwm_out_sim
#telemetry # all available telemetry drivers
sim/tone_alarm
tone_alarm
#uavcan

View File

@ -47,7 +47,6 @@ px4_add_board(
rc_input
stm32
stm32/adc
stm32/tone_alarm
#tap_esc
telemetry # all available telemetry drivers
#test_ppm

View File

@ -183,6 +183,9 @@ function(px4_add_board)
set(PX4_PLATFORM ${PLATFORM} CACHE STRING "PX4 board OS" FORCE)
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake)
# platform-specific include path
include_directories(${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/common/include)
if(ARCHITECTURE)
set(CMAKE_SYSTEM_PROCESSOR ${ARCHITECTURE} CACHE INTERNAL "system processor" FORCE)
endif()

View File

@ -174,6 +174,7 @@ function(px4_add_common_flags)
${PX4_BINARY_DIR}/src/lib
${PX4_BINARY_DIR}/src/modules
${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/${PX4_CHIP_MANUFACTURER}/${PX4_CHIP}
${PX4_SOURCE_DIR}/src
${PX4_SOURCE_DIR}/src/include
${PX4_SOURCE_DIR}/src/lib

View File

@ -40,7 +40,7 @@ include(px4_base)
# Like add_library but with PX4 platform dependencies
#
function(px4_add_library target)
add_library(${target} ${ARGN})
add_library(${target} EXCLUDE_FROM_ALL ${ARGN})
target_compile_definitions(${target} PRIVATE MODULE_NAME="${target}")

View File

@ -36,8 +36,6 @@ include(cygwin_cygpath)
set(NUTTX_DIR ${PX4_BINARY_DIR}/NuttX/nuttx)
set(NUTTX_APPS_DIR ${PX4_BINARY_DIR}/NuttX/apps)
add_subdirectory(src)
add_executable(px4 ${PX4_SOURCE_DIR}/src/platforms/empty.c)
set(FW_NAME ${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}.elf)
set_target_properties(px4 PROPERTIES OUTPUT_NAME ${FW_NAME})

View File

@ -38,6 +38,7 @@
# Required OS Interface Functions
#
# * px4_os_add_flags
# * px4_os_determine_build_chip
# * px4_os_prebuild_targets
#
@ -84,6 +85,38 @@ function(px4_os_add_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)
# determine chip and chip manufacturer based on NuttX config
if (CONFIG_STM32_STM32F10XX)
set(CHIP_MANUFACTURER "stm")
set(CHIP "stm32f1")
elseif(CONFIG_STM32_STM32F4XXX)
set(CHIP_MANUFACTURER "stm")
set(CHIP "stm32f4")
elseif(CONFIG_ARCH_CHIP_STM32F7)
set(CHIP_MANUFACTURER "stm")
set(CHIP "stm32f7")
elseif(CONFIG_ARCH_CHIP_MK66FN2M0VMD18)
set(CHIP_MANUFACTURER "nxp")
set(CHIP "k66")
else()
message(FATAL_ERROR "Could not determine chip architecture from NuttX config. You may have to add it.")
endif()
set(PX4_CHIP ${CHIP} CACHE STRING "PX4 Chip" FORCE)
set(PX4_CHIP_MANUFACTURER ${CHIP_MANUFACTURER} CACHE STRING "PX4 Chip Manufacturer" FORCE)
endfunction()
#=============================================================================
#
# px4_os_prebuild_targets

View File

@ -0,0 +1,37 @@
############################################################################
#
# 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})

View File

@ -0,0 +1,56 @@
/****************************************************************************
*
* 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
__BEGIN_DECLS
#include <nuttx/spi/spi.h>
#include <nuttx/i2c/i2c_master.h>
/* For historical reasons (NuttX STM32 numbering) PX4 bus numbering is 1 based
* All PX4 code, including, board code is written to assuming 1 based numbering.
* The following macros are used to allow the board config to define the bus
* numbers in terms of the NuttX driver numbering. 1,2,3 for one based numbering
* schemes or 0,1,2 for zero based schemes.
*/
#define PX4_BUS_NUMBER_TO_PX4(x) ((x)+PX4_BUS_OFFSET) /* Use to define Zero based to match Nuttx Driver but provide 1 based to PX4 */
#define PX4_BUS_NUMBER_FROM_PX4(x) ((x)-PX4_BUS_OFFSET) /* Use to map PX4 1 based to NuttX driver 0 based */
#define px4_enter_critical_section() enter_critical_section()
#define px4_leave_critical_section(flags) leave_critical_section(flags)
#include <arch/board/board.h>
__END_DECLS

View File

@ -0,0 +1,36 @@
############################################################################
#
# 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})

View File

@ -31,6 +31,6 @@
#
############################################################################
px4_add_library(tone_alarm_interface
px4_add_library(arch_tone_alarm
ToneAlarmInterface.cpp
)

View File

@ -115,7 +115,9 @@
# define rCNSC CAT3(rC, TONE_ALARM_CHANNEL, SC) /* Channel Status and Control Register used by Tone alarm */
# define STATUS CAT3(TPM_STATUS_CH, TONE_ALARM_CHANNEL, F) /* Capture and Compare Status Register used by Tone alarm */
void ToneAlarmInterface::init()
namespace ToneAlarmInterface
{
void init()
{
#ifdef GPIO_TONE_ALARM_NEG
px4_arch_configgpio(GPIO_TONE_ALARM_NEG);
@ -157,7 +159,7 @@ void ToneAlarmInterface::init()
rMOD = 0; // Default the timer to a modulo value of 1; playing notes will change this.
}
void ToneAlarmInterface::start_note(unsigned frequency)
void start_note(unsigned frequency)
{
// Calculate the signal switching period.
// (Signal switching period is one half of the frequency period).
@ -174,7 +176,7 @@ void ToneAlarmInterface::start_note(unsigned frequency)
px4_arch_configgpio(GPIO_TONE_ALARM);
}
void ToneAlarmInterface::stop_note()
void stop_note()
{
// Stop the current note.
rSC &= ~TPM_SC_CMOD_MASK;
@ -182,3 +184,5 @@ void ToneAlarmInterface::stop_note()
// Ensure the GPIO is not driving the speaker.
px4_arch_configgpio(GPIO_TONE_ALARM_IDLE);
}
} /* namespace ToneAlarmInterface */

View File

@ -0,0 +1,38 @@
############################################################################
#
# 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/tone_alarm tone_alarm)

View File

@ -0,0 +1,112 @@
/****************************************************************************
*
* 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 "../../common/px4_platform_micro_hal.h"
__BEGIN_DECLS
#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_KINETISK66
// Fixme: using ??
#define PX4_BBSRAM_SIZE 2048
#define PX4_BBSRAM_GETDESC_IOCTL 0
#define PX4_NUMBER_I2C_BUSES KINETIS_NI2C
#define GPIO_OUTPUT_SET GPIO_OUTPUT_ONE
#define GPIO_OUTPUT_CLEAR GPIO_OUTPUT_ZERO
#include <chip.h>
#include <kinetis_spi.h>
#include <kinetis_i2c.h>
#include <kinetis_uid.h>
/* Kinetis defines the 128 bit UUID as
* init32_t[4] that can be read as words
* init32_t[0] PX4_CPU_UUID_ADDRESS[0] bits 127:96 (offset 0)
* init32_t[1] PX4_CPU_UUID_ADDRESS[1] bits 95:64 (offset 4)
* init32_t[2] PX4_CPU_UUID_ADDRESS[1] bits 63:32 (offset 8)
* init32_t[3] PX4_CPU_UUID_ADDRESS[3] bits 31:0 (offset C)
*
* PX4 uses the words in bigendian order MSB to LSB
* word [0] [1] [2] [3]
* bits 127:96 95-64 63-32, 31-00,
*/
#define PX4_CPU_UUID_BYTE_LENGTH KINETIS_UID_SIZE
#define PX4_CPU_UUID_WORD32_LENGTH (PX4_CPU_UUID_BYTE_LENGTH/sizeof(uint32_t))
/* The mfguid will be an array of bytes with
* MSD @ index 0 - LSD @ index PX4_CPU_MFGUID_BYTE_LENGTH-1
*
* It will be converted to a string with the MSD on left and LSD on the right most position.
*/
#define PX4_CPU_MFGUID_BYTE_LENGTH PX4_CPU_UUID_BYTE_LENGTH
/* define common formating across all commands */
#define PX4_CPU_UUID_WORD32_FORMAT "%08x"
#define PX4_CPU_UUID_WORD32_SEPARATOR ":"
#define PX4_CPU_UUID_WORD32_UNIQUE_H 3 /* Least significant digits change the most */
#define PX4_CPU_UUID_WORD32_UNIQUE_M 2 /* Middle High significant digits */
#define PX4_CPU_UUID_WORD32_UNIQUE_L 1 /* Middle Low significant digits */
#define PX4_CPU_UUID_WORD32_UNIQUE_N 0 /* Most significant digits change the least */
/* Separator nnn:nnn:nnnn 2 char per byte term */
#define PX4_CPU_UUID_WORD32_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH)+1)
#define PX4_CPU_MFGUID_FORMAT_SIZE ((2*PX4_CPU_MFGUID_BYTE_LENGTH)+1)
#define kinetis_bbsram_savepanic(fileno, context, length) (0) // todo:Not implemented yet
#define px4_savepanic(fileno, context, length) kinetis_bbsram_savepanic(fileno, context, length)
/* bus_num is zero based on kinetis and must be translated from the legacy one based */
#define PX4_BUS_OFFSET 1 /* Kinetis buses are 0 based and adjustment is needed */
#define px4_spibus_initialize(bus_num_1based) kinetis_spibus_initialize(PX4_BUS_NUMBER_FROM_PX4(bus_num_1based))
#define px4_i2cbus_initialize(bus_num_1based) kinetis_i2cbus_initialize(PX4_BUS_NUMBER_FROM_PX4(bus_num_1based))
#define px4_i2cbus_uninitialize(pdev) kinetis_i2cbus_uninitialize(pdev)
#define px4_arch_configgpio(pinset) kinetis_pinconfig(pinset)
#define px4_arch_unconfiggpio(pinset)
#define px4_arch_gpioread(pinset) kinetis_gpioread(pinset)
#define px4_arch_gpiowrite(pinset, value) kinetis_gpiowrite(pinset, value)
/* kinetis_gpiosetevent is not implemented and will need to be added */
#define px4_arch_gpiosetevent(pinset,r,f,e,fp,a) kinetis_gpiosetevent(pinset,r,f,e,fp,a)
__END_DECLS

View File

@ -0,0 +1,36 @@
############################################################################
#
# 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})

View File

@ -0,0 +1,105 @@
/****************************************************************************
*
* 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 "../../common/px4_platform_micro_hal.h"
__BEGIN_DECLS
#include <stm32_tim.h>
#include <stm32_spi.h>
#include <stm32_i2c.h>
/* STM32/32F7 defines the 96 bit UUID as
* init32_t[3] that can be read as bytes/half-words/words
* init32_t[0] PX4_CPU_UUID_ADDRESS[0] bits 31:0 (offset 0)
* init32_t[1] PX4_CPU_UUID_ADDRESS[1] bits 63:32 (offset 4)
* init32_t[2] PX4_CPU_UUID_ADDRESS[3] bits 96:64 (offset 8)
*
* The original PX4 stm32 (legacy) based implementation **displayed** the
* UUID as: ABCD EFGH IJKL
* Where:
* A was bit 31 and D was bit 0
* E was bit 63 and H was bit 32
* I was bit 95 and L was bit 64
*
* Since the string was used by some manufactures to identify the units
* it must be preserved.
*
* For new targets moving forward we will use
* IJKL EFGH ABCD
*/
#define PX4_CPU_UUID_BYTE_LENGTH 12
#define PX4_CPU_UUID_WORD32_LENGTH (PX4_CPU_UUID_BYTE_LENGTH/sizeof(uint32_t))
/* The mfguid will be an array of bytes with
* MSD @ index 0 - LSD @ index PX4_CPU_MFGUID_BYTE_LENGTH-1
*
* It will be converted to a string with the MSD on left and LSD on the right most position.
*/
#define PX4_CPU_MFGUID_BYTE_LENGTH PX4_CPU_UUID_BYTE_LENGTH
/* By not defining PX4_CPU_UUID_CORRECT_CORRELATION the following maintains the legacy incorrect order
* used for selection of significant digits of the UUID in the PX4 code base.
* This is done to avoid the ripple effects changing the IDs used on STM32 base platforms
*/
#if defined(PX4_CPU_UUID_CORRECT_CORRELATION)
# define PX4_CPU_UUID_WORD32_UNIQUE_H 0 /* Least significant digits change the most */
# define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */
# define PX4_CPU_UUID_WORD32_UNIQUE_L 2 /* Most significant digits change the least */
#else
/* Legacy incorrect ordering */
# define PX4_CPU_UUID_WORD32_UNIQUE_H 2 /* Most significant digits change the least */
# define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */
# define PX4_CPU_UUID_WORD32_UNIQUE_L 0 /* Least significant digits change the most */
#endif
/* Separator nnn:nnn:nnnn 2 char per byte term */
#define PX4_CPU_UUID_WORD32_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH)+1)
#define PX4_CPU_MFGUID_FORMAT_SIZE ((2*PX4_CPU_MFGUID_BYTE_LENGTH)+1)
#define px4_savepanic(fileno, context, length) stm32_bbsram_savepanic(fileno, context, length)
#define PX4_BUS_OFFSET 0 /* STM buses are 1 based no adjustment needed */
#define px4_spibus_initialize(bus_num_1based) stm32_spibus_initialize(bus_num_1based)
#define px4_i2cbus_initialize(bus_num_1based) stm32_i2cbus_initialize(bus_num_1based)
#define px4_i2cbus_uninitialize(pdev) stm32_i2cbus_uninitialize(pdev)
#define px4_arch_configgpio(pinset) stm32_configgpio(pinset)
#define px4_arch_unconfiggpio(pinset) stm32_unconfiggpio(pinset)
#define px4_arch_gpioread(pinset) stm32_gpioread(pinset)
#define px4_arch_gpiowrite(pinset, value) stm32_gpiowrite(pinset, value)
#define px4_arch_gpiosetevent(pinset,r,f,e,fp,a) stm32_gpiosetevent(pinset,r,f,e,fp,a)
__END_DECLS

View File

@ -32,31 +32,17 @@
****************************************************************************/
/**
* @file px4io_driver.h
* @file arch_px4io_serial.h
*
* Interface for PX4IO
* Serial Interface definition for PX4IO
*/
#pragma once
/* XXX trim includes */
#include <px4_config.h>
#include <px4_posix.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <debug.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <arch/board/board.h>
#include <perf/perf_counter.h>
#include <board_config.h>
#include <px4_config.h>
#include <perf/perf_counter.h>
#include <drivers/device/device.h>
#include <modules/px4iofirmware/protocol.h>
@ -117,87 +103,17 @@ private:
PX4IO_serial &operator = (const PX4IO_serial &);
};
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F4XXX)
/** XXX use F4 implementation for F1 as well. **/
#define PX4IO_INTERFACE_CLASS PX4IO_serial_f4
#define PX4IO_INTERFACE_F4
class PX4IO_serial_f4 : public PX4IO_serial
{
public:
PX4IO_serial_f4();
~PX4IO_serial_f4();
virtual int init();
virtual int ioctl(unsigned operation, unsigned &arg);
protected:
/**
* Start the transaction with IO and wait for it to complete.
*/
int _bus_exchange(IOPacket *_packet);
private:
DMA_HANDLE _tx_dma;
DMA_HANDLE _rx_dma;
IOPacket *_current_packet;
/** saved DMA status */
static const unsigned _dma_status_inactive = 0x80000000; // low bits overlap DMA_STATUS_* values
static const unsigned _dma_status_waiting = 0x00000000;
volatile unsigned _rx_dma_status;
/** client-waiting lock/signal */
px4_sem_t _completion_semaphore;
/**
* DMA completion handler.
*/
static void _dma_callback(DMA_HANDLE handle, uint8_t status, void *arg);
void _do_rx_dma_callback(unsigned status);
/**
* Serial interrupt handler.
*/
static int _interrupt(int vector, void *context, void *arg);
void _do_interrupt();
/**
* Cancel any DMA in progress with an error.
*/
void _abort_dma();
/**
* Performance counters.
*/
perf_counter_t _pc_dmasetup;
perf_counter_t _pc_dmaerrs;
/* do not allow top copying this class */
PX4IO_serial_f4(PX4IO_serial_f4 &);
PX4IO_serial_f4 &operator = (const PX4IO_serial_f4 &);
/**
* IO Buffer storage
*/
static IOPacket _io_buffer_storage; // XXX static to ensure DMA-able memory
};
#elif defined(CONFIG_ARCH_CHIP_STM32F7)
#define PX4IO_INTERFACE_CLASS PX4IO_serial_f7
#define PX4IO_INTERFACE_F7
#include <stm32_dma.h>
class PX4IO_serial_f7 : public PX4IO_serial
class ArchPX4IOSerial : public PX4IO_serial
{
public:
PX4IO_serial_f7();
~PX4IO_serial_f7();
ArchPX4IOSerial();
ArchPX4IOSerial(ArchPX4IOSerial &) = delete;
ArchPX4IOSerial &operator = (const ArchPX4IOSerial &) = delete;
~ArchPX4IOSerial();
virtual int init();
virtual int ioctl(unsigned operation, unsigned &arg);
@ -245,16 +161,9 @@ private:
perf_counter_t _pc_dmasetup;
perf_counter_t _pc_dmaerrs;
/* do not allow top copying this class */
PX4IO_serial_f7(PX4IO_serial_f7 &);
PX4IO_serial_f7 &operator = (const PX4IO_serial_f7 &);
/**
* IO Buffer storage
*/
static uint8_t _io_buffer_storage[] __attribute__((aligned(ARMV7M_DCACHE_LINESIZE)));
static uint8_t _io_buffer_storage[] __attribute__((aligned(PX4IO_SERIAL_BUF_ALIGN)));
};
#else
#error "Interface not implemented for this chip"
#endif

View File

@ -31,6 +31,6 @@
#
############################################################################
px4_add_library(tone_alarm_interface
px4_add_library(arch_tone_alarm
ToneAlarmInterface.cpp
)

View File

@ -35,19 +35,24 @@
#include <px4_defines.h>
#include <board_config.h>
void ToneAlarmInterface::init()
namespace ToneAlarmInterface
{
void init()
{
// Configure the GPIO to the idle state.
px4_arch_configgpio(GPIO_TONE_ALARM_IDLE);
}
void ToneAlarmInterface::start_note(unsigned frequency)
void start_note(unsigned frequency)
{
px4_arch_gpiowrite(GPIO_TONE_ALARM_GPIO, 1);
}
void ToneAlarmInterface::stop_note()
void stop_note()
{
// Stop the current note.
px4_arch_gpiowrite(GPIO_TONE_ALARM_GPIO, 0);
}
} /* namespace ToneAlarmInterface */

View File

@ -219,7 +219,10 @@
# define rSR REG(STM32_GTIM_SR_OFFSET)
#endif
void ToneAlarmInterface::init()
namespace ToneAlarmInterface
{
void init()
{
#ifdef GPIO_TONE_ALARM_NEG
px4_arch_configgpio(GPIO_TONE_ALARM_NEG);
@ -251,7 +254,7 @@ void ToneAlarmInterface::init()
rCR1 = GTIM_CR1_CEN; // Ensure the timer is running.
}
void ToneAlarmInterface::start_note(unsigned frequency)
void start_note(unsigned frequency)
{
// Calculate the signal switching period.
// (Signal switching period is one half of the frequency period).
@ -276,7 +279,7 @@ void ToneAlarmInterface::start_note(unsigned frequency)
px4_arch_configgpio(GPIO_TONE_ALARM);
}
void ToneAlarmInterface::stop_note()
void stop_note()
{
// Stop the current note.
rCCER &= ~TONE_CCER;
@ -284,3 +287,5 @@ void ToneAlarmInterface::stop_note()
// Ensure the GPIO is not driving the speaker.
px4_arch_configgpio(GPIO_TONE_ALARM_IDLE);
}
} /* namespace ToneAlarmInterface */

View File

@ -0,0 +1,36 @@
############################################################################
#
# 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(../stm32_common/io_pins io_pins)

View File

@ -0,0 +1,37 @@
/****************************************************************************
*
* 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 "../../../stm32_common/include/px4_arch/io_timer.h"

View File

@ -0,0 +1,51 @@
/****************************************************************************
*
* 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 "../stm32_common/px4_arch_micro_hal.h"
__BEGIN_DECLS
#include <stm32.h>
#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F4
#define PX4_FLASH_BASE STM32_FLASH_BASE
#if defined(CONFIG_STM32_STM32F4XXX)
# include <stm32_bbsram.h>
# define PX4_BBSRAM_SIZE STM32_BBSRAM_SIZE
# define PX4_BBSRAM_GETDESC_IOCTL STM32_BBSRAM_GETDESC_IOCTL
#endif
#define PX4_NUMBER_I2C_BUSES STM32_NI2C
__END_DECLS

View File

@ -0,0 +1,38 @@
############################################################################
#
# 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(../stm32_common/tone_alarm tone_alarm)
add_subdirectory(px4io_serial)

View File

@ -0,0 +1,51 @@
/****************************************************************************
*
* 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 "../stm32_common/px4_arch_micro_hal.h"
__BEGIN_DECLS
#include <stm32.h>
#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F4
#define PX4_FLASH_BASE STM32_FLASH_BASE
#if defined(CONFIG_STM32_STM32F4XXX)
# include <stm32_bbsram.h>
# define PX4_BBSRAM_SIZE STM32_BBSRAM_SIZE
# define PX4_BBSRAM_GETDESC_IOCTL STM32_BBSRAM_GETDESC_IOCTL
#endif
#define PX4_NUMBER_I2C_BUSES STM32_NI2C
__END_DECLS

View File

@ -0,0 +1,36 @@
############################################################################
#
# Copyright (c) 2015-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.
#
############################################################################
px4_add_library(arch_px4io_serial
px4io_serial.cpp
)

View File

@ -0,0 +1,38 @@
/****************************************************************************
*
* 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
#define PX4IO_SERIAL_BUF_ALIGN 4
#include "../stm32_common/px4io_serial/arch_px4io_serial.h"

View File

@ -32,14 +32,12 @@
****************************************************************************/
/**
* @file px4io_serial_f4.cpp
* @file px4io_serial.cpp
*
* Serial interface for PX4IO on STM32F4
*/
#include "px4io_serial.h"
#ifdef PX4IO_INTERFACE_F4
#include "arch_px4io_serial.h"
/* serial register accessors */
#define REG(_x) (*(volatile uint32_t *)(PX4IO_SERIAL_BASE + _x))
@ -51,9 +49,9 @@
#define rCR3 REG(STM32_USART_CR3_OFFSET)
#define rGTPR REG(STM32_USART_GTPR_OFFSET)
IOPacket PX4IO_serial_f4::_io_buffer_storage;
uint8_t ArchPX4IOSerial::_io_buffer_storage[sizeof(IOPacket)];
PX4IO_serial_f4::PX4IO_serial_f4() :
ArchPX4IOSerial::ArchPX4IOSerial() :
_tx_dma(nullptr),
_rx_dma(nullptr),
_current_packet(nullptr),
@ -69,7 +67,7 @@ PX4IO_serial_f4::PX4IO_serial_f4() :
{
}
PX4IO_serial_f4::~PX4IO_serial_f4()
ArchPX4IOSerial::~ArchPX4IOSerial()
{
if (_tx_dma != nullptr) {
stm32_dmastop(_tx_dma);
@ -105,12 +103,12 @@ PX4IO_serial_f4::~PX4IO_serial_f4()
}
int
PX4IO_serial_f4::init()
ArchPX4IOSerial::init()
{
/* initialize base implementation */
int r;
if ((r = PX4IO_serial::init(&_io_buffer_storage)) != 0) {
if ((r = PX4IO_serial::init((IOPacket *)&_io_buffer_storage[0])) != 0) {
return r;
}
@ -167,7 +165,7 @@ PX4IO_serial_f4::init()
}
int
PX4IO_serial_f4::ioctl(unsigned operation, unsigned &arg)
ArchPX4IOSerial::ioctl(unsigned operation, unsigned &arg)
{
switch (operation) {
@ -232,7 +230,7 @@ PX4IO_serial_f4::ioctl(unsigned operation, unsigned &arg)
}
int
PX4IO_serial_f4::_bus_exchange(IOPacket *_packet)
ArchPX4IOSerial::_bus_exchange(IOPacket *_packet)
{
_current_packet = _packet;
@ -351,17 +349,17 @@ PX4IO_serial_f4::_bus_exchange(IOPacket *_packet)
}
void
PX4IO_serial_f4::_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg)
ArchPX4IOSerial::_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg)
{
if (arg != nullptr) {
PX4IO_serial_f4 *ps = reinterpret_cast<PX4IO_serial_f4 *>(arg);
ArchPX4IOSerial *ps = reinterpret_cast<ArchPX4IOSerial *>(arg);
ps->_do_rx_dma_callback(status);
}
}
void
PX4IO_serial_f4::_do_rx_dma_callback(unsigned status)
ArchPX4IOSerial::_do_rx_dma_callback(unsigned status)
{
/* on completion of a reply, wake the waiter */
if (_rx_dma_status == _dma_status_waiting) {
@ -386,10 +384,10 @@ PX4IO_serial_f4::_do_rx_dma_callback(unsigned status)
}
int
PX4IO_serial_f4::_interrupt(int irq, void *context, void *arg)
ArchPX4IOSerial::_interrupt(int irq, void *context, void *arg)
{
if (arg != nullptr) {
PX4IO_serial_f4 *instance = reinterpret_cast<PX4IO_serial_f4 *>(arg);
ArchPX4IOSerial *instance = reinterpret_cast<ArchPX4IOSerial *>(arg);
instance->_do_interrupt();
}
@ -398,7 +396,7 @@ PX4IO_serial_f4::_interrupt(int irq, void *context, void *arg)
}
void
PX4IO_serial_f4::_do_interrupt()
ArchPX4IOSerial::_do_interrupt()
{
uint32_t sr = rSR; /* get UART status register */
(void)rDR; /* read DR to clear status */
@ -458,7 +456,7 @@ PX4IO_serial_f4::_do_interrupt()
}
void
PX4IO_serial_f4::_abort_dma()
ArchPX4IOSerial::_abort_dma()
{
/* disable UART DMA */
rCR3 &= ~(USART_CR3_DMAT | USART_CR3_DMAR);
@ -471,4 +469,3 @@ PX4IO_serial_f4::_abort_dma()
stm32_dmastop(_rx_dma);
}
#endif /* PX4IO_INTERFACE_F4 */

View File

@ -0,0 +1,38 @@
############################################################################
#
# 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(../stm32_common/tone_alarm tone_alarm)
add_subdirectory(px4io_serial)

View File

@ -0,0 +1,55 @@
/****************************************************************************
*
* 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 "../stm32_common/px4_arch_micro_hal.h"
__BEGIN_DECLS
#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F7
#include <chip.h>
#include <chip/stm32_flash.h>
#include <up_internal.h> //include up_systemreset() which is included on stm32.h
#include <stm32_bbsram.h>
#define PX4_BBSRAM_SIZE STM32F7_BBSRAM_SIZE
#define PX4_BBSRAM_GETDESC_IOCTL STM32F7_BBSRAM_GETDESC_IOCTL
#define PX4_FLASH_BASE 0x08000000
#define PX4_NUMBER_I2C_BUSES STM32F7_NI2C
void stm32_flash_lock(void);
void stm32_flash_unlock(void);
int stm32_flash_writeprotect(size_t page, bool enabled);
__END_DECLS

View File

@ -0,0 +1,36 @@
############################################################################
#
# Copyright (c) 2015-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.
#
############################################################################
px4_add_library(arch_px4io_serial
px4io_serial.cpp
)

View File

@ -0,0 +1,38 @@
/****************************************************************************
*
* 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
#define PX4IO_SERIAL_BUF_ALIGN ARMV7M_DCACHE_LINESIZE
#include "../stm32_common/px4io_serial/arch_px4io_serial.h"

View File

@ -32,14 +32,12 @@
****************************************************************************/
/**
* @file px4io_serial_f7.cpp
* @file px4io_serial.cpp
*
* Serial interface for PX4IO on STM32F7
*/
#include "px4io_serial.h"
#ifdef PX4IO_INTERFACE_F7
#include "arch_px4io_serial.h"
#include "stm32_uart.h"
#include <nuttx/cache.h>
@ -60,9 +58,9 @@
#define DMA_BUFFER_MASK (ARMV7M_DCACHE_LINESIZE - 1)
#define DMA_ALIGN_UP(n) (((n) + DMA_BUFFER_MASK) & ~DMA_BUFFER_MASK)
uint8_t PX4IO_serial_f7::_io_buffer_storage[DMA_ALIGN_UP(sizeof(IOPacket))];
uint8_t ArchPX4IOSerial::_io_buffer_storage[DMA_ALIGN_UP(sizeof(IOPacket))];
PX4IO_serial_f7::PX4IO_serial_f7() :
ArchPX4IOSerial::ArchPX4IOSerial() :
_tx_dma(nullptr),
_rx_dma(nullptr),
_current_packet(nullptr),
@ -78,7 +76,7 @@ PX4IO_serial_f7::PX4IO_serial_f7() :
{
}
PX4IO_serial_f7::~PX4IO_serial_f7()
ArchPX4IOSerial::~ArchPX4IOSerial()
{
if (_tx_dma != nullptr) {
stm32_dmastop(_tx_dma);
@ -114,7 +112,7 @@ PX4IO_serial_f7::~PX4IO_serial_f7()
}
int
PX4IO_serial_f7::init()
ArchPX4IOSerial::init()
{
/* initialize base implementation */
int r = PX4IO_serial::init((IOPacket *)&_io_buffer_storage[0]);
@ -178,7 +176,7 @@ PX4IO_serial_f7::init()
}
int
PX4IO_serial_f7::ioctl(unsigned operation, unsigned &arg)
ArchPX4IOSerial::ioctl(unsigned operation, unsigned &arg)
{
switch (operation) {
@ -243,7 +241,7 @@ PX4IO_serial_f7::ioctl(unsigned operation, unsigned &arg)
}
int
PX4IO_serial_f7::_bus_exchange(IOPacket *_packet)
ArchPX4IOSerial::_bus_exchange(IOPacket *_packet)
{
_current_packet = _packet;
@ -369,17 +367,17 @@ PX4IO_serial_f7::_bus_exchange(IOPacket *_packet)
}
void
PX4IO_serial_f7::_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg)
ArchPX4IOSerial::_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg)
{
if (arg != nullptr) {
PX4IO_serial_f7 *ps = reinterpret_cast<PX4IO_serial_f7 *>(arg);
ArchPX4IOSerial *ps = reinterpret_cast<ArchPX4IOSerial *>(arg);
ps->_do_rx_dma_callback(status);
}
}
void
PX4IO_serial_f7::_do_rx_dma_callback(unsigned status)
ArchPX4IOSerial::_do_rx_dma_callback(unsigned status)
{
/* on completion of a reply, wake the waiter */
if (_rx_dma_status == _dma_status_waiting) {
@ -405,10 +403,10 @@ PX4IO_serial_f7::_do_rx_dma_callback(unsigned status)
}
int
PX4IO_serial_f7::_interrupt(int irq, void *context, void *arg)
ArchPX4IOSerial::_interrupt(int irq, void *context, void *arg)
{
if (arg != nullptr) {
PX4IO_serial_f7 *instance = reinterpret_cast<PX4IO_serial_f7 *>(arg);
ArchPX4IOSerial *instance = reinterpret_cast<ArchPX4IOSerial *>(arg);
instance->_do_interrupt();
}
@ -417,7 +415,7 @@ PX4IO_serial_f7::_interrupt(int irq, void *context, void *arg)
}
void
PX4IO_serial_f7::_do_interrupt()
ArchPX4IOSerial::_do_interrupt()
{
uint32_t sr = rISR; /* get UART status register */
@ -485,7 +483,7 @@ PX4IO_serial_f7::_do_interrupt()
}
void
PX4IO_serial_f7::_abort_dma()
ArchPX4IOSerial::_abort_dma()
{
/* stop DMA */
stm32_dmastop(_tx_dma);
@ -502,4 +500,3 @@ PX4IO_serial_f7::_abort_dma()
rICR = rISR & rISR_ERR_FLAGS_MASK; /* clear the flags */
}
#endif /* PX4IO_INTERFACE_F7 */

View File

@ -42,6 +42,7 @@
# Required OS Interface Functions
#
# * px4_os_add_flags
# * px4_os_determine_build_chip
# * px4_os_prebuild_targets
#
@ -325,6 +326,23 @@ function(px4_os_add_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

View File

@ -0,0 +1,37 @@
############################################################################
#
# 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})

View File

@ -1,6 +1,6 @@
############################################################################
#
# Copyright (c) 2017 PX4 Development Team. All rights reserved.
# 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
@ -31,4 +31,3 @@
#
############################################################################
add_subdirectory(px4_layer)

View File

@ -0,0 +1,36 @@
/****************************************************************************
*
* 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

View File

@ -0,0 +1,36 @@
############################################################################
#
# 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})

View File

@ -0,0 +1,36 @@
############################################################################
#
# 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(tone_alarm)

View File

@ -0,0 +1,36 @@
/****************************************************************************
*
* 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>

View File

@ -31,6 +31,6 @@
#
############################################################################
px4_add_library(tone_alarm_interface
px4_add_library(arch_tone_alarm
ToneAlarmInterface.cpp
)

View File

@ -35,20 +35,26 @@
* @file ToneAlarmInterface.cpp
*/
#include <lib/drivers/tone_alarm/ToneAlarmInterface.h>
#include <drivers/drv_tone_alarm.h>
#include <px4_defines.h>
void ToneAlarmInterface::init()
namespace ToneAlarmInterface
{
void init()
{
// Nothing to be done in simulation.
}
void ToneAlarmInterface::start_note(unsigned frequency)
void start_note(unsigned frequency)
{
// Nothing to be done in simulation.
}
void ToneAlarmInterface::stop_note()
void stop_note()
{
// Nothing to be done in simulation.
}
} /* namespace ToneAlarmInterface */

View File

@ -0,0 +1,36 @@
############################################################################
#
# 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})

View File

@ -5,8 +5,6 @@ include(fastrpc)
include(qurt_lib)
include(qurt_flags)
add_subdirectory(src)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES)

View File

@ -45,6 +45,7 @@
# Required OS Inteface Functions
#
# * px4_os_add_flags
# * px4_os_determine_build_chip
# * px4_os_prebuild_targets
#
@ -144,6 +145,23 @@ function(px4_os_add_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

View File

@ -0,0 +1,37 @@
############################################################################
#
# 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})

View File

@ -40,7 +40,7 @@ set(QURT_LAYER_SRCS
px4_qurt_impl.cpp
px4_qurt_tasks.cpp
lib_crc32.c
../../../posix/src/px4_layer/drv_hrt.cpp
${PX4_SOURCE_DIR}/platforms/posix/src/px4/common/drv_hrt.cpp
qurt_stubs.c
main.cpp
shmem_qurt.cpp
@ -49,8 +49,8 @@ set(QURT_LAYER_SRCS
if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
list(APPEND QURT_LAYER_SRCS
../stubs/stubs_posix.c
../stubs/stubs_qurt.c
stubs/posix.c
stubs/qurt.c
)
endif()

View File

@ -0,0 +1,36 @@
/****************************************************************************
*
* 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>

Some files were not shown because too many files have changed in this diff Show More