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 
18 /*
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful, but
25  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27  * for more details.
28  *
29  * You should have received a copy of the GNU General Public License along
30  * with this program; if not, see <http://www.gnu.org/licenses/>
31  *
32  * Additional note on redistribution: The copyright and license notices above
33  * must be maintained in each individual source file that is a derivative work
34  * of this source file; otherwise redistribution is prohibited.
35  */
36 
37 /* Pull in the board-specific static HW definitions.
38  * Including .c files is a bit ugly but this allows all of
39  * the HW definitions to be const and static to limit their
40  * scope.
41  *
42  * NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
43  */
44 #include "board_hw_defs.c"
45 
46 #include <pios_board_info.h>
47 #include <pios.h>
48 
50 
52 
53  /* Delay system */
55 
56 #if defined(PIOS_INCLUDE_ANNUNC)
58 #endif /* PIOS_INCLUDE_ANNUNC */
59 
60  PWR_BackupAccessCmd(ENABLE);
61  RCC_LSEConfig(RCC_LSE_OFF);
62 
63 #if defined(PIOS_INCLUDE_SPI)
64  /* Set up the SPI interface to the flash */
65  if (PIOS_SPI_Init(&pios_spi_flash_id, &pios_spi_flash_cfg)) {
67  }
68 #endif /* PIOS_INCLUDE_SPI */
69 
70 #if defined(PIOS_INCLUDE_RE1_FPGA)
71  if (PIOS_RE1FPGA_Init(pios_spi_flash_id, 1, &pios_re1fpga_cfg, true) != 0) {
73  }
74  // For the bootloader, we use a green notification LED
76 #endif /* defined(PIOS_INCLUDE_RE1_FPGA) */
77 
78 #if defined(PIOS_INCLUDE_FLASH)
79  /* Inititialize all flash drivers */
80  PIOS_Flash_Internal_Init(&pios_internal_flash_id, &flash_internal_cfg);
81 
82 #if defined(PIOS_INCLUDE_FLASH_JEDEC)
83  PIOS_Flash_Jedec_Init(&pios_external_flash_id, pios_spi_flash_id, 0, &flash_s25fl127_cfg);
84 #endif /* PIOS_INCLUDE_FLASH_JEDEC */
85 
86  /* Register the partition table */
88 
89 #endif /* PIOS_INCLUDE_FLASH */
90 
91 #if defined(PIOS_INCLUDE_USB)
92  /* Initialize board specific USB data */
94 
95  /* Activate the HID-only USB configuration */
97 
98  uintptr_t pios_usb_id;
99  PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
100 
101 #if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
102  uintptr_t pios_usb_hid_id;
103  if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
104  PIOS_Assert(0);
105  }
107  PIOS_Assert(0);
108  }
109 #endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
110 
112 
113 #endif /* PIOS_INCLUDE_USB */
114 }
115 
int32_t PIOS_RE1FPGA_Init(pios_spi_t spi_id, uint32_t slave_num, const struct pios_re1fpga_cfg *cfg, bool load_config)
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_Flash_Jedec_Init(uintptr_t *flash_id, pios_spi_t spi_id, uint32_t slave_num, const struct pios_flash_jedec_cfg *cfg)
#define PIOS_DEBUG_Assert(test)
Definition: pios_debug.h:51
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
int32_t PIOS_SPI_Init(pios_spi_t *spi_dev, const struct pios_spi_cfg *cfg)
int32_t PIOS_RE1FPGA_SetNotificationLedColor(enum pios_re1fpga_led_colors led_colors)
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)
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)