dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_board.c
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 /* Pull in the board-specific static HW definitions.
31  * Including .c files is a bit ugly but this allows all of
32  * the HW definitions to be const and static to limit their
33  * scope.
34  *
35  * NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
36  */
37 #include "board_hw_defs.c"
38 
39 #include <pios_board_info.h>
40 #include <pios.h>
41 
43 
44 static void hack_rx_pin()
45 {
46  /* This is a workaround for FrSky XM bugs.
47  * They go into firmware update mode when the pin floats at
48  * startup. There's a new firmware that fixes this, but not everyone
49  * can readily upgrade it...
50  */
51 
52  GPIO_InitTypeDef hold_rx_low = pios_uart3_usart_cfg.rx.init;
53 
54  hold_rx_low.GPIO_PuPd = GPIO_PuPd_DOWN;
55 
56  GPIO_Init(GPIOA, &hold_rx_low);
57 }
58 
60 {
61  hack_rx_pin();
62 
63  /* Delay system */
65 
66 #if defined(PIOS_INCLUDE_ANNUNC)
68 #endif /* PIOS_INCLUDE_ANNUNC */
69 
70 #if defined(PIOS_INCLUDE_FLASH)
71  /* Inititialize all flash drivers */
72  PIOS_Flash_Internal_Init(&pios_internal_flash_id, &flash_internal_cfg);
73 
74  /* Register the partition table */
76 #endif /* PIOS_INCLUDE_FLASH */
77 
78 #if defined(PIOS_INCLUDE_USB)
79  /* Initialize board specific USB data */
81 
82  /* Activate the HID-only USB configuration */
84 
85  uintptr_t pios_usb_id;
86  PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
87 
88 #if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
89  uintptr_t pios_usb_hid_id;
90  if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
91  PIOS_Assert(0);
92  }
94  PIOS_Assert(0);
95  }
96 #endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
97 
98 #endif /* PIOS_INCLUDE_USB */
99 }
100 
int32_t PIOS_Flash_Internal_Init(uintptr_t *flash_id, const struct pios_flash_internal_cfg *cfg)
Main PiOS header to include all the compiled in PiOS options.
#define NELEMENTS(x)
Definition: pios.h:192
int32_t PIOS_USB_HID_Init(uintptr_t *usbhid_id, const struct pios_usb_hid_cfg *cfg, uintptr_t lower_id)
int32_t PIOS_DELAY_Init(void)
Definition: pios_delay.c:98
const struct pios_com_driver pios_usb_hid_com_driver
static void hack_rx_pin()
Definition: pios_board.c:44
void PIOS_Board_Init()
Definition: pios_board.c:44
int32_t PIOS_ANNUNC_Init(const struct pios_annunc_cfg *cfg)
int32_t PIOS_USB_DESC_HID_ONLY_Init(void)
uintptr_t pios_com_telem_usb_id
Definition: pios_board.c:42
int32_t PIOS_COM_MSG_Init(uintptr_t *com_id, const struct pios_com_driver *driver, uintptr_t lower_id)
void PIOS_FLASH_register_partition_table(const struct pios_flash_partition partition_table[], uint8_t num_partitions)
int32_t PIOS_USB_Init(uintptr_t *usb_id, const struct pios_usb_cfg *cfg)
const struct pios_flash_partition pios_flash_partition_table[]
Definition: unittest_init.c:50
#define PIOS_Assert(test)
Definition: pios_debug.h:52
int32_t PIOS_USB_BOARD_DATA_Init(void)