PD Buddy Sink Firmware
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.

pdb_prl.h 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * PD Buddy Firmware Library - USB Power Delivery for everyone
  3. * Copyright 2017-2018 Clayton G. Hobbs
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #ifndef PDB_PRL_H
  18. #define PDB_PRL_H
  19. #include <stdint.h>
  20. #include <ch.h>
  21. #include "pdb_conf.h"
  22. /*
  23. * Structure for the protocol layer threads and variables
  24. */
  25. struct pdb_prl {
  26. /* RX thread and working area */
  27. THD_WORKING_AREA(_rx_wa, PDB_PRLRX_WA_SIZE);
  28. thread_t *rx_thread;
  29. /* TX thread and working area */
  30. THD_WORKING_AREA(_tx_wa, PDB_PRLTX_WA_SIZE);
  31. thread_t *tx_thread;
  32. /* Hard reset thread and working area */
  33. THD_WORKING_AREA(_hardrst_wa, PDB_HARDRST_WA_SIZE);
  34. thread_t *hardrst_thread;
  35. /* TX mailbox for PD messages to be transmitted */
  36. mailbox_t tx_mailbox;
  37. /* The ID of the last message received */
  38. int8_t _rx_messageid;
  39. /* The message being worked with by the RX thread */
  40. union pd_msg *_rx_message;
  41. /* The ID of the next message we will transmit */
  42. int8_t _tx_messageidcounter;
  43. /* The message being worked with by the TX thread */
  44. union pd_msg *_tx_message;
  45. /* Queue for the TX mailbox */
  46. msg_t _tx_mailbox_queue[PDB_MSG_POOL_SIZE];
  47. };
  48. #endif /* PDB_PRL_H */