esp.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "compiler.h"
  2. #include "common.h"
  3. #include "io.h"
  4. #include "console.h"
  5. #include "esplink.h"
  6. struct esplink_head __esplink_head esplink_head;
  7. uint32_t __esplink esplink[(65536 - sizeof(struct esplink_head)) >> 2];
  8. IRQHANDLER(esp,0)
  9. {
  10. uint32_t irqstatus = ESP_CPU_IRQ;
  11. ESP_CPU_IRQ_CLR = irqstatus;
  12. if (irqstatus & (1 << EL_DIRQ_UNDERRUN)) {
  13. con_printf("[ESP] ESP link memory underrun!!\n");
  14. ESP_SPI_IRQ = (0x10 << EL_UIRQ_READY); /* Block writes, reinitialize! */
  15. }
  16. if (irqstatus & (1 << EL_DIRQ_HELLO)) {
  17. con_printf("[ESP] Got hello, sending ready...\n");
  18. /* Hello, are you there? Yes, I'm here, and you can write data now */
  19. ESP_SPI_IRQ_SET = (0x10 << EL_UIRQ_READY)|(0x10 << EL_UIRQ_WREN);
  20. }
  21. }
  22. void esp_init(void)
  23. {
  24. static char __dram_data esp_signature[] = "Hej tomtebuggar slå i glasen!";
  25. ESP_CPU_IRQ = 0;
  26. ESP_SPI_IRQ = 0;
  27. memset(&esplink_head, 0, sizeof esplink_head);
  28. esplink_head.hlen = sizeof esplink_head;
  29. esplink_head.board.cfg = SYS_BOARDCFG;
  30. esplink_head.signature = esp_signature;
  31. esplink_head.signature_len = sizeof esp_signature - 1;
  32. esplink_head.magic = ESPLINK_HEAD_MAGIC;
  33. ESP_SPI_IRQ = (0x10 << EL_UIRQ_READY);
  34. unmask_irq(ESP_IRQ);
  35. }