Mirror of CollapseOS
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

30 行
1018B

  1. #include "emul.h"
  2. typedef struct {
  3. // Initialization status. 0 == not woken 8 == woken 9 == CMD0 received
  4. // 10 == CMD8 received, 11 == CMD55 received, 12 == CMD41 received (fully
  5. // initialized).
  6. unsigned int initstat;
  7. // We receive commands into this buffer.
  8. byte recvbuf[6];
  9. // Where the next SPI byte should be stored in recvbuf.
  10. unsigned int recvidx;
  11. // Buffer to the arguments for a response
  12. byte sendbuf[5];
  13. // Index of the next byte from sendbuf we should return. If -1, buffer is
  14. // empty.
  15. int sendidx;
  16. // File used for contents read/write
  17. FILE *fp;
  18. // number of bytes read into the current CMD17. -1 means no CMD17 active.
  19. int cmd17bytes;
  20. // number of bytes received for the current CMD24. -2 means no CMD24 active.
  21. // -1 means we're still waiting for the data token.
  22. int cmd24bytes;
  23. // running crc16 during read and write operations.
  24. uint16_t crc16;
  25. } SDC;
  26. void sdc_init(SDC *sdc);
  27. byte sdc_spix(SDC *sdc, byte val);