PD Buddy Sink Firmware
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

messages.h 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * PD Buddy - USB Power Delivery for everyone
  3. * Copyright (C) 2017 Clayton G. Hobbs <clay@lakeserv.net>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef PDB_MESSAGES_H
  19. #define PDB_MESSAGES_H
  20. #include <stdint.h>
  21. #include <ch.h>
  22. /*
  23. * PD message union
  24. *
  25. * This can be safely read from or written to in either form without any
  26. * transformations because everything in the system is little-endian.
  27. *
  28. * Two bytes of padding are required at the start to prevent problems due to
  29. * alignment. Specifically, without the padding, &obj[0] != &bytes[2], making
  30. * the statement in the previous paragraph invalid.
  31. */
  32. union pd_msg {
  33. struct {
  34. uint8_t _pad1[2];
  35. uint8_t bytes[30];
  36. } __attribute__((packed));
  37. struct {
  38. uint8_t _pad2[2];
  39. uint16_t hdr;
  40. uint32_t obj[7];
  41. } __attribute__((packed));
  42. };
  43. /* Available messages */
  44. #define PDB_MSG_POOL_SIZE 4
  45. extern memory_pool_t pdb_msg_pool;
  46. /*
  47. * Initialize the msg_pool
  48. */
  49. void pdb_msg_pool_init(void);
  50. #endif /* PDB_MESSAGES_H */