Skip to content

Commit

Permalink
Add NEUTRONRCF435 support including AT32F435RGT7 1M FLASH
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveCEvans committed Mar 19, 2023
1 parent 6ff80a4 commit 6ac6545
Show file tree
Hide file tree
Showing 15 changed files with 224 additions and 12 deletions.
6 changes: 5 additions & 1 deletion make/mcu/AT32F4.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ INCLUDE_DIRS := $(INCLUDE_DIRS) \
$(MIDDLEWARES_DIR)/usbd_class/msc \
$(VCP_INCLUDES)

LD_SCRIPT = $(LINKER_DIR)/at32_flash_f43xM.ld
ifeq ($(TARGET),AT32F435M)
LD_SCRIPT = $(LINKER_DIR)/at32_flash_f43xm.ld
else
LD_SCRIPT = $(LINKER_DIR)/at32_flash_f43xg.ld
endif

ARCH_FLAGS = -std=c99 -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion
DEVICE_FLAGS += -DUSE_ATBSP_DRIVER -DAT32F43x -DHSE_VALUE=$(HSE_VALUE) -DAT32 -DUSE_OTG_HOST_MODE
Expand Down
2 changes: 1 addition & 1 deletion src/config/ATSTARTF435/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#define FC_TARGET_MCU AT32F435
#define FC_TARGET_MCU AT32F435M

#define BOARD_NAME ATSTARTF435
#define MANUFACTURER_ID AT
Expand Down
67 changes: 67 additions & 0 deletions src/config/NEUTRONRCF435/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* This file is part of Betaflight.
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software 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.
*
* Betaflight 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/>.
*/

#define FC_TARGET_MCU AT32F435G

#define BOARD_NAME NEUTRONRCF435
#define MANUFACTURER_ID NERC

#define LED0_PIN PC4

#define USE_GYRO
#define USE_ACC
#define USE_ACCGYRO_BMI270
#define GYRO_1_CS_PIN PA15
#define GYRO_1_SPI_INSTANCE SPI1
#define GYRO_1_ALIGN CW270_DEG

// MPU6000 interrupts
#define USE_EXTI
#define USE_GYRO_EXTI
#define GYRO_1_EXTI_PIN PB8

#define SPI1_SCK_PIN PA5
#define SPI2_SCK_PIN PB13
#define SPI3_SCK_PIN PB3
#define SPI1_SDI_PIN PA6
#define SPI2_SDI_PIN PB14
#define SPI3_SDI_PIN PB4
#define SPI1_SDO_PIN PA7
#define SPI2_SDO_PIN PB15
#define SPI3_SDO_PIN PB5

#define USE_FLASH
#define USE_FLASH_W25Q128FV
#define FLASH_CS_PIN PB9
#define FLASH_SPI_INSTANCE SPI3

#define I2C2_SCL_PIN PB10
#define I2C2_SDA_PIN PB11

#define BARO_I2C_INSTANCE I2CDEV_2
#define USE_BARO
#define USE_BARO_BMP280
#define USE_BARO_DPS310

#define USE_MAX7456
#define MAX7456_SPI_INSTANCE SPI2
#define MAX7456_SPI_CS_PIN PB12

2 changes: 1 addition & 1 deletion src/config/REVO_AT/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#define FC_TARGET_MCU AT32F435
#define FC_TARGET_MCU AT32F435M

// REVO with STM32F405 swapped for an AT32F435

Expand Down
41 changes: 41 additions & 0 deletions src/link/at32_flash_f43xg.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
*****************************************************************************
**
** File : at32_flash_f43xG.ld
**
** Abstract : Linker script for AT32F435/7xG Device with
** 1024KByte FLASH, 384KByte RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : Artery Tek AT32
**
** Environment : Arm gcc toolchain
**
*****************************************************************************
*/

/*
FLASH : 0x0800 0000 -- 0x083E FFFF
MEM : 0x2000 0000 -- 0x2007 FFFF
*/

MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 16K
FLASH_CONFIG (r) : ORIGIN = 0x08004000, LENGTH = 16K
FLASH1 (rx) : ORIGIN = 0x08008000, LENGTH = 992K
SYSTEM_MEMORY (rx) : ORIGIN = 0x1FFF0000, LENGTH = 16K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K /* external ram */
}

REGION_ALIAS("STACKRAM", RAM)
REGION_ALIAS("VECTAB", RAM)

REGION_ALIAS("MOVABLE_FLASH", FLASH1)

INCLUDE "at32_flash_f4_split.ld"
File renamed without changes.
2 changes: 1 addition & 1 deletion src/link/at32_flash_f4_split.ld
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**
** File : at32_flash_f4_split.ld
**
** Abstract : Common linker script for STM32 devices.
** Abstract : Common linker script for AT32 devices.
**
*****************************************************************************
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/config/config_streamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ int config_streamer_flush(config_streamer_t *c)
c->err = write_word(c, &c->buffer.w);
c->at = 0;
}
return c-> err;
return c->err;
}

int config_streamer_finish(config_streamer_t *c)
Expand Down
2 changes: 1 addition & 1 deletion src/main/drivers/at32/platform_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#pragma once

#if defined(AT32F435ZMT7)
#if defined(AT32F435)

#include "at32f435_437.h"
#include "at32f435_437_i2c.h"
Expand Down
5 changes: 0 additions & 5 deletions src/main/target/AT32F435/target.mk

This file was deleted.

96 changes: 96 additions & 0 deletions src/main/target/AT32F435G/target.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* This file is part of Cleanflight and Betaflight.
*
* Cleanflight and Betaflight are free software. You can redistribute
* this software and/or modify this software 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 and Betaflight are distributed in the hope that they
* 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 TARGET_BOARD_IDENTIFIER "A435"

#define USBD_PRODUCT_STRING "Betaflight AT32F435"

#ifndef AT32F435
#define AT32F435
#endif

#ifdef DEBUG
// Development aid - invalid inputs or other failures are tested and will sit in a while(true) loop
// so that you can go straight to the problem with the debugger
#define HANG_ON_ERRORS
#endif

#define USE_VIRTUAL_GYRO

#define USE_UART1
#define USE_UART2
#define USE_UART3
#define SERIAL_PORT_COUNT (UNIFIED_SERIAL_PORT_COUNT + 3)

#define TARGET_IO_PORTA 0xffff
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff

#define USE_SPI
#define USE_SPI_DEVICE_1
#define USE_SPI_DEVICE_2
#define USE_SPI_DEVICE_3
#define USE_SPI_DMA_ENABLE_LATE

#define USE_EXTI
#define USE_GYRO_EXTI


#define USE_I2C
#define USE_I2C_DEVICE_1
#define USE_I2C_DEVICE_2
#define USE_I2C_DEVICE_3

#define USE_USB_DETECT
#define USE_PERSISTENT_MSC_RTC
#define USE_VCP

#define UNIFIED_SERIAL_PORT_COUNT 1

#define USE_ADC

#define USE_PWM_OUTPUT

// Remove these undefines as support is added
//#undef USE_BEEPER
#undef USE_LED_STRIP
#undef USE_TRANSPONDER

// #undef USE_DSHOT
// #undef USE_DSHOT_TELEMETRY
// bitbang not implemented yet
#undef USE_DSHOT_BITBANG
// burst mode not implemented yet
#undef USE_DSHOT_DMAR


#undef USE_CAMERA_CONTROL
#undef USE_RX_PPM
#undef USE_RX_PWM
#undef USE_RX_SPI
#undef USE_RX_CC2500
#undef USE_RX_EXPRESSLRS
// #undef USE_SERIAL_4WAY_BLHELI_BOOTLOADER
#undef USE_SERIAL_4WAY_SK_BOOTLOADER

#define FLASH_PAGE_SIZE ((uint32_t)0x0800) // 2K sectors
5 changes: 5 additions & 0 deletions src/main/target/AT32F435G/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TARGET_MCU := AT32F435
MCU_FLASH_SIZE := 1024
DEVICE_FLAGS = -D$(TARGET_MCU) -DAT32F435RGT7
TARGET_MCU_FAMILY := AT32F4
#error
File renamed without changes.
4 changes: 4 additions & 0 deletions src/main/target/AT32F435M/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TARGET_MCU := AT32F435
MCU_FLASH_SIZE := 4096
DEVICE_FLAGS = -D$(TARGET_MCU) -DAT32F435ZMT7
TARGET_MCU_FAMILY := AT32F4
2 changes: 1 addition & 1 deletion src/main/target/common_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
#define USE_I2C_GYRO
#endif

#if defined(USE_GYRO_SPI_ICM20689) || defined(USE_GYRO_SPI_MPU6000) || defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_L3GD20) || defined(USE_GYRO_SPI_ICM42605) || defined(USE_GYRO_SPI_ICM42688P) || defined(USE_ACCGYRO_BMI270)
#if defined(USE_GYRO_SPI_ICM20689) || defined(USE_GYRO_SPI_MPU6000) || defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_L3GD20) || defined(USE_GYRO_SPI_ICM42605) || defined(USE_GYRO_SPI_ICM42688P) || defined(USE_ACCGYRO_BMI160) || defined(USE_ACCGYRO_BMI270)
#define USE_SPI_GYRO
#endif

Expand Down

0 comments on commit 6ac6545

Please sign in to comment.