Naze32 clone with Frysky receiver
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Transaction.h 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2015 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_TRANSACTION_H
  17. #define MBED_TRANSACTION_H
  18. #include "platform.h"
  19. #include "FunctionPointer.h"
  20. namespace mbed {
  21. /** Transaction structure
  22. */
  23. typedef struct {
  24. void *tx_buffer; /**< Tx buffer */
  25. size_t tx_length; /**< Length of Tx buffer*/
  26. void *rx_buffer; /**< Rx buffer */
  27. size_t rx_length; /**< Length of Rx buffer */
  28. uint32_t event; /**< Event for a transaction */
  29. event_callback_t callback; /**< User's callback */
  30. uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */
  31. } transaction_t;
  32. /** Transaction class defines a transaction.
  33. */
  34. template<typename Class>
  35. class Transaction {
  36. public:
  37. Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) {
  38. }
  39. Transaction() : _obj(), _data() {
  40. }
  41. ~Transaction() {
  42. }
  43. /** Get object's instance for the transaction
  44. *
  45. * @return The object which was stored
  46. */
  47. Class* get_object() {
  48. return _obj;
  49. }
  50. /** Get the transaction
  51. *
  52. * @return The transaction which was stored
  53. */
  54. transaction_t* get_transaction() {
  55. return &_data;
  56. }
  57. private:
  58. Class* _obj;
  59. transaction_t _data;
  60. };
  61. }
  62. #endif