mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 05:43:34 +08:00
Working motors and mtd for CF2
This commit is contained in:
committed by
Lorenz Meier
parent
b65ff53b00
commit
9c8e56401b
@@ -37,6 +37,7 @@ px4_add_module(
|
||||
crazyflie_usb.c
|
||||
crazyflie_led.c
|
||||
crazyflie_timer_config.c
|
||||
crazyflie_i2c.cpp
|
||||
DEPENDS
|
||||
platforms__common
|
||||
)
|
||||
|
||||
@@ -83,6 +83,8 @@ __BEGIN_DECLS
|
||||
#define PX4_I2C_BUS_ONBOARD_HZ 400000
|
||||
#define PX4_I2C_BUS_EXPANSION_HZ 400000
|
||||
|
||||
#define PX4_I2C_BUS_MTD PX4_I2C_BUS_EXPANSION
|
||||
|
||||
|
||||
|
||||
/* Devices on the onboard bus.
|
||||
@@ -127,6 +129,13 @@ __BEGIN_DECLS
|
||||
#define GPIO_TIM2_CH1OUT GPIO_TIM2_CH1OUT_2
|
||||
#define GPIO_TIM4_CH4OUT GPIO_TIM4_CH4OUT_1
|
||||
|
||||
#define GPIO_TIM2_CH2IN GPIO_TIM2_CH2IN_1
|
||||
#define GPIO_TIM2_CH4IN GPIO_TIM2_CH4IN_2
|
||||
#define GPIO_TIM2_CH1IN GPIO_TIM2_CH1IN_2
|
||||
#define GPIO_TIM4_CH4IN GPIO_TIM4_CH4IN_1
|
||||
|
||||
|
||||
|
||||
/* High-resolution timer */
|
||||
#define HRT_TIMER 8 /* use timer8 for the HRT */
|
||||
#define HRT_TIMER_CHANNEL 1 /* use capture/compare channel */
|
||||
@@ -176,6 +185,20 @@ extern void stm32_usbinitialize(void);
|
||||
int nsh_archinitialize(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2c_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called to set I2C bus frequncies.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_i2c_initialize(void);
|
||||
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2016 PX4 Development Team. All rights reserved.
|
||||
* Author: David Sidrane <david_s5@nscdg.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -145,6 +145,7 @@ __EXPORT int matherr(struct exception *e)
|
||||
|
||||
__EXPORT int nsh_archinitialize(void)
|
||||
{
|
||||
int result;
|
||||
|
||||
/* configure the high-resolution time/callout interface */
|
||||
hrt_init();
|
||||
@@ -175,10 +176,10 @@ __EXPORT int nsh_archinitialize(void)
|
||||
|
||||
result = board_i2c_initialize();
|
||||
|
||||
// if (result != OK) {
|
||||
if (result != OK) {
|
||||
// up_ledon(LED_AMBER);
|
||||
// return -ENODEV;
|
||||
// }
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stm32.h>
|
||||
#include <stm32_gpio_out.h>
|
||||
#include <stm32_gpio.h>
|
||||
#include <stm32_tim.h>
|
||||
|
||||
#include <drivers/stm32/drv_io_timer.h>
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
#include <drivers/stm32/drv_io_timer.h>
|
||||
|
||||
#include "board_config.h"
|
||||
|
||||
@@ -55,7 +55,7 @@ __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 = STM32_APB1_TIM2_CLKIN,
|
||||
.first_channel_index = 0,
|
||||
.last_channel_index = 2,
|
||||
.handler = io_timer_handler0,
|
||||
@@ -65,7 +65,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 = STM32_APB1_TIM4_CLKIN,
|
||||
.first_channel_index = 3,
|
||||
.last_channel_index = 3,
|
||||
.handler = io_timer_handler1,
|
||||
|
||||
@@ -72,10 +72,6 @@
|
||||
#include <drivers/drv_rc_input.h>
|
||||
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_controls_0.h>
|
||||
#include <uORB/topics/actuator_controls_1.h>
|
||||
#include <uORB/topics/actuator_controls_2.h>
|
||||
#include <uORB/topics/actuator_controls_3.h>
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
#include <uORB/topics/actuator_armed.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
@@ -1078,10 +1074,18 @@ crazyflie_main(int argc, char *argv[])
|
||||
errx(0, "Crazyflie driver stopped");
|
||||
}
|
||||
|
||||
if (crazyflie_start() != OK) {
|
||||
errx(1, "failed to start the Crazyflie driver");
|
||||
if (!strcmp(verb, "start")) {
|
||||
if (crazyflie_start() == OK) {
|
||||
errx(0, "Crazyflie driver started");
|
||||
}
|
||||
else {
|
||||
errx(1, "failed to start the Crazyflie driver");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: Ensure driver is running
|
||||
|
||||
if (!strcmp(verb, "test")) {
|
||||
test();
|
||||
}
|
||||
|
||||
@@ -80,10 +80,15 @@ int mtd_main(int argc, char *argv[])
|
||||
static void ramtron_attach(void);
|
||||
#else
|
||||
|
||||
#ifndef PX4_I2C_BUS_ONBOARD
|
||||
# error PX4_I2C_BUS_ONBOARD not defined, cannot locate onboard EEPROM
|
||||
#ifndef PX4_I2C_BUS_MTD
|
||||
# ifdef PX4_I2C_BUS_ONBOARD
|
||||
# define PX4_I2C_BUS_MTD PX4_I2C_BUS_ONBOARD
|
||||
# else
|
||||
# error PX4_I2C_BUS_MTD and PX4_I2C_BUS_ONBOARD not defined, cannot locate onboard EEPROM
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
static void at24xxx_attach(void);
|
||||
#endif
|
||||
static void mtd_start(char *partition_names[], unsigned n_partitions);
|
||||
@@ -225,7 +230,7 @@ static void
|
||||
at24xxx_attach(void)
|
||||
{
|
||||
/* find the right I2C */
|
||||
struct i2c_dev_s *i2c = px4_i2cbus_initialize(PX4_I2C_BUS_ONBOARD);
|
||||
struct i2c_dev_s *i2c = px4_i2cbus_initialize(PX4_I2C_BUS_MTD);
|
||||
/* this resets the I2C bus, set correct bus speed again */
|
||||
I2C_SETFREQUENCY(i2c, 400000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user