diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2022-04-30 08:41:56 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2022-04-30 08:42:45 -0400 |
commit | e164629b3839eee0fda0be0e0a9842e78cf02f2b (patch) | |
tree | b72b58665b85a104e5b953af45f00579341b2802 /source/usbserial.cpp | |
parent | 162dd6de8a0d883962b0b1475f47cbb08e0958d4 (diff) | |
parent | 3dd57491b1e81a9d93054eff19ca0e6c65c85b9b (diff) |
merge in branch devel
Diffstat (limited to 'source/usbserial.cpp')
-rw-r--r-- | source/usbserial.cpp | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/source/usbserial.cpp b/source/usbserial.cpp deleted file mode 100644 index c24be2f..0000000 --- a/source/usbserial.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @file usbserial.cpp - * @brief Wrapper for ChibiOS's SerialUSBDriver. - * - * Copyright (C) 2020 Clyne Sullivan - * - * Distributed under the GNU GPL v3 or later. You should have received a copy of - * the GNU General Public License along with this program. - * If not, see <https://www.gnu.org/licenses/>. - */ - -#include "usbserial.hpp" - -SerialUSBDriver *USBSerial::m_driver = &SDU1; - -void USBSerial::begin() -{ - palSetPadMode(GPIOA, 11, PAL_MODE_ALTERNATE(10)); - palSetPadMode(GPIOA, 12, PAL_MODE_ALTERNATE(10)); - - sduObjectInit(m_driver); - sduStart(m_driver, &serusbcfg); - - // Reconnect bus so device can re-enumerate on reset - usbDisconnectBus(serusbcfg.usbp); - chThdSleepMilliseconds(1500); - usbStart(serusbcfg.usbp, &usbcfg); - usbConnectBus(serusbcfg.usbp); -} - -bool USBSerial::isActive() -{ - if (auto config = m_driver->config; config != nullptr) { - if (auto usbp = config->usbp; usbp != nullptr) - return usbp->state == USB_ACTIVE; - } - - return false; -} - -size_t USBSerial::read(unsigned char *buffer, size_t count) -{ - auto bss = reinterpret_cast<BaseSequentialStream *>(m_driver); - return streamRead(bss, buffer, count); -} - -size_t USBSerial::write(const unsigned char *buffer, size_t count) -{ - auto bss = reinterpret_cast<BaseSequentialStream *>(m_driver); - return streamWrite(bss, buffer, count); -} - |