aboutsummaryrefslogtreecommitdiff
path: root/fdl/ch573/systick.fdl
blob: 8e0568589078175667b2df8af2c35e4860ad187f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import "ch573/common.fdl";

/** Package for SYSTICK (system counter). */
package ch573.systick {
  location systick_base = 0xE000F000;

  using ch573.common;

  type systick_t : struct {
    reg cfg(32) @0x0 : struct {
      /** Enable the systick. */
      rw enabled : enable_t;

      /** Enable the systick interrupt. */
      rw interrupt_enable : enable_t;

      /** Clock source for the systick. */
      rw clock_source : enum(1) {
        [[ c: unqualified ]]
        SYSTICK_CLOCK_SOURCE_HCLK = 1,

        [[ c: unqualified ]]
        SYSTICK_CLOCK_SOURCE_HCLK_DIV_8 = 0,
      };

      reserved(5);

      /** Write 1 to reload the systick. */
      wo st_reload : (1);
      reserved(23);
    };

    assert_pos(0x4);
    union {
      struct {
        /** Lower 32 bits of the systick count. */
        reg count_low(32);
        assert_pos(0x8);

        /** Upper 32 bits of the systick count. */
        reg count_high(32);
      };
      /** Full 64 bits of the systick count. */
      reg count(64);
    };

    assert_pos(0xC);
    union {
      struct {
        /** Lower 32 bits of the systick reload value. */
        reg reload_low(32);
        assert_pos(0x10);
        /** Upper 32 bits of the systick reload value. */
        reg reload_high(32);
      };
      /** Full 64-bit systick reload value. */
      reg reload(64);
    };

    reg (32) @0x14 : struct {
      /** Software interrupt happened. (Set to 1 to trigger a software
       * interrupt.) */
      software_interrupt_flag : (1);

      /** Counter interrupt happened. */
      counter_interrupt_flag : (1);
      reserved(30);
    };
  };

  instance systick at systick_base : systick_t;
};