Skip to content

Commit

Permalink
F446 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ezshinoda committed Jan 2, 2018
1 parent f6c7003 commit 67b9966
Show file tree
Hide file tree
Showing 11 changed files with 950 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ void PWR_ClearFlag(uint32_t PWR_FLAG)
/* Check the parameters */
assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));

#if defined (STM32F427_437xx) || defined (STM32F429_439xx)
#if defined (STM32F427_437xx) || defined (STM32F429_439xx) || defined (STM32F446xx)
if (PWR_FLAG != PWR_FLAG_UDRDY)
{
PWR->CR |= PWR_FLAG << 2;
Expand Down
2 changes: 1 addition & 1 deletion src/main/drivers/timer_stm32f4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const timerDef_t timerDefinitions[HARDWARE_TIMER_DEFINITION_COUNT] = {

uint32_t timerClock(TIM_TypeDef *tim)
{
#if defined (STM32F411xE)
#if defined (STM32F411xE) || defined (STM32F446xx)
UNUSED(tim);
return SystemCoreClock;
#elif defined (STM32F40_41xxx)
Expand Down
490 changes: 490 additions & 0 deletions src/main/startup/startup_stm32f446xx.s

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions src/main/target/NUCLEO_F446RE/config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/

#include <platform.h>

#ifdef USE_TARGET_CONFIG


#include "io/serial.h"


void targetConfiguration(void)
{

serialConfigMutable()->portConfigs[0].functionMask = FUNCTION_MSP;
serialConfigMutable()->portConfigs[1].functionMask = FUNCTION_MSP;
serialConfigMutable()->portConfigs[2].functionMask = FUNCTION_MSP;



}
#endif
36 changes: 36 additions & 0 deletions src/main/target/NUCLEO_F446RE/target.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>

#include <platform.h>
#include "drivers/io.h"

#include "drivers/timer.h"
#include "drivers/timer_def.h"
#include "drivers/dma.h"

const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 0, 1),
DEF_TIM(TIM8, CH1, PC6, TIM_USE_MOTOR, 0, 1),
DEF_TIM(TIM8, CH2, PC7, TIM_USE_MOTOR, 0, 1),
DEF_TIM(TIM8, CH3, PC8, TIM_USE_MOTOR, 0, 1),
DEF_TIM(TIM3, CH4, PB1, 0, 0, 0),
DEF_TIM(TIM3, CH2, PA4, 0, 0, 0),
DEF_TIM(TIM2, CH2, PA1, 0, 0, 0),
DEF_TIM(TIM2, CH3, PA2, 0, 0, 0)
};
153 changes: 153 additions & 0 deletions src/main/target/NUCLEO_F446RE/target.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* This software is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#define USE_TARGET_CONFIG

#define TARGET_BOARD_IDENTIFIER "N446" // STM32 Nucleo F446RE
#define USBD_PRODUCT_STRING "NucleoF446RE"

#define LED0_PIN PA5 // Onboard LED

//#define BEEPER PD12

#define USE_EXTI

#define USE_SPI
//#define USE_SPI_DEVICE_1
#define USE_SPI_DEVICE_2

#define SPI2_NSS_PIN PB12
#define SPI2_SCK_PIN PB13
#define SPI2_MISO_PIN PB14
#define SPI2_MOSI_PIN PB15

#define USE_GYRO
#define USE_FAKE_GYRO
#define USE_GYRO_SPI_MPU6500
#define USE_GYRO_SPI_MPU9250

#define USE_ACC
#define USE_FAKE_ACC
#define USE_ACC_SPI_MPU6500
#define USE_ACC_SPI_MPU9250

#define MPU9250_CS_PIN PB12
#define MPU9250_SPI_INSTANCE SPI2

#define MPU6500_CS_PIN PB12
#define MPU6500_SPI_INSTANCE SPI2

#define USE_EXTI

//#define MPU_INT_EXTI PC13
//#define USE_MPU_DATA_READY_SIGNAL
//#define ENSURE_MPU_DATA_READY_IS_LOW

#define USE_BARO
#define USE_FAKE_BARO
//#define USE_BARO_BMP085
//#define USE_BARO_BMP280
//#define USE_BARO_MS5611

//#define OSD
//#define USE_MAX7456
//#define MAX7456_SPI_INSTANCE SPI2
//#define MAX7456_SPI_CS_PIN SPI2_NSS_PIN

#define CMS

//#define USE_SDCARD
//
//#define SDCARD_SPI_INSTANCE SPI2
//#define SDCARD_SPI_CS_PIN PB12
//// SPI2 is on the APB1 bus whose clock runs at 36MHz. Divide to under 400kHz for init:
//#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 128
//// Divide to under 25MHz for normal operation:
//#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 2
//
//// Note, this is the same DMA channel as UART1_RX. Luckily we don't use DMA for USART Rx.
//#define SDCARD_DMA_CHANNEL_TX DMA1_Channel5
//#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA1_FLAG_TC5

// Performance logging for SD card operations:
// #define AFATFS_USE_INTROSPECTIVE_LOGGING

#define USE_MAG
#define USE_FAKE_MAG
//#define USE_MAG_AK8963
//#define USE_MAG_AK8975
//#define USE_MAG_HMC5883

#define USE_VCP

#define USE_UART1
#define UART1_TX_PIN PA9
#define UART1_RX_PIN PA10

#define USE_UART2
#define UART2_TX_PIN PA2
#define UART2_RX_PIN PA3

#define USE_UART3
#define UART3_TX_PIN PB10
#define UART3_RX_PIN PB11

//#define USE_UART4
//#define USE_UART5

#define USE_SOFTSERIAL1
#define USE_SOFTSERIAL2

#define SERIAL_PORT_COUNT 6

#define USE_ESCSERIAL
#define ESCSERIAL_TIMER_TX_PIN PB8 // (HARDARE=0,PPM)
#define USE_SERIAL_4WAY_BLHELI_INTERFACE

#define USE_I2C

#define USE_I2C_DEVICE_2
#define I2C2_SCL NONE // PB10, shared with UART3TX
#define I2C2_SDA NONE // PB11, shared with UART3RX

#define USE_I2C_DEVICE_3
#define I2C3_SCL NONE // PA8
#define I2C3_SDA NONE // PC9
#define I2C_DEVICE (I2CDEV_2)

#define USE_ADC
#define ADC_INSTANCE ADC1
#define VBAT_ADC_PIN PC0
#define CURRENT_METER_ADC_PIN PC1
#define RSSI_ADC_PIN PC2
#define EXTERNAL1_ADC_PIN PC3

#define USE_ESC_SENSOR

#define USE_SONAR
#define SONAR_TRIGGER_PIN PB0
#define SONAR_ECHO_PIN PB1

#define MAX_SUPPORTED_MOTORS 12

#define TARGET_IO_PORTA (0xffff & ~(BIT(14)|BIT(13)))
#define TARGET_IO_PORTB (0xffff & ~(BIT(2)))
#define TARGET_IO_PORTC (0xffff & ~(BIT(15)|BIT(14)|BIT(13)))
#define TARGET_IO_PORTD BIT(2)

#define USABLE_TIMER_CHANNEL_COUNT 12
#define USED_TIMERS (TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(8) )
10 changes: 10 additions & 0 deletions src/main/target/NUCLEO_F446RE/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
F446_TARGETS += $(TARGET)
FEATURES = VCP

TARGET_SRC = \
drivers/accgyro/accgyro_mpu6500.c \
drivers/accgyro/accgyro_spi_mpu6500.c \
drivers/accgyro/accgyro_spi_mpu9250.c \
drivers/accgyro/accgyro_fake.c \
drivers/barometer/barometer_fake.c \
drivers/compass/compass_fake.c
43 changes: 43 additions & 0 deletions src/main/target/SPEKTRUMF400/target.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>

#include <platform.h>
#include "drivers/io.h"

#include "drivers/timer.h"
#include "drivers/timer_def.h"
#include "drivers/dma.h"

const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, 0, 0), // pin 27 - M1 - DMA1_ST2
DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 0, 0), // pin 26 - M2 - DMA1_ST7
DEF_TIM(TIM3, CH2, PB5, TIM_USE_MOTOR, 0, 0), // pin 57 - M3 - DMA1_ST5
DEF_TIM(TIM3, CH1, PB4, TIM_USE_MOTOR, 0, 0), // pin 56 - M4 - DMA1_ST4
DEF_TIM(TIM8, CH1, PC6, TIM_USE_LED, 0, 0), // LED_STRIP - DMA2_ST2

// Backdoor timers
DEF_TIM(TIM1, CH2, PA9, TIM_USE_NONE , 0, 0), // UART1_TX T1C2
DEF_TIM(TIM1, CH3, PA10, TIM_USE_NONE , 0, 0), // UART1_RX T1C3

DEF_TIM(TIM2, CH3, PA2, TIM_USE_NONE , 0, 0), // UART2_TX T5C3,T9C1,T2C3
DEF_TIM(TIM9, CH2, PA3, TIM_USE_NONE , 0, 0), // UART2_RX T5C4,T9C2,T2C4

DEF_TIM(TIM5, CH1, PA0, TIM_USE_NONE , 0, 0), // UART4_TX T5C1
DEF_TIM(TIM5, CH2, PA1, TIM_USE_NONE , 0, 0), // UART4_RX T5C2,T2C2
};
Loading

0 comments on commit 67b9966

Please sign in to comment.