timer_a.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. MSP430 Emulator
  3. Copyright (C) 2020 Rudolf Geosits (rgeosits@live.esu.edu)
  4. "MSP430 Emulator" is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. "MSP430 Emulator" is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef _TIMER_A_H_
  16. #define _TIMER_A_H_
  17. #include "../cpu/registers.h"
  18. #include "../utilities.h"
  19. enum {STOP_MODE = 0, UP_MODE, CONTINOUS_MODE, UP_DOWN_MODE, NUM_MODES};
  20. struct Timer_a {
  21. // (ALL RESET WITH POR)
  22. // --- TIMER_A0 ----------
  23. // Timer_A0 Control, @0x160
  24. uint16_t *TA0CTL;
  25. // Timer_A0 Counter, @0x170
  26. uint16_t *TA0R;
  27. // Timer_A0 Capture/Compare Control 0, @0x162
  28. uint16_t *TA0CCTL0;
  29. // Timer_A0 Capture/Compare 0, @0x172
  30. uint16_t *TA0CCR0;
  31. // Timer_A0 Capture/Compare Control 1, @0x164
  32. uint16_t *TA0CCTL1;
  33. // Timer_A0 Capture/Compare 1, @0x174
  34. uint16_t *TA0CCR1;
  35. // Timer_A0 Capture/Compare Control 2, @0x166
  36. uint16_t *TA0CCTL2;
  37. // Timer_A0 Capture/Compare 2, @0x176
  38. uint16_t *TA0CCR2;
  39. // Timer_A0 Interrupt Vector, @0x12E
  40. uint16_t *TA0IV; // READ ONLY
  41. // --- TIMER_A1
  42. // Timer_A1 Control
  43. uint16_t *TA1CTL;
  44. // Timer_A1 Counter
  45. uint16_t *TA1R;
  46. // Timer_A1 Capture/Compare Control 0
  47. uint16_t *TA1CCTL0;
  48. // Timer_A1 Capture/Compare 0
  49. uint16_t *TA1CCR0;
  50. // Timer_A1 Capture/Compare Control 1
  51. uint16_t *TA1CCTL1;
  52. // Timer_A1 Capture/Compare 1
  53. uint16_t *TA1CCR1;
  54. // Timer_A1 Capture/Compare Control 2
  55. uint16_t *TA1CCTL2;
  56. // Timer_A1 Capture/Compare 2
  57. uint16_t *TA1CCR2;
  58. // Timer_A1 Interrupt Vector
  59. uint16_t *TA1IV; // READ ONLY
  60. bool timer_0_running;
  61. bool capture_mode_0;
  62. bool compare_mode_0;
  63. uint8_t source_0;
  64. uint8_t idiv_0;
  65. uint8_t mode_0;
  66. bool timer_1_running;
  67. bool capture_mode_1;
  68. bool compare_mode_1;
  69. uint8_t source_1;
  70. uint8_t idiv_1;
  71. uint8_t mode_1;
  72. };
  73. void *timer_A0_thread (void *data);
  74. void setup_timer_a (Emulator *emu);
  75. void handle_timer_a (Emulator *emu);
  76. #endif