Mirror of CollapseOS
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

40 satır
1.3KB

  1. #include <stdint.h>
  2. #include <stdbool.h>
  3. typedef struct {
  4. // Bit 7: interrupt status, low when interrupt request pending.
  5. // Bit 6: Parity error
  6. // Bit 5: Receiver overrun
  7. // Bit 4: Framing error
  8. // Bit 3: Clear To Send
  9. // Bit 2: Data Carrier Detected
  10. // Bit 1: Transmit Data Register Empty (TDRE)
  11. // Bit 0: Receive Data Register Full (RDRF)
  12. // We care about bits 7, 1, 0, maybe 5 later.
  13. uint8_t status;
  14. // Bit 7: interrupt enable
  15. // Bits 6:5: RTS + transmit interrupt enable
  16. // Bits 4:2: parity + stop bit
  17. // Bits 1:0: speed divider
  18. // We don't actually care about any of those except the interrupt enable
  19. // bits.
  20. uint8_t control;
  21. uint8_t rx;
  22. uint8_t tx;
  23. // Will be set to true the first time acia_has_irq() is called when IRQ is
  24. // set. Then, as long as it stays true, acia_has_irq() will return false.
  25. // When IRQ status is reset, so is in_int.
  26. bool in_int;
  27. } ACIA;
  28. void acia_init(ACIA *acia);
  29. bool acia_has_irq(ACIA *acia);
  30. bool acia_cantransmit(ACIA *acia);
  31. bool acia_hastx(ACIA *acia);
  32. uint8_t acia_read(ACIA *acia);
  33. void acia_write(ACIA *acia, uint8_t val);
  34. uint8_t acia_ctl_rd(ACIA *acia);
  35. void acia_ctl_wr(ACIA *acia, uint8_t val);
  36. uint8_t acia_data_rd(ACIA *acia);
  37. void acia_data_wr(ACIA *acia, uint8_t val);