Skip to content

Commit

Permalink
HAL_ChibiOS: added ChibiOS configuration for VR Core 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeMike authored and tridge committed Jan 24, 2019
1 parent f615ab9 commit 33f7f5b
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libraries/AP_BoardConfig/AP_BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <AP_Param/AP_Param.h>
#include <AP_RTC/AP_RTC.h>

#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN || defined(HAL_CHIBIOS_ARCH_FMUV3) || defined(HAL_CHIBIOS_ARCH_FMUV4) || defined(HAL_CHIBIOS_ARCH_FMUV5) || defined(HAL_CHIBIOS_ARCH_MINDPXV2) || defined(HAL_CHIBIOS_ARCH_FMUV4PRO) || defined(HAL_CHIBIOS_ARCH_BRAINV51) || defined(HAL_CHIBIOS_ARCH_BRAINV52) || defined(HAL_CHIBIOS_ARCH_UBRAINV51)
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN || defined(HAL_CHIBIOS_ARCH_FMUV3) || defined(HAL_CHIBIOS_ARCH_FMUV4) || defined(HAL_CHIBIOS_ARCH_FMUV5) || defined(HAL_CHIBIOS_ARCH_MINDPXV2) || defined(HAL_CHIBIOS_ARCH_FMUV4PRO) || defined(HAL_CHIBIOS_ARCH_BRAINV51) || defined(HAL_CHIBIOS_ARCH_BRAINV52) || defined(HAL_CHIBIOS_ARCH_UBRAINV51) || defined(HAL_CHIBIOS_ARCH_COREV10)
#define AP_FEATURE_BOARD_DETECT 1
#else
#define AP_FEATURE_BOARD_DETECT 0
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_BoardConfig/board_drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void AP_BoardConfig::board_autodetect(void)
#elif defined(CONFIG_ARCH_BOARD_VRUBRAIN_V52)
state.board_type.set_and_notify(VRX_BOARD_UBRAIN52);
hal.console->printf("Detected VR Micro Brain 5.2\n");
#elif defined(CONFIG_ARCH_BOARD_VRCORE_V10)
#elif defined(CONFIG_ARCH_BOARD_VRCORE_V10) || defined(HAL_CHIBIOS_ARCH_COREV10)
state.board_type.set_and_notify(VRX_BOARD_CORE10);
hal.console->printf("Detected VR Core 1.0\n");
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V54)
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_HAL/AP_HAL_Boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#define HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 5016
#define HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 5017
#define HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51 5018
#define HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10 5019

/* InertialSensor driver types */
#define HAL_INS_NONE 0
Expand Down
60 changes: 60 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/VRCore-v10/hwdef-bl.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# hw definition file for processing by chibios_hwdef.py
# for VRCOREv10 hardware


# MCU class and specific type
MCU STM32F4xx STM32F407xx

# board ID for firmware load
APJ_BOARD_ID 1910

# crystal frequency
OSCILLATOR_HZ 8000000
STM32_PLLM_VALUE 8

# flash size
FLASH_SIZE_KB 1024

# board voltage
STM32_VDD 330U

# USB setup
USB_VENDOR 0x27AC
USB_PRODUCT 0x1910
USB_STRING_MANUFACTURER "Laser Navigation"
USB_STRING_SERIAL "%SERIAL%"

# don't allow bootloader to use more than 16k
FLASH_USE_MAX_KB 16

# bootloader is installed at zero offset
FLASH_RESERVE_START_KB 0

# the location where the bootloader will put the firmware
define FLASH_BOOTLOADER_LOAD_KB 16

# ChibiOS system timer
STM32_ST_USE_TIMER 5


# order of UARTs (and USB)
UART_ORDER OTG1

PA9 VBUS INPUT

PA11 OTG_FS_DM OTG1
PA12 OTG_FS_DP OTG1

PA13 JTMS-SWDIO SWD
PA14 JTCK-SWCLK SWD

PD14 LED_BOOTLOADER OUTPUT
PC5 LED_ACTIVITY OUTPUT

define HAL_LED_ON 0

define HAL_CHIBIOS_ARCH_COREV10 1

define HAL_STORAGE_SIZE 16384
define HAL_USE_EMPTY_STORAGE 1

176 changes: 176 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/VRCore-v10/hwdef.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# hw definition file for processing by chibios_hwdef.py
# for VRCOREv10 hardware

define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10

# MCU class and specific type
MCU STM32F4xx STM32F407xx

# board ID for firmware load
APJ_BOARD_ID 1910

# crystal frequency
OSCILLATOR_HZ 8000000
STM32_PLLM_VALUE 8

# flash size
FLASH_SIZE_KB 1024

# board voltage
STM32_VDD 330U

# USB setup
USB_VENDOR 0x27AC
USB_PRODUCT 0x1910
USB_STRING_MANUFACTURER "Laser Navigation"
USB_STRING_SERIAL "%SERIAL%"

# ChibiOS system timer
STM32_ST_USE_TIMER 5

# only one I2C bus
I2C_ORDER I2C2 I2C1

# order of UARTs (and USB)
UART_ORDER OTG1 USART1 USART3 USART2
STDOUT_SERIAL SD3
STDOUT_BAUDRATE 57600


PA0 BUZZER OUTPUT LOW GPIO(32)
PA1 TIM2_CH2 TIM2 PWM(1) GPIO(50)
PA2 TIM2_CH3 TIM2 PWM(2) GPIO(51)
PA3 TIM2_CH4 TIM2 PWM(3) GPIO(52)
PA4 SDCARD_CS CS
PA5 SPI1_SCK SPI1
PA6 SPI1_MISO SPI1
PA7 SPI1_MOSI SPI1
#PA8
PA9 VBUS INPUT
#P10
PA11 OTG_FS_DM OTG1
PA12 OTG_FS_DP OTG1
PA13 JTMS-SWDIO SWD
PA14 JTCK-SWCLK SWD
#PA15

PB0 TIM3_CH3 TIM3 PWM(5) GPIO(54)
PB1 TIM3_CH4 TIM3 PWM(6) GPIO(55)
#PB2
PB3 LED_EXT3 OUTPUT GPIO(30)
PB4 LED_EXT4 OUTPUT GPIO(31)
PB5 TIM3_CH2 TIM3 PWM(4) GPIO(53)
PB6 USART1_TX USART1
PB7 USART1_RX USART1
PB8 I2C1_SCL I2C1
PB9 I2C1_SDA I2C1
PB10 I2C2_SCL I2C2
PB11 I2C2_SDA I2C2
#PB12
PB13 SPI2_SCK SPI2
PB14 SPI2_MISO SPI2
PB15 SPI2_MOSI SPI2

PC0 BATT_VOLTAGE_SENS ADC1
PC1 BATT_CURRENT_SENS ADC1
#PC2
#PC3
#PC4
PC5 LED_GREEN OUTPUT GPIO(25)
#PC6
PC7 TIM8_CH2 TIM8 RCIN FLOAT LOW
PC8 RELAY_1 OUTPUT LOW GPIO(33)
PC9 RELAY_2 OUTPUT LOW GPIO(34)
PC10 SPI3_SCK SPI3
PC11 SPI3_MISO SPI3
PC12 SPI3_MOSI SPI3
#PC13
#PC14
#PC15

#PD0
#PD1
#PD2
#PD3
#PD4
PD5 USART2_TX USART2
PD6 USART2_RX USART2
PD7 SBUS_INV OUTPUT
PD8 USART3_TX USART3
PD9 USART3_RX USART3
#PD10
#PD11
PD12 TIM4_CH1 TIM4 PWM(8) GPIO(57)
PD13 TIM4_CH2 TIM4 PWM(7) GPIO(56)
PD15 LED_RED OUTPUT GPIO(27)
PD14 LED_BLUE OUTPUT GPIO(26)

PE0 BARO_CS CS
#PE1
PE2 LED_EXT1 OUTPUT GPIO(29)
PE3 LED_EXT2 OUTPUT GPIO(28)
PE4 RELAY_3 OUTPUT LOW GPIO(35)
#PE5 TIM9_CH1 TIM9 PWM(13) GPIO(62)
#PE6 TIM9_CH2 TIM9 PWM(14) GPIO(63)
#PE7
#PE8
PE9 TIM1_CH1 TIM1 PWM(9) GPIO(58)
PE10 MPU_CS CS
PE11 TIM1_CH2 TIM1 PWM(10) GPIO(59)
#PE12
PE13 TIM1_CH3 TIM1 PWM(11) GPIO(60)
PE14 TIM1_CH4 TIM1 PWM(12) GPIO(61)
PE15 FRAM_CS CS

# SPI device table. The DEVID values are chosen to match the PX4 port
# of ArduPilot so users don't need to re-do their accel and compass calibrations
# when moving to ChibiOS
SPIDEV ms5611 SPI1 DEVID3 BARO_CS MODE3 20*MHZ 20*MHZ
SPIDEV mpu9250 SPI2 DEVID4 MPU_CS MODE3 4*MHZ 8*MHZ
SPIDEV ramtron SPI3 DEVID10 FRAM_CS MODE3 8*MHZ 8*MHZ
SPIDEV sdcard SPI3 DEVID1 SDCARD_CS MODE0 400*KHZ 25*MHZ

define HAL_CHIBIOS_ARCH_COREV10 1

define HAL_BOARD_LOG_DIRECTORY "/APM/LOGS"
define HAL_BOARD_TERRAIN_DIRECTORY "/APM/TERRAIN"

define HAL_STORAGE_SIZE 16384
define STORAGE_FLASH_PAGE 22

# enable RAMTROM parameter storage
define HAL_WITH_RAMTRON 1

# enable FAT filesystem
define HAL_OS_FATFS_IO 1

define HAL_GPIO_LED_ON 0
define HAL_GPIO_LED_OFF 1

define HAL_GPIO_A_LED_PIN 25
define HAL_GPIO_B_LED_PIN 26
define HAL_GPIO_C_LED_PIN 27
define EXTERNAL_LED_GPS 28
define EXTERNAL_LED_ARMED 29
define EXTERNAL_LED_MOTOR1 30
define EXTERNAL_LED_MOTOR2 31

define RELAY1_PIN_DEFAULT 33
define RELAY2_PIN_DEFAULT 34
define RELAY3_PIN_DEFAULT 35

define HAL_BUZZER_PIN 32
define HAL_BUZZER_ON 1
define HAL_BUZZER_OFF 0

# battery setup
define HAL_BATT_VOLT_PIN 2
define HAL_BATT_CURR_PIN 3
define HAL_BATT_VOLT_SCALE 10.1
define HAL_BATT_CURR_SCALE 17.0

define STM32_PWM_USE_ADVANCED TRUE

# 12 PWM available by default
define BOARD_PWM_COUNT_DEFAULT 14

4 changes: 2 additions & 2 deletions libraries/AP_Notify/AP_Notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ void AP_Notify::add_backends(void)
#endif
#endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX

#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10
ADD_BACKEND(new ExternalLED()); // despite the name this is a built in set of onboard LED's
#endif // CONFIG_HAL_BOARD_SUBTYPE == various CHIBIOS-VRBRAINs

#if defined(HAL_HAVE_PIXRACER_LED)
ADD_BACKEND(new PixRacerLED());
#elif (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && defined(HAL_GPIO_C_LED_PIN))
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10
ADD_BACKEND(new VRBoard_LED());
#else
ADD_BACKEND(new AP_BoardLED());
Expand Down

0 comments on commit 33f7f5b

Please sign in to comment.