1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

LP-480 Make PIOS_BOARD_IO_USB_[VCP|HID]_Function enums based on HWSETTINGS_USB_[HID|VCP]PORT values to allow simple type casting.

This commit is contained in:
Vladimir Zidar 2017-04-16 18:11:20 +02:00
parent 1548312823
commit 280e771ded
2 changed files with 19 additions and 39 deletions

View File

@ -161,39 +161,15 @@ static void PIOS_BOARD_IO_HID_Init(uint32_t *com_id, uint16_t rx_buf_len, uint16
}
}
PIOS_BOARD_IO_USB_HID_Function PIOS_BOARD_IO_HWSettings_USB_HID_Function()
{
static const PIOS_BOARD_IO_USB_HID_Function map[] = {
[HWSETTINGS_USB_HIDPORT_USBTELEMETRY] = PIOS_BOARD_IO_USB_HID_TELEMETRY,
[HWSETTINGS_USB_HIDPORT_RCTRANSMITTER] = PIOS_BOARD_IO_USB_HID_RCTX,
};
uint8_t hwsettings_usb_hidport;
HwSettingsUSB_HIDPortGet(&hwsettings_usb_hidport);
return (hwsettings_usb_hidport < NELEMENTS(map)) ? map[hwsettings_usb_hidport] : PIOS_BOARD_IO_USB_HID_NONE;
}
PIOS_BOARD_IO_USB_VCP_Function PIOS_BOARD_IO_HWSettings_USB_VCP_Function()
{
static const PIOS_BOARD_IO_USB_VCP_Function map[] = {
[HWSETTINGS_USB_VCPPORT_USBTELEMETRY] = PIOS_BOARD_IO_USB_VCP_TELEMETRY,
[HWSETTINGS_USB_VCPPORT_COMBRIDGE] = PIOS_BOARD_IO_USB_VCP_COMBRIDGE,
[HWSETTINGS_USB_VCPPORT_DEBUGCONSOLE] = PIOS_BOARD_IO_USB_VCP_DEBUGCONSOLE,
[HWSETTINGS_USB_VCPPORT_MAVLINK] = PIOS_BOARD_IO_USB_VCP_MAVLINK,
};
uint8_t hwsettings_usb_vcpport;
HwSettingsUSB_VCPPortGet(&hwsettings_usb_vcpport);
return (hwsettings_usb_vcpport < NELEMENTS(map)) ? map[hwsettings_usb_vcpport] : PIOS_BOARD_IO_USB_VCP_NONE;
}
void PIOS_BOARD_IO_Configure_USB()
{
PIOS_BOARD_IO_Configure_USB_Function(PIOS_BOARD_IO_HWSettings_USB_HID_Function(),
PIOS_BOARD_IO_HWSettings_USB_VCP_Function());
uint8_t hwsettings_usb_hidport;
uint8_t hwsettings_usb_vcpport;
HwSettingsUSB_HIDPortGet(&hwsettings_usb_hidport);
HwSettingsUSB_VCPPortGet(&hwsettings_usb_vcpport);
PIOS_BOARD_IO_Configure_USB_Function((PIOS_BOARD_IO_USB_HID_Function)hwsettings_usb_hidport, (PIOS_BOARD_IO_USB_VCP_Function)hwsettings_usb_vcpport);
}
void PIOS_BOARD_IO_Configure_USB_Function(PIOS_BOARD_IO_USB_HID_Function hid_function, __attribute__((unused)) PIOS_BOARD_IO_USB_VCP_Function vcp_function)

View File

@ -208,23 +208,27 @@ typedef enum {
} PIOS_BOARD_IO_RADIOAUX_Function;
#ifdef PIOS_INCLUDE_USB
# ifndef BOOTLOADER
# include "hwsettings.h"
void PIOS_BOARD_IO_Configure_USB();
typedef enum {
PIOS_BOARD_IO_USB_HID_NONE = 0,
PIOS_BOARD_IO_USB_HID_TELEMETRY,
PIOS_BOARD_IO_USB_HID_RCTX,
PIOS_BOARD_IO_USB_HID_NONE = HWSETTINGS_USB_HIDPORT_DISABLED,
PIOS_BOARD_IO_USB_HID_TELEMETRY = HWSETTINGS_USB_HIDPORT_USBTELEMETRY,
PIOS_BOARD_IO_USB_HID_RCTX = HWSETTINGS_USB_HIDPORT_RCTRANSMITTER,
} PIOS_BOARD_IO_USB_HID_Function;
typedef enum {
PIOS_BOARD_IO_USB_VCP_NONE = 0,
PIOS_BOARD_IO_USB_VCP_TELEMETRY,
PIOS_BOARD_IO_USB_VCP_COMBRIDGE,
PIOS_BOARD_IO_USB_VCP_DEBUGCONSOLE,
PIOS_BOARD_IO_USB_VCP_MAVLINK,
PIOS_BOARD_IO_USB_VCP_NONE = HWSETTINGS_USB_VCPPORT_DISABLED,
PIOS_BOARD_IO_USB_VCP_TELEMETRY = HWSETTINGS_USB_VCPPORT_USBTELEMETRY,
PIOS_BOARD_IO_USB_VCP_COMBRIDGE = HWSETTINGS_USB_VCPPORT_COMBRIDGE,
PIOS_BOARD_IO_USB_VCP_DEBUGCONSOLE = HWSETTINGS_USB_VCPPORT_DEBUGCONSOLE,
PIOS_BOARD_IO_USB_VCP_MAVLINK = HWSETTINGS_USB_VCPPORT_MAVLINK,
} PIOS_BOARD_IO_USB_VCP_Function;
void PIOS_BOARD_IO_Configure_USB_Function(PIOS_BOARD_IO_USB_HID_Function hid_function, PIOS_BOARD_IO_USB_VCP_Function vcp_function);
# endif
#endif
#ifdef PIOS_INCLUDE_PWM
void PIOS_BOARD_IO_Configure_PWM(const struct pios_pwm_cfg *pwm_cfg);