9 changed files with 803 additions and 0 deletions
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
|
||||
px4_add_board( |
||||
PLATFORM nuttx |
||||
VENDOR hex |
||||
MODEL io-v2 |
||||
TOOLCHAIN arm-none-eabi |
||||
CONSTRAINED_FLASH |
||||
ARCHITECTURE cortex-m3 |
||||
DRIVERS |
||||
MODULES |
||||
px4iofirmware |
||||
) |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
{ |
||||
"board_id": 10, |
||||
"magic": "PX4FWv2", |
||||
"description": "Firmware for the PX4IOv2 board", |
||||
"image": "", |
||||
"build_time": 0, |
||||
"summary": "PX4IOv2", |
||||
"version": "2.0", |
||||
"image_size": 0, |
||||
"image_maxsize": 61440, |
||||
"git_identity": "", |
||||
"board_revision": 0 |
||||
} |
@ -0,0 +1,141 @@
@@ -0,0 +1,141 @@
|
||||
/************************************************************************************
|
||||
* nuttx-configs/px4io/include/board.h |
||||
* include/arch/board/board.h |
||||
* |
||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved. |
||||
* Author: Gregory Nutt <gnutt@nuttx.org> |
||||
* Copyright (C) 2012 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 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 __ARCH_BOARD_BOARD_H |
||||
#define __ARCH_BOARD_BOARD_H |
||||
|
||||
/************************************************************************************
|
||||
* Included Files |
||||
************************************************************************************/ |
||||
|
||||
#include <nuttx/config.h> |
||||
#ifndef __ASSEMBLY__ |
||||
# include <stdint.h> |
||||
#endif |
||||
#include <stm32.h> |
||||
|
||||
/************************************************************************************
|
||||
* Definitions |
||||
************************************************************************************/ |
||||
|
||||
/* Clocking *************************************************************************/ |
||||
|
||||
/* On-board crystal frequency is 24MHz (HSE) */ |
||||
|
||||
#define STM32_BOARD_XTAL 24000000ul |
||||
|
||||
/* Use the HSE output as the system clock */ |
||||
|
||||
#define STM32_SYSCLK_SW RCC_CFGR_SW_HSE |
||||
#define STM32_SYSCLK_SWS RCC_CFGR_SWS_HSE |
||||
#define STM32_SYSCLK_FREQUENCY STM32_BOARD_XTAL |
||||
|
||||
/* AHB clock (HCLK) is SYSCLK (24MHz) */ |
||||
|
||||
#define STM32_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK |
||||
#define STM32_HCLK_FREQUENCY STM32_SYSCLK_FREQUENCY |
||||
#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* same as above, to satisfy compiler */ |
||||
|
||||
/* APB2 clock (PCLK2) is HCLK (24MHz) */ |
||||
|
||||
#define STM32_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK |
||||
#define STM32_PCLK2_FREQUENCY STM32_HCLK_FREQUENCY |
||||
#define STM32_APB2_CLKIN (STM32_PCLK2_FREQUENCY) /* Timers 2-4 */ |
||||
|
||||
/* APB2 timer 1 will receive PCLK2. */ |
||||
|
||||
#define STM32_APB2_TIM1_CLKIN (STM32_PCLK2_FREQUENCY) |
||||
#define STM32_APB2_TIM15_CLKIN (STM32_PCLK2_FREQUENCY) |
||||
#define STM32_APB2_TIM16_CLKIN (STM32_PCLK2_FREQUENCY) |
||||
#define STM32_APB2_TIM17_CLKIN (STM32_PCLK2_FREQUENCY) |
||||
|
||||
/* APB1 clock (PCLK1) is HCLK (24MHz) */ |
||||
|
||||
#define STM32_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLK |
||||
#define STM32_PCLK1_FREQUENCY (STM32_HCLK_FREQUENCY) |
||||
|
||||
/* All timers run off PCLK */ |
||||
|
||||
|
||||
#define STM32_APB1_TIM2_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
#define STM32_APB1_TIM3_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
#define STM32_APB1_TIM4_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
#define STM32_APB1_TIM5_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
#define STM32_APB1_TIM12_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
#define STM32_APB1_TIM13_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
#define STM32_APB1_TIM14_CLKIN (STM32_PCLK1_FREQUENCY) |
||||
|
||||
/* Timer Frequencies, if APBx is set to 1, frequency is same to APBx
|
||||
* otherwise frequency is 2xAPBx. |
||||
* Note: TIM1, 15-17 are on APB2, others on APB1 |
||||
*/ |
||||
|
||||
#define BOARD_TIM1_FREQUENCY STM32_APB2_TIM1_CLKIN |
||||
#define BOARD_TIM2_FREQUENCY STM32_APB1_TIM2_CLKIN |
||||
#define BOARD_TIM3_FREQUENCY STM32_APB1_TIM3_CLKIN |
||||
#define BOARD_TIM4_FREQUENCY STM32_APB1_TIM4_CLKIN |
||||
#define BOARD_TIM5_FREQUENCY STM32_APB1_TIM5_CLKIN |
||||
#define BOARD_TIM6_FREQUENCY STM32_APB1_TIM6_CLKIN |
||||
#define BOARD_TIM7_FREQUENCY STM32_APB1_TIM7_CLKIN |
||||
#define BOARD_TIM12_FREQUENCY STM32_APB1_TIM12_CLKIN |
||||
#define BOARD_TIM13_FREQUENCY STM32_APB1_TIM13_CLKIN |
||||
#define BOARD_TIM14_FREQUENCY STM32_APB1_TIM14_CLKIN |
||||
#define BOARD_TIM15_FREQUENCY STM32_APB2_TIM15_CLKIN |
||||
#define BOARD_TIM16_FREQUENCY STM32_APB2_TIM16_CLKIN |
||||
#define BOARD_TIM17_FREQUENCY STM32_APB2_TIM17_CLKIN |
||||
|
||||
|
||||
/*
|
||||
* Some of the USART pins are not available; override the GPIO |
||||
* definitions with an invalid pin configuration. |
||||
*/ |
||||
#undef GPIO_USART2_CTS |
||||
#define GPIO_USART2_CTS 0xffffffff |
||||
#undef GPIO_USART2_RTS |
||||
#define GPIO_USART2_RTS 0xffffffff |
||||
#undef GPIO_USART2_CK |
||||
#define GPIO_USART2_CK 0xffffffff |
||||
#undef GPIO_USART3_CK |
||||
#define GPIO_USART3_CK 0xffffffff |
||||
#undef GPIO_USART3_CTS |
||||
#define GPIO_USART3_CTS 0xffffffff |
||||
#undef GPIO_USART3_RTS |
||||
#define GPIO_USART3_RTS 0xffffffff |
||||
|
||||
#endif /* __ARCH_BOARD_BOARD_H */ |
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
# |
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT. |
||||
# |
||||
# You can use "make menuconfig" to make any modifications to the installed .config file. |
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your |
||||
# modifications. |
||||
# |
||||
# CONFIG_DEV_NULL is not set |
||||
CONFIG_ARCH="arm" |
||||
CONFIG_ARCH_BOARD_CUSTOM=y |
||||
CONFIG_ARCH_BOARD_CUSTOM_DIR="../nuttx-config" |
||||
CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y |
||||
CONFIG_ARCH_BOARD_CUSTOM_NAME="px4" |
||||
CONFIG_ARCH_CHIP="stm32" |
||||
CONFIG_ARCH_CHIP_STM32=y |
||||
CONFIG_ARCH_CHIP_STM32F100C8=y |
||||
CONFIG_ARMV7M_USEBASEPRI=y |
||||
CONFIG_BOARD_LOOPSPERMSEC=2000 |
||||
CONFIG_C99_BOOL8=y |
||||
CONFIG_DEBUG_FULLOPT=y |
||||
CONFIG_DEBUG_SYMBOLS=y |
||||
CONFIG_DEFAULT_SMALL=y |
||||
CONFIG_DISABLE_MOUNTPOINT=y |
||||
CONFIG_DISABLE_MQUEUE=y |
||||
CONFIG_DISABLE_PTHREAD=y |
||||
CONFIG_FDCLONE_DISABLE=y |
||||
CONFIG_FDCLONE_STDIO=y |
||||
CONFIG_HAVE_CXX=y |
||||
CONFIG_HAVE_CXXINITIALIZE=y |
||||
CONFIG_IDLETHREAD_STACKSIZE=280 |
||||
CONFIG_MAX_TASKS=2 |
||||
CONFIG_MAX_WDOGPARMS=2 |
||||
CONFIG_MM_FILL_ALLOCATIONS=y |
||||
CONFIG_MM_SMALL=y |
||||
CONFIG_NAME_MAX=12 |
||||
CONFIG_NFILE_DESCRIPTORS=3 |
||||
CONFIG_NFILE_STREAMS=0 |
||||
CONFIG_PREALLOC_TIMERS=0 |
||||
CONFIG_PREALLOC_WDOGS=1 |
||||
CONFIG_RAM_SIZE=8192 |
||||
CONFIG_RAM_START=0x20000000 |
||||
CONFIG_RAW_BINARY=y |
||||
CONFIG_SDCLONE_DISABLE=y |
||||
CONFIG_SERIAL_TERMIOS=y |
||||
CONFIG_STACK_COLORATION=y |
||||
CONFIG_START_DAY=30 |
||||
CONFIG_START_MONTH=11 |
||||
CONFIG_STDIO_DISABLE_BUFFERING=y |
||||
CONFIG_STM32_ADC1=y |
||||
CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y |
||||
CONFIG_STM32_DMA1=y |
||||
CONFIG_STM32_JTAG_SW_ENABLE=y |
||||
CONFIG_STM32_USART1=y |
||||
CONFIG_STM32_USART2=y |
||||
CONFIG_STM32_USART3=y |
||||
CONFIG_STM32_USART_SINGLEWIRE=y |
||||
CONFIG_TASK_NAME_SIZE=0 |
||||
CONFIG_USART1_RXBUFSIZE=64 |
||||
CONFIG_USART1_RXDMA=y |
||||
CONFIG_USART1_SERIAL_CONSOLE=y |
||||
CONFIG_USART1_TXBUFSIZE=32 |
||||
CONFIG_USART2_RXBUFSIZE=64 |
||||
CONFIG_USART2_TXBUFSIZE=64 |
||||
CONFIG_USART3_RXBUFSIZE=64 |
||||
CONFIG_USART3_RXDMA=y |
||||
CONFIG_USART3_TXBUFSIZE=64 |
||||
CONFIG_USEC_PER_TICK=1000 |
||||
CONFIG_USERMAIN_STACKSIZE=1100 |
||||
CONFIG_USER_ENTRYPOINT="user_start" |
||||
CONFIG_WDOG_INTRESERVE=0 |
@ -0,0 +1,136 @@
@@ -0,0 +1,136 @@
|
||||
/**************************************************************************** |
||||
* configs/px4io-v2/scripts/ld.script |
||||
* |
||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. |
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> |
||||
* |
||||
* 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. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
/* The STM32F100C8 has 64Kb of FLASH beginning at address 0x0800:0000 and |
||||
* 8Kb of SRAM beginning at address 0x2000:0000. When booting from FLASH, |
||||
* FLASH memory is aliased to address 0x0000:0000 where the code expects to |
||||
* begin execution by jumping to the entry point in the 0x0800:0000 address |
||||
* range. |
||||
*/ |
||||
|
||||
MEMORY |
||||
{ |
||||
flash (rx) : ORIGIN = 0x08001000, LENGTH = 60K |
||||
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K |
||||
} |
||||
|
||||
OUTPUT_ARCH(arm) |
||||
ENTRY(__start) /* treat __start as the anchor for dead code stripping */ |
||||
EXTERN(_vectors) /* force the vectors to be included in the output */ |
||||
|
||||
/* |
||||
* Ensure that abort() is present in the final object. The exception handling |
||||
* code pulled in by libgcc.a requires it (and that code cannot be easily avoided). |
||||
*/ |
||||
EXTERN(abort) |
||||
|
||||
SECTIONS |
||||
{ |
||||
.text : { |
||||
_stext = ABSOLUTE(.); |
||||
*(.vectors) |
||||
*(.text .text.*) |
||||
*(.fixup) |
||||
*(.gnu.warning) |
||||
*(.rodata .rodata.*) |
||||
*(.gnu.linkonce.t.*) |
||||
*(.glue_7) |
||||
*(.glue_7t) |
||||
*(.got) |
||||
*(.gcc_except_table) |
||||
*(.gnu.linkonce.r.*) |
||||
_etext = ABSOLUTE(.); |
||||
/* |
||||
* This is a hack to make the newlib libm __errno() call |
||||
* use the NuttX get_errno_ptr() function. |
||||
*/ |
||||
__errno = get_errno_ptr; |
||||
} > flash |
||||
|
||||
/* |
||||
* Init functions (static constructors and the like) |
||||
*/ |
||||
.init_section : { |
||||
_sinit = ABSOLUTE(.); |
||||
KEEP(*(.init_array .init_array.*)) |
||||
_einit = ABSOLUTE(.); |
||||
} > flash |
||||
|
||||
.ARM.extab : { |
||||
*(.ARM.extab*) |
||||
} > flash |
||||
|
||||
__exidx_start = ABSOLUTE(.); |
||||
.ARM.exidx : { |
||||
*(.ARM.exidx*) |
||||
} > flash |
||||
__exidx_end = ABSOLUTE(.); |
||||
|
||||
_eronly = ABSOLUTE(.); |
||||
|
||||
/* The STM32F100CB has 8Kb of SRAM beginning at the following address */ |
||||
|
||||
.data : { |
||||
_sdata = ABSOLUTE(.); |
||||
*(.data .data.*) |
||||
*(.gnu.linkonce.d.*) |
||||
CONSTRUCTORS |
||||
_edata = ABSOLUTE(.); |
||||
. = ALIGN(4); |
||||
} > sram AT > flash |
||||
|
||||
.bss : { |
||||
_sbss = ABSOLUTE(.); |
||||
*(.bss .bss.*) |
||||
*(.gnu.linkonce.b.*) |
||||
*(COMMON) |
||||
. = ALIGN(4); |
||||
_ebss = ABSOLUTE(.); |
||||
} > sram |
||||
|
||||
/* Stabs debugging sections. */ |
||||
.stab 0 : { *(.stab) } |
||||
.stabstr 0 : { *(.stabstr) } |
||||
.stab.excl 0 : { *(.stab.excl) } |
||||
.stab.exclstr 0 : { *(.stab.exclstr) } |
||||
.stab.index 0 : { *(.stab.index) } |
||||
.stab.indexstr 0 : { *(.stab.indexstr) } |
||||
.comment 0 : { *(.comment) } |
||||
.debug_abbrev 0 : { *(.debug_abbrev) } |
||||
.debug_info 0 : { *(.debug_info) } |
||||
.debug_line 0 : { *(.debug_line) } |
||||
.debug_pubnames 0 : { *(.debug_pubnames) } |
||||
.debug_aranges 0 : { *(.debug_aranges) } |
||||
} |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
############################################################################ |
||||
# |
||||
# 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. |
||||
# |
||||
############################################################################ |
||||
|
||||
add_library(drivers_board |
||||
init.c |
||||
timer_config.cpp |
||||
) |
||||
|
||||
target_link_libraries(drivers_board |
||||
PRIVATE |
||||
nuttx_arch |
||||
) |
@ -0,0 +1,170 @@
@@ -0,0 +1,170 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* Copyright (c) 2013, 2014 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 board_config.h |
||||
* |
||||
* PX4IOV2 internal definitions |
||||
*/ |
||||
|
||||
#pragma once |
||||
|
||||
/******************************************************************************
|
||||
* Included Files |
||||
******************************************************************************/ |
||||
|
||||
#include <px4_platform_common/px4_config.h> |
||||
#include <nuttx/compiler.h> |
||||
#include <stdint.h> |
||||
|
||||
#include <px4_platform_common/board_common.h> |
||||
|
||||
/******************************************************************************
|
||||
* Definitions |
||||
******************************************************************************/ |
||||
/* Configuration **************************************************************/ |
||||
|
||||
/******************************************************************************
|
||||
* Serial |
||||
******************************************************************************/ |
||||
#define PX4FMU_SERIAL_BASE STM32_USART2_BASE |
||||
#define PX4FMU_SERIAL_VECTOR STM32_IRQ_USART2 |
||||
#define PX4FMU_SERIAL_TX_GPIO GPIO_USART2_TX |
||||
#define PX4FMU_SERIAL_RX_GPIO GPIO_USART2_RX |
||||
#define PX4FMU_SERIAL_TX_DMA DMACHAN_USART2_TX |
||||
#define PX4FMU_SERIAL_RX_DMA DMACHAN_USART2_RX |
||||
#define PX4FMU_SERIAL_CLOCK STM32_PCLK1_FREQUENCY |
||||
#define PX4FMU_SERIAL_BITRATE 1500000 |
||||
|
||||
/******************************************************************************
|
||||
* GPIOS |
||||
******************************************************************************/ |
||||
|
||||
/* LEDS **********************************************************************/ |
||||
|
||||
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN14) |
||||
#define GPIO_LED2 (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN15) |
||||
#define GPIO_LED3 (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN13) |
||||
#define GPIO_LED4 (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN11) |
||||
|
||||
#define GPIO_HEATER_OFF (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN14) |
||||
|
||||
#define GPIO_PC14 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN14) |
||||
#define GPIO_PC15 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN15) |
||||
|
||||
/* PixHawk 1:
|
||||
* PC14 Floating |
||||
* PC15 Floating |
||||
* |
||||
* PixHawk 2: |
||||
* PC14 3.3v |
||||
* PC15 GND |
||||
*/ |
||||
|
||||
#define GPIO_SENSE_PC14_DN (GPIO_INPUT|GPIO_CNF_INPULLDWN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN14) |
||||
#define GPIO_SENSE_PC15_UP (GPIO_INPUT|GPIO_CNF_INPULLUP|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN15) |
||||
# define SENSE_PH1 0b10 /* Floating pulled as set */ |
||||
# define SENSE_PH2 0b01 /* Driven as tied */ |
||||
|
||||
#define GPIO_HEATER_OFF (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN14) |
||||
|
||||
#define GPIO_USART1_RX_SPEKTRUM (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN10) |
||||
|
||||
/* Safety switch button *******************************************************/ |
||||
|
||||
#define GPIO_BTN_SAFETY (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN5) |
||||
|
||||
/* Power switch controls ******************************************************/ |
||||
|
||||
#define GPIO_SPEKTRUM_PWR_EN (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN13) |
||||
#define SPEKTRUM_POWER(_on_true) px4_arch_gpiowrite(GPIO_SPEKTRUM_PWR_EN, (_on_true)) |
||||
|
||||
#define SPEKTRUM_OUT(_one_true) px4_arch_gpiowrite(GPIO_USART1_RX_SPEKTRUM, (_one_true)) |
||||
#define SPEKTRUM_RX_AS_UART() px4_arch_configgpio(GPIO_USART1_RX) |
||||
#define SPEKTRUM_RX_AS_GPIO_OUTPUT() px4_arch_configgpio(GPIO_USART1_RX_SPEKTRUM) |
||||
|
||||
#define GPIO_SERVO_FAULT_DETECT (GPIO_INPUT|GPIO_CNF_INPULLUP|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15) |
||||
|
||||
/* Analog inputs **************************************************************/ |
||||
|
||||
#define GPIO_ADC_VSERVO (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4) |
||||
|
||||
/* the same rssi signal goes to both an adc and a timer input */ |
||||
#define GPIO_ADC_RSSI (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5) |
||||
#define GPIO_TIM_RSSI (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN12) |
||||
|
||||
/* PWM pins **************************************************************/ |
||||
|
||||
#define GPIO_PPM (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN8) |
||||
|
||||
#define GPIO_PWM1 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN0) |
||||
#define GPIO_PWM2 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN1) |
||||
#define GPIO_PWM3 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN8) |
||||
#define GPIO_PWM4 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN9) |
||||
#define GPIO_PWM5 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN6) |
||||
#define GPIO_PWM6 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN7) |
||||
#define GPIO_PWM7 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN0) |
||||
#define GPIO_PWM8 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN1) |
||||
|
||||
#define DIRECT_PWM_OUTPUT_CHANNELS 8 |
||||
|
||||
/* SBUS pins *************************************************************/ |
||||
|
||||
/* XXX these should be UART pins */ |
||||
#define GPIO_SBUS_INPUT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN11) |
||||
#define GPIO_SBUS_OUTPUT (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN10) |
||||
#define GPIO_SBUS_OENABLE (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN4) |
||||
|
||||
/*
|
||||
* High-resolution timer |
||||
*/ |
||||
#define HRT_TIMER 1 /* use timer1 for the HRT */ |
||||
#define HRT_TIMER_CHANNEL 2 /* use capture/compare channel 2 */ |
||||
#define HRT_PPM_CHANNEL 1 /* use capture/compare channel 1 PA8 */ |
||||
#define GPIO_PPM_IN (GPIO_ALT|GPIO_CNF_INPULLUP|GPIO_PORTA|GPIO_PIN8) |
||||
|
||||
/* LED definitions ******************************************************************/ |
||||
/* PX4 has two LEDs that we will encode as: */ |
||||
|
||||
#define LED_STARTED 0 /* LED? */ |
||||
#define LED_HEAPALLOCATE 1 /* LED? */ |
||||
#define LED_IRQSENABLED 2 /* LED? + LED? */ |
||||
#define LED_STACKCREATED 3 /* LED? */ |
||||
#define LED_INIRQ 4 /* LED? + LED? */ |
||||
#define LED_SIGNAL 5 /* LED? + LED? */ |
||||
#define LED_ASSERTION 6 /* LED? + LED? + LED? */ |
||||
#define LED_PANIC 7 /* N/C + N/C + N/C + LED? */ |
||||
|
||||
#define BOARD_NUM_IO_TIMERS 3 |
||||
|
||||
#define BOARD_DISABLE_I2C_SPI |
@ -0,0 +1,165 @@
@@ -0,0 +1,165 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* Copyright (C) 2012 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 px4iov2_init.c |
||||
* |
||||
* PX4FMU-specific early startup code. This file implements the |
||||
* stm32_boardinitialize() function that is called during cpu startup. |
||||
* |
||||
* Code here is run before the rcS script is invoked; it should start required |
||||
* subsystems and perform board-specific initialization. |
||||
*/ |
||||
|
||||
/****************************************************************************
|
||||
* Included Files |
||||
****************************************************************************/ |
||||
|
||||
#include <px4_platform_common/px4_config.h> |
||||
|
||||
#include <stdbool.h> |
||||
#include <stdio.h> |
||||
#include <debug.h> |
||||
#include <errno.h> |
||||
|
||||
#include <nuttx/board.h> |
||||
|
||||
#include <stm32.h> |
||||
#include "board_config.h" |
||||
|
||||
#include <arch/board/board.h> |
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions |
||||
****************************************************************************/ |
||||
|
||||
/****************************************************************************
|
||||
* Protected Functions |
||||
****************************************************************************/ |
||||
|
||||
/****************************************************************************
|
||||
* Public Functions |
||||
****************************************************************************/ |
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_boardinitialize |
||||
* |
||||
* Description: |
||||
* All STM32 architectures must provide the following entry point. This entry point |
||||
* is called early in the intitialization -- after all memory has been configured |
||||
* and mapped but before any devices have been initialized. |
||||
* |
||||
************************************************************************************/ |
||||
|
||||
__EXPORT void stm32_boardinitialize(void) |
||||
{ |
||||
|
||||
/* configure GPIOs */ |
||||
|
||||
/* Set up for sensing HW */ |
||||
|
||||
stm32_configgpio(GPIO_SENSE_PC14_DN); |
||||
stm32_configgpio(GPIO_SENSE_PC15_UP); |
||||
|
||||
/* LEDS - default to off */ |
||||
stm32_configgpio(GPIO_LED1); |
||||
stm32_configgpio(GPIO_LED2); |
||||
stm32_configgpio(GPIO_LED3); |
||||
stm32_configgpio(GPIO_LED4); |
||||
|
||||
/* PixHawk 1:
|
||||
* PC14 Floating |
||||
* PC15 Floating |
||||
* |
||||
* PixHawk 2: |
||||
* PC14 3.3v |
||||
* PC15 GND |
||||
*/ |
||||
|
||||
uint8_t sense = stm32_gpioread(GPIO_SENSE_PC15_UP) << 1 | stm32_gpioread(GPIO_SENSE_PC14_DN); |
||||
|
||||
if (sense == SENSE_PH2) { |
||||
stm32_configgpio(GPIO_HEATER_OFF); |
||||
} |
||||
|
||||
stm32_configgpio(GPIO_PC14); |
||||
stm32_configgpio(GPIO_PC15); |
||||
|
||||
|
||||
stm32_configgpio(GPIO_BTN_SAFETY); |
||||
|
||||
/* spektrum power enable is active high - enable it by default */ |
||||
stm32_configgpio(GPIO_SPEKTRUM_PWR_EN); |
||||
|
||||
stm32_configgpio(GPIO_SERVO_FAULT_DETECT); |
||||
|
||||
/* RSSI inputs */ |
||||
stm32_configgpio(GPIO_TIM_RSSI); /* xxx alternate function */ |
||||
stm32_configgpio(GPIO_ADC_RSSI); |
||||
|
||||
/* servo rail voltage */ |
||||
stm32_configgpio(GPIO_ADC_VSERVO); |
||||
|
||||
stm32_configgpio(GPIO_SBUS_INPUT); /* xxx alternate function */ |
||||
stm32_configgpio(GPIO_SBUS_OUTPUT); |
||||
|
||||
/* sbus output enable is active low - disable it by default */ |
||||
stm32_gpiowrite(GPIO_SBUS_OENABLE, true); |
||||
stm32_configgpio(GPIO_SBUS_OENABLE); |
||||
|
||||
stm32_configgpio(GPIO_PPM); /* xxx alternate function */ |
||||
|
||||
stm32_gpiowrite(GPIO_PWM1, true); |
||||
stm32_configgpio(GPIO_PWM1); |
||||
|
||||
stm32_gpiowrite(GPIO_PWM2, true); |
||||
stm32_configgpio(GPIO_PWM2); |
||||
|
||||
stm32_gpiowrite(GPIO_PWM3, true); |
||||
stm32_configgpio(GPIO_PWM3); |
||||
|
||||
stm32_gpiowrite(GPIO_PWM4, true); |
||||
stm32_configgpio(GPIO_PWM4); |
||||
|
||||
stm32_gpiowrite(GPIO_PWM5, true); |
||||
stm32_configgpio(GPIO_PWM5); |
||||
|
||||
stm32_gpiowrite(GPIO_PWM6, true); |
||||
stm32_configgpio(GPIO_PWM6); |
||||
|
||||
stm32_gpiowrite(GPIO_PWM7, true); |
||||
stm32_configgpio(GPIO_PWM7); |
||||
|
||||
stm32_gpiowrite(GPIO_PWM8, true); |
||||
stm32_configgpio(GPIO_PWM8); |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* Copyright (C) 2012 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_arch/io_timer_hw_description.h> |
||||
|
||||
constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { |
||||
initIOTimer(Timer::Timer2), |
||||
initIOTimer(Timer::Timer3), |
||||
initIOTimer(Timer::Timer4), |
||||
}; |
||||
|
||||
constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { |
||||
initIOTimerChannel(io_timers, {Timer::Timer2, Timer::Channel1}, {GPIO::PortA, GPIO::Pin0}), |
||||
initIOTimerChannel(io_timers, {Timer::Timer2, Timer::Channel2}, {GPIO::PortA, GPIO::Pin1}), |
||||
initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel3}, {GPIO::PortB, GPIO::Pin8}), |
||||
initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel4}, {GPIO::PortB, GPIO::Pin9}), |
||||
initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel1}, {GPIO::PortA, GPIO::Pin6}), |
||||
initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel2}, {GPIO::PortA, GPIO::Pin7}), |
||||
initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel3}, {GPIO::PortB, GPIO::Pin0}), |
||||
initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel4}, {GPIO::PortB, GPIO::Pin1}), |
||||
}; |
||||
|
||||
constexpr io_timers_channel_mapping_t io_timers_channel_mapping = |
||||
initIOTimerChannelMapping(io_timers, timer_io_channels); |
Loading…
Reference in new issue