aboutsummaryrefslogtreecommitdiff
path: root/fdl/ch573/adc.fdl
blob: bf7fcadb5399d10712b39d69ed5d3bb0f7b65664 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/** Fiddle file for the analog to digital converter. */
import "ch573/common.fdl";

/** Package for the analog to diginal converter. */
package ch573.adc {
  location adc_base = 0x40001000;

  using ch573.common;

  type adc_t : struct {
    reg (8) @ 0x58 : struct {
       channel_select : (4);
       reserved (4);
    };

    reg cfg(8) @0x59: struct {
      adc_power_on : enable_t;
      adc_buf_en : enable_t;
      adc_diff_en : enable_t;

      ofs_test : enum (1) {
        [[ c: unqualified ]]
        OFFSET_TEST_NORMAL = 0,
        [[ c: unqualified ]]
        OFFSET_TEST_CALIBRATE = 1,
      };

      pga_gain : enum (2) {
       [[ c: unqualified ]]
        GAIN_DIV_4 = 0,
       [[ c: unqualified ]]
        GAIN_DIV_2 = 1,
       [[ c: unqualified ]]
        GAIN_NONE = 2,
       [[ c: unqualified ]]
        GAIN_MUL_2 = 3,
      };

      clock_div : enum (2) {
       [[ c: unqualified ]]
        CK32M_DIV_10 = 0,
       [[ c: unqualified ]]
        CK32M_DIV_4 = 1,
       [[ c: unqualified ]]
        CK32M_DIV_6 = 2,
       [[ c: unqualified ]]
        CK32M_DIV_8 = 3,
      };
    };

    reg convert(8) @0x5A : struct {
      adc_start : bit_t;
      reserved(6);
      eoc_x : bit_t;
    };

    reg tem_sensor(8) @0x5B : struct {
      pwr : enable_t;
      reserved(7);
    };

    ro reg data(16) @0x5C : struct {
      ro data_12 : (12);
      reserved(4);
    };

    ro reg interrupt_flag(8) @0x5E : struct {
      reserved(7);
      ro if_eoc : (1);
    };

    reg dma_interrupt_control(8) @0x61 : struct {
      auto_en : enable_t;
      reserved(2);
      ie_eoc : enable_t;
      ie_dma_end : enable_t;
      dma_loop : enable_t;
      reserved(1);
      dma_enable : enable_t;
    };

    reg dma_interrupt_flag(8) @0x62 : struct {
      reserved(3);
      if_dma_end : bit_t;
      if_end_adc : bit_t;
      reserved(3);
    };

    reg auto_cycle(8) @0x63;

    reg dma_now(16) @0x64;
    reg dma_beg(16) @0x68;
    reg dma_end(16) @0x6C;
  };

  instance adc at adc_base : adc_t;
};