Clean up Crazyflie

1) Remove uneeded spi and reset code
   2) Use the Board commin for providing the BOARD_NAME
   3) Add PX4_PWM_ALTERNATE_RANGES in suport of a board agnostic
      way to override the PWM_.*_{MIN|MAX} values
   4) Remove #ifdefs from the IO timers*. Drive the config deltas
      from the crazyflie_timer_config.c and one board agnostic
      ifdef PX4_IO_TIMER_ALTERNATE_RATE that is non board specific

      *I would like to eliminate PX4_IO_TIMER_ALTERNATE_RATE
      as well, but I need HW to validate that the startup
      script can just set the rate on the PWM to 3921 fast
      enough to not effect the motors.
This commit is contained in:
David Sidrane
2016-11-01 10:07:46 -10:00
committed by Lorenz Meier
parent c4d91ef644
commit ab43baa02d
5 changed files with 55 additions and 62 deletions
+2 -1
View File
@@ -33,12 +33,13 @@
px4_add_module( px4_add_module(
MODULE drivers__boards__crazyflie MODULE drivers__boards__crazyflie
SRCS SRCS
../common/board_name.c
../common/board_dma_alloc.c
crazyflie_init.c crazyflie_init.c
crazyflie_usb.c crazyflie_usb.c
crazyflie_led.c crazyflie_led.c
crazyflie_timer_config.c crazyflie_timer_config.c
crazyflie_i2c.cpp crazyflie_i2c.cpp
crazyflie_spi.c
DEPENDS DEPENDS
platforms__common platforms__common
) )
+40 -7
View File
@@ -43,7 +43,7 @@
* Included Files * Included Files
****************************************************************************************************/ ****************************************************************************************************/
#include <nuttx/config.h> #include <px4_config.h>
#include <nuttx/compiler.h> #include <nuttx/compiler.h>
#include <stdint.h> #include <stdint.h>
@@ -154,6 +154,29 @@
#define GPIO_TIM4_CH4IN GPIO_TIM4_CH4IN_1 #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 */ /* High-resolution timer */
#define HRT_TIMER 8 /* use timer8 for the HRT */ #define HRT_TIMER 8 /* use timer8 for the HRT */
@@ -165,6 +188,8 @@
#define BOARD_FMU_GPIO_TAB { {0, 0, 0}, } #define BOARD_FMU_GPIO_TAB { {0, 0, 0}, }
#define BOARD_NAME "CRAZYFLIE"
__BEGIN_DECLS __BEGIN_DECLS
/**************************************************************************************************** /****************************************************************************************************
@@ -182,20 +207,26 @@ __BEGIN_DECLS
****************************************************************************************************/ ****************************************************************************************************/
/**************************************************************************************************** /****************************************************************************************************
* Name: stm32_spiinitialize * Name: board_spi_reset board_peripheral_reset
* *
* Description: * 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); #define board_spi_reset(ms)
void board_spi_reset(int ms); #define board_peripheral_reset(ms)
/****************************************************************************************************
* Name: stm32_usbinitialize
*
* Description:
* Called to configure USB IO.
*
****************************************************************************************************/
extern void stm32_usbinitialize(void); extern void stm32_usbinitialize(void);
extern void board_peripheral_reset(int ms);
/**************************************************************************** /****************************************************************************
* Name: nsh_archinitialize * Name: nsh_archinitialize
* *
@@ -225,6 +256,8 @@ int nsh_archinitialize(void);
int board_i2c_initialize(void); int board_i2c_initialize(void);
#include "../common/board_common.h"
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
__END_DECLS __END_DECLS
+1 -12
View File
@@ -115,17 +115,6 @@ __END_DECLS
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/************************************************************************************
* Name: board_peripheral_reset
*
* Description:
*
************************************************************************************/
__EXPORT void board_peripheral_reset(int ms)
{
}
/************************************************************************************ /************************************************************************************
* Name: stm32_boardinitialize * Name: stm32_boardinitialize
* *
@@ -195,7 +184,7 @@ __EXPORT int nsh_archinitialize(void)
result = board_i2c_initialize(); result = board_i2c_initialize();
if (result != OK) { if (result != OK) {
//led_on(1); led_on(LED_RED);
return -ENODEV; return -ENODEV;
} }
@@ -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 */
}
@@ -45,17 +45,26 @@
#include <stm32_gpio.h> #include <stm32_gpio.h>
#include <stm32_tim.h> #include <stm32_tim.h>
#include "board_config.h"
#include <drivers/drv_pwm_output.h> #include <drivers/drv_pwm_output.h>
#include <drivers/stm32/drv_io_timer.h> #include <drivers/stm32/drv_io_timer.h>
#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] = { __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = {
{ {
.base = STM32_TIM2_BASE, .base = STM32_TIM2_BASE,
.clock_register = STM32_RCC_APB1ENR, .clock_register = STM32_RCC_APB1ENR,
.clock_bit = RCC_APB1ENR_TIM2EN, .clock_bit = RCC_APB1ENR_TIM2EN,
.clock_freq = STM32_APB1_TIM2_CLKIN, .clock_freq = TIM2_CLKIN,
.first_channel_index = 0, .first_channel_index = 0,
.last_channel_index = 2, .last_channel_index = 2,
.handler = io_timer_handler0, .handler = io_timer_handler0,
@@ -65,7 +74,7 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = {
.base = STM32_TIM4_BASE, .base = STM32_TIM4_BASE,
.clock_register = STM32_RCC_APB1ENR, .clock_register = STM32_RCC_APB1ENR,
.clock_bit = RCC_APB1ENR_TIM4EN, .clock_bit = RCC_APB1ENR_TIM4EN,
.clock_freq = STM32_APB1_TIM4_CLKIN, .clock_freq = TIM4_CLKIN,
.first_channel_index = 3, .first_channel_index = 3,
.last_channel_index = 3, .last_channel_index = 3,
.handler = io_timer_handler1, .handler = io_timer_handler1,