39 #include "board_hw_defs.c"
44 #include <uavobjectsinit.h>
46 #include "hwplayuavosd.h"
47 #include "modulesettings.h"
48 #include "onscreendisplaysettings.h"
51 #include "attitudeactual.h"
53 #include "baroaltitude.h"
54 #include "flightstatus.h"
55 #include "manualcontrolcommand.h"
56 #include "positionactual.h"
57 #include "stabilizationsettings.h"
58 #include "tabletinfo.h"
72 #if defined(PIOS_INCLUDE_VIDEO)
73 void OSD_configure_bw_levels(
void)
75 GPIO_InitTypeDef GPIO_InitStructure;
76 TIM_OCInitTypeDef TIM_OCInitStructure;
77 TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
81 RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
84 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
87 GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_TIM1);
88 GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_TIM1);
91 GPIO_StructInit(&GPIO_InitStructure);
92 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_10;
93 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
94 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
95 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
96 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
97 GPIO_Init(GPIOA, &GPIO_InitStructure);
101 TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
102 TIM_TimeBaseStructure.TIM_Prescaler = (
PIOS_SYSCLK / 25500000) - 1;
103 TIM_TimeBaseStructure.TIM_Period = 255;
104 TIM_TimeBaseStructure.TIM_ClockDivision = 0;
105 TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
106 TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
109 TIM_ARRPreloadConfig(TIM1, ENABLE);
112 TIM_OCStructInit(&TIM_OCInitStructure);
113 TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
114 TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
115 TIM_OCInitStructure.TIM_Pulse = 90;
116 TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
119 TIM_OC1Init(TIM1, &TIM_OCInitStructure);
120 TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable);
121 TIM_OC3Init(TIM1, &TIM_OCInitStructure);
122 TIM_OC3PreloadConfig(TIM1, TIM_OCPreload_Enable);
125 TIM_CtrlPWMOutputs(TIM1, ENABLE);
128 TIM_Cmd(TIM1, ENABLE);
144 GPIO_InitTypeDef GPIO_InitStructure;
145 GPIO_StructInit(&GPIO_InitStructure);
146 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
147 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
148 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
149 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
150 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
151 GPIO_Init(GPIOB, &GPIO_InitStructure);
152 GPIO_ResetBits(GPIOB, GPIO_Pin_12);
154 #if defined(PIOS_INCLUDE_ANNUNC)
158 #if defined(PIOS_INCLUDE_FLASH)
171 HwPlayUavOsdInitialize();
172 ModuleSettingsInitialize();
174 #if defined(PIOS_INCLUDE_RTC)
182 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
198 if (boot_count < 3) {
203 HwPlayUavOsdSetDefaults(HwPlayUavOsdHandle(), 0);
204 ModuleSettingsSetDefaults(ModuleSettingsHandle(),0);
205 AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
208 #if defined(PIOS_INCLUDE_USB)
213 bool usb_hid_present =
false;
214 bool usb_cdc_present =
false;
216 #if defined(PIOS_INCLUDE_USB_CDC)
220 usb_hid_present =
true;
221 usb_cdc_present =
true;
226 usb_hid_present =
true;
229 uintptr_t pios_usb_id;
232 #if defined(PIOS_INCLUDE_USB_CDC)
234 uint8_t hw_usb_vcpport;
236 HwPlayUavOsdUSB_VCPPortGet(&hw_usb_vcpport);
238 if (!usb_cdc_present) {
240 hw_usb_vcpport = HWPLAYUAVOSD_USB_VCPPORT_DISABLED;
247 #if defined(PIOS_INCLUDE_USB_HID)
249 uint8_t hw_usb_hidport;
250 HwPlayUavOsdUSB_HIDPortGet(&hw_usb_hidport);
252 if (!usb_hid_present) {
254 hw_usb_hidport = HWPLAYUAVOSD_USB_HIDPORT_DISABLED;
261 if (usb_hid_present || usb_cdc_present) {
268 HwPlayUavOsdMainPortGet(&hw_mainport);
270 PIOS_HAL_ConfigurePort(hw_mainport,
286 #if defined(PIOS_INCLUDE_SPI)
287 if (
PIOS_SPI_Init(&pios_spi_max7456_id, &pios_spi_max7456_cfg))
290 GPIO_StructInit(&GPIO_InitStructure);
291 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
292 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
293 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
294 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
295 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
296 GPIO_Init(GPIOC, &GPIO_InitStructure);
297 GPIO_SetBits(GPIOC, GPIO_Pin_0);
298 GPIO_Init(GPIOA, &GPIO_InitStructure);
299 GPIO_ResetBits(GPIOA, GPIO_Pin_0);
301 #if defined (PIOS_INCLUDE_MAX7456)
305 #endif // defined (PIOS_INCLUDE_MAX7456)
307 #endif // defined(PIOS_INCLUDE_SPI)
309 #if defined(PIOS_INCLUDE_VIDEO)
315 OnScreenDisplaySettingsInitialize();
318 OnScreenDisplaySettingsOSDEnabledGet(&osd_state);
319 if (osd_state == ONSCREENDISPLAYSETTINGS_OSDENABLED_ENABLED) {
320 OSD_configure_bw_levels();
322 #endif // defined(PIOS_INCLUDE_VIDEO)
332 AttitudeActualInitialize();
334 BaroAltitudeInitialize();
335 FlightStatusInitialize();
336 ManualControlCommandInitialize();
337 PositionActualInitialize();
338 StabilizationSettingsInitialize();
339 TabletInfoInitialize();
int32_t PIOS_Flash_Internal_Init(uintptr_t *flash_id, const struct pios_flash_internal_cfg *cfg)
int32_t PIOS_USB_DESC_HID_CDC_Init(void)
void PIOS_HAL_ConfigureCDC(HwSharedUSB_VCPPortOptions port_type, uintptr_t usb_id, const struct pios_usb_cdc_cfg *cdc_cfg)
Main PiOS header to include all the compiled in PiOS options.
#define PIOS_DEBUG_Assert(test)
static const struct pios_usart_cfg pios_usart_main_cfg
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity)
uintptr_t pios_uavo_settings_fs_id
uint16_t PIOS_IAP_ReadBootCount(void)
int32_t PIOS_FLASHFS_Logfs_Init(uintptr_t *fs_id, const struct flashfs_logfs_cfg *cfg, enum pios_flash_partition_labels partition_label)
Initialize the flash object setting FS.
static const struct pios_tim_clock_cfg tim_8_cfg
static void PIOS_BOARD_Init_Uavos(void)
struct max7456_dev_s * max7456_dev_t
void PIOS_WDG_Clear(void)
Clear the watchdog timer.
uintptr_t pios_com_telem_serial_id
const struct pios_com_driver pios_usart_com_driver
static const struct pios_tim_clock_cfg tim_5_cfg
void PIOS_IAP_Init(void)
PIOS_IAP_Init - performs required initializations for iap module.
int32_t PIOS_TIM_InitClock(const struct pios_tim_clock_cfg *cfg)
const struct pios_spi_cfg mask
int32_t PIOS_SPI_Init(pios_spi_t *spi_dev, const struct pios_spi_cfg *cfg)
int32_t PIOS_ANNUNC_Init(const struct pios_annunc_cfg *cfg)
void PIOS_RTC_Init(const struct pios_rtc_cfg *cfg)
int32_t PIOS_USB_DESC_HID_ONLY_Init(void)
void PIOS_HAL_ConfigureHID(HwSharedUSB_HIDPortOptions port_type, uintptr_t usb_id, const struct pios_usb_hid_cfg *hid_cfg)
uintptr_t pios_com_telem_usb_id
static const struct pios_tim_clock_cfg tim_12_cfg
void PIOS_USBHOOK_Activate(void)
void PIOS_FLASH_register_partition_table(const struct pios_flash_partition partition_table[], uint8_t num_partitions)
Includes PiOS and core architecture components.
int32_t AlarmsClear(SystemAlarmsAlarmElem alarm)
int32_t PIOS_USB_Init(uintptr_t *usb_id, const struct pios_usb_cfg *cfg)
void PIOS_IAP_WriteBootCount(uint16_t)
void PIOS_HAL_CriticalError(uint32_t led_id, enum pios_hal_panic code)
Flash a blink code.
#define PIOS_Assert(test)
int PIOS_MAX7456_init(max7456_dev_t *dev_out, pios_spi_t spi_handle, uint32_t slave_idx)
Allocate and initialise MAX7456 device.
int32_t PIOS_USB_BOARD_DATA_Init(void)
void PIOS_RESET_Clear(void)
PIOS_RESET_Clear Does nothing on POSIX systems.