diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-26 13:29:09 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-26 13:29:09 +0000 |
commit | eb0c1ac0c3a3544366b7be5014a23d96ec4e9c9e (patch) | |
tree | bab95b57ba0de647a19fdd35d920922d6db3160a /os/hal/include/usb.h | |
parent | ae70b0edcea8b466894e140839371fb122a4aa92 (diff) | |
download | ChibiOS-eb0c1ac0c3a3544366b7be5014a23d96ec4e9c9e.tar.gz ChibiOS-eb0c1ac0c3a3544366b7be5014a23d96ec4e9c9e.tar.bz2 ChibiOS-eb0c1ac0c3a3544366b7be5014a23d96ec4e9c9e.zip |
USB synchronous API, to be completed.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8648 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include/usb.h')
-rw-r--r-- | os/hal/include/usb.h | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/os/hal/include/usb.h b/os/hal/include/usb.h index 896aa31cd..4aed90a08 100644 --- a/os/hal/include/usb.h +++ b/os/hal/include/usb.h @@ -236,6 +236,14 @@ /* Driver pre-compile time settings. */
/*===========================================================================*/
+/**
+ * @brief Enables synchronous APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
+#define USB_USE_WAIT TRUE
+#endif
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@@ -537,10 +545,24 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp, *
* @notapi
*/
+#if (USB_USE_WAIT == TRUE) || defined(__DOXYGEN__)
#define _usb_isr_invoke_in_cb(usbp, ep) { \
(usbp)->transmitting &= ~(1 << (ep)); \
- (usbp)->epc[ep]->in_cb(usbp, ep); \
+ if ((usbp)->epc[ep]->in_cb != NULL) { \
+ (usbp)->epc[ep]->in_cb(usbp, ep); \
+ } \
+ osalSysLockFromISR(); \
+ osalThreadResumeI(&(usbp)->epc[ep]->in_state->thread, MSG_OK); \
+ osalSysUnlockFromISR(); \
+}
+#else
+#define _usb_isr_invoke_in_cb(usbp, ep) { \
+ (usbp)->transmitting &= ~(1 << (ep)); \
+ if ((usbp)->epc[ep]->in_cb != NULL) { \
+ (usbp)->epc[ep]->in_cb(usbp, ep); \
+ } \
}
+#endif
/**
* @brief Common ISR code, OUT endpoint event.
@@ -550,10 +572,25 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp, *
* @notapi
*/
+#if (USB_USE_WAIT == TRUE) || defined(__DOXYGEN__)
+#define _usb_isr_invoke_out_cb(usbp, ep) { \
+ (usbp)->receiving &= ~(1 << (ep)); \
+ if ((usbp)->epc[ep]->out_cb != NULL) { \
+ (usbp)->epc[ep]->out_cb(usbp, ep); \
+ } \
+ osalSysLockFromISR(); \
+ osalThreadResumeI(&(usbp)->epc[ep]->out_state->thread, \
+ usbGetReceiveTransactionSizeI(usbp, ep)); \
+ osalSysUnlockFromISR(); \
+}
+#else
#define _usb_isr_invoke_out_cb(usbp, ep) { \
(usbp)->receiving &= ~(1 << (ep)); \
- (usbp)->epc[ep]->out_cb(usbp, ep); \
+ if ((usbp)->epc[ep]->out_cb != NULL) { \
+ (usbp)->epc[ep]->out_cb(usbp, ep); \
+ } \
}
+#endif
/** @} */
/*===========================================================================*/
@@ -577,6 +614,10 @@ extern "C" { const uint8_t *buf, size_t n);
bool usbStartReceiveI(USBDriver *usbp, usbep_t ep);
bool usbStartTransmitI(USBDriver *usbp, usbep_t ep);
+#if USB_USE_WAIT == TRUE
+ msg_t usbReceive(USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n);
+ msg_t usbTransmit(USBDriver *usbp, usbep_t ep, const uint8_t *buf, size_t n);
+#endif
bool usbStallReceiveI(USBDriver *usbp, usbep_t ep);
bool usbStallTransmitI(USBDriver *usbp, usbep_t ep);
void _usb_reset(USBDriver *usbp);
|