1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 11:29:58 +03:00
Commit graph

84 commits

Author SHA1 Message Date
Jay Blackman
53d44aa1b1
Adding common source location in ./src/platform (#14044)
* Adding common source location in ./src/platform

To enable the continued clean up of multiple files still in ./src/main/driver (more PRs to follow) that are specifically for AT32, APM32 and STM32

Source will be moved to MCU_COMMON_SRC where it is specifically for that MCU (or variant). The test will be to ensure no files in the MCU_EXCLUDES for SITL.

* Use of +=
2024-11-25 21:16:45 +01:00
nerdCopter
ed6a4a4769
duplicate emptyline removal (#14027)
* trailing space removal

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* deduplicate empty lines

---------

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
2024-11-15 23:07:25 +01:00
luckk
6dcc268918
Add apm32f405/f407 support (#13796)
* Add APM32F4 driver libraries and USB middleware

* Add the APM32F405 and APM32F407 target files

* Add APM32 startup files

* Add APM32F4 linker files

* Add APM32F4.mk

* Add APM32 driver files

* Add APM32F40X MCU type

* Sync with the Betaflight master branch and modify the driver directory structure

* Implement CLI on the APM32

* Implement ADC on the APM32

* Implement  config streamer on the APM32

* Implement I2C on the APM32

* Implement SPI on the APM32

* Implement DSHOT on the APM32

* Implement transponder ir on the APM32

* Implement serial uart on the APM32

* Implement MCO on the APM32

* Implement DWT on the APM32

* Update the init.c file, adding APM32 MCO configuration

* Remove all duplicated APM32 driver files and retaining only the APM32 LIB directory

* Create APM32F4.mk

* Add linker files for APM32F405 and APM32F407

* Add startup and library config files for APM32F405 and APM32F407

* Add target files for APM32F405 and APM32F407

* Add apm32 MCU driver files

* Add build configuration for APM32 MCU

* Implement config streamer on APM32

* Implement CLI on the APM32

* Implement ADC on the APM32

* Implement RCC on the APM32

* Implement MCO on the APM32

* Implement I2C on the APM32

* Implement SPI on the APM32

* Implement serial uart on the APM32

* Implement IO on the APM32

* Implement DMA on the APM32

* Implement DSHOT on the APM32

* Implement transponder ir on the APM32

* Update init.c

* Add the inclusion of the 'platform.h' file to the APM USB driver source file

* Merge bus SPI duplicate code from APM32 to STM32

* Update timer_apm32.c

* Merge motor duplicate code from APM32 to STM32

* Merge serial uart duplicate code from APM32 to STM32

* Update APM32F4.mk

* Update cli.c

* Update APM32F4.mk

* Remove the apm32_flash_f4_split.ld

* Associate the apm32 linker file with stm32_flash_f4_split.ld
2024-08-19 08:34:31 +10:00
Steve Evans
fe23761520
Add gyro jitter analysis to DEBUG_SCHEDULER_DETERMINISM (#13230) 2023-12-18 12:24:36 +01:00
Jan Post
2792d518d1
Implement Stopwatch (#12623)
* Implement stopwatch to measure time periods

* Add float version of stopwatchGetMicros()
2023-04-07 10:16:43 +10:00
Dominic Clifton
b3053be4dd
OctoSPI and Memory Mapped Flash support (#11825)
* STM32H730/STM32H750 - Fix use of USE_LP_UART1 instead of USE_LPUART1.

* STM32H723 - Prepare for being able to build for using non-internal-flash
config storage.

* STM32H723 - Prepare for using non-default strings.

* STM32H723 - Disable 'use custom defaults' when using USE_EXST.

* STM32H723 - Disable CUSTOM_DEFAULTS_EXTENDED when EXST is used.

* OCTOSPI - Add initialisation code.

* Add support for RAM_CODE.

* STM32H730 - Add support for RAM_CODE via the .ram_code attribute.

* OCTOSPI - Proof-of-concept for disabling/enabling memory mapped mode on
a running system.

NOTE: The HAL libs are compiled into a memory mapped region, and this cannot be used for OctoSPI access when memory mapped mode is disabled.

* OCTOSPI - Drop HAL support after determining that it's not suitable for
the memory mapped flash use-case.

* OCTOSPI - Sometimes, when disabling memory map mode, the abort fails.
Handle this by disabling the OSPI peripheral first and re-enabling it
afterwards.

* SD/FLASH - Update comments regarding possible solutions to the catch-22
issue with SD/SPI/QUADSPI/OCTOSPI pin configurations.

* OCTOSPI - Use device instance directly.

* OCTOSPI - Prepare W25Q flash driver for octospi support.

* OCTOSPI - Add octospi flash detection.

Note: The method to detect flash chips is similar to the method used for
QUADSPI and as such the code was used as a base. However the initial
OCTOSPI implementation doesn't support the non-memory-mapped use-case so
the un-tested code is gated with `USE_OCTOSPI_EXPERIMENTAL`.

The key differences are:
* uses octospi api not quadspi api.
* flash chip clock speeds should not be changed for memory-mapped flash
chips, bootloader already set it correctly.
* only certain flash chips are capable of memory mapped support.

* W25Q - Ensure w25q128fv_readRegister returns 0 if the receive fails.

* OCTOSPI - Implement octoSpiTransmit1LINE, octoSpiReceive1LINE and
octoSpiReceive4LINES.

* OCTOSPI - Specify device from init.

* OCTOSPI - More fixes and work on init.

Current status is that memory mapped mode is disabled and flash chip is
detected, but w25q128fv_detect should not be calling w25q128fv_reset.

* FLASH - Add comment regarding wasted flash space on targets that only
use one bus type for the flash chip.

* FLASH - Split `detect` into `identify` and `configure`.

* OCTOSPI - Extract flashMemoryMappedModeEnable/Disable to separate
methods.

* FLASH - Reduce size of targets that don't support the use of multiple
flash interfaces.

* Single-flash-chip targets usually only support one type of io
interface.
* Without this, compiler warnings are generated in `flashSpiInit` for
targets that only use flash chip drivers that support quadspi or octospi
that don't even use SPI for flash.

* FLASH - Use MMFLASH_CODE/DATA to conditionally move code/data to RAM.

Only targets compiled to support memory mapped flash chips need the some
specific code in RAM.  Otherwise the code/data should be in the normal
linker section.

* FLASH - W25Q Prepare for memory mapped flash usage.

* Wait/Delay functions must work with interrupts disabled.
* Code used for reading/writing must run from RAM.

* OCTOSPI - Implement remaining required methods.

* OCTOSPI - Fixes for earlier code (not last commit).

* FLASH - W25Q update timeout values from Datasheet Rev L.

* FLASH - Prepare flash driver for use when memory mapped flash is
disabled.

* System - Prepare microsISR for use when memory mapped flash is disabled.

* FLASH - Add support for CONFIG_IN_MEMORY_MAPPED_FLASH.

* Flash - Fix incorrect gating on cli flash commands.

When compiling with USE_FLASH_CHIP and without USE_FLASHFS there were
compiler warnings.

* MMFLASH - Fix release-mode build.

* FLASH - Allow SPI pins to be reconfigured when using CONFIG_IN_MEMORY_MAPPED_FLASH.

MMFLASH only works via QuadSPI/OctoSPI peripherals.

* EXST - Disable the 2GB workaround which is now causing a different
error.

The error we get with 'remove-section' enabled is:

"error in private header data: sorry, cannot handle this file".  The
cause of this new error in the objcopy codebase is an out of memory
condition, somehow the 2GB files and this error are related but the root
cause of both is still unknown.

* OCTOSPI - Add support for STM32H723.

* STM32H723 - Add linker scripts for EXST usage.

* NucleoH723ZG - Add build script to demonstrate OCTOSPI and Memory Mapped
flash support.

* FLASH - WUse the size in bits to set the size of the buffer.

* FLASH - Fix typo in W25N driver defines.

Was using W28N instead of W25N

* OCTOSPI - Fix missing semilcolon when compiling without
USE_FLASH_MEMORY_MAPPED.

* OCTPSPI - Fix missing call to 'memoryMappedModeInit'.

* SPRacingH7RF - Add example build script to allow for testing prior to
unified target / cloud-build support.
2023-02-04 06:24:01 +11:00
J Blackman
74be33dfbc
AT32 development, introduction of AT32F435 target (#12247)
* AT32F435: new target (#12159)
* AT32F435: New target (WIP)
* IO and Timer Updates
* Adding pseudonyms for the STM TypeDef items.
- implementation to follow
* Adding config_streamer support for AT32
* Implementation for IO
* Adding in Peripheral mapping from emsr.
* Warnings cleanup for AT drivers
* Getting things to the linking stage
* Add AT-START-F435 LEDs as default in AT32F435 as a temporary measure to aid bringup
* Remove tabs
* Enable selection of serial port to use for MSP
* Setup defaults for AT-START-F435 to use MSP on UART1
* Fix for most recent 4.5.0 Makefile changes
* Solve for sanity check.
* Add AT32F435 MCU type
* Fix compilation issue with SITL
* Merge conflict resolution
* Minor cleanup
* Adding line feed.

---------

Co-authored-by: Steve Evans <Steve@SCEvans.com>
2023-01-31 11:31:23 +11:00
Steve Evans
701b0ae55c Remove F1 and F3 support 2022-06-14 19:10:13 +01:00
Steve Evans
07f6bea174 Fix failsafe timings and behaviour to match Failsafe.md 2022-03-30 18:29:21 +01:00
Steve Evans
fb09cdb116 Fix ITM unlock 2021-10-07 01:42:17 +01:00
Steve Evans
d5f62be013 Trigger gyro SPI DMA reads in EXTI handler if supported and lock gyroTask loop to gyro to eliminate missed updates and jitter 2021-09-28 01:38:18 +13:00
DusKing1
73c87c0593 fix typos in code comments in common folder 2021-08-16 15:06:07 +08:00
Steve Evans
87c8847c13 New SPI API supporting DMA
Call targetConfiguration() once before config is loaded and again afterwards in case the config needs to be changed to load from SD card etc

Drop SPI clock during binding

Remove debug

Add per device SPI DMA enable

Fix sdioPinConfigure() declaration warning

Reduce clock speed during SPI RX initialisation
2021-07-25 12:40:25 +12:00
Sam Lane
4c99ad743d Rename FAST_RAM to FAST_DATA 2020-08-23 08:49:26 +01:00
mikeller
cd27b63b89 Exclude SWD pins from being initialised as pull up if unused. 2020-01-28 10:52:21 +13:00
jflyper
a88d5470eb Add unused pin state traverse and initialization facility 2020-01-21 12:18:43 +09:00
Dominic Clifton
376441f89f F3 - Add support for code in CCM RAM. 2019-09-02 18:40:13 +02:00
Dominic Clifton
d016aa2fc4 DSHOT - Use cycle counting instead of recording timestamp in dshot motor_DMA_IRQHandler.
It turns out that two calls to micros() and the calculation of
directionChangeDurationUs took 581 cycles, vs 396 cycles without the
calls to micros() and deferred calculation of the duration which is only
needed in the CLI.

This brings the time down from around 7 microseconds to 5.5 microseconds
on an F3 at 72Mhz.

This makes the difference between 100% invalid telemetry and 4% invalid
telemetry on the first motor on the F3.

Squashed commits:
* Remove the forward declaration for `pwmDshotSetDirectionInput` and make
it static.
* Remove unneeded forward declaration of `motor_DMA_IRQHandler`.
* Remove duplication in DMA IRQ Handler.
  Doesn't affect resulting code but improves readability.
* Use an inline function to read DWT->CYCCNT.
* Remove unneeded forward declarations from cli.c now that the correct
header is included.
* Update DWT unlock method.
2019-08-29 20:01:20 +02:00
mikeller
5cf42f40b6 Add booting into the flash boot loader as an option. 2019-06-16 14:46:38 +12:00
Dominic Clifton
91d6a1cc8d Move memory section initialisation earlier into the init sequence.
Allows startup-code/libs/etc to be moved into different memory regions.
2019-03-06 10:32:04 +01:00
Andrey Mironov
c0bac1c663
Used operator > to get rid of potential deadband 2018-07-12 21:42:09 +03:00
Andrey Mironov
a0d2f444ac Ensured micros() doesn't return a smaller value on millisecond bound 2018-07-12 16:40:02 +03:00
blckmn
a9f74cd6df Removed excess trailing spaces before new lines on licenses. 2018-04-25 20:58:00 +10:00
blckmn
46fe22b4bd Direct license replacement 2018-04-22 09:22:46 +10:00
mikeller
655c5fabc9 Improved arming disabled reason beeps. 2018-01-13 18:08:06 +13:00
blckmn
e8c4ef83d9 IO Clean up and use of Low level for F7
- Move F7 to optional LL driver for IO and
- cleaned up and removed the remaining old gpio functions from other targets
2017-07-28 04:03:56 +10:00
mikeller
67acc6c7ec Added beeps to indicate the reason for arming being disabled. 2017-07-04 01:38:04 +12:00
jflyper
2c7970a9ed Revive visual indication of gyro detection failure 2017-06-30 14:33:35 +09:00
Martin Budden
2493c214b0 Created subdirectories in drivers directory 2017-04-12 08:06:22 +01:00
Sami Korhonen
1f8805cdf0 squash betaflightF7
Parts and driver boost from @npsm
2016-10-21 08:51:02 +03:00
borisbstyle
e289f354a6 Merge pull request #1264 from jflyper/fix-micros-final
Fix micros using COUNTFLAG
2016-10-09 00:52:44 +02:00
jflyper
76392c2da7 Travis kick 2016-10-08 07:20:40 +09:00
jflyper
e948498695 atomic.h inclusion path fixed for development branch 2016-10-07 20:22:12 +09:00
jflyper
2a0e22f8b4 Travis, what did you do with common/atomic.h? 2016-10-05 02:00:02 +09:00
jflyper
a89c36b5e1 Cache sysTickPending inside ATOMIC_BLOCK 2016-10-04 03:53:59 +09:00
jflyper
59e78fcd8e Fix micros using COUNTFLAG
Current micros() may return past time when called from ISR or elevated BASEPRI context. This is because a call to the SysTick interrupt handler sysTick_Hanlder(), which is responsible for 1ms rollover is blocked in these contexts.

This PR introduces microsISR() that is guranteed to return correct time in these contexts. Legacy micros() was also modified to call microISR() in these contexts.

The microISR() uses SysTick's COUNTFLAG to detect a pending rollover and use it to compensate the return value on its own. Actual rollover to sysTickUptime variable is still handled in the sysTick_Hanlder().
2016-10-04 01:45:23 +09:00
Martin Budden
4d03791cbc Removed unused EXTI_CALLBACK_HANDLER_COUNT 2016-09-13 23:16:05 +01:00
Martin Budden
3d8ee50934 Removed unnecesary #includes from drivers 2016-07-11 18:45:35 +01:00
blckmn
948f2c6362 Removing some more target / platform specific code out of main.c and simplifying initialisation of system 2016-06-10 18:42:16 +10:00
blckmn
7ca39bbde6 STM32F4: Drivers 2016-06-08 05:37:08 +10:00
blckmn
928609e2bb Moving EXTI to new io
Updated i2c to use new io
2016-06-03 20:21:10 +10:00
cmenard
d174314692 Add Lux target 2016-02-02 23:03:08 +01:00
borisbstyle
52868ddc00 Merge commit 'fix_waiting_for_data_problem' into betaflight 2015-11-05 01:23:40 +01:00
ProDrone
c40db74e61 Working - except when exiting from bootloader
Fixes the `Waiting for Data` problem in configurator when:

- Clicking on `Save and Reboot` button
- Clicking on `Flash Firmware`  button

When the system reboots after programming the new firmware it still
needs a connect/disconnect cycle to work normal. This cannot be solved
since the bootloader is a fixed program in ROM.

Fix is for F1 targets and only tested on naze boards.
2015-10-27 20:09:59 +01:00
borisbstyle
eb138dc601 COLIBRI_RACE MPU_DATA_READY Handler
Colibri Race MPU INT support

revert some things

revert more

Update Colibri Race Binaries

Update target.h Colibri_race

Update Target.h
2015-10-16 12:41:49 +02:00
Dominic Clifton
4da387e93d More cleanup of MPU driver code. Support MPU INT on CC3D and Naze32
Rev6.

MPU6050 Correction From merge
2015-10-16 10:40:54 +02:00
Dominic Clifton
9b054f6fde More cleanup of MPU driver code. Support MPU INT on CC3D and Naze32
Rev6.
2015-10-15 23:04:55 +01:00
borisbstyle
dae052632c Merge branch 'master' into betaflight
Conflicts:
	src/main/drivers/accgyro_mpu3050.c
	src/main/drivers/accgyro_mpu6050.c
	src/main/drivers/accgyro_spi_mpu6000.c
	src/main/drivers/accgyro_spi_mpu6500.c
	src/main/drivers/sensor.h
2015-09-15 23:36:40 +02:00
Dominic Clifton
c6f5b98a79 Improve failure LED status flashing. Now users can identify and report
hardware failures by counting the number of long flashes.

Fix up sensor read API so that code that uses sensors can detect
malfunctions.

If a failure mode occurs in a debug mode the code reboots the system
rather than rebooting to the bootloader.
2015-09-12 01:33:19 +01:00
borisbstyle
febee3fb90 Merge branch 'master' into betaflight
Conflicts:
	src/main/drivers/system.c
	src/main/rx/rx.h
2015-09-07 10:08:34 +02:00