Remove FY90Q support. Dead hardware, not even available anymore, and doesn't offer anything over already cheap acroafro.
This commit is contained in:
parent
8b6ff25bdb
commit
3d39ece50f
9
Makefile
9
Makefile
|
@ -14,7 +14,7 @@
|
|||
# Things that the user might override on the commandline
|
||||
#
|
||||
|
||||
# The target to build, must be one of NAZE, FY90Q OR OLIMEXINO
|
||||
# The target to build, must be one of NAZE OR OLIMEXINO
|
||||
TARGET ?= NAZE
|
||||
|
||||
# Compile-time options
|
||||
|
@ -30,7 +30,7 @@ SERIAL_DEVICE ?= /dev/ttyUSB0
|
|||
# Things that need to be maintained as the source changes
|
||||
#
|
||||
|
||||
VALID_TARGETS = NAZE FY90Q OLIMEXINO
|
||||
VALID_TARGETS = NAZE OLIMEXINO
|
||||
|
||||
# Working directories
|
||||
ROOT = $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
|
@ -89,11 +89,6 @@ NAZE_SRC = drv_adc.c \
|
|||
drv_timer.c \
|
||||
$(COMMON_SRC)
|
||||
|
||||
# Source files for the FY90Q target
|
||||
FY90Q_SRC = drv_adc_fy90q.c \
|
||||
drv_pwm_fy90q.c \
|
||||
$(COMMON_SRC)
|
||||
|
||||
# Source files for the OLIMEXINO target
|
||||
OLIMEXINO_SRC = drv_spi.c \
|
||||
drv_adc.c \
|
||||
|
|
1400
baseflight.uvproj
1400
baseflight.uvproj
File diff suppressed because it is too large
Load Diff
|
@ -1,359 +0,0 @@
|
|||
;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
|
||||
;* File Name : startup_stm32f10x_md.s
|
||||
;* Author : MCD Application Team
|
||||
;* Version : V3.5.0
|
||||
;* Date : 11-March-2011
|
||||
;* Description : STM32F10x Medium Density Devices vector table for MDK-ARM
|
||||
;* toolchain.
|
||||
;* This module performs:
|
||||
;* - Set the initial SP
|
||||
;* - Set the initial PC == Reset_Handler
|
||||
;* - Set the vector table entries with the exceptions ISR address
|
||||
;* - Configure the clock system
|
||||
;* - Branches to __main in the C library (which eventually
|
||||
;* calls main()).
|
||||
;* After Reset the CortexM3 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;* <<< Use Configuration Wizard in Context Menu >>>
|
||||
;*******************************************************************************
|
||||
; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
;*******************************************************************************
|
||||
|
||||
; Amount of memory (in bytes) allocated for Stack
|
||||
; Tailor this value to your application needs
|
||||
; <h> Stack Configuration
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x00001000
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
|
||||
; <h> Heap Configuration
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x00000200
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window Watchdog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
||||
DCD TAMPER_IRQHandler ; Tamper
|
||||
DCD RTC_IRQHandler ; RTC
|
||||
DCD FLASH_IRQHandler ; Flash
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
||||
DCD ADC1_2_IRQHandler ; ADC1_2
|
||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
||||
DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
|
||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT __main
|
||||
IMPORT SystemInit
|
||||
LDR R0, =0x20004FF0
|
||||
LDR R1, =0xDEADBEEF
|
||||
LDR R2, [R0, #0]
|
||||
STR R0, [R0, #0] ; Invalidate
|
||||
CMP R2, R1
|
||||
BEQ Reboot_Loader
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
RCC_APB2ENR EQU 0x40021018
|
||||
GPIO_AFIO_MASK EQU 0x00000015
|
||||
GPIOA_CRH EQU 0x40010804
|
||||
GPIOA_BRR EQU 0x40010814
|
||||
GPIOC_CRH EQU 0x40011004
|
||||
GPIOC_BRR EQU 0x40011014
|
||||
AFIO_MAPR EQU 0x40010004
|
||||
|
||||
Reboot_Loader PROC
|
||||
EXPORT Reboot_Loader
|
||||
|
||||
; RCC Enable GPIOA+C+AFIO
|
||||
LDR R6, =RCC_APB2ENR
|
||||
LDR R0, =GPIO_AFIO_MASK
|
||||
STR R0, [R6]
|
||||
; MAPR pt1
|
||||
LDR R0, =AFIO_MAPR
|
||||
LDR R1, [R0]
|
||||
BIC R1, R1, #0xF000000
|
||||
STR R1, [R0]
|
||||
; MAPR pt2
|
||||
LSLS R1, R0, #9
|
||||
STR R1, [R0]
|
||||
; GPIO A BRR
|
||||
LDR R4, =GPIOA_BRR
|
||||
MOVS R0, #0x8000
|
||||
STR R0, [R4]
|
||||
; GPIO A CRL
|
||||
LDR R1, =GPIOA_CRH
|
||||
LDR R0, =0x34444444
|
||||
STR R0, [R1]
|
||||
; GPIO C BRR
|
||||
LDR R4, =GPIOC_BRR
|
||||
MOVS R0, #0x1000
|
||||
STR R0, [R4]
|
||||
; GPIO C CRL
|
||||
LDR R1, =GPIOC_CRH
|
||||
LDR R0, =0x44434444
|
||||
STR R0, [R1]
|
||||
; Reboot to ROM
|
||||
LDR R0, =0x1FFFF000
|
||||
LDR SP,[R0, #0]
|
||||
LDR R0,[R0, #4]
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT WWDG_IRQHandler [WEAK]
|
||||
EXPORT PVD_IRQHandler [WEAK]
|
||||
EXPORT TAMPER_IRQHandler [WEAK]
|
||||
EXPORT RTC_IRQHandler [WEAK]
|
||||
EXPORT FLASH_IRQHandler [WEAK]
|
||||
EXPORT RCC_IRQHandler [WEAK]
|
||||
EXPORT EXTI0_IRQHandler [WEAK]
|
||||
EXPORT EXTI1_IRQHandler [WEAK]
|
||||
EXPORT EXTI2_IRQHandler [WEAK]
|
||||
EXPORT EXTI3_IRQHandler [WEAK]
|
||||
EXPORT EXTI4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
||||
EXPORT ADC1_2_IRQHandler [WEAK]
|
||||
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
|
||||
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT TIM1_BRK_IRQHandler [WEAK]
|
||||
EXPORT TIM1_UP_IRQHandler [WEAK]
|
||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT TIM3_IRQHandler [WEAK]
|
||||
EXPORT TIM4_IRQHandler [WEAK]
|
||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
||||
EXPORT SPI1_IRQHandler [WEAK]
|
||||
EXPORT SPI2_IRQHandler [WEAK]
|
||||
EXPORT USART1_IRQHandler [WEAK]
|
||||
EXPORT USART2_IRQHandler [WEAK]
|
||||
EXPORT USART3_IRQHandler [WEAK]
|
||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
||||
EXPORT RTCAlarm_IRQHandler [WEAK]
|
||||
EXPORT USBWakeUp_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_IRQHandler
|
||||
TAMPER_IRQHandler
|
||||
RTC_IRQHandler
|
||||
FLASH_IRQHandler
|
||||
RCC_IRQHandler
|
||||
EXTI0_IRQHandler
|
||||
EXTI1_IRQHandler
|
||||
EXTI2_IRQHandler
|
||||
EXTI3_IRQHandler
|
||||
EXTI4_IRQHandler
|
||||
DMA1_Channel1_IRQHandler
|
||||
DMA1_Channel2_IRQHandler
|
||||
DMA1_Channel3_IRQHandler
|
||||
DMA1_Channel4_IRQHandler
|
||||
DMA1_Channel5_IRQHandler
|
||||
DMA1_Channel6_IRQHandler
|
||||
DMA1_Channel7_IRQHandler
|
||||
ADC1_2_IRQHandler
|
||||
USB_HP_CAN1_TX_IRQHandler
|
||||
USB_LP_CAN1_RX0_IRQHandler
|
||||
CAN1_RX1_IRQHandler
|
||||
CAN1_SCE_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
TIM1_BRK_IRQHandler
|
||||
TIM1_UP_IRQHandler
|
||||
TIM1_TRG_COM_IRQHandler
|
||||
TIM1_CC_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
TIM3_IRQHandler
|
||||
TIM4_IRQHandler
|
||||
I2C1_EV_IRQHandler
|
||||
I2C1_ER_IRQHandler
|
||||
I2C2_EV_IRQHandler
|
||||
I2C2_ER_IRQHandler
|
||||
SPI1_IRQHandler
|
||||
SPI2_IRQHandler
|
||||
USART1_IRQHandler
|
||||
USART2_IRQHandler
|
||||
USART3_IRQHandler
|
||||
EXTI15_10_IRQHandler
|
||||
RTCAlarm_IRQHandler
|
||||
USBWakeUp_IRQHandler
|
||||
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
|
||||
;*******************************************************************************
|
||||
; User Stack and Heap initialization
|
||||
;*******************************************************************************
|
||||
IF :DEF:__MICROLIB
|
||||
|
||||
EXPORT __initial_sp
|
||||
EXPORT __heap_base
|
||||
EXPORT __heap_limit
|
||||
|
||||
ELSE
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, =(Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
ENDIF
|
||||
|
||||
END
|
||||
|
||||
;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE*****
|
26
src/board.h
26
src/board.h
|
@ -176,22 +176,6 @@ typedef struct baro_t {
|
|||
} baro_t;
|
||||
|
||||
// Hardware definitions and GPIO
|
||||
#ifdef FY90Q
|
||||
// FY90Q
|
||||
#define LED0_GPIO GPIOC
|
||||
#define LED0_PIN Pin_12
|
||||
#define LED1_GPIO GPIOA
|
||||
#define LED1_PIN Pin_15
|
||||
|
||||
#define GYRO
|
||||
#define ACC
|
||||
#define LED0
|
||||
#define LED1
|
||||
|
||||
#define SENSORS_SET (SENSOR_ACC)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef OLIMEXINO
|
||||
// OLIMEXINO
|
||||
|
||||
|
@ -238,7 +222,6 @@ typedef struct baro_t {
|
|||
#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG)
|
||||
// #define PROD_DEBUG
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Helpful macros
|
||||
|
@ -276,14 +259,6 @@ typedef struct baro_t {
|
|||
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef FY90Q
|
||||
// FY90Q
|
||||
#include "drv_adc.h"
|
||||
#include "drv_i2c.h"
|
||||
#include "drv_pwm.h"
|
||||
#include "drv_uart.h"
|
||||
#else
|
||||
|
||||
#ifdef OLIMEXINO
|
||||
// OLIMEXINO
|
||||
#include "drv_adc.h"
|
||||
|
@ -322,4 +297,3 @@ typedef struct baro_t {
|
|||
#include "drv_hcsr04.h"
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,3 @@ typedef struct drv_adc_config_t {
|
|||
|
||||
void adcInit(drv_adc_config_t *init);
|
||||
uint16_t adcGetChannel(uint8_t channel);
|
||||
#ifdef FY90Q
|
||||
void adcSensorInit(sensor_t *acc, sensor_t *gyro);
|
||||
#endif
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
#ifdef FY90Q
|
||||
#include "board.h"
|
||||
|
||||
#define ADC_CHANNELS 9
|
||||
|
||||
volatile uint16_t adcData[ADC_CHANNELS] = { 0, };
|
||||
extern uint16_t acc_1G;
|
||||
|
||||
static void adcAccRead(int16_t *accelData);
|
||||
static void adcAccAlign(int16_t *accelData);
|
||||
static void adcGyroRead(int16_t *gyroData);
|
||||
static void adcGyroAlign(int16_t *gyroData);
|
||||
static void adcDummyInit(void);
|
||||
|
||||
void adcSensorInit(sensor_t *acc, sensor_t *gyro)
|
||||
{
|
||||
acc->init = adcDummyInit;
|
||||
acc->read = adcAccRead;
|
||||
acc->align = adcAccAlign;
|
||||
|
||||
gyro->init = adcDummyInit;
|
||||
gyro->read = adcGyroRead;
|
||||
gyro->align = adcGyroAlign;
|
||||
gyro->scale = 1.0f;
|
||||
|
||||
acc_1G = 376;
|
||||
}
|
||||
|
||||
void adcCalibrateADC(ADC_TypeDef *ADCx, int n)
|
||||
{
|
||||
while (n > 0) {
|
||||
delay(5);
|
||||
// Enable ADC reset calibration register
|
||||
ADC_ResetCalibration(ADCx);
|
||||
// Check the end of ADC reset calibration register
|
||||
while(ADC_GetResetCalibrationStatus(ADCx));
|
||||
// Start ADC calibration
|
||||
ADC_StartCalibration(ADCx);
|
||||
// Check the end of ADC calibration
|
||||
while(ADC_GetCalibrationStatus(ADCx));
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
void adcInit(void)
|
||||
{
|
||||
ADC_InitTypeDef ADC_InitStructure;
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
|
||||
// ADC assumes all the GPIO was already placed in 'AIN' mode
|
||||
DMA_DeInit(DMA1_Channel1);
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR;
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&adcData;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
|
||||
DMA_InitStructure.DMA_BufferSize = ADC_CHANNELS;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
|
||||
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
|
||||
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
|
||||
/* Enable DMA1 channel1 */
|
||||
DMA_Cmd(DMA1_Channel1, ENABLE);
|
||||
|
||||
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
|
||||
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
|
||||
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||
ADC_InitStructure.ADC_NbrOfChannel = ADC_CHANNELS;
|
||||
ADC_Init(ADC1, &ADC_InitStructure);
|
||||
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_28Cycles5); // GY_X
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 2, ADC_SampleTime_28Cycles5); // GY_Y
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 3, ADC_SampleTime_28Cycles5); // GY_Z
|
||||
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 4, ADC_SampleTime_28Cycles5); // ACC_X
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 5, ADC_SampleTime_28Cycles5); // ACC_Y
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 6, ADC_SampleTime_28Cycles5); // ACC_Z
|
||||
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 7, ADC_SampleTime_28Cycles5); // POT_ELE
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 8, ADC_SampleTime_28Cycles5); // POT_AIL
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 9, ADC_SampleTime_28Cycles5); // POT_RUD
|
||||
|
||||
ADC_DMACmd(ADC1, ENABLE);
|
||||
|
||||
ADC_Cmd(ADC1, ENABLE);
|
||||
|
||||
// Calibrate ADC
|
||||
adcCalibrateADC(ADC1, 2);
|
||||
|
||||
// Fire off ADC
|
||||
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
|
||||
}
|
||||
|
||||
static void adcAccRead(int16_t *accelData)
|
||||
{
|
||||
// ADXL335
|
||||
// 300mV/g
|
||||
// Vcc 3.0V
|
||||
accelData[0] = adcData[3];
|
||||
accelData[1] = adcData[4];
|
||||
accelData[2] = adcData[5];
|
||||
}
|
||||
|
||||
static void adcAccAlign(int16_t *accelData)
|
||||
{
|
||||
// align OK
|
||||
}
|
||||
|
||||
static void adcGyroRead(int16_t *gyroData)
|
||||
{
|
||||
// Vcc: 3.0V
|
||||
// Pitch/Roll: LPR550AL, 2000dps mode.
|
||||
// 0.5mV/dps
|
||||
// Zero-rate: 1.23V
|
||||
// Yaw: LPY550AL, 2000dps mode.
|
||||
// 0.5mV/dps
|
||||
// Zero-rate: 1.23V
|
||||
|
||||
// Need to match with: 14.375lsb per dps
|
||||
// 12-bit ADC
|
||||
|
||||
gyroData[0] = adcData[0] * 2;
|
||||
gyroData[1] = adcData[1] * 2;
|
||||
gyroData[2] = adcData[2] * 2;
|
||||
}
|
||||
|
||||
static void adcGyroAlign(int16_t *gyroData)
|
||||
{
|
||||
// align OK
|
||||
}
|
||||
|
||||
static void adcDummyInit(void)
|
||||
{
|
||||
// nothing to init here
|
||||
}
|
||||
|
||||
uint16_t adcGetBattery(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -1,344 +0,0 @@
|
|||
#ifdef FY90Q
|
||||
#include "board.h"
|
||||
|
||||
#define PULSE_1MS (1000) // 1ms pulse width
|
||||
// #define PULSE_PERIOD (2500) // pulse period (400Hz)
|
||||
// #define PULSE_PERIOD_SERVO_DIGITAL (5000) // pulse period for digital servo (200Hz)
|
||||
// #define PULSE_PERIOD_SERVO_ANALOG (20000) // pulse period for analog servo (50Hz)
|
||||
|
||||
// Forward declaration
|
||||
static void pwmIRQHandler(TIM_TypeDef *tim);
|
||||
static void ppmIRQHandler(TIM_TypeDef *tim);
|
||||
|
||||
// external vars (ugh)
|
||||
extern int16_t failsafeCnt;
|
||||
|
||||
// local vars
|
||||
static struct TIM_Channel {
|
||||
TIM_TypeDef *tim;
|
||||
uint16_t channel;
|
||||
uint16_t cc;
|
||||
} Channels[] = {
|
||||
{ TIM2, TIM_Channel_1, TIM_IT_CC1 },
|
||||
{ TIM2, TIM_Channel_2, TIM_IT_CC2 },
|
||||
{ TIM2, TIM_Channel_3, TIM_IT_CC3 },
|
||||
{ TIM2, TIM_Channel_4, TIM_IT_CC4 },
|
||||
{ TIM3, TIM_Channel_1, TIM_IT_CC1 },
|
||||
{ TIM3, TIM_Channel_2, TIM_IT_CC2 },
|
||||
{ TIM3, TIM_Channel_3, TIM_IT_CC3 },
|
||||
{ TIM3, TIM_Channel_4, TIM_IT_CC4 },
|
||||
};
|
||||
|
||||
static volatile uint16_t *OutputChannels[] = {
|
||||
&(TIM4->CCR1),
|
||||
&(TIM4->CCR2),
|
||||
&(TIM4->CCR3),
|
||||
&(TIM4->CCR4),
|
||||
// Extended use during CPPM input (TODO)
|
||||
&(TIM3->CCR1),
|
||||
&(TIM3->CCR2),
|
||||
&(TIM3->CCR3),
|
||||
&(TIM3->CCR4),
|
||||
};
|
||||
|
||||
static struct PWM_State {
|
||||
uint8_t state;
|
||||
uint16_t rise;
|
||||
uint16_t fall;
|
||||
uint16_t capture;
|
||||
} Inputs[8] = { { 0, } };
|
||||
|
||||
static TIM_ICInitTypeDef TIM_ICInitStructure = { 0, };
|
||||
static bool usePPMFlag = false;
|
||||
static uint8_t numOutputChannels = 0;
|
||||
|
||||
void TIM2_IRQHandler(void)
|
||||
{
|
||||
if (usePPMFlag)
|
||||
ppmIRQHandler(TIM2);
|
||||
else
|
||||
pwmIRQHandler(TIM2);
|
||||
}
|
||||
|
||||
static void ppmIRQHandler(TIM_TypeDef *tim)
|
||||
{
|
||||
uint16_t diff;
|
||||
static uint16_t now;
|
||||
static uint16_t last = 0;
|
||||
static uint8_t chan = 0;
|
||||
static uint8_t GoodPulses;
|
||||
|
||||
if (TIM_GetITStatus(tim, TIM_IT_CC1) == SET) {
|
||||
last = now;
|
||||
now = TIM_GetCapture1(tim);
|
||||
rcActive = true;
|
||||
}
|
||||
|
||||
TIM_ClearITPendingBit(tim, TIM_IT_CC1);
|
||||
|
||||
if (now > last) {
|
||||
diff = (now - last);
|
||||
} else {
|
||||
diff = ((0xFFFF - last) + now);
|
||||
}
|
||||
|
||||
if (diff > 4000) {
|
||||
chan = 0;
|
||||
} else {
|
||||
if (diff > PULSE_MIN && diff < PULSE_MAX && chan < 8) { // 750 to 2250 ms is our 'valid' channel range
|
||||
Inputs[chan].capture = diff;
|
||||
if (chan < 4 && diff > FAILSAFE_DETECT_TRESHOLD)
|
||||
GoodPulses |= (1 << chan); // if signal is valid - mark channel as OK
|
||||
if (GoodPulses == 0x0F) { // If first four chanells have good pulses, clear FailSafe counter
|
||||
GoodPulses = 0;
|
||||
if (failsafeCnt > 20)
|
||||
failsafeCnt -= 20;
|
||||
else
|
||||
failsafeCnt = 0;
|
||||
}
|
||||
}
|
||||
chan++;
|
||||
failsafeCnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void pwmIRQHandler(TIM_TypeDef *tim)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t val = 0;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
struct TIM_Channel channel = Channels[i];
|
||||
struct PWM_State *state = &Inputs[i];
|
||||
|
||||
if (channel.tim == tim && (TIM_GetITStatus(tim, channel.cc) == SET)) {
|
||||
TIM_ClearITPendingBit(channel.tim, channel.cc);
|
||||
|
||||
switch (channel.channel) {
|
||||
case TIM_Channel_1:
|
||||
val = TIM_GetCapture1(channel.tim);
|
||||
break;
|
||||
case TIM_Channel_2:
|
||||
val = TIM_GetCapture2(channel.tim);
|
||||
break;
|
||||
case TIM_Channel_3:
|
||||
val = TIM_GetCapture3(channel.tim);
|
||||
break;
|
||||
case TIM_Channel_4:
|
||||
val = TIM_GetCapture4(channel.tim);
|
||||
break;
|
||||
}
|
||||
|
||||
if (state->state == 0)
|
||||
state->rise = val;
|
||||
else
|
||||
state->fall = val;
|
||||
|
||||
if (state->state == 0) {
|
||||
// switch states
|
||||
state->state = 1;
|
||||
|
||||
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling;
|
||||
TIM_ICInitStructure.TIM_Channel = channel.channel;
|
||||
TIM_ICInit(channel.tim, &TIM_ICInitStructure);
|
||||
} else {
|
||||
// compute capture
|
||||
if (state->fall > state->rise)
|
||||
state->capture = (state->fall - state->rise);
|
||||
else
|
||||
state->capture = ((0xffff - state->rise) + state->fall);
|
||||
|
||||
// switch state
|
||||
state->state = 0;
|
||||
|
||||
// ping failsafe
|
||||
failsafeCnt = 0;
|
||||
|
||||
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
|
||||
TIM_ICInitStructure.TIM_Channel = channel.channel;
|
||||
TIM_ICInit(channel.tim, &TIM_ICInitStructure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void pwmInitializeInput(bool usePPM)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure = { 0, };
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = { 0, };
|
||||
NVIC_InitTypeDef NVIC_InitStructure = { 0, };
|
||||
uint8_t i;
|
||||
|
||||
// Input pins
|
||||
if (usePPM) {
|
||||
// Configure TIM2_CH1 for PPM input
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
// Input timer on TIM2 only for PPM
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
// TIM2 timebase
|
||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = (72 - 1);
|
||||
TIM_TimeBaseStructure.TIM_Period = 0xffff;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
|
||||
|
||||
// Input capture on TIM2_CH1 for PPM
|
||||
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
|
||||
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
|
||||
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
|
||||
TIM_ICInitStructure.TIM_ICFilter = 0x0;
|
||||
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
|
||||
TIM_ICInit(TIM2, &TIM_ICInitStructure);
|
||||
|
||||
// TIM2_CH1 capture compare interrupt enable
|
||||
TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
|
||||
TIM_Cmd(TIM2, ENABLE);
|
||||
|
||||
// configure number of PWM outputs, in PPM mode, we use bottom 4 channels more more motors
|
||||
numOutputChannels = 10;
|
||||
} else {
|
||||
// Configure TIM2 all 4 channels
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
// TODO Configure EXTI4 1 channel
|
||||
|
||||
// Input timers on TIM2 for PWM
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
// TIM2 timebase
|
||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = (72 - 1);
|
||||
TIM_TimeBaseStructure.TIM_Period = 0xffff;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
|
||||
|
||||
// PWM Input capture
|
||||
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
|
||||
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
|
||||
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
|
||||
TIM_ICInitStructure.TIM_ICFilter = 0x0;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
TIM_ICInitStructure.TIM_Channel = Channels[i].channel;
|
||||
TIM_ICInit(Channels[i].tim, &TIM_ICInitStructure);
|
||||
}
|
||||
|
||||
// TODO EXTI4
|
||||
|
||||
TIM_ITConfig(TIM2, TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4, ENABLE);
|
||||
// TODO EXTI4
|
||||
TIM_Cmd(TIM2, ENABLE);
|
||||
|
||||
// In PWM input mode, all 4 channels are wasted
|
||||
numOutputChannels = 4;
|
||||
}
|
||||
}
|
||||
|
||||
bool pwmInit(drv_pwm_config_t *init)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure = { 0, };
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = { 0, };
|
||||
TIM_OCInitTypeDef TIM_OCInitStructure = { 0, };
|
||||
|
||||
uint8_t i;
|
||||
|
||||
// Inputs
|
||||
|
||||
// RX1 TIM2_CH1 PA0 [also PPM] [also used for throttle calibration]
|
||||
// RX2 TIM2_CH2 PA1
|
||||
// RX3 TIM2_CH3 PA2 [also UART2_TX]
|
||||
// RX4 TIM2_CH4 PA3 [also UART2_RX]
|
||||
// RX5 TIM3_CH1 PA6 [also ADC_IN6]
|
||||
// RX6 TIM3_CH2 PA7 [also ADC_IN7]
|
||||
// RX7 TIM3_CH3 PB0 [also ADC_IN8]
|
||||
// RX8 TIM3_CH4 PB1 [also ADC_IN9]
|
||||
|
||||
// Outputs
|
||||
// PWM1 TIM1_CH1 PA8
|
||||
// PWM2 TIM1_CH4 PA11
|
||||
// PWM3 TIM4_CH1 PB6 [also I2C1_SCL]
|
||||
// PWM4 TIM4_CH2 PB7 [also I2C1_SDA]
|
||||
// PWM5 TIM4_CH3 PB8
|
||||
// PWM6 TIM4_CH4 PB9
|
||||
|
||||
// use PPM or PWM input
|
||||
usePPMFlag = init->usePPM;
|
||||
|
||||
// preset channels to center
|
||||
for (i = 0; i < 8; i++)
|
||||
Inputs[i].capture = 1500;
|
||||
|
||||
// Timers run at 1mhz.
|
||||
// TODO: clean this shit up. Make it all dynamic etc.
|
||||
if (init->enableInput)
|
||||
pwmInitializeInput(usePPMFlag);
|
||||
|
||||
// Output pins (4x)
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
// Output timer
|
||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = (72 - 1);
|
||||
|
||||
TIM_TimeBaseStructure.TIM_Period = (1000000 / init->motorPwmRate) - 1;
|
||||
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
|
||||
|
||||
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
|
||||
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
|
||||
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;
|
||||
TIM_OCInitStructure.TIM_Pulse = PULSE_1MS;
|
||||
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
|
||||
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
|
||||
|
||||
// PWM1,2,3,4
|
||||
TIM_OC1Init(TIM4, &TIM_OCInitStructure);
|
||||
TIM_OC2Init(TIM4, &TIM_OCInitStructure);
|
||||
TIM_OC3Init(TIM4, &TIM_OCInitStructure);
|
||||
TIM_OC4Init(TIM4, &TIM_OCInitStructure);
|
||||
TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Enable);
|
||||
TIM_OC2PreloadConfig(TIM4, TIM_OCPreload_Enable);
|
||||
TIM_OC3PreloadConfig(TIM4, TIM_OCPreload_Enable);
|
||||
TIM_OC4PreloadConfig(TIM4, TIM_OCPreload_Enable);
|
||||
|
||||
TIM_Cmd(TIM4, ENABLE);
|
||||
TIM_CtrlPWMOutputs(TIM4, ENABLE);
|
||||
TIM_OC1PreloadConfig (TIM4, TIM_OCPreload_Enable);
|
||||
|
||||
// turn on more motor outputs if we're using ppm / not using pwm input
|
||||
if (!init->enableInput || init->usePPM) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void pwmWrite(uint8_t channel, uint16_t value)
|
||||
{
|
||||
if (channel < numOutputChannels)
|
||||
*OutputChannels[channel] = value;
|
||||
}
|
||||
|
||||
uint16_t pwmRead(uint8_t channel)
|
||||
{
|
||||
return Inputs[channel].capture;
|
||||
}
|
||||
#endif
|
|
@ -121,9 +121,7 @@ void systemInit(bool overclock)
|
|||
SysTick_Config(SystemCoreClock / 1000);
|
||||
|
||||
// Configure the rest of the stuff
|
||||
#ifndef FY90Q
|
||||
i2cInit(I2C2);
|
||||
#endif
|
||||
spiInit();
|
||||
|
||||
// sleep for 100ms
|
||||
|
|
|
@ -20,15 +20,6 @@ sensor_t gyro; // gyro access functions
|
|||
baro_t baro; // barometer access functions
|
||||
uint8_t accHardware = ACC_DEFAULT; // which accel chip is used/detected
|
||||
|
||||
#ifdef FY90Q
|
||||
// FY90Q analog gyro/acc
|
||||
bool sensorsAutodetect(void)
|
||||
{
|
||||
adcSensorInit(&acc, &gyro);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
// AfroFlight32 i2c sensors
|
||||
bool sensorsAutodetect(void)
|
||||
{
|
||||
int16_t deg, min;
|
||||
|
@ -133,7 +124,6 @@ retry:
|
|||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t batteryAdcToVoltage(uint16_t src)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue