esp.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "compiler.h"
  2. #include "common.h"
  3. #include "io.h"
  4. #include "console.h"
  5. #include "esplink.h"
  6. struct dram_io_head __dram_io_head dram_io_head;
  7. uint32_t __dram_io dram_io[(65536 - sizeof(struct dram_io_head)) >> 2];
  8. IRQHANDLER(esp,0)
  9. {
  10. uint32_t irqstatus = ESP_CPU_IRQ;
  11. ESP_CPU_IRQ_CLR = irqstatus;
  12. if (irqstatus & (1 << RV_IRQ_UNDERRUN)) {
  13. con_printf("[ESP] ESP link memory underrun!!\n");
  14. }
  15. if (irqstatus & (1 << RV_IRQ_HELLO)) {
  16. con_printf("[ESP] Got hello, sending ready...\n");
  17. /* Hello, are you there? Yes, I'm here... */
  18. ESP_SPI_IRQ_SET = 1 << ESP_IRQ_READY;
  19. }
  20. }
  21. void esp_init(void)
  22. {
  23. static char __dram_data esp_signature[] = "Hej tomtebuggar slå i glasen!";
  24. dram_io_head.magic = 0;
  25. dram_io_head.hlen = sizeof dram_io_head;
  26. dram_io_head.dptr = dram_io;
  27. dram_io_head.dlen = sizeof dram_io;
  28. dram_io_head.board.cfg = SYS_BOARDCFG;
  29. dram_io_head.signature = esp_signature;
  30. dram_io_head.signature_len = sizeof esp_signature - 1;
  31. memset(&dram_io_head.resv, 0, sizeof dram_io_head.resv);
  32. dram_io_head.magic = DRAM_IO_MAGIC;
  33. ESP_SPI_IRQ_SET = 1 << ESP_IRQ_READY;
  34. unmask_irq(ESP_IRQ);
  35. }