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 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  *
27  * Additional note on redistribution: The copyright and license notices above
28  * must be maintained in each individual source file that is a derivative work
29  * of this source file; otherwise redistribution is prohibited.
30  */
31 
32 #include "board_hw_defs.c"
33 #include <pios_board_info.h>
34 #include <pios.h>
35 
36 
38 
40 {
41  // Drive USB re-enumerate pin low (so it doesn't pull DP down!)
42  GPIO_InitTypeDef GPIO_InitStructure;
43  GPIO_StructInit(&GPIO_InitStructure);
44  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
45  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
46  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
47  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
48  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
49  GPIO_Init(GPIOB, &GPIO_InitStructure);
50  GPIO_ResetBits(GPIOB, GPIO_Pin_12);
51 
53 
54  const struct pios_board_info *bdinfo = &pios_board_info_blob;
55 
56 #if defined(PIOS_INCLUDE_ANNUNC)
57  const struct pios_annunc_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
58  PIOS_Assert(led_cfg);
59  PIOS_ANNUNC_Init(led_cfg);
60 #endif /* PIOS_INCLUDE_ANNUNC */
61 
62 #if defined(PIOS_INCLUDE_FLASH)
63  PIOS_Flash_Internal_Init(&pios_internal_flash_id, &flash_internal_cfg);
64 
65  PIOS_FLASH_register_partition_table(pios_flash_partition_table_internal, NELEMENTS(pios_flash_partition_table_internal));
66 #endif /* PIOS_INCLUDE_FLASH */
67 
68 #if defined(PIOS_INCLUDE_USB)
70  /* Bootloader only uses HID */
72 
73  uintptr_t pios_usb_id;
74  PIOS_USB_Init(&pios_usb_id, PIOS_BOARD_HW_DEFS_GetUsbCfg(bdinfo->board_rev));
75 
76 #if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
77  uintptr_t pios_usb_hid_id;
78  if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id))
79  PIOS_Assert(0);
81  PIOS_Assert(0);
82 #endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
83 
85 #endif /* PIOS_INCLUDE_USB */
86 }
87 
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_board_info pios_board_info_blob
const struct pios_com_driver pios_usb_hid_com_driver
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_USBHOOK_Activate(void)
Definition: pios_usbhook.c:80
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)
#define PIOS_Assert(test)
Definition: pios_debug.h:52
int32_t PIOS_USB_BOARD_DATA_Init(void)