fpga.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #define FPGA_CMD_IRQ(x) ((x) << 0)
  11. #define FPGA_CMD_ACK(x) ((x) << 2)
  12. #define FPGA_CMD_WR (0 << 4)
  13. #define FPGA_CMD_RD (1 << 4)
  14. #define FPGA_CMD_CONTROL_MASK 0x0f
  15. #define FPGA_CMD_NULL (1 << 8) /* Don't skip an empty command */
  16. #define FPGA_CMD_STATUS (1 << 9) /* Include status in read command */
  17. struct fpga_iov {
  18. unsigned int cmd;
  19. union {
  20. const void *addr;
  21. uint32_t iaddr;
  22. };
  23. union {
  24. const void *wdata;
  25. void *rdata;
  26. };
  27. size_t len;
  28. };
  29. extern_c esp_err_t fpga_iov(const struct fpga_iov *iov, size_t niov);
  30. extern_c esp_err_t fpga_io_write(unsigned int cmd, const void *addr,
  31. const void *data, size_t len);
  32. extern_c esp_err_t fpga_io_read(unsigned int cmd, const void *addr,
  33. void *data, size_t len);
  34. extern_c uint32_t fpga_io_status(unsigned int cmd);
  35. struct esplink_head;
  36. extern_c void esplink_init(void);
  37. extern_c void esplink_start(const struct esplink_head *head);
  38. extern_c void esplink_poll(void);
  39. extern_c EventGroupHandle_t esplink_filled;
  40. #define ELQUEUE_DL(n) ((n) << 1)
  41. #define ELQUEUE_UL(n) (((n) << 1) + 1)
  42. #define ELWAIT_ONLINE ELQUEUE_DL(EL_RB_COUNT)
  43. static inline EventBits_t esplink_wait_for(EventBits_t queues, bool online)
  44. {
  45. return xEventGroupWaitBits(esplink_filled,
  46. queues | (online ? ELWAIT_ONLINE : 0),
  47. 0, pdTRUE, portMAX_DELAY) ^ ELWAIT_ONLINE;
  48. }