fpga.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "common.h"
  3. #include "jtag.h"
  4. #include "esplink.h"
  5. #include "fw.h"
  6. extern_c int fpga_program_spz(spz_stream *spz);
  7. extern_c int fpga_reset(void);
  8. extern_c esp_err_t fpga_service_init(void);
  9. extern_c void fpga_service_enable(bool);
  10. extern_c void fpga_timesync_trigger(void);
  11. #define FPGA_CMD_IRQ(x) ((x) << 0)
  12. #define FPGA_CMD_ACK(x) ((x) << 3)
  13. #define FPGA_CMD_WR (0 << 6)
  14. #define FPGA_CMD_RD (1 << 6)
  15. #define FPGA_CMD_STAMP (1 << 7) /* Save timestamp */
  16. /* Internal bits, not sent over the wire: */
  17. #define FPGA_CMD_NULL (1 << 8) /* Don't skip an empty command */
  18. #define FPGA_CMD_STATUS (1 << 9) /* Include status in read command */
  19. struct fpga_iov {
  20. unsigned int cmd;
  21. union {
  22. const volatile void *addr;
  23. uint32_t iaddr;
  24. };
  25. union {
  26. const void *wdata;
  27. void *rdata;
  28. };
  29. size_t len;
  30. };
  31. extern_c esp_err_t fpga_iov(const struct fpga_iov *iov, size_t niov);
  32. extern_c esp_err_t fpga_io_write(unsigned int cmd, const volatile void *addr,
  33. const void *data, size_t len);
  34. extern_c esp_err_t fpga_io_read(unsigned int cmd, const volatile void *addr,
  35. void *data, size_t len);
  36. extern_c uint32_t fpga_io_status(unsigned int cmd);
  37. extern_c void fpga_enable_nce(void);
  38. struct esplink_head;
  39. extern_c void esplink_init(void);
  40. extern_c void esplink_start(const struct esplink_head *head);
  41. extern_c void esplink_poll(void);
  42. extern_c EventGroupHandle_t esplink_filled;
  43. #define ELQUEUE_DL(n) ((n) << 1)
  44. #define ELQUEUE_UL(n) (((n) << 1) + 1)
  45. #define ELWAIT_ONLINE ELQUEUE_DL(EL_RB_COUNT)
  46. static inline EventBits_t esplink_wait_for(EventBits_t queues, bool online)
  47. {
  48. return xEventGroupWaitBits(esplink_filled,
  49. queues | (online ? ELWAIT_ONLINE : 0),
  50. 0, pdTRUE, portMAX_DELAY) ^ ELWAIT_ONLINE;
  51. }