fpga.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. extern_c esp_err_t fpga_send_config(void);
  39. struct esplink_head;
  40. extern_c void esplink_init(void);
  41. extern_c void esplink_start(const struct esplink_head *head);
  42. extern_c void esplink_poll(void);
  43. extern_c EventGroupHandle_t esplink_filled;
  44. #define ELQUEUE_DL(n) ((n) << 1)
  45. #define ELQUEUE_UL(n) (((n) << 1) + 1)
  46. #define ELWAIT_ONLINE ELQUEUE_DL(EL_RB_COUNT)
  47. static inline EventBits_t esplink_wait_for(EventBits_t queues, bool online)
  48. {
  49. return xEventGroupWaitBits(esplink_filled,
  50. queues | (online ? ELWAIT_ONLINE : 0),
  51. 0, pdTRUE, portMAX_DELAY) ^ ELWAIT_ONLINE;
  52. }