tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/p1am/defines.go (about)

     1  package p1am
     2  
     3  //go:generate go run ./internal/cmd/gen_defines
     4  
     5  type ModuleProps struct {
     6  	ModuleID                                 uint32
     7  	DI, DO, AI, AO, Status, Config, DataSize byte
     8  	Name                                     string
     9  }
    10  
    11  var modules = []ModuleProps{
    12  	//{0x000000ID,di,do,ai,ao,st,cf,ds}
    13  	{0x00000000, 0, 0, 0, 0, 0, 0, 0, "Empty"}, //Empty first entry for defaultgs
    14  
    15  	{0x04A00081, 1, 0, 0, 0, 0, 0, 1, "P1-08ND3"}, //P1-08ND3
    16  
    17  	{0x04A00085, 1, 0, 0, 0, 0, 0, 1, "P1-08NA"}, //P1-08NA
    18  
    19  	{0x04A00087, 1, 0, 0, 0, 0, 0, 1, "P1-08SIM"}, //P1-08SIM
    20  
    21  	{0x04A00088, 1, 0, 0, 0, 0, 0, 1, "P1-08NE3"}, //P1-08NE3
    22  
    23  	{0x05200082, 2, 0, 0, 0, 0, 0, 1, "P1-16ND3"}, //P1-16ND3
    24  
    25  	{0x05200089, 2, 0, 0, 0, 0, 0, 1, "P1-16NE3"}, //P1-16NE3
    26  
    27  	{0x1403F481, 0, 0, 0, 32, 4, 4, 0xA0, "P1-04PWM"}, //P1-04PWM
    28  
    29  	{0x1404008D, 0, 1, 0, 0, 0, 0, 1, "P1-08TA"}, //P1-08TA
    30  
    31  	{0x1404008F, 0, 1, 0, 0, 0, 0, 1, "P1-08TRS"}, //P1-08TRS
    32  
    33  	{0x14040091, 0, 2, 0, 0, 0, 0, 1, "P1-16TR"}, //P1-16TR
    34  
    35  	{0x14050081, 0, 1, 0, 0, 0, 0, 1, "P1-08TD1"}, //P1-08TD1
    36  
    37  	{0x14050082, 0, 1, 0, 0, 0, 0, 1, "P1-08TD2"}, //P1-08TD2
    38  
    39  	{0x14080085, 0, 2, 0, 0, 0, 0, 1, "P1-15TD1"}, //P1-15TD1
    40  
    41  	{0x14080086, 0, 2, 0, 0, 0, 0, 1, "P1-15TD2"}, //P1-15TD2
    42  
    43  	{0x24A50081, 1, 1, 0, 0, 0, 0, 1, "P1-16CDR"}, //P1-16CDR
    44  
    45  	{0x24A50082, 1, 1, 0, 0, 0, 0, 1, "P1-15CDD1"}, //P1-15CDD1
    46  
    47  	{0x24A50083, 1, 1, 0, 0, 0, 0, 1, "P1-15CDD2"}, //P1-15CDD2
    48  
    49  	{0x34605581, 0, 0, 16, 0, 12, 18, 16, "P1-04AD"}, //P1-04AD
    50  
    51  	{0x34605588, 0, 0, 16, 0, 12, 8, 16, "P1-04RTD"}, //P1-04RTD
    52  
    53  	{0x3460558F, 0, 0, 16, 0, 12, 2, 12, "P1-04ADL-1"}, //P1-04ADL-1
    54  
    55  	{0x34605590, 0, 0, 16, 0, 12, 2, 12, "P1-04ADL-2"}, //P1-04ADL-2
    56  
    57  	{0x34608C81, 0, 0, 16, 0, 12, 20, 32, "P1-04THM"}, //P1-04THM
    58  
    59  	{0x34608C8E, 0, 0, 16, 0, 12, 8, 32, "P1-04NTC"}, //P1-04NTC
    60  
    61  	{0x34A0558A, 0, 0, 32, 0, 12, 2, 12, "P1-08ADL-1"}, //P1-08ADL-1
    62  
    63  	{0x34A0558B, 0, 0, 32, 0, 12, 2, 12, "P1-08ADL-2"}, //P1-08ADL-2
    64  
    65  	{0x34A5A481, 2, 0, 36, 36, 4, 12, 0xC0, "P1-02HSC"}, //P1-02HSC
    66  
    67  	{0x44035583, 0, 0, 0, 16, 4, 0, 12, "P1-04DAL-1"}, //P1-04DAL-1
    68  
    69  	{0x44035584, 0, 0, 0, 16, 4, 0, 12, "P1-04DAL-2"}, //P1-04DAL-2
    70  
    71  	{0x44055588, 0, 0, 0, 32, 4, 0, 12, "P1-08DAL-1"}, //P1-08DAL-1
    72  
    73  	{0x44055589, 0, 0, 0, 32, 4, 0, 12, "P1-08DAL-2"}, //P1-08DAL-2
    74  
    75  	{0x5461A783, 0, 0, 16, 8, 12, 2, 12, "P1-4ADL2DAL-1"}, //P1-4ADL2DAL-1
    76  
    77  	{0x5461A784, 0, 0, 16, 8, 12, 2, 12, "P1-4ADL2DAL-2"}, //P1-4ADL2DAL-2
    78  
    79  	{0xFFFFFFFF, 0, 0, 0, 0, 0, 0, 0, "BAD SLOT"}, //empty in case no modules are defined.
    80  
    81  	{0x00000000, 0, 0, 0, 0, 0, 0, 0, "BAD SLOT"}, //empty in case no modules are defined.
    82  }
    83  
    84  var defaultConfig = map[uint32][]byte{
    85  	0x34605590:// P1_04ADL_2_DEFAULT_CONFIG
    86  	{0x40, 0x03},
    87  	0x34608C8E: // P1_04NTC_DEFAULT_CONFIG
    88  	{0x40, 0x03, 0x60, 0x05,
    89  		0x20, 0x00, 0x80, 0x02},
    90  	0x34608C81: // P1_04THM_DEFAULT_CONFIG
    91  	{0x40, 0x03, 0x60, 0x05,
    92  		0x21, 0x00, 0x22, 0x00,
    93  		0x23, 0x00, 0x24, 0x00,
    94  		0x00, 0x00, 0x00, 0x00,
    95  		0x00, 0x00, 0x00, 0x00},
    96  	0x34605588: // P1_04RTD_DEFAULT_CONFIG
    97  	{0x40, 0x03, 0x60, 0x05,
    98  		0x20, 0x01, 0x80, 0x00},
    99  	0x34605581: // P1_04AD_DEFAULT_CONFIG
   100  	{0x40, 0x03, 0x00, 0x00,
   101  		0x20, 0x03, 0x00, 0x00,
   102  		0x21, 0x03, 0x00, 0x00,
   103  		0x22, 0x03, 0x00, 0x00,
   104  		0x23, 0x03},
   105  	0x3460558F:// P1_04ADL_1_DEFAULT_CONFIG
   106  	{0x40, 0x03},
   107  	0x34A0558A:// P1_08ADL_1_DEFAULT_CONFIG
   108  	{0x40, 0x07},
   109  	0x34A0558B:// P1_08ADL_2_DEFAULT_CONFIG
   110  	{0x40, 0x07},
   111  	0x5461A783:// P1_04ADL2DAL_1_DEFAULT_CONFIG
   112  	{0x40, 0x03},
   113  	0x5461A784:// P1_04ADL2DAL_2_DEFAULT_CONFIG
   114  	{0x40, 0x03},
   115  	0x1403F481:// P1_04PWM_DEFAULT_CONFIG
   116  	{0x02, 0x02, 0x02, 0x02},
   117  	0x34A5A481: // P1_02HSC_DEFAULT_CONFIG
   118  	{0x00, 0x00, 0x00, 0x00,
   119  		0x00, 0x00, 0x00, 0x01,
   120  		0x00, 0x00, 0x00, 0x01},
   121  }
   122  
   123  const NUMBER_OF_MODULES = 15 //Current max 15 Modules
   124  const SWITCH_BUILTIN = 31
   125  const baseEnable = 33
   126  const MOD_HDR = 0x02
   127  const VERSION_HDR = 0x03
   128  const ACTIVE_HDR = 0x04
   129  const DROPOUT_HDR = 0x05
   130  const CFG_HDR = 0x10
   131  const READ_CFG_HDR = 0x11
   132  const PETWD_HDR = 0x30
   133  const STARTWD_HDR = 0x31
   134  const STOPWD_HDR = 0x32
   135  const CONFIGWD_HDR = 0x33
   136  const READ_STATUS_HDR = 0x40
   137  const READ_DISCRETE_HDR = 0x50
   138  const READ_ANALOG_HDR = 0x51
   139  const READ_BLOCK_HDR = 0x52
   140  const WRITE_DISCRETE_HDR = 0x60
   141  const WRITE_ANALOG_HDR = 0x61
   142  const WRITE_BLOCK_HDR = 0x62
   143  const FW_UPDATE_HDR = 0xAA
   144  const DUMMY = 0xFF
   145  const EMPTY_SLOT_ID = 0xFFFFFFFE
   146  const MAX_TIMEOUT = 0xFFFFFFFF
   147  const DISCRETE_IN_BLOCK = 0
   148  const ANALOG_IN_BLOCK = 1
   149  const DISCRETE_OUT_BLOCK = 2
   150  const ANALOG_OUT_BLOCK = 3
   151  const STATUS_IN_BLOCK = 4
   152  const MISSING24V_STATUS = 3
   153  const BURNOUT_STATUS = 5
   154  const UNDER_RANGE_STATUS = 7
   155  const OVER_RANGE_STATUS = 11
   156  const TOGGLE = 0x01
   157  const HOLD = 0x00