Advertisement
Guest User

NFE-Silverware-SantaWhoop

a guest
Nov 20th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 23.08 KB | None | 0 0
  1. #include "defines.h"
  2. #include "hardware.h"
  3.  
  4. //Universal pids are already loaded for 6mm and 7mm whoops by default.  Adjust pids in pid.c file for any non whoop builds.  
  5.  
  6. //**********************************************************************************************************************
  7. //***********************************************HARDWARE SELECTION*****************************************************
  8.  
  9. // *************DEFINE FLIGHT CONTROLLER HARDWARE
  10. // *************SELECT ONLY ONE
  11. // *************uncomment BWHOOP define for bwhoop, bwhoop pro, E011C Santa Edition, and Beta FPV Lite Flight Controllers
  12. // *************uncomment E011 define for E011 flight Controller
  13. // *************uncomment H8mini_blue_board for the H8 mini flight controller with blue circuit board
  14. #define BWHOOP
  15. //#define E011
  16. //#define H8mini_blue_board
  17. //#define Alienwhoop_ZERO  // requires defining RX_SBUS radio protocol
  18.  
  19.  
  20.  
  21. //**********************************************************************************************************************
  22. //***********************************************RECEIVER SETTINGS******************************************************
  23.  
  24. // *************rate in deg/sec
  25. // *************for acro mode
  26. #define MAX_RATE 860.0
  27. #define MAX_RATEYAW 500.0
  28.  
  29. // *************max angle for level mode
  30. #define LEVEL_MAX_ANGLE 65.0f
  31.  
  32. // ************* low rates multiplier if rates are assigned to a channel
  33. #define LOW_RATES_MULTI 0.5f
  34.  
  35. // *************EXPO from 0.00 to 1.00 , 0 = no exp
  36. // *************positive = less sensitive near center
  37. #define ACRO_EXPO_ROLL 0.80
  38. #define ACRO_EXPO_PITCH 0.80
  39. #define ACRO_EXPO_YAW 0.60
  40.  
  41. #define ANGLE_EXPO_ROLL 0.55
  42. #define ANGLE_EXPO_PITCH 0.0
  43. #define ANGLE_EXPO_YAW 0.55
  44.  
  45. // *************transmitter stick adjustable deadband for roll/pitch/yaw
  46. // *************.01f = 1% of stick range - comment out to disable
  47. #define STICKS_DEADBAND .01f
  48.  
  49. // *************Radio protocol selection
  50. // *************select only one
  51. //#define RX_SBUS
  52. //#define RX_DSMX_2048
  53. //#define RX_DSM2_1024
  54. //#define RX_NRF24_BAYANG_TELEMETRY
  55. //#define RX_BAYANG_PROTOCOL_BLE_BEACON
  56. #define RX_BAYANG_PROTOCOL_TELEMETRY_AUTOBIND
  57.  
  58. // *************Transmitter Type Selection
  59. //#define USE_STOCK_TX
  60. //#define USE_DEVO
  61. #define USE_MULTI
  62.  
  63. // *******************************SWITCH SELECTION*****************************
  64. // *************CHAN_ON - on always ( all protocols)
  65. // *************CHAN_OFF - off always ( all protocols)
  66. // *************Aux channels are selectable as CHAN_5 through CHAN_10 for DEVO and MULTIMODULE users
  67. // *************Toy transmitter mapping is CHAN_5 (rates button), CHAN_6 (stick gestures RRD/LLD),
  68. //**************CHAN_7 (headfree button), CHAN_8 (roll trim buttons), CHAN_9 (pitch trim buttons)
  69.  
  70. //*************Arm switch and Idle Up switch (idle up will behave like betaflight airmode)
  71. //*************comment out to disable arming or idle up features ONLY if not wanted.  Other features set to CHAN_OFF to disable
  72.  
  73. //*************Assign feature to auxiliary channel.  NOTE - Switching on LEVELMODE is required for any leveling modes to
  74. //*************be active.  With LEVELMODE active - MCU will apply RACEMODE if racemode channel is on, HORIZON if horizon
  75. //*************channel is on, or racemodeHORIZON if both channels are on - and will be standard LEVELMODE if neither
  76. //*************racemode or horizon are switched on.
  77. #define ARMING CHAN_5
  78. #define IDLE_UP CHAN_5
  79. #define IDLE_THR 0.05f                   //This designates an idle throttle of 5%
  80. #define LEVELMODE CHAN_6
  81. #define RACEMODE  CHAN_7
  82. #define HORIZON   CHAN_8
  83. #define PIDPROFILE CHAN_10                //For switching stickAccelerator & stickTransition profiles on pid.c page
  84. #define RATES CHAN_ON
  85. #define LEDS_ON CHAN_9
  86.  
  87. // *************switch for fpv / other, requires fet
  88. // *************comment out to disable
  89. //#define FPV_ON CHAN_ON
  90.  
  91. // *************enable buzzer functionality
  92. // *************external buzzer requires pin assignment in hardware.h before defining below
  93. // *************change channel assignment from CHAN_OFF to a numbered aux switch if you want switch control
  94. // *************if no channel is assigned but buzzer is set to CHAN_ON - buzzer will activate on LVC and FAILSAFE.
  95. //#define BUZZER_ENABLE CHAN_OFF
  96.  
  97. // *************start in level mode for toy tx.
  98. //#define AUX1_START_ON
  99.  
  100. // *************automatically remove center bias in toy tx ( needs throttle off for 1 second )
  101. //#define STOCK_TX_AUTOCENTER
  102.  
  103.  
  104.  
  105. //**********************************************************************************************************************
  106. //***********************************************VOLTAGE SETTINGS*******************************************************
  107.  
  108. // ************* Raises pids automatically as battery voltage drops in flight.
  109. #define PID_VOLTAGE_COMPENSATION
  110. #define LEVELMODE_PID_ATTENUATION 0.90f  //used to prevent oscillations in angle modes with pid_voltage_compensation enabled due to high pids
  111.  
  112. // *************compensation for battery voltage vs throttle drop
  113. #define VDROP_FACTOR 0.5
  114. // *************calculate above factor automatically
  115. #define AUTO_VDROP_FACTOR
  116.  
  117. // *************lower throttle when battery below threshold - forced landing low voltage cutoff
  118. // *************THIS FEATURE WILL BE OFF BY DEFAULT EVEN WHEN DEFINED - USE STICK GESTURE LEFT-LEFT-LEFT TO ACTIVATE THEN DOWN-DOWN-DOWN TO SAVE AS ON
  119. // *************Led light will blink once when LVC forced landing is turned on, blink twice when turned off, and will blink multiple times upon save command
  120. #define LVC_LOWER_THROTTLE
  121. #define LVC_LOWER_THROTTLE_VOLTAGE 3.30
  122. #define LVC_LOWER_THROTTLE_VOLTAGE_RAW 2.70
  123. #define LVC_LOWER_THROTTLE_KP 3.0
  124.  
  125. // *************do not start software if battery is too low (below 3.3v)
  126. // *************flashes 2 times repeatedly at startup
  127. #define STOP_LOWBATTERY
  128.  
  129. // *************voltage to start warning led blinking
  130. #define VBATTLOW 3.5
  131.  
  132. // *************voltage hysteresis in volts
  133. #define HYST 0.10
  134.  
  135. // *************automatic voltage telemetry correction/calibration factor - change the values below if voltage telemetry is inaccurate
  136. #define ACTUAL_BATTERY_VOLTAGE 4.20
  137. #define REPORTED_TELEMETRY_VOLTAGE 4.20
  138.  
  139.  
  140.  
  141. //**********************************************************************************************************************
  142. //***********************************************FILTER SETTINGS********************************************************
  143.  
  144. // *************Select the appropriate filtering set for your craft's gyro, D-term, and motor output or select CUSTOM_FILTERING to pick your own values.  
  145. // *************If your throttle does not want to drop crisply and quickly when you lower the throttle stick, then move to a stronger filter set
  146.  
  147. //#define WEAK_FILTERING
  148. #define STRONG_FILTERING
  149. //#define VERY_STRONG_FILTERING
  150. //#define CUSTOM_FILTERING
  151. //#define ALIENWHOOP_ZERO_FILTERING
  152.  
  153.  
  154. #ifdef CUSTOM_FILTERING
  155. // *************gyro low pass filter ( iir )
  156. // *************set only one below - kalman, 1st order, or second order - and adjust frequency
  157. //**************ABOVE 100 ADJUST IN INCRIMENTS OF 20, BELOW 100 ADJUST IN INCRIMENTS OF 10
  158. #define SOFT_KALMAN_GYRO KAL1_HZ_90
  159. //#define SOFT_LPF_1ST_HZ 80
  160. //#define SOFT_LPF_2ND_HZ 80
  161.  
  162. // *************D term low pass filter type - set only one below and adjust frequency if adjustable filter is used
  163. // *************1st order adjustable, second order adjustable, or 3rd order fixed (non adjustable)
  164. //#define DTERM_LPF_1ST_HZ 100
  165. #define  DTERM_LPF_2ND_HZ 100
  166.  
  167. // *************enable motor output filter - select and adjust frequency
  168. #define MOTOR_FILTER2_ALPHA MFILT1_HZ_70
  169. //#define MOTOR_KAL KAL1_HZ_70
  170. #endif
  171.  
  172.  
  173. //**********************************************************************************************************************
  174. //***********************************************MOTOR OUTPUT SETTINGS**************************************************
  175.  
  176. // *************invert yaw pid for "PROPS OUT" configuration
  177. //#define INVERT_YAW_PID
  178.  
  179. // *************pwm frequency for motor control
  180. // *************a higher frequency makes the motors more linear
  181. // *************in Hz
  182. #define PWMFREQ 32000
  183.  
  184. // *************clip feedforward attempts to resolve issues that occur near full throttle by adding any clipped motor commands to the next loop output
  185. //#define CLIP_FF
  186.  
  187. // *************torque boost is a highly eperimental feature.  it is a lpf D term on motor outputs that will accelerate the response
  188. // *************of the motors when the command to the motors is changing by increasing or decreasing the voltage thats sent.  It differs
  189. // *************from throttle transient compensation in that it acts on all motor commands - not just throttle changes.  this feature
  190. // *************is very noise sensative so D term specifically has to be lowered and gyro/d filtering may need to be increased.
  191. // *************reccomendation right now is to leave boost at or below 2, drop your p gains a few points, then cut your D in half and
  192. // *************retune it back up to where it feels good.  I'm finding about 60 to 65% of my previous D value seems to work.
  193. //#define TORQUE_BOOST 0.5
  194.  
  195. // *************makes throttle feel more poppy - can intensify small throttle imbalances visible in FPV if factor is set too high
  196. //#define THROTTLE_TRANSIENT_COMPENSATION
  197. //#define THROTTLE_TRANSIENT_COMPENSATION_FACTOR 4.0
  198.  
  199. // *************throttle angle compensation in level mode
  200. //#define AUTO_THROTTLE
  201.  
  202. // *************mix lower throttle reduces thrust imbalances by reducing throttle proportionally to the adjustable reduction percent
  203. // *************mix increase throttle increases the authority of the pid controller at lowest throttle values like airmode when combined with idle up
  204. // *************mix3 has a stronger effect and works better with brushless
  205. #define MIX_LOWER_THROTTLE
  206. #define MIX_THROTTLE_REDUCTION_PERCENT 10
  207. //#define MIX_INCREASE_THROTTLE
  208.  
  209. //#define MIX_LOWER_THROTTLE_3
  210. #define MIX_INCREASE_THROTTLE_3
  211. #define MIX_THROTTLE_INCREASE_MAX 0.2f
  212.  
  213. //**************joelucid's yaw fix
  214. #define YAW_FIX
  215.  
  216. //**************joelucid's transient windup protection.  Removes roll and pitch bounce back after flips
  217. #define TRANSIENT_WINDUP_PROTECTION
  218.  
  219.  
  220.  
  221. //**********************************************************************************************************************
  222. //***********************************************ADDITIONAL FEATURES****************************************************
  223.  
  224. // *************lost quad beeps using motors (30 sec timeout) - pulses motors after timeout period to help find a lost model
  225. //#define MOTOR_BEEPS
  226.  
  227. // *************0 - 7 - power for telemetry
  228. #define TX_POWER 7
  229.  
  230. // *************Flash saving features
  231. //#define DISABLE_GESTURES2
  232.  
  233. // *************led brightness in-flight ( solid lights only)
  234. // *************0- 15 range
  235. #define LED_BRIGHTNESS 15
  236.  
  237. // *************Comment out to disable pid tuning gestures
  238. //#define PID_GESTURE_TUNING
  239. //#define COMBINE_PITCH_ROLL_PID_TUNING
  240.  
  241. // *************flash save method
  242. // *************flash_save 1: pids + accel calibration
  243. // *************flash_save 2: accel calibration to option bytes
  244. #define FLASH_SAVE1
  245. //#define FLASH_SAVE2
  246.  
  247. // *************enable inverted flight code ( brushless only )
  248. //#define INVERTED_ENABLE
  249. //#define FN_INVERTED CH_OFF //for brushless only
  250.  
  251. // *************SPECIAL TEST MODE TO CHECK TRANSMITTER STICK THROWS
  252. // *************This define will allow you to check if your radio is reaching 100% throws entering <RIGHT-RIGHT-DOWN> gesture
  253. // ************* will disable throttle and will rapid blink the led when sticks are moved to 100% throws
  254. // *************entering <LEFT-LEFT-DOWN> will return the quad to normal operation.
  255. //#define STICK_TRAVEL_CHECK
  256.  
  257.  
  258.  
  259.  
  260.  
  261. //#############################################################################################################################
  262. //#############################################################################################################################
  263. // debug / other things
  264. // this should not be usually changed
  265. //#############################################################################################################################
  266. //#############################################################################################################################
  267.  
  268. //enables use of stick accelerator and stick transition for d term lpf 1 & 2
  269. #define ADVANCED_PID_CONTROLLER
  270.  
  271. //Throttle must drop below this value if arming feature is enabled for arming to take place.  MIX_INCREASE_THROTTLE_3 if enabled
  272. //will also not activate on the ground untill this threshold is passed during takeoff for safety and better staging behavior.
  273. #define THROTTLE_SAFETY .10f
  274.  
  275. // level mode "manual" trims ( in degrees)
  276. // pitch positive forward
  277. // roll positive right
  278. #define TRIM_PITCH 0.0
  279. #define TRIM_ROLL 0.0
  280.  
  281. // max rate used by level pid ( limit )
  282. #define LEVEL_MAX_RATE 230
  283.  
  284. // limit minimum motor output to a value (0.0 - 1.0)
  285. #define MOTOR_MIN_ENABLE
  286. #define MOTOR_MIN_VALUE 0.05
  287.  
  288.  
  289. #ifdef LVC_LOWER_THROTTLE
  290. #define SWITCHABLE_FEATURE_2
  291. #endif
  292.  
  293. #ifdef INVERT_YAW_PID
  294. #define SWITCHABLE_FEATURE_3
  295. #endif
  296.  
  297. #ifdef ALIENWHOOP_ZERO_FILTERING
  298. #define SOFT_KALMAN_GYRO KAL1_HZ_90
  299. #define  DTERM_LPF_2ND_HZ 100
  300. #define MOTOR_FILTER2_ALPHA MFILT1_HZ_50
  301. #define SWITCHABLE_MOTOR_FILTER2_ALPHA MFILT1_HZ_90
  302. #define SWITCHABLE_FEATURE_1
  303. #endif
  304.  
  305. #ifdef WEAK_FILTERING
  306. #define SOFT_KALMAN_GYRO KAL1_HZ_90
  307. #define  DTERM_LPF_2ND_HZ 100
  308. #define MOTOR_FILTER2_ALPHA MFILT1_HZ_90
  309. #endif
  310.  
  311. #ifdef STRONG_FILTERING
  312. #define SOFT_KALMAN_GYRO KAL1_HZ_80
  313. #define  DTERM_LPF_2ND_HZ 90
  314. #define MOTOR_FILTER2_ALPHA MFILT1_HZ_80
  315. #endif
  316.  
  317. #ifdef VERY_STRONG_FILTERING
  318. #define SOFT_KALMAN_GYRO KAL1_HZ_70
  319. #define  DTERM_LPF_2ND_HZ 80
  320. #define MOTOR_FILTER2_ALPHA MFILT1_HZ_70
  321. #endif
  322.  
  323. #define GYRO_LOW_PASS_FILTER 0
  324.  
  325. #define DISABLE_FLIP_SEQUENCER
  326. #define STARTFLIP CHAN_OFF
  327.  
  328. // disable motors for testing
  329. //#define NOMOTORS
  330.  
  331. // throttle direct to motors for thrust measure
  332. // #define MOTORS_TO_THROTTLE
  333.  
  334. // throttle direct to motors for thrust measure as a flight mode
  335. //#define MOTORS_TO_THROTTLE_MODE MULTI_CHAN_8
  336.  
  337. // *************motor curve to use - select one
  338. // *************the pwm frequency has to be set independently
  339. #define MOTOR_CURVE_NONE
  340.  
  341. // loop time in uS
  342. // this affects soft gyro lpf frequency if used
  343. #define LOOPTIME 1000
  344.  
  345. // failsafe time in uS
  346. #define FAILSAFETIME 1000000  // one second
  347.  
  348. // debug things ( debug struct and other)
  349. //#define DEBUG
  350.  
  351. // rxdebug structure
  352. //#define RXDEBUG
  353.  
  354. // enable motors if pitch / roll controls off center (at zero throttle)
  355. // possible values: 0 / 1
  356. // use in acro build only
  357. #define ENABLESTIX 0
  358. #define ENABLESTIX_TRESHOLD 0.3
  359. #define ENABLESTIX_TIMEOUT 1e6
  360.  
  361. // overclock to 64Mhz
  362.  
  363. #define ENABLE_OVERCLOCK
  364.  
  365. #pragma diag_warning 1035 , 177 , 4017
  366. #pragma diag_error 260
  367.  
  368. //--fpmode=fast
  369.  
  370. // define logic - do not change
  371. ///////////////
  372.  
  373. // used for pwm calculations
  374. #ifdef ENABLE_OVERCLOCK
  375. #define SYS_CLOCK_FREQ_HZ 64000000
  376. #else
  377. #define SYS_CLOCK_FREQ_HZ 48000000
  378. #endif
  379.  
  380. #ifdef MOTOR_BEEPS
  381. #ifdef USE_ESC_DRIVER
  382. #warning "MOTOR BEEPS_WORKS WITH BRUSHED MOTORS ONLY"
  383. #endif
  384. #endif
  385.  
  386. // for the ble beacon to work after in-flight reset
  387. #ifdef RX_BAYANG_PROTOCOL_BLE_BEACON
  388. #undef STOP_LOWBATTERY
  389. #endif
  390.  
  391. // gcc warnings in main.c
  392.  
  393. //Hardware target defines moved from hardware.h so that board selection of bwhoop or e011 can be performed in config.h file
  394.  
  395. #ifdef BWHOOP
  396. //LEDS
  397. #define LED_NUMBER 2
  398. #define LED1PIN GPIO_Pin_2
  399. #define LED1PORT GPIOA
  400. #define LED2PIN GPIO_Pin_3
  401. #define LED2PORT GPIOA
  402. #define LED1_INVERT
  403. #define LED2_INVERT
  404.  
  405. //SOFT I2C & GYRO
  406. #define SOFTI2C_SDAPIN GPIO_Pin_10
  407. #define SOFTI2C_SDAPORT GPIOA
  408. #define SOFTI2C_SCLPIN GPIO_Pin_9
  409. #define SOFTI2C_SCLPORT GPIOA
  410. #define SOFTI2C_GYRO_ADDRESS 0x68
  411. #define GYRO_ID_1 0x68
  412. #define GYRO_ID_2 0x98 // new id
  413. #define GYRO_ID_3 0x7D
  414. #define GYRO_ID_4 0x72
  415. #define SENSOR_ROTATE_90_CW
  416.  
  417. // SPI PINS DEFINITONS & RADIO
  418. #if defined(RX_SBUS) || defined(RX_DSMX_2048) || defined(RX_DSM2_1024)
  419. #define SERIAL_RX_SPEKBIND_BINDTOOL_PIN GPIO_Pin_3
  420. #define SERIAL_RX_PIN GPIO_Pin_14
  421. #define SERIAL_RX_PORT GPIOA
  422. #define SERIAL_RX_SOURCE GPIO_PinSource14
  423. #define SERIAL_RX_CHANNEL GPIO_AF_1
  424. #define SOFTSPI_NONE
  425. //dummy spi placeholders
  426. #define SPI_MOSI_PIN GPIO_Pin_x
  427. #define SPI_MOSI_PORT GPIOA
  428. #define SPI_CLK_PIN GPIO_Pin_y
  429. #define SPI_CLK_PORT GPIOA
  430. #define SPI_SS_PIN GPIO_Pin_z
  431. #define SPI_SS_PORT GPIOA
  432. #define RADIO_CHECK
  433. #else
  434. #define SOFTSPI_3WIRE
  435. #define SPI_MOSI_PIN GPIO_Pin_0
  436. #define SPI_MOSI_PORT GPIOA
  437. #define SPI_CLK_PIN GPIO_Pin_1
  438. #define SPI_CLK_PORT GPIOF
  439. #define SPI_SS_PIN GPIO_Pin_0
  440. #define SPI_SS_PORT GPIOF
  441. #define RADIO_XN297L
  442. #define RADIO_CHECK
  443. #endif
  444.  
  445. //VOLTAGE DIVIDER
  446. #define BATTERYPIN GPIO_Pin_5
  447. #define BATTERYPORT GPIOA
  448. #define BATTERY_ADC_CHANNEL ADC_Channel_5
  449. #define ADC_SCALEFACTOR 0.001364
  450. #define ADC_REF 1.17857f
  451.  
  452. // MOTOR PINS
  453. #define MOTOR0_PIN_PB1 // motor 0 back-left
  454. #define MOTOR1_PIN_PA4 // motor 1 front-left
  455. #define MOTOR2_PIN_PA6 // motor 2 back-right
  456. #define MOTOR3_PIN_PA7 // motor 3 front-right
  457. #endif
  458.  
  459. #ifdef E011
  460. //LEDS
  461. #define LED_NUMBER 2
  462. #define LED1PIN GPIO_Pin_2
  463. #define LED1PORT GPIOA
  464. #define LED2PIN GPIO_Pin_3
  465. #define LED2PORT GPIOA
  466. #define LED1_INVERT
  467. #define LED2_INVERT
  468.  
  469. //SOFT I2C & GYRO
  470. #define SOFTI2C_SDAPIN GPIO_Pin_10
  471. #define SOFTI2C_SDAPORT GPIOA
  472. #define SOFTI2C_SCLPIN GPIO_Pin_9
  473. #define SOFTI2C_SCLPORT GPIOA
  474. #define SOFTI2C_GYRO_ADDRESS 0x68
  475. #define GYRO_ID_1 0x68
  476. #define GYRO_ID_2 0x98 // new id
  477. #define GYRO_ID_3 0x7D
  478. #define GYRO_ID_4 0x72
  479. #define SENSOR_ROTATE_90_CW
  480. #define SOFTI2C_PUSHPULL_CLK
  481.  
  482. // SPI PINS DEFINITONS & RADIO
  483. #if defined(RX_SBUS) || defined(RX_DSMX_2048) || defined(RX_DSM2_1024)
  484. #define SERIAL_RX_SPEKBIND_BINDTOOL_PIN GPIO_Pin_3
  485. #define SERIAL_RX_PIN GPIO_Pin_14
  486. #define SERIAL_RX_PORT GPIOA
  487. #define SERIAL_RX_SOURCE GPIO_PinSource14
  488. #define SERIAL_RX_CHANNEL GPIO_AF_1
  489. #define SOFTSPI_NONE
  490. //dummy spi placeholders
  491. #define SPI_MOSI_PIN GPIO_Pin_x
  492. #define SPI_MOSI_PORT GPIOA
  493. #define SPI_CLK_PIN GPIO_Pin_y
  494. #define SPI_CLK_PORT GPIOA
  495. #define SPI_SS_PIN GPIO_Pin_z
  496. #define SPI_SS_PORT GPIOA
  497. #define RADIO_CHECK
  498. #else
  499. #define SOFTSPI_3WIRE
  500. #define SPI_MOSI_PIN GPIO_Pin_0
  501. #define SPI_MOSI_PORT GPIOF
  502. #define SPI_CLK_PIN GPIO_Pin_1
  503. #define SPI_CLK_PORT GPIOF
  504. #define SPI_SS_PIN GPIO_Pin_0
  505. #define SPI_SS_PORT GPIOA
  506. #define RADIO_XN297L
  507. #define RADIO_CHECK
  508. #endif
  509.  
  510. //VOLTAGE DIVIDER
  511. #define BATTERYPIN GPIO_Pin_5
  512. #define BATTERYPORT GPIOA
  513. #define BATTERY_ADC_CHANNEL ADC_Channel_5
  514. #define ADC_SCALEFACTOR 0.001364
  515. #define ADC_REF 1.17857f
  516.  
  517. // Assingment of pin to motor
  518. #define MOTOR0_PIN_PA6 // motor 0 back-left
  519. #define MOTOR1_PIN_PA4 // motor 1 front-left
  520. #define MOTOR2_PIN_PB1 // motor 2 back-right
  521. #define MOTOR3_PIN_PA7 // motor 3 front-right
  522. #endif
  523.  
  524. #ifdef H8mini_blue_board
  525. //LEDS
  526. #define LED_NUMBER 1
  527. #define LED1PIN GPIO_Pin_1
  528. #define LED1PORT GPIOF
  529. #define LED2PIN GPIO_Pin_3
  530. #define LED2PORT GPIOA
  531.  
  532. //SOFT I2C & GYRO
  533. #define SOFTI2C_SDAPIN GPIO_Pin_10
  534. #define SOFTI2C_SDAPORT GPIOA
  535. #define SOFTI2C_SCLPIN GPIO_Pin_9
  536. #define SOFTI2C_SCLPORT GPIOA
  537. #define SOFTI2C_GYRO_ADDRESS 0x68
  538. #define SOFTI2C_PUSHPULL_CLK
  539. #define GYRO_ID_1 0x68
  540. #define GYRO_ID_2 0x78 // common h8 gyro
  541. #define GYRO_ID_3 0x7D
  542. #define GYRO_ID_4 0x72
  543. #define SENSOR_ROTATE_180
  544.  
  545. // SPI PINS DEFINITONS & RADIO
  546. #if defined(RX_SBUS) || defined(RX_DSMX_2048) || defined(RX_DSM2_1024)
  547. #define SERIAL_RX_SPEKBIND_BINDTOOL_PIN GPIO_Pin_3
  548. #define SERIAL_RX_PIN GPIO_Pin_14
  549. #define SERIAL_RX_PORT GPIOA
  550. #define SERIAL_RX_SOURCE GPIO_PinSource14
  551. #define SERIAL_RX_CHANNEL GPIO_AF_1
  552. #define SOFTSPI_NONE
  553. //dummy spi placeholders
  554. #define SPI_MOSI_PIN GPIO_Pin_x
  555. #define SPI_MOSI_PORT GPIOA
  556. #define SPI_CLK_PIN GPIO_Pin_y
  557. #define SPI_CLK_PORT GPIOA
  558. #define SPI_SS_PIN GPIO_Pin_z
  559. #define SPI_SS_PORT GPIOA
  560. #define RADIO_CHECK
  561. #else
  562. #define SOFTSPI_3WIRE
  563. #define SPI_MOSI_PIN GPIO_Pin_1
  564. #define SPI_MOSI_PORT GPIOA
  565. #define SPI_CLK_PIN GPIO_Pin_2
  566. #define SPI_CLK_PORT GPIOA
  567. #define SPI_SS_PIN GPIO_Pin_3
  568. #define SPI_SS_PORT GPIOA
  569. #define RADIO_XN297L
  570. #define RADIO_CHECK
  571. #endif
  572.  
  573. //VOLTAGE DIVIDER
  574. #define BATTERYPIN GPIO_Pin_5
  575. #define BATTERYPORT GPIOA
  576. #define BATTERY_ADC_CHANNEL ADC_Channel_5
  577. #define ADC_SCALEFACTOR 0.001364
  578. #define ADC_REF 1.17857f
  579.  
  580. // Assingment of pin to motor
  581. #define MOTOR0_PIN_PA6 // motor 0 back-left
  582. #define MOTOR1_PIN_PA4 // motor 1 front-left
  583. #define MOTOR2_PIN_PB1 // motor 2 back-right
  584. #define MOTOR3_PIN_PA7 // motor 3 front-right
  585. #endif
  586.  
  587. #ifdef Alienwhoop_ZERO
  588. //LEDS
  589. #define LED_NUMBER 1
  590. #define LED1PIN GPIO_Pin_0
  591. #define LED1PORT GPIOF
  592. #define LED2PIN GPIO_Pin_0
  593. #define LED2PORT GPIOA
  594.  
  595. //SOFT I2C & GYRO
  596. #define SOFTI2C_SDAPIN GPIO_Pin_10
  597. #define SOFTI2C_SDAPORT GPIOA
  598. #define SOFTI2C_SCLPIN GPIO_Pin_9
  599. #define SOFTI2C_SCLPORT GPIOA
  600. #define SOFTI2C_GYRO_ADDRESS 0x68
  601. //#define SOFTI2C_GYRO_ADDRESS 0x69
  602. #define GYRO_ID_1 0x68
  603. #define GYRO_ID_2 0x98 // new id
  604. #define GYRO_ID_3 0x78
  605. #define GYRO_ID_4 0x72
  606. #define SENSOR_ROTATE_90_CCW
  607.  
  608. // SPI PINS DEFINITONS & RADIO
  609. #if defined(RX_SBUS) || defined(RX_DSMX_2048) || defined(RX_DSM2_1024)
  610. #define SERIAL_RX_SPEKBIND_BINDTOOL_PIN GPIO_Pin_2
  611. #define SERIAL_RX_SPEKBIND_RX_PIN GPIO_Pin_3
  612. #define SERIAL_RX_PIN GPIO_Pin_3
  613. #define SERIAL_RX_PORT GPIOA
  614. #define SERIAL_RX_SOURCE GPIO_PinSource3
  615. #define SERIAL_RX_CHANNEL GPIO_AF_1
  616. #define SOFTSPI_NONE
  617. //dummy spi placeholders
  618. #define SPI_MOSI_PIN GPIO_Pin_x
  619. #define SPI_MOSI_PORT GPIOA
  620. #define SPI_CLK_PIN GPIO_Pin_y
  621. #define SPI_CLK_PORT GPIOA
  622. #define SPI_SS_PIN GPIO_Pin_z
  623. #define SPI_SS_PORT GPIOA
  624. #define RADIO_CHECK
  625. #else
  626. #define SOFTSPI_3WIRE
  627. #define SPI_MOSI_PIN GPIO_Pin_3
  628. #define SPI_MOSI_PORT GPIOA
  629. #define SPI_CLK_PIN GPIO_Pin_2
  630. #define SPI_CLK_PORT GPIOA
  631. #define SPI_SS_PIN GPIO_Pin_1
  632. #define SPI_SS_PORT GPIOA
  633. #define RADIO_CHECK
  634. #define RADIO_XN297L
  635. #endif
  636.  
  637. //VOLTAGE DIVIDER
  638. #define BATTERYPIN GPIO_Pin_5
  639. #define BATTERYPORT GPIOA
  640. #define BATTERY_ADC_CHANNEL ADC_Channel_5
  641. #define ADC_SCALEFACTOR 0.002423
  642. #define ADC_REF 1.0f
  643.  
  644.  
  645. // MOTOR PINS
  646. // MOTOR PINS
  647. #define MOTOR0_PIN_PA7
  648. //#define MOTOR1_PIN_PA4  //2nd Draft prototype patch
  649. //#define MOTOR2_PIN_PB1  //2nd Draft prototype patch
  650. #define MOTOR1_PIN_PB1
  651. #define MOTOR2_PIN_PA4
  652. #define MOTOR3_PIN_PA6
  653. #endif
  654.  
  655.  
  656. //**********************************************************************************************************************
  657. //***********************************************BETA TESTING ON STICK GESTURE******************************************
  658. // *************DEFINE ONLY ONE OPTION FROM THIS SECTION!!!
  659. // *************This is a new section that will allow certain beta testing features to be activated by the stick gesture
  660. // *************auxillary channel.  Even when defined - the quad will power up with these features off.  To activate -  
  661. // *************use the following stick gesture on the pitch/roll stick RIGHT-RIGHT-DOWN (leds will blink). To deactivate -
  662. // *************stick gesture LEFT-LEFT-DOWN.  Please test the features you are interested in below and give feedback!!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement