mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Using hardware detection procedure to initializa chip select
lines before initialization talk with all chips
This commit is contained in:
parent
a21694b065
commit
9a5e53d8ae
3 changed files with 97 additions and 0 deletions
69
src/main/target/RACEBASE/hardware_revision.c
Executable file
69
src/main/target/RACEBASE/hardware_revision.c
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "build_config.h"
|
||||||
|
|
||||||
|
#include "drivers/system.h"
|
||||||
|
#include "drivers/bus_spi.h"
|
||||||
|
#include "drivers/sensor.h"
|
||||||
|
#include "drivers/io.h"
|
||||||
|
#include "drivers/gpio.h"
|
||||||
|
#include "drivers/exti.h"
|
||||||
|
#include "drivers/accgyro.h"
|
||||||
|
#include "drivers/accgyro_mpu.h"
|
||||||
|
#include "drivers/accgyro_mpu6500.h"
|
||||||
|
|
||||||
|
#include "hardware_revision.h"
|
||||||
|
|
||||||
|
uint8_t hardwareRevision = 1;
|
||||||
|
|
||||||
|
void detectHardwareRevision(void)
|
||||||
|
{
|
||||||
|
gpio_config_t gpio;
|
||||||
|
|
||||||
|
// GYRO CS as output
|
||||||
|
gpio.pin = GPIO_Pin_5;
|
||||||
|
gpio.mode = Mode_Out_PP;
|
||||||
|
gpio.speed = Speed_2MHz;
|
||||||
|
gpioInit(GPIOB, &gpio);
|
||||||
|
GPIO_SetBits(GPIOB, GPIO_Pin_5);
|
||||||
|
|
||||||
|
gpio.pin = GPIO_Pin_7;
|
||||||
|
gpio.mode = Mode_Out_PP;
|
||||||
|
gpio.speed = Speed_2MHz;
|
||||||
|
gpioInit(GPIOA, &gpio);
|
||||||
|
GPIO_SetBits(GPIOA, GPIO_Pin_7);
|
||||||
|
|
||||||
|
gpio.pin = GPIO_Pin_12;
|
||||||
|
gpio.mode = Mode_Out_PP;
|
||||||
|
gpio.speed = Speed_2MHz;
|
||||||
|
gpioInit(GPIOB, &gpio);
|
||||||
|
GPIO_SetBits(GPIOB, GPIO_Pin_12);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void updateHardwareRevision(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
24
src/main/target/RACEBASE/hardware_revision.h
Executable file
24
src/main/target/RACEBASE/hardware_revision.h
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include "drivers/exti.h"
|
||||||
|
|
||||||
|
extern uint8_t hardwareRevision;
|
||||||
|
|
||||||
|
void updateHardwareRevision(void);
|
||||||
|
void detectHardwareRevision(void);
|
|
@ -18,6 +18,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define TARGET_BOARD_IDENTIFIER "RBFC"
|
#define TARGET_BOARD_IDENTIFIER "RBFC"
|
||||||
|
#define USE_HARDWARE_REVISION_DETECTION
|
||||||
#define TARGET_CONFIG
|
#define TARGET_CONFIG
|
||||||
|
|
||||||
#define LED0 PB3
|
#define LED0 PB3
|
||||||
|
@ -76,6 +77,9 @@
|
||||||
#define USE_MAX7456
|
#define USE_MAX7456
|
||||||
#define MAX7456_SPI_INSTANCE SPI2
|
#define MAX7456_SPI_INSTANCE SPI2
|
||||||
#define MAX7456_SPI_CS_PIN PA7
|
#define MAX7456_SPI_CS_PIN PA7
|
||||||
|
#define MAX7456_SPI_CLK (SPI_CLOCK_STANDARD*2)
|
||||||
|
#define MAX7456_RESTORE_CLK (SPI_CLOCK_FAST)
|
||||||
|
|
||||||
|
|
||||||
#define M25P16_CS_PIN PB12
|
#define M25P16_CS_PIN PB12
|
||||||
#define M25P16_SPI_INSTANCE SPI2
|
#define M25P16_SPI_INSTANCE SPI2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue