From 698ea8e86e23ba6899bc7b33a591308e4de9881c Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Wed, 16 May 2012 23:37:39 -0400 Subject: [PATCH] usb util: Add common utility functions for USB descriptors Make a home for generic functions related to USB. --- flight/PiOS/Common/pios_usb_util.c | 42 ++++++++++++++++++++++++++++++ flight/PiOS/inc/pios_usb_util.h | 38 +++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 flight/PiOS/Common/pios_usb_util.c create mode 100644 flight/PiOS/inc/pios_usb_util.h diff --git a/flight/PiOS/Common/pios_usb_util.c b/flight/PiOS/Common/pios_usb_util.c new file mode 100644 index 000000000..4bbf98d23 --- /dev/null +++ b/flight/PiOS/Common/pios_usb_util.c @@ -0,0 +1,42 @@ +/** + ****************************************************************************** + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @addtogroup PIOS_USB_UTIL USB utility functions + * @brief USB utility functions + * @{ + * + * @file pios_usb_util.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @brief USB utility functions + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "pios_usb_util.h" + +uint8_t * PIOS_USB_UTIL_AsciiToUtf8(uint8_t * dst, uint8_t * src, uint16_t srclen) +{ + for (uint8_t i = 0; i < srclen; i++) { + *dst = *src; + dst += 2; + src += 1; + } + + return dst; +} diff --git a/flight/PiOS/inc/pios_usb_util.h b/flight/PiOS/inc/pios_usb_util.h new file mode 100644 index 000000000..111b49239 --- /dev/null +++ b/flight/PiOS/inc/pios_usb_util.h @@ -0,0 +1,38 @@ +/** + ****************************************************************************** + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @addtogroup PIOS_USB_UTIL USB utility functions + * @brief USB utility functions + * @{ + * + * @file pios_usb_util.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @brief USB utility functions + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PIOS_USB_UTIL_H +#define PIOS_USB_UTIL_H + +#include /* uint8_t */ + +uint8_t * PIOS_USB_UTIL_AsciiToUtf8(uint8_t * dst, uint8_t * src, uint16_t srclen); + +#endif /* PIOS_USB_UTIL_H */