diff --git a/src/drivers/boards/crazyflie/CMakeLists.txt b/src/drivers/boards/crazyflie/CMakeLists.txt index f7c5ae68fb..d677d46ae7 100644 --- a/src/drivers/boards/crazyflie/CMakeLists.txt +++ b/src/drivers/boards/crazyflie/CMakeLists.txt @@ -33,12 +33,13 @@ px4_add_module( MODULE drivers__boards__crazyflie SRCS + ../common/board_name.c + ../common/board_dma_alloc.c crazyflie_init.c crazyflie_usb.c crazyflie_led.c crazyflie_timer_config.c crazyflie_i2c.cpp - crazyflie_spi.c DEPENDS platforms__common ) diff --git a/src/drivers/boards/crazyflie/board_config.h b/src/drivers/boards/crazyflie/board_config.h index 0146ef9d79..b77ca82bf2 100644 --- a/src/drivers/boards/crazyflie/board_config.h +++ b/src/drivers/boards/crazyflie/board_config.h @@ -43,7 +43,7 @@ * Included Files ****************************************************************************************************/ -#include +#include #include #include @@ -154,6 +154,29 @@ #define GPIO_TIM4_CH4IN GPIO_TIM4_CH4IN_1 +/* This board overrides the defaults by providing + * PX4_PWM_ALTERNATE_RANGES and a replacement set of + * constants + */ + + +/* PWM directly wired to transistor. Duty cycle directly corresponds to power + * So we need to override the defaults + */ + +#define PX4_PWM_ALTERNATE_RANGES +#define PWM_LOWEST_MIN 0 +#define PWM_MOTOR_OFF 0 +#define PWM_DEFAULT_MIN 0 +#define PWM_HIGHEST_MIN 0 +#define PWM_HIGHEST_MAX 255 +#define PWM_DEFAULT_MAX 255 +#define PWM_LOWEST_MAX 255 + +/* Override the io timers to update at 328.125 kHz (recommended) */ + +#define PX4_IO_TIMER_ALTERNATE_RATE 255 + /* High-resolution timer */ #define HRT_TIMER 8 /* use timer8 for the HRT */ @@ -165,6 +188,8 @@ #define BOARD_FMU_GPIO_TAB { {0, 0, 0}, } +#define BOARD_NAME "CRAZYFLIE" + __BEGIN_DECLS /**************************************************************************************************** @@ -182,20 +207,26 @@ __BEGIN_DECLS ****************************************************************************************************/ /**************************************************************************************************** - * Name: stm32_spiinitialize + * Name: board_spi_reset board_peripheral_reset * * Description: - * Called to configure SPI chip select GPIO pins for the PX4FMU board. + * Called to reset SPI and the perferal bus * ****************************************************************************************************/ -extern void stm32_spiinitialize(void); -void board_spi_reset(int ms); +#define board_spi_reset(ms) +#define board_peripheral_reset(ms) + +/**************************************************************************************************** + * Name: stm32_usbinitialize + * + * Description: + * Called to configure USB IO. + * + ****************************************************************************************************/ extern void stm32_usbinitialize(void); -extern void board_peripheral_reset(int ms); - /**************************************************************************** * Name: nsh_archinitialize * @@ -225,6 +256,8 @@ int nsh_archinitialize(void); int board_i2c_initialize(void); +#include "../common/board_common.h" + #endif /* __ASSEMBLY__ */ __END_DECLS diff --git a/src/drivers/boards/crazyflie/crazyflie_init.c b/src/drivers/boards/crazyflie/crazyflie_init.c index f22bc48838..646677e07b 100644 --- a/src/drivers/boards/crazyflie/crazyflie_init.c +++ b/src/drivers/boards/crazyflie/crazyflie_init.c @@ -115,17 +115,6 @@ __END_DECLS * Public Functions ****************************************************************************/ -/************************************************************************************ - * Name: board_peripheral_reset - * - * Description: - * - ************************************************************************************/ -__EXPORT void board_peripheral_reset(int ms) -{ - -} - /************************************************************************************ * Name: stm32_boardinitialize * @@ -195,7 +184,7 @@ __EXPORT int nsh_archinitialize(void) result = board_i2c_initialize(); if (result != OK) { - //led_on(1); + led_on(LED_RED); return -ENODEV; } diff --git a/src/drivers/boards/crazyflie/crazyflie_spi.c b/src/drivers/boards/crazyflie/crazyflie_spi.c deleted file mode 100644 index dfe2bb1258..0000000000 --- a/src/drivers/boards/crazyflie/crazyflie_spi.c +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** - * - * 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 "board_config.h" - -__EXPORT void board_spi_reset(int ms) -{ - /* Do nothing, no SPI devices used */ -} diff --git a/src/drivers/boards/crazyflie/crazyflie_timer_config.c b/src/drivers/boards/crazyflie/crazyflie_timer_config.c index 1f746dee1a..feedf26c7b 100644 --- a/src/drivers/boards/crazyflie/crazyflie_timer_config.c +++ b/src/drivers/boards/crazyflie/crazyflie_timer_config.c @@ -45,17 +45,26 @@ #include #include +#include "board_config.h" + #include #include -#include "board_config.h" + +/* IO Timers normally free-run at 1MHz + * Here we make adjustments to the Frequency that sets the timer's prescale + * so that the prescale is set to 0 + */ + +#define TIM2_CLKIN 1000000 +#define TIM4_CLKIN 1000000 __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = { { .base = STM32_TIM2_BASE, .clock_register = STM32_RCC_APB1ENR, .clock_bit = RCC_APB1ENR_TIM2EN, - .clock_freq = STM32_APB1_TIM2_CLKIN, + .clock_freq = TIM2_CLKIN, .first_channel_index = 0, .last_channel_index = 2, .handler = io_timer_handler0, @@ -65,7 +74,7 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = { .base = STM32_TIM4_BASE, .clock_register = STM32_RCC_APB1ENR, .clock_bit = RCC_APB1ENR_TIM4EN, - .clock_freq = STM32_APB1_TIM4_CLKIN, + .clock_freq = TIM4_CLKIN, .first_channel_index = 3, .last_channel_index = 3, .handler = io_timer_handler1,