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.h>
40 #include <pios_hal.h>
41 #include <openpilot.h>
42 #include <uavobjectsinit.h>
43 #include "hwsparky2.h"
44 #include "manualcontrolsettings.h"
45 #include "modulesettings.h"
46 #include <pios_openlrs_rcvr_priv.h>
47 
48 
49 #define PIOS_COM_CAN_RX_BUF_LEN 256
50 #define PIOS_COM_CAN_TX_BUF_LEN 256
51 
53 uintptr_t pios_com_can_id;
54 uintptr_t pios_internal_adc_id = 0;
56 
57 uintptr_t pios_can_id;
58 
59 void set_vtx_channel(HwSparky2VTX_ChOptions channel)
60 {
61  uint8_t chan = 0;
62  uint8_t band = 0xFF; // Set to "A" band
63 
64  switch (channel) {
65  case HWSPARKY2_VTX_CH_BOSCAMACH15725:
66  chan = 0;
67  band = 0;
68  case HWSPARKY2_VTX_CH_BOSCAMACH25745:
69  chan = 1;
70  band = 0;
71  break;
72  case HWSPARKY2_VTX_CH_BOSCAMACH35765:
73  chan = 2;
74  band = 0;
75  break;
76  case HWSPARKY2_VTX_CH_BOSCAMACH45785:
77  chan = 3;
78  band = 0;
79  break;
80  case HWSPARKY2_VTX_CH_BOSCAMACH55805:
81  chan = 4;
82  band = 0;
83  break;
84  case HWSPARKY2_VTX_CH_BOSCAMACH65825:
85  chan = 5;
86  band = 0;
87  break;
88  case HWSPARKY2_VTX_CH_BOSCAMACH75845:
89  chan = 6;
90  band = 0;
91  break;
92  case HWSPARKY2_VTX_CH_BOSCAMACH85865:
93  chan = 7;
94  band = 0;
95  break;
96  case HWSPARKY2_VTX_CH_BOSCAMBCH15733:
97  chan = 0;
98  band = 1;
99  break;
100  case HWSPARKY2_VTX_CH_BOSCAMBCH25752:
101  chan = 1;
102  band = 1;
103  break;
104  case HWSPARKY2_VTX_CH_BOSCAMBCH35771:
105  chan = 2;
106  band = 1;
107  break;
108  case HWSPARKY2_VTX_CH_BOSCAMBCH45790:
109  chan = 3;
110  band = 1;
111  break;
112  case HWSPARKY2_VTX_CH_BOSCAMBCH55809:
113  chan = 4;
114  band = 1;
115  break;
116  case HWSPARKY2_VTX_CH_BOSCAMBCH65828:
117  chan = 5;
118  band = 1;
119  break;
120  case HWSPARKY2_VTX_CH_BOSCAMBCH75847:
121  chan = 6;
122  band = 1;
123  break;
124  case HWSPARKY2_VTX_CH_BOSCAMBCH85866:
125  chan = 7;
126  band = 1;
127  break;
128  case HWSPARKY2_VTX_CH_BOSCAMECH15705:
129  chan = 0;
130  band = 2;
131  break;
132  case HWSPARKY2_VTX_CH_BOSCAMECH25685:
133  chan = 1;
134  band = 2;
135  break;
136  case HWSPARKY2_VTX_CH_BOSCAMECH35665:
137  chan = 2;
138  band = 2;
139  break;
140  case HWSPARKY2_VTX_CH_BOSCAMECH45645:
141  chan = 3;
142  band = 2;
143  break;
144  case HWSPARKY2_VTX_CH_BOSCAMECH55885:
145  chan = 4;
146  band = 2;
147  break;
148  case HWSPARKY2_VTX_CH_BOSCAMECH65905:
149  chan = 5;
150  band = 2;
151  break;
152  case HWSPARKY2_VTX_CH_BOSCAMECH75925:
153  chan = 6;
154  band = 2;
155  break;
156  case HWSPARKY2_VTX_CH_BOSCAMECH85945:
157  chan = 7;
158  band = 2;
159  break;
160  case HWSPARKY2_VTX_CH_AIRWAVECH15740:
161  chan = 0;
162  band = 3;
163  break;
164  case HWSPARKY2_VTX_CH_AIRWAVECH25760:
165  chan = 1;
166  band = 3;
167  break;
168  case HWSPARKY2_VTX_CH_AIRWAVECH35780:
169  chan = 2;
170  band = 3;
171  break;
172  case HWSPARKY2_VTX_CH_AIRWAVECH45800:
173  chan = 3;
174  band = 3;
175  break;
176  case HWSPARKY2_VTX_CH_AIRWAVECH55820:
177  chan = 4;
178  band = 3;
179  break;
180  case HWSPARKY2_VTX_CH_AIRWAVECH65840:
181  chan = 5;
182  band = 3;
183  break;
184  case HWSPARKY2_VTX_CH_AIRWAVECH75860:
185  chan = 6;
186  band = 3;
187  break;
188  case HWSPARKY2_VTX_CH_AIRWAVECH85860:
189  chan = 7;
190  band = 3;
191  break;
192  }
193 
194  GPIO_InitTypeDef GPIO_InitStructure;
195  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
196  GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
197  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
198  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
199 
200  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
201  GPIO_Init(GPIOB, &GPIO_InitStructure);
202  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
203  GPIO_Init(GPIOB, &GPIO_InitStructure);
204  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
205  GPIO_Init(GPIOB, &GPIO_InitStructure);
206 
207  if (chan & 0x01) {
208  GPIO_SetBits(GPIOB, GPIO_Pin_14);
209  } else {
210  GPIO_ResetBits(GPIOB, GPIO_Pin_14);
211  }
212 
213  if (chan & 0x02) {
214  GPIO_SetBits(GPIOB, GPIO_Pin_13);
215  } else {
216  GPIO_ResetBits(GPIOB, GPIO_Pin_13);
217  }
218 
219  if (chan & 0x04) {
220  GPIO_SetBits(GPIOB, GPIO_Pin_12);
221  } else {
222  GPIO_ResetBits(GPIOB, GPIO_Pin_12);
223  }
224 
225  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
226  GPIO_Init(GPIOA, &GPIO_InitStructure);
227  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
228  GPIO_Init(GPIOA, &GPIO_InitStructure);
229 
230  if (band & 0x01) {
231  GPIO_SetBits(GPIOA, GPIO_Pin_9);
232  } else {
233  GPIO_ResetBits(GPIOA, GPIO_Pin_9);
234  }
235 
236  if (band & 0x02) {
237  GPIO_SetBits(GPIOA, GPIO_Pin_10);
238  } else {
239  GPIO_ResetBits(GPIOA, GPIO_Pin_10);
240  }
241 }
242 
249 #include <pios_board_info.h>
250 
251 void PIOS_Board_Init(void) {
252  const struct pios_board_info * bdinfo = &pios_board_info_blob;
253 
254  // Make sure all the PWM outputs are low
255  const struct pios_servo_cfg * servo_cfg = get_servo_cfg(bdinfo->board_rev);
256  const struct pios_tim_channel * channels = servo_cfg->channels;
257  uint8_t num_channels = servo_cfg->num_channels;
258  for (int i = 0; i < num_channels; i++) {
259  GPIO_Init(channels[i].pin.gpio, (GPIO_InitTypeDef*) &channels[i].pin.init);
260  }
261 
262 #if defined(PIOS_INCLUDE_ANNUNC)
263  const struct pios_annunc_cfg * led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
264  PIOS_Assert(led_cfg);
265  PIOS_ANNUNC_Init(led_cfg);
266 #endif /* PIOS_INCLUDE_ANNUNC */
267 
268  pios_spi_t pios_spi_gyro_id;
269 
270  /* Set up the SPI interface to the gyro/acelerometer */
271  if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) {
273  }
274 
275  /* Set up the SPI interface to the flash and rfm22b */
276  if (PIOS_SPI_Init(&pios_spi_telem_flash_id, &pios_spi_telem_flash_cfg)) {
278  }
279 
280 #if defined(PIOS_INCLUDE_FLASH)
281  /* Inititialize all flash drivers */
282 #if defined(PIOS_INCLUDE_FLASH_JEDEC)
283  if (get_external_flash(bdinfo->board_rev)) {
284  if (PIOS_Flash_Jedec_Init(&pios_external_flash_id, pios_spi_telem_flash_id, 1, &flash_m25p_cfg) != 0)
286  }
287 #endif /* PIOS_INCLUDE_FLASH_JEDEC */
288 
289  PIOS_Flash_Internal_Init(&pios_internal_flash_id, &flash_internal_cfg);
290 
291  /* Register the partition table */
292  const struct pios_flash_partition * flash_partition_table;
293  uint32_t num_partitions;
294  flash_partition_table = PIOS_BOARD_HW_DEFS_GetPartitionTable(bdinfo->board_rev, &num_partitions);
295  PIOS_FLASH_register_partition_table(flash_partition_table, num_partitions);
296 
297  /* Mount all filesystems */
300 #if defined(PIOS_INCLUDE_FLASH_JEDEC)
301 #endif /* PIOS_INCLUDE_FLASH_JEDEC */
302 
303 #endif /* PIOS_INCLUDE_FLASH */
304 
305  /* Initialize the hardware UAVOs */
306  HwSparky2Initialize();
307  ModuleSettingsInitialize();
308 
309 #if defined(PIOS_INCLUDE_RTC)
310  PIOS_RTC_Init(&pios_rtc_main_cfg);
311 #endif
312 
313  /* Initialize watchdog as early as possible to catch faults during init
314  * but do it only if there is no debugger connected
315  */
316  if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
317  PIOS_WDG_Init();
318  }
319 
320  PIOS_RESET_Clear(); // Clear the RCC reset flags after use.
321 
322  /* Set up pulse timers */
328 
329  NVIC_InitTypeDef tim_8_up_irq = {
330  .NVIC_IRQChannel = TIM8_UP_TIM13_IRQn,
331  .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
332  .NVIC_IRQChannelSubPriority = 0,
333  .NVIC_IRQChannelCmd = ENABLE,
334  };
335  NVIC_Init(&tim_8_up_irq);
336 
337  /* IAP System Setup */
338  PIOS_IAP_Init();
339  uint16_t boot_count = PIOS_IAP_ReadBootCount();
340  if (boot_count < 3) {
341  PIOS_IAP_WriteBootCount(++boot_count);
342  AlarmsClear(SYSTEMALARMS_ALARM_BOOTFAULT);
343  } else {
344  /* Too many failed boot attempts, force hw config to defaults */
345  HwSparky2SetDefaults(HwSparky2Handle(), 0);
346  ModuleSettingsSetDefaults(ModuleSettingsHandle(),0);
347  AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
348  }
349 
350 
351  //PIOS_IAP_Init();
352 
353 #if defined(PIOS_INCLUDE_USB)
354  /* Initialize board specific USB data */
356 
357  /* Flags to determine if various USB interfaces are advertised */
358  bool usb_hid_present = false;
359  bool usb_cdc_present = false;
360 
361 #if defined(PIOS_INCLUDE_USB_CDC)
363  PIOS_Assert(0);
364  }
365  usb_hid_present = true;
366  usb_cdc_present = true;
367 #else
369  PIOS_Assert(0);
370  }
371  usb_hid_present = true;
372 #endif
373 
374  uintptr_t pios_usb_id;
375  PIOS_USB_Init(&pios_usb_id, PIOS_BOARD_HW_DEFS_GetUsbCfg(bdinfo->board_rev));
376 
377 #if defined(PIOS_INCLUDE_USB_CDC)
378 
379  uint8_t hw_usb_vcpport;
380  /* Configure the USB VCP port */
381  HwSparky2USB_VCPPortGet(&hw_usb_vcpport);
382 
383  if (!usb_cdc_present) {
384  /* Force VCP port function to disabled if we haven't advertised VCP in our USB descriptor */
385  hw_usb_vcpport = HWSPARKY2_USB_VCPPORT_DISABLED;
386  }
387 
388  PIOS_HAL_ConfigureCDC(hw_usb_vcpport, pios_usb_id, &pios_usb_cdc_cfg);
389 
390 #endif /* PIOS_INCLUDE_USB_CDC */
391 
392 #if defined(PIOS_INCLUDE_USB_HID)
393  /* Configure the usb HID port */
394  uint8_t hw_usb_hidport;
395  HwSparky2USB_HIDPortGet(&hw_usb_hidport);
396 
397  if (!usb_hid_present) {
398  /* Force HID port function to disabled if we haven't advertised HID in our USB descriptor */
399  hw_usb_hidport = HWSPARKY2_USB_HIDPORT_DISABLED;
400  }
401 
402  PIOS_HAL_ConfigureHID(hw_usb_hidport, pios_usb_id, &pios_usb_hid_cfg);
403 
404 #endif /* PIOS_INCLUDE_USB_HID */
405 
406  if (usb_hid_present || usb_cdc_present) {
408  }
409 #endif /* PIOS_INCLUDE_USB */
410 
411  /* Configure IO ports */
412  HwSparky2DSMxModeOptions hw_DSMxMode;
413  HwSparky2DSMxModeGet(&hw_DSMxMode);
414 
415  /* Configure main USART port */
416  uint8_t hw_mainport;
417  HwSparky2MainPortGet(&hw_mainport);
418 
419  PIOS_HAL_ConfigurePort(hw_mainport, // port type protocol
420  &pios_usart_main_cfg, // usart_port_cfg
421  &pios_usart_com_driver, // com_driver
422  NULL, // i2c_id
423  NULL, // i2c_cfg
424  NULL, // i2c_cfg
425  NULL, // pwm_cfg
426  PIOS_LED_ALARM, // led_id
427  &pios_dsm_main_cfg, // dsm_cfg
428  hw_DSMxMode, // dsm_mode
429  NULL); // sbus_cfg
430 
431  /* Configure FlexiPort */
432  uint8_t hw_flexiport;
433  HwSparky2FlexiPortGet(&hw_flexiport);
434 
435  PIOS_HAL_ConfigurePort(hw_flexiport, // port type protocol
436  &pios_usart_flexi_cfg, // usart_port_cfg
437  &pios_usart_com_driver, // com_driver
438  &pios_i2c_flexiport_adapter_id, // i2c_id
439  &pios_i2c_flexiport_adapter_cfg, // i2c_cfg
440  NULL, // i2c_cfg
441  NULL, // pwm_cfg
442  PIOS_LED_ALARM, // led_id
443  &pios_dsm_flexi_cfg, // dsm_cfg
444  hw_DSMxMode, // dsm_mode
445  NULL); // sbus_cfg
446 
447 #if defined(PIOS_INCLUDE_OPENLRS)
448  HwSparky2Data hwSparky2;
449  HwSparky2Get(&hwSparky2);
450 
451  const struct pios_openlrs_cfg *openlrs_cfg = PIOS_BOARD_HW_DEFS_GetOpenLRSCfg(bdinfo->board_rev);
452 
453  PIOS_HAL_ConfigureRFM22B(pios_spi_telem_flash_id,
454  bdinfo->board_type, bdinfo->board_rev,
455  hwSparky2.RfBand, hwSparky2.MaxRfPower,
456  openlrs_cfg, &openlrs_handle);
457 #endif /* PIOS_INCLUDE_OPENLRS */
458 
459  /* Configure the receiver port*/
460  uint8_t hw_rcvrport;
461  HwSparky2RcvrPortGet(&hw_rcvrport);
462 
463  if (bdinfo->board_rev != BRUSHEDSPARKY_V0_2 && hw_DSMxMode >= HWSPARKY2_DSMXMODE_BIND3PULSES) {
464  hw_DSMxMode = HWSPARKY2_DSMXMODE_AUTODETECT; /* Do not try to bind through XOR */
465  }
466 
467  PIOS_HAL_ConfigurePort(hw_rcvrport, // port type protocol
468  get_usart_rcvr_cfg(bdinfo->board_rev), // usart_port_cfg
469  &pios_usart_com_driver, // com_driver
470  NULL, // i2c_id
471  NULL, // i2c_cfg
472  &pios_ppm_cfg, // ppm_cfg
473  NULL, // pwm_cfg
474  PIOS_LED_ALARM, // led_id
475  &pios_dsm_rcvr_cfg, // dsm_cfg
476  hw_DSMxMode, // dsm_mode
477  get_sbus_cfg(bdinfo->board_rev)); // sbus_cfg
478 
479 #ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS
480  /* Set up the servo outputs */
482 #else
483  PIOS_DEBUG_Init(&pios_tim_servo_all_channels, NELEMENTS(pios_tim_servo_all_channels));
484 #endif
485 
486  if (PIOS_I2C_Init(&pios_i2c_mag_pressure_adapter_id, &pios_i2c_mag_pressure_adapter_cfg)) {
488  }
489 
490 #if defined(PIOS_INCLUDE_CAN)
491  if(get_use_can(bdinfo->board_rev)) {
494 
499 
500  /* pios_com_bridge_id = pios_com_can_id; */
501  }
502 #endif
503 
504  PIOS_DELAY_WaitmS(50);
505 
507 
508 #if defined(PIOS_INCLUDE_ADC)
509  uintptr_t internal_adc_id;
510  PIOS_INTERNAL_ADC_Init(&internal_adc_id, &pios_adc_cfg);
512 #endif
513 
514 #if defined(PIOS_INCLUDE_MS5611)
515  if ((PIOS_MS5611_Init(&pios_ms5611_cfg, pios_i2c_mag_pressure_adapter_id) != 0)
516  || (PIOS_MS5611_Test() != 0))
518 #endif
519 
520  uint8_t Magnetometer;
521  HwSparky2MagnetometerGet(&Magnetometer);
522 
523  if (Magnetometer != HWSPARKY2_MAGNETOMETER_INTERNAL)
524  pios_mpu_cfg.use_internal_mag = false;
525 
526 
527 #if defined(PIOS_INCLUDE_MPU)
528  pios_mpu_dev_t mpu_dev = NULL;
529  if (PIOS_MPU_SPI_Init(&mpu_dev, pios_spi_gyro_id, 0, &pios_mpu_cfg) != 0)
531 
532  HwSparky2GyroRangeOptions hw_gyro_range;
533  HwSparky2GyroRangeGet(&hw_gyro_range);
534  switch(hw_gyro_range) {
535  case HWSPARKY2_GYRORANGE_250:
537  break;
538  case HWSPARKY2_GYRORANGE_500:
540  break;
541  case HWSPARKY2_GYRORANGE_1000:
543  break;
544  case HWSPARKY2_GYRORANGE_2000:
546  break;
547  }
548 
549  HwSparky2AccelRangeOptions hw_accel_range;
550  HwSparky2AccelRangeGet(&hw_accel_range);
551  switch(hw_accel_range) {
552  case HWSPARKY2_ACCELRANGE_2G:
554  break;
555  case HWSPARKY2_ACCELRANGE_4G:
557  break;
558  case HWSPARKY2_ACCELRANGE_8G:
560  break;
561  case HWSPARKY2_ACCELRANGE_16G:
563  break;
564  }
565 
566  HwSparky2MPU9250GyroLPFOptions hw_mpu_dlpf;
567  HwSparky2MPU9250GyroLPFGet(&hw_mpu_dlpf);
568  uint16_t bandwidth = \
569  (hw_mpu_dlpf == HWSPARKY2_MPU9250GYROLPF_184) ? 184 : \
570  (hw_mpu_dlpf == HWSPARKY2_MPU9250GYROLPF_92) ? 92 : \
571  (hw_mpu_dlpf == HWSPARKY2_MPU9250GYROLPF_41) ? 41 : \
572  (hw_mpu_dlpf == HWSPARKY2_MPU9250GYROLPF_20) ? 20 : \
573  (hw_mpu_dlpf == HWSPARKY2_MPU9250GYROLPF_10) ? 10 : \
574  (hw_mpu_dlpf == HWSPARKY2_MPU9250GYROLPF_5) ? 5 : \
575  188;
576  PIOS_MPU_SetGyroBandwidth(bandwidth);
577 #endif
578 
579  PIOS_WDG_Clear();
580 
581 #if defined(PIOS_INCLUDE_I2C)
582  uint8_t hw_magnetometer;
583  HwSparky2MagnetometerGet(&hw_magnetometer);
584 
585  /* TODO: factor to pios_hal impl */
586  switch (hw_magnetometer) {
587  case HWSPARKY2_MAGNETOMETER_NONE:
588  case HWSPARKY2_MAGNETOMETER_INTERNAL:
589  /* internal mag is handled by MPU code above */
590  break;
591 
592  /* default external mags and handle them in PiOS HAL rather than maintaining list here */
593  default:
594  {
595  HwSparky2ExtMagPortOptions hw_mag_port;
596  HwSparky2ExtMagPortGet(&hw_mag_port);
597 
598  pios_i2c_t i2c_mag_id = 0;
599  const void *i2c_mag_cfg = NULL;
600  switch (hw_mag_port) {
601  case HWSPARKY2_EXTMAGPORT_FLEXIPORT:
602  if (hw_flexiport == HWSHARED_PORTTYPES_I2C) {
603  i2c_mag_id = pios_i2c_flexiport_adapter_id;
604  i2c_mag_cfg = &pios_i2c_flexiport_adapter_cfg;
605  }
606  break;
607  case HWSPARKY2_EXTMAGPORT_AUXI2C:
608  i2c_mag_id = pios_i2c_mag_pressure_adapter_id;
609  i2c_mag_cfg = &pios_i2c_mag_pressure_adapter_cfg;
610  break;
611  }
612 
613  if (i2c_mag_id && i2c_mag_cfg) {
614  uint8_t hw_orientation;
615  HwSparky2ExtMagOrientationGet(&hw_orientation);
616 
617  PIOS_HAL_ConfigureExternalMag(hw_magnetometer, hw_orientation,
618  &i2c_mag_id, i2c_mag_cfg);
619  } else {
621  }
622  }
623  break;
624  }
625 
626  /* I2C is slow, sensor init as well, reset watchdog to prevent reset here */
627  PIOS_WDG_Clear();
628 
629 #endif /* PIOS_INCLUDE_I2C */
630 
631  switch (bdinfo->board_rev) {
632  case BRUSHEDSPARKY_V0_2:
633  {
634  HwSparky2VTX_ChOptions channel;
635  HwSparky2VTX_ChGet(&channel);
636  set_vtx_channel(channel);
637  }
638  break;
639  }
640 
641 }
642 
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.
int32_t PIOS_INTERNAL_ADC_Init(uintptr_t *internal_adc_id, const struct pios_internal_adc_cfg *cfg)
GPIO_InitTypeDef init
Definition: pios_stm32.h:61
#define NELEMENTS(x)
Definition: pios.h:192
void set_vtx_channel(HwSparky2VTX_ChOptions channel)
Definition: pios_board.c:59
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)
GPIO_TypeDef * gpio
Definition: pios_stm32.h:60
#define PIOS_DEBUG_Assert(test)
Definition: pios_debug.h:51
int PIOS_HAL_ConfigureExternalMag(HwSharedMagOptions mag, HwSharedMagOrientationOptions orientation, pios_i2c_t *i2c_id, const struct pios_i2c_adapter_cfg *i2c_cfg)
Definition: pios_hal.c:1298
static const struct pios_usart_cfg pios_usart_main_cfg
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity)
Definition: alarms.c:97
uintptr_t pios_uavo_settings_fs_id
Definition: pios_board.c:50
const struct pios_tim_channel * channels
uint16_t PIOS_IAP_ReadBootCount(void)
Definition: pios_iap.c:93
struct stm32_gpio pin
Definition: pios_tim_priv.h:17
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
const struct pios_board_info pios_board_info_blob
struct pios_mpu_dev * pios_mpu_dev_t
Definition: pios_mpu.h:150
#define PIOS_COM_CAN_RX_BUF_LEN
Definition: pios_board.c:49
uintptr_t pios_can_id
Definition: pios_board.c:61
#define PIOS_LED_ALARM
Definition: pios_board.h:86
#define PIOS_IRQ_PRIO_MID
Definition: pios_board.h:170
Configuration structure for the MS5611 driver.
int32_t PIOS_I2C_Init(pios_i2c_t *i2c_id, const char *path)
void PIOS_WDG_Clear(void)
Clear the watchdog timer.
Definition: pios_wdg.c:147
int32_t PIOS_MPU_SPI_Init(pios_mpu_dev_t *dev, pios_spi_t spi_id, uint32_t slave_num, const struct pios_mpu_cfg *cfg)
Initialize the MPU-xxxx 6/9-axis sensor on SPI.
void PIOS_DEBUG_Init(const struct pios_tim_channel *channels, uint8_t num_channels)
Definition: pios_debug.c:44
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.
Definition: pios_iap.c:44
int32_t PIOS_MPU_SetAccelRange(enum pios_mpu_accel_range range)
const struct pios_adc_driver pios_internal_adc_driver
int32_t PIOS_TIM_InitClock(const struct pios_tim_clock_cfg *cfg)
Definition: pios_tim.c:62
uintptr_t pios_internal_adc_id
Definition: pios_board.c:51
struct pios_i2c_adapter * pios_i2c_t
Definition: pios_i2c.h:48
int32_t PIOS_SPI_Init(pios_spi_t *spi_dev, const struct pios_spi_cfg *cfg)
const struct pios_usart_cfg * get_usart_rcvr_cfg(uint32_t board_revision)
Get the rcvr uart configuration.
void PIOS_Board_Init()
Definition: pios_board.c:44
#define PIOS_COM_CAN_TX_BUF_LEN
Definition: pios_board.c:50
int32_t PIOS_ANNUNC_Init(const struct pios_annunc_cfg *cfg)
uint8_t i
Definition: msp_messages.h:97
int32_t PIOS_SENSORS_Init()
Initialize the PIOS_SENSORS interface.
Definition: pios_sensors.c:51
void PIOS_RTC_Init(const struct pios_rtc_cfg *cfg)
int32_t PIOS_USB_DESC_HID_ONLY_Init(void)
int32_t PIOS_CAN_Init(uintptr_t *id, const struct pios_can_cfg *cfg)
const struct pios_sbus_cfg * get_sbus_cfg(enum board_revision board_rev)
void PIOS_HAL_ConfigureHID(HwSharedUSB_HIDPortOptions port_type, uintptr_t usb_id, const struct pios_usb_hid_cfg *hid_cfg)
int32_t PIOS_Servo_Init(const struct pios_servo_cfg *cfg)
Definition: pios_servo.c:109
void PIOS_MPU_SetGyroBandwidth(uint16_t bandwidth)
Sets the bandwidth desired from the gyro. The driver will automatically select the lowest bandwidth l...
const struct pios_com_driver pios_can_com_driver
static const struct pios_usart_cfg pios_usart_flexi_cfg
#define BRUSHEDSPARKY_V0_2
Definition: pios_board.h:33
uintptr_t pios_com_openlog_logging_id
Definition: pios_board.c:49
static const struct pios_tim_clock_cfg tim_12_cfg
void PIOS_USBHOOK_Activate(void)
Definition: pios_usbhook.c:80
int32_t PIOS_COM_Init(uintptr_t *com_id, const struct pios_com_driver *driver, uintptr_t lower_id, uint16_t rx_buffer_len, uint16_t tx_buffer_len)
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)
Definition: alarms.c:171
int32_t PIOS_USB_Init(uintptr_t *usb_id, const struct pios_usb_cfg *cfg)
uint8_t num_channels
uint16_t PIOS_WDG_Init()
Initialize the watchdog timer for a specified timeout.
Definition: pios_wdg.c:63
int32_t PIOS_ADC_Init(uintptr_t *adc_id, const struct pios_adc_driver *driver, uintptr_t lower_id)
void PIOS_IAP_WriteBootCount(uint16_t)
Definition: pios_iap.c:98
int32_t PIOS_MS5611_Init(const struct pios_ms5611_cfg *cfg, pios_i2c_t i2c_device)
static const struct pios_tim_clock_cfg tim_3_cfg
void PIOS_HAL_CriticalError(uint32_t led_id, enum pios_hal_panic code)
Flash a blink code.
Definition: pios_hal.c:291
static const struct pios_tim_clock_cfg tim_9_cfg
const struct pios_servo_cfg * get_servo_cfg(uint32_t board_revision)
Get the flashfs settings.
#define PIOS_Assert(test)
Definition: pios_debug.h:52
int32_t PIOS_DELAY_WaitmS(uint32_t mS)
Definition: pios_delay.c:140
int32_t PIOS_MPU_SetGyroRange(enum pios_mpu_gyro_range range)
int32_t PIOS_USB_BOARD_DATA_Init(void)
static const struct pios_servo_cfg * servo_cfg
Definition: pios_servo.c:55
void PIOS_RESET_Clear(void)
PIOS_RESET_Clear Does nothing on POSIX systems.
Definition: pios_reset.c:38
void PIOS_SENSORS_SetMissing(enum pios_sensor_type type)
Assert that an optional (non-accel/gyro), but expected sensor is missing.
Definition: pios_sensors.c:191
uintptr_t pios_com_can_id
Definition: pios_board.c:59