usb_transfer_flags.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef USB_TRANSFER_FLAGS_H
  2. #define USB_TRANSFER_FLAGS_H
  3. #include "app/usb/usb_transfers.h"
  4. // @USB_TRANSFER_FLAG_SHORTPACKET
  5. // The bitwise flag used to indicate weither the short packet has received at last OUT transaction or not.
  6. #define USB_TRANSFER_FLAG_SHORTPACKET (1ul << 0) // Short packet flag
  7. static inline bool usb_transfer_check_shortpacket( sUSBTransfer_t * transf )
  8. {
  9. // check if the last transaction was a Short-packet transaction
  10. return usb_transfer_check_flags_fast( transf,
  11. USB_TRANSFER_FLAG_SHORTPACKET,
  12. USB_TRANSFER_FLAG_SHORTPACKET,
  13. eUSBTransferFlagMode_Or );
  14. }
  15. static inline void usb_transfer_set_shortpacket( sUSBTransfer_t * transf )
  16. {
  17. // set the Short-packet signature for transaction
  18. usb_transfer_modify_flags( transf, USB_TRANSFER_FLAG_SHORTPACKET, USB_TRANSFER_FLAG_SHORTPACKET );
  19. // protect the flag from clearing
  20. usb_transfer_modify_flags_locks( transf, USB_TRANSFER_FLAG_SHORTPACKET, USB_TRANSFER_FLAG_SHORTPACKET );
  21. }
  22. static inline void usb_transfer_clear_shortpacket( sUSBTransfer_t * transf )
  23. {
  24. // un-protect the flag from clearing
  25. usb_transfer_modify_flags_locks( transf, USB_TRANSFER_FLAG_SHORTPACKET, 0 );
  26. // reset the Short-packet signature for transaction
  27. usb_transfer_modify_flags( transf, USB_TRANSFER_FLAG_SHORTPACKET, 0 );
  28. }
  29. #endif