1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

CC3D / NAZE - Adding support for hardware controlled inverter for use by

SBUS RX.
This commit is contained in:
Dominic Clifton 2014-08-01 23:36:42 +01:00
parent f08760634e
commit 4d9a672d9c
8 changed files with 103 additions and 1 deletions

View file

@ -184,6 +184,7 @@ NAZE_SRC = startup_stm32f10x_md_gcc.S \
drivers/bus_i2c_stm32f10x.c \
drivers/compass_hmc5883l.c \
drivers/gpio_stm32f10x.c \
drivers/inverter.c \
drivers/light_led_stm32f10x.c \
drivers/light_ws2811strip.c \
drivers/light_ws2811strip_stm32f10x.c \
@ -252,6 +253,7 @@ CC3D_SRC = startup_stm32f10x_md_gcc.S \
drivers/bus_i2c_stm32f10x.c \
drivers/bus_spi.c \
drivers/gpio_stm32f10x.c \
drivers/inverter.c \
drivers/light_led_stm32f10x.c \
drivers/light_ws2811strip.c \
drivers/light_ws2811strip_stm32f10x.c \

View file

@ -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 <stdbool.h>
#include <stdint.h>
#include "platform.h"
#include "gpio.h"
#include "inverter.h"
void initInverter(void)
{
#ifdef INVERTER
struct {
GPIO_TypeDef *gpio;
gpio_config_t cfg;
} gpio_setup = {
.gpio = INVERTER_GPIO,
.cfg = { INVERTER_PIN, Mode_Out_OD, Speed_2MHz }
};
RCC_APB2PeriphClockCmd(INVERTER_PERIPHERAL, ENABLE);
gpioInit(gpio_setup.gpio, &gpio_setup.cfg);
#endif
}

View file

@ -0,0 +1,29 @@
/*
* 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/>.
*/
#pragma once
#ifdef INVERTER
#define INVERTER_OFF digitalLo(INVERTER_GPIO, INVERTER_PIN);
#define INVERTER_ON digitalHi(INVERTER_GPIO, INVERTER_PIN);
#else
#define INVERTER_OFF ;
#define INVERTER_ON ;
#endif
void initInverter(void);

View file

@ -28,6 +28,9 @@
#include "build_config.h"
#include "gpio.h"
#include "inverter.h"
#include "serial.h"
#include "serial_uart.h"
@ -64,6 +67,13 @@ serialPort_t *uartOpen(USART_TypeDef *USARTx, serialReceiveCallbackPtr callback,
uartPort_t *s = NULL;
#ifdef INVERTER
if (inversion == SERIAL_INVERTED && USARTx == INVERTER_USART) {
// Enable hardware inverter if available.
INVERTER_ON;
}
#endif
if (USARTx == USART1) {
s = serialUSART1(baudRate, mode);
} else if (USARTx == USART2) {

View file

@ -24,6 +24,7 @@
#include "gpio.h"
#include "light_led.h"
#include "sound_beeper.h"
#include "inverter.h"
#include "bus_i2c.h"
#include "bus_spi.h"
@ -112,6 +113,7 @@ void systemInit(bool overclock)
ledInit();
beeperInit();
initInverter();
// Init cycle counter
cycleCounterInit();

View file

@ -25,6 +25,9 @@
#include "drivers/system.h"
#include "drivers/gpio.h"
#include "drivers/inverter.h"
#include "drivers/serial.h"
#include "drivers/serial_uart.h"
#include "io/serial.h"
@ -57,7 +60,8 @@ void sbusUpdateSerialRxFunctionConstraint(functionConstraint_t *functionConstrai
bool sbusInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback)
{
int b;
sBusPort = openSerialPort(FUNCTION_SERIAL_RX, sbusDataReceive, SBUS_BAUDRATE, (portMode_t)(MODE_RX | MODE_SBUS), SERIAL_NOT_INVERTED);
sBusPort = openSerialPort(FUNCTION_SERIAL_RX, sbusDataReceive, SBUS_BAUDRATE, (portMode_t)(MODE_RX | MODE_SBUS), SERIAL_INVERTED);
for (b = 0; b < SBUS_MAX_CHANNEL; b++)
sbusChannelData[b] = 2 * (rxConfig->midrc - SBUS_OFFSET);

View file

@ -20,8 +20,14 @@
#define LED0_PERIPHERAL RCC_APB2Periph_GPIOB
#define LED0
#define INVERTER_PIN Pin_2 // PB2 (BOOT1) used as inverter select GPIO
#define INVERTER_GPIO GPIOB
#define INVERTER_PERIPHERAL RCC_APB2Periph_GPIOB
#define INVERTER_USART USART1
#define ACC
#define GYRO
#define INVERTER
// #define SOFT_I2C // enable to test software i2c
// #define SOFT_I2C_PB1011 // If SOFT_I2C is enabled above, need to define pinout as well (I2C1 = PB67, I2C2 = PB1011)

View file

@ -32,6 +32,11 @@
#define BARO_GPIO GPIOC
#define BARO_PIN Pin_13
#define INVERTER_PIN Pin_2 // PB2 (BOOT1) abused as inverter select GPIO
#define INVERTER_GPIO GPIOB
#define INVERTER_PERIPHERAL RCC_APB2Periph_GPIOB
#define INVERTER_USART USART2
#define GYRO
#define ACC
#define MAG
@ -40,6 +45,7 @@
#define BEEPER
#define LED0
#define LED1
#define INVERTER
#define I2C_DEVICE (I2CDEV_2)