|
| 1 | +[CCode (cheader_filename = "widgetlords.h")] |
| 2 | +namespace WidgetLords |
| 3 | +{ |
| 4 | + public const uint8 DIR_RS485; |
| 5 | + |
| 6 | + namespace PiSpi |
| 7 | + { |
| 8 | + [CCode (cname = "pi_spi_init")] |
| 9 | + void init(); |
| 10 | + |
| 11 | + [CCode (cname = "pi_spi_2ao_write_single")] |
| 12 | + void write_single_2ao(uint8 channel, uint16 counts, bool optional = false); |
| 13 | + |
| 14 | + [CCode (cname = "pi_spi_8ai_read_single")] |
| 15 | + void read_single_8ai(uint8 channel, bool optional = false); |
| 16 | + |
| 17 | + [CCode (cname = "pi_spi_8di_read")] |
| 18 | + uint8 read_8di(uint8 address, bool optional = false); |
| 19 | + |
| 20 | + [CCode (cname = "pi_spi_8di_read_single")] |
| 21 | + uint8 read_single_8di(uint8 address, uint8 channel, bool optional = false); |
| 22 | + |
| 23 | + [CCode (cname = "pi_spi_8di_init")] |
| 24 | + void init_8di(uint8 address, bool optional = false); |
| 25 | + |
| 26 | + [CCode (cname = "pi_spi_8ko_write")] |
| 27 | + void write_8ko(uint8 data, bool optional = false); |
| 28 | + |
| 29 | + [CCode (cname = "pi_spi_8ko_write_single")] |
| 30 | + void write_single_8ko(uint8 channel, uint8 data, bool optional = false); |
| 31 | + } |
| 32 | + |
| 33 | + namespace PiSpiDin |
| 34 | + { |
| 35 | + [CCode (cname = "enum chip_enable", cprefix = "", has_type_id = false)] |
| 36 | + public enum ChipEnable |
| 37 | + { |
| 38 | + CE0, |
| 39 | + CE1, |
| 40 | + CE2, |
| 41 | + CE3, |
| 42 | + CE4 |
| 43 | + } |
| 44 | + |
| 45 | + [CCode (cname = "pi_spi_din_init")] |
| 46 | + void init(); |
| 47 | + |
| 48 | + [CCode (cname = "pi_spi_din_4ao_init")] |
| 49 | + void init_4ao(); |
| 50 | + |
| 51 | + [CCode (cname = "pi_spi_din_4ao_write_single")] |
| 52 | + void write_single_4ao(uint8 channel, uint16 counts); |
| 53 | + |
| 54 | + [CCode (cname = "pi_spi_din_8ai_read_single")] |
| 55 | + uint16 read_single_8ai(ChipEnable ce, uint8 channel); |
| 56 | + |
| 57 | + [CCode (cname = "pi_spi_din_8di_read")] |
| 58 | + uint8 read_8di(ChipEnable ce, uint8 address); |
| 59 | + |
| 60 | + [CCode (cname = "pi_spi_din_8di_read_single")] |
| 61 | + uint8 read_single_8di(ChipEnable ce, uint8 address, uint8 channel); |
| 62 | + |
| 63 | + [CCode (cname = "pi_spi_din_8di_init")] |
| 64 | + void init_8di(ChipEnable ce, uint8 address); |
| 65 | + |
| 66 | + [CCode (cname = "pi_spi_din_4ko_write")] |
| 67 | + void write_4ko(ChipEnable ce, uint8 address, uint8 state); |
| 68 | + |
| 69 | + [CCode (cname = "pi_spi_din_4ko_write_single")] |
| 70 | + void write_single_4ko(ChipEnable ce, uint8 address, uint8 channel, uint8 state); |
| 71 | + |
| 72 | + [CCode (cname = "pi_spi_din_4ko_init")] |
| 73 | + void init_4ko(ChipEnable ce, uint8 address); |
| 74 | + |
| 75 | + [CCode (cname = "vpe_2901a_init")] |
| 76 | + void vpe_2901a_init(); |
| 77 | + |
| 78 | + [CCode (cname = "vpe_2901a_2ao_write_single")] |
| 79 | + void vpe_2901a_2ao_write_single(uint8 channel, uint16 counts); |
| 80 | + |
| 81 | + [CCode (cname = "vpe_2901a_2ko_write_single")] |
| 82 | + void vpe_2901a_2ko_write_single(uint8 channel, uint8 value); |
| 83 | + |
| 84 | + [CCode (cname = "vpe_2901a_2di_read_single")] |
| 85 | + uint8 vpe_2901a_2di_read_single(uint8 channel); |
| 86 | + |
| 87 | + [CCode (cname = "VPE_2901A_SDAFE_1")] |
| 88 | + public const uint8 VPE_2901A_SDAFE_1; |
| 89 | + [CCode (cname = "VPE_2901A_SDAFE_2")] |
| 90 | + public const uint8 VPE_2901A_SDAFE_2; |
| 91 | + |
| 92 | + [CCode (cname = "vpe_3011b_init")] |
| 93 | + void vpe_3011b_init(); |
| 94 | + |
| 95 | + [CCode (cname = "vpe_3011b_4ko_write_single")] |
| 96 | + void vpe_3011b_4ko_write_single(uint8 channel, uint8 value); |
| 97 | + |
| 98 | + [CCode (cname = "vpe_3011b_8di_read")] |
| 99 | + uint8 vpe_3011b_8di_read(); |
| 100 | + |
| 101 | + [CCode (cname = "vpe_3011b_8di_read_single")] |
| 102 | + uint8 vpe_3011b_8di_read_single(uint8 channel); |
| 103 | + |
| 104 | + [CCode (cname = "VPE_3011B_SDAFE_1")] |
| 105 | + public const uint8 VPE_3011B_SDAFE_1; |
| 106 | + [CCode (cname = "VPE_3011B_SDAFE_2")] |
| 107 | + public const uint8 VPE_3011B_SDAFE_2; |
| 108 | + [CCode (cname = "VPE_3011B_SDAFE_3")] |
| 109 | + public const uint8 VPE_3011B_SDAFE_3; |
| 110 | + [CCode (cname = "VPE_3011B_SDAFE_4")] |
| 111 | + public const uint8 VPE_3011B_SDAFE_4; |
| 112 | + |
| 113 | + //--------------------------------SDAFE--------------------------------- |
| 114 | + [CCode (cname = "enum sdafe_type", cprefix = "", has_type_id = false)] |
| 115 | + public enum SdafeType |
| 116 | + { |
| 117 | + TYPE_1_MA, // Input 0 to 20 mA, Returns 0 to 20000, Scaler 1000 |
| 118 | + TYPE_2_MA, // Input 0 to 20 mA, Returns 0 to 10000, Scaler 100 |
| 119 | + TYPE_3_MA, // Input 4 to 20 mA, Returns 0 to 10000, Scaler 100 Note: Readings below 4 mA return as 0 |
| 120 | + |
| 121 | + TYPE_4_5VDC, // Input 0 to 5 VDC, Returns 0 to 5000, Scaler 1000 |
| 122 | + TYPE_5_5VDC, // Input 0 to 5 VDC, Returns 0 to 10000, Scaler 100 |
| 123 | + TYPE_6_5VDC, // Input 1 to 5 VDC, Returns 0 to 10000, Scaler 100 Note: Readngs beluw 1 VDC return as 0 |
| 124 | + |
| 125 | + TYPE_7_10VDC, // Input 0 to 10 VDC, Returns 0 to 10000, Scaler 1000 |
| 126 | + TYPE_8_10VDC, // Input 0 to 10 VDC, Returns 0 to 10000, Scaler 100 |
| 127 | + TYPE_9_10VDC // Input 2 to 10 VDC, Returns 0 to 10000, Scaler 100 Note: Readings below 2 VDC return as 0 |
| 128 | + } |
| 129 | + |
| 130 | + [CCode (cname = "enum sdafe_status", cprefix = "SDAFE_", has_type_id = false)] |
| 131 | + public enum SdafeStatus |
| 132 | + { |
| 133 | + OK, |
| 134 | + POLARITY, |
| 135 | + OVER_RANGE, |
| 136 | + COMM_ERROR |
| 137 | + } |
| 138 | + |
| 139 | + [CCode (cname = "struct sdafe_reading", destroy_function = "", has_type_id = false)] |
| 140 | + public struct SdafeReading |
| 141 | + { |
| 142 | + uint16 value; |
| 143 | + SdafeStatus status; |
| 144 | + uint16 counts; |
| 145 | + SdafeType type; |
| 146 | + } |
| 147 | + |
| 148 | + [CCode (cname = "sdafe_set_type")] |
| 149 | + void sdafe_set_type(uint8 channel, SdafeType type); |
| 150 | + |
| 151 | + [CCode (cname = "sdafe_read")] |
| 152 | + SdafeReading sdafe_read(uint8 channel); |
| 153 | + } |
| 154 | +} |
0 commit comments