private void PopulateRegisters() { if (IsOpen) { byte data = (byte)0; if (!Read((byte)66, ref data)) throw new Exception("Unable to read register RegVersion"); if (!Read((byte)66, ref data)) throw new Exception("Unable to read register RegVersion"); Version = new Version(((int)data & 240) >> 4, (int)data & 15); } registers = new RegisterCollection(); byte num1 = (byte)0; RegisterCollection registerCollection1 = registers; string name1 = "RegFifo"; int num2 = (int)num1; int num3 = 1; byte num4 = (byte)(num2 + num3); int num5 = 0; int num6 = 1; int num7 = 1; Register register1 = new Register(name1, (uint)num2, (uint)num5, num6 != 0, num7 != 0); registerCollection1.Add(register1); RegisterCollection registerCollection2 = registers; string name2 = "RegOpMode"; int num8 = (int)num4; int num9 = 1; byte num10 = (byte)(num8 + num9); int num11 = 9; int num12 = 0; int num13 = 1; Register register2 = new Register(name2, (uint)num8, (uint)num11, num12 != 0, num13 != 0); registerCollection2.Add(register2); RegisterCollection registerCollection3 = registers; string name3 = "RegBitrateMsb"; int num14 = (int)num10; int num15 = 1; byte num16 = (byte)(num14 + num15); int num17 = 26; int num18 = 0; int num19 = 1; Register register3 = new Register(name3, (uint)num14, (uint)num17, num18 != 0, num19 != 0); registerCollection3.Add(register3); RegisterCollection registerCollection4 = registers; string name4 = "RegBitrateLsb"; int num20 = (int)num16; int num21 = 1; byte num22 = (byte)(num20 + num21); int num23 = 11; int num24 = 0; int num25 = 1; Register register4 = new Register(name4, (uint)num20, (uint)num23, num24 != 0, num25 != 0); registerCollection4.Add(register4); RegisterCollection registerCollection5 = registers; string name5 = "RegFdevMsb"; int num26 = (int)num22; int num27 = 1; byte num28 = (byte)(num26 + num27); int num29 = 0; int num30 = 0; int num31 = 1; Register register5 = new Register(name5, (uint)num26, (uint)num29, num30 != 0, num31 != 0); registerCollection5.Add(register5); RegisterCollection registerCollection6 = registers; string name6 = "RegFdevLsb"; int num32 = (int)num28; int num33 = 1; byte num34 = (byte)(num32 + num33); int num35 = 82; int num36 = 0; int num37 = 1; Register register6 = new Register(name6, (uint)num32, (uint)num35, num36 != 0, num37 != 0); registerCollection6.Add(register6); RegisterCollection registerCollection7 = registers; string name7 = "RegFrfMsb"; int num38 = (int)num34; int num39 = 1; byte num40 = (byte)(num38 + num39); int num41 = 228; int num42 = 0; int num43 = 1; Register register7 = new Register(name7, (uint)num38, (uint)num41, num42 != 0, num43 != 0); registerCollection7.Add(register7); RegisterCollection registerCollection8 = registers; string name8 = "RegFrfMid"; int num44 = (int)num40; int num45 = 1; byte num46 = (byte)(num44 + num45); int num47 = 192; int num48 = 0; int num49 = 1; Register register8 = new Register(name8, (uint)num44, (uint)num47, num48 != 0, num49 != 0); registerCollection8.Add(register8); RegisterCollection registerCollection9 = registers; string name9 = "RegFrfLsb"; int num50 = (int)num46; int num51 = 1; byte num52 = (byte)(num50 + num51); int num53 = 0; int num54 = 0; int num55 = 1; Register register9 = new Register(name9, (uint)num50, (uint)num53, num54 != 0, num55 != 0); registerCollection9.Add(register9); RegisterCollection registerCollection10 = registers; string name10 = "RegPaConfig"; int num56 = (int)num52; int num57 = 1; byte num58 = (byte)(num56 + num57); int num59 = 15; int num60 = 0; int num61 = 1; Register register10 = new Register(name10, (uint)num56, (uint)num59, num60 != 0, num61 != 0); registerCollection10.Add(register10); RegisterCollection registerCollection11 = registers; string name11 = "RegPaRamp"; int num62 = (int)num58; int num63 = 1; byte num64 = (byte)(num62 + num63); int num65 = 25; int num66 = 0; int num67 = 1; Register register11 = new Register(name11, (uint)num62, (uint)num65, num66 != 0, num67 != 0); registerCollection11.Add(register11); RegisterCollection registerCollection12 = registers; string name12 = "RegOcp"; int num68 = (int)num64; int num69 = 1; byte num70 = (byte)(num68 + num69); int num71 = 43; int num72 = 0; int num73 = 1; Register register12 = new Register(name12, (uint)num68, (uint)num71, num72 != 0, num73 != 0); registerCollection12.Add(register12); RegisterCollection registerCollection13 = registers; string name13 = "RegLna"; int num74 = (int)num70; int num75 = 1; byte num76 = (byte)(num74 + num75); int num77 = 32; int num78 = 0; int num79 = 1; Register register13 = new Register(name13, (uint)num74, (uint)num77, num78 != 0, num79 != 0); registerCollection13.Add(register13); RegisterCollection registerCollection14 = registers; string name14 = "RegRxConfig"; int num80 = (int)num76; int num81 = 1; byte num82 = (byte)(num80 + num81); int num83 = 8; int num84 = 0; int num85 = 1; Register register14 = new Register(name14, (uint)num80, (uint)num83, num84 != 0, num85 != 0); registerCollection14.Add(register14); RegisterCollection registerCollection15 = registers; string name15 = "RegRssiConfig"; int num86 = (int)num82; int num87 = 1; byte num88 = (byte)(num86 + num87); int num89 = 2; int num90 = 0; int num91 = 1; Register register15 = new Register(name15, (uint)num86, (uint)num89, num90 != 0, num91 != 0); registerCollection15.Add(register15); RegisterCollection registerCollection16 = registers; string name16 = "RegRssiCollision"; int num92 = (int)num88; int num93 = 1; byte num94 = (byte)(num92 + num93); int num95 = 10; int num96 = 0; int num97 = 1; Register register16 = new Register(name16, (uint)num92, (uint)num95, num96 != 0, num97 != 0); registerCollection16.Add(register16); RegisterCollection registerCollection17 = registers; string name17 = "RegRssiThresh"; int num98 = (int)num94; int num99 = 1; byte num100 = (byte)(num98 + num99); int num101 = (int)byte.MaxValue; int num102 = 0; int num103 = 1; Register register17 = new Register(name17, (uint)num98, (uint)num101, num102 != 0, num103 != 0); registerCollection17.Add(register17); RegisterCollection registerCollection18 = registers; string name18 = "RegRssiValue"; int num104 = (int)num100; int num105 = 1; byte num106 = (byte)(num104 + num105); int num107 = 0; int num108 = 0; int num109 = 1; Register register18 = new Register(name18, (uint)num104, (uint)num107, num108 != 0, num109 != 0); registerCollection18.Add(register18); RegisterCollection registerCollection19 = registers; string name19 = "RegRxBw"; int num110 = (int)num106; int num111 = 1; byte num112 = (byte)(num110 + num111); int num113 = 21; int num114 = 0; int num115 = 1; Register register19 = new Register(name19, (uint)num110, (uint)num113, num114 != 0, num115 != 0); registerCollection19.Add(register19); RegisterCollection registerCollection20 = registers; string name20 = "RegAfcBw"; int num116 = (int)num112; int num117 = 1; byte num118 = (byte)(num116 + num117); int num119 = 11; int num120 = 0; int num121 = 1; Register register20 = new Register(name20, (uint)num116, (uint)num119, num120 != 0, num121 != 0); registerCollection20.Add(register20); RegisterCollection registerCollection21 = registers; string name21 = "RegOokPeak"; int num122 = (int)num118; int num123 = 1; byte num124 = (byte)(num122 + num123); int num125 = 40; int num126 = 0; int num127 = 1; Register register21 = new Register(name21, (uint)num122, (uint)num125, num126 != 0, num127 != 0); registerCollection21.Add(register21); RegisterCollection registerCollection22 = registers; string name22 = "RegOokFix"; int num128 = (int)num124; int num129 = 1; byte num130 = (byte)(num128 + num129); int num131 = 12; int num132 = 0; int num133 = 1; Register register22 = new Register(name22, (uint)num128, (uint)num131, num132 != 0, num133 != 0); registerCollection22.Add(register22); RegisterCollection registerCollection23 = registers; string name23 = "RegOokAvg"; int num134 = (int)num130; int num135 = 1; byte num136 = (byte)(num134 + num135); int num137 = 18; int num138 = 0; int num139 = 1; Register register23 = new Register(name23, (uint)num134, (uint)num137, num138 != 0, num139 != 0); registerCollection23.Add(register23); RegisterCollection registerCollection24 = registers; string name24 = "RegRes17"; int num140 = (int)num136; int num141 = 1; byte num142 = (byte)(num140 + num141); int num143 = 71; int num144 = 0; int num145 = 1; Register register24 = new Register(name24, (uint)num140, (uint)num143, num144 != 0, num145 != 0); registerCollection24.Add(register24); RegisterCollection registerCollection25 = registers; string name25 = "RegRes18"; int num146 = (int)num142; int num147 = 1; byte num148 = (byte)(num146 + num147); int num149 = 50; int num150 = 0; int num151 = 1; Register register25 = new Register(name25, (uint)num146, (uint)num149, num150 != 0, num151 != 0); registerCollection25.Add(register25); RegisterCollection registerCollection26 = registers; string name26 = "RegRes19"; int num152 = (int)num148; int num153 = 1; byte num154 = (byte)(num152 + num153); int num155 = 62; int num156 = 0; int num157 = 1; Register register26 = new Register(name26, (uint)num152, (uint)num155, num156 != 0, num157 != 0); registerCollection26.Add(register26); RegisterCollection registerCollection27 = registers; string name27 = "RegAfcFei"; int num158 = (int)num154; int num159 = 1; byte num160 = (byte)(num158 + num159); int num161 = 0; int num162 = 0; int num163 = 1; Register register27 = new Register(name27, (uint)num158, (uint)num161, num162 != 0, num163 != 0); registerCollection27.Add(register27); RegisterCollection registerCollection28 = registers; string name28 = "RegAfcMsb"; int num164 = (int)num160; int num165 = 1; byte num166 = (byte)(num164 + num165); int num167 = 0; int num168 = 0; int num169 = 1; Register register28 = new Register(name28, (uint)num164, (uint)num167, num168 != 0, num169 != 0); registerCollection28.Add(register28); RegisterCollection registerCollection29 = registers; string name29 = "RegAfcLsb"; int num170 = (int)num166; int num171 = 1; byte num172 = (byte)(num170 + num171); int num173 = 0; int num174 = 0; int num175 = 1; Register register29 = new Register(name29, (uint)num170, (uint)num173, num174 != 0, num175 != 0); registerCollection29.Add(register29); RegisterCollection registerCollection30 = registers; string name30 = "RegFeiMsb"; int num176 = (int)num172; int num177 = 1; byte num178 = (byte)(num176 + num177); int num179 = 0; int num180 = 0; int num181 = 1; Register register30 = new Register(name30, (uint)num176, (uint)num179, num180 != 0, num181 != 0); registerCollection30.Add(register30); RegisterCollection registerCollection31 = registers; string name31 = "RegFeiLsb"; int num182 = (int)num178; int num183 = 1; byte num184 = (byte)(num182 + num183); int num185 = 0; int num186 = 0; int num187 = 1; Register register31 = new Register(name31, (uint)num182, (uint)num185, num186 != 0, num187 != 0); registerCollection31.Add(register31); RegisterCollection registerCollection32 = registers; string name32 = "RegPreambleDetect"; int num188 = (int)num184; int num189 = 1; byte num190 = (byte)(num188 + num189); int num191 = 64; int num192 = 0; int num193 = 1; Register register32 = new Register(name32, (uint)num188, (uint)num191, num192 != 0, num193 != 0); registerCollection32.Add(register32); RegisterCollection registerCollection33 = registers; string name33 = "RegRxTimeout1"; int num194 = (int)num190; int num195 = 1; byte num196 = (byte)(num194 + num195); int num197 = 0; int num198 = 0; int num199 = 1; Register register33 = new Register(name33, (uint)num194, (uint)num197, num198 != 0, num199 != 0); registerCollection33.Add(register33); RegisterCollection registerCollection34 = registers; string name34 = "RegRxTimeout2"; int num200 = (int)num196; int num201 = 1; byte num202 = (byte)(num200 + num201); int num203 = 0; int num204 = 0; int num205 = 1; Register register34 = new Register(name34, (uint)num200, (uint)num203, num204 != 0, num205 != 0); registerCollection34.Add(register34); RegisterCollection registerCollection35 = registers; string name35 = "RegRxTimeout3"; int num206 = (int)num202; int num207 = 1; byte num208 = (byte)(num206 + num207); int num209 = 0; int num210 = 0; int num211 = 1; Register register35 = new Register(name35, (uint)num206, (uint)num209, num210 != 0, num211 != 0); registerCollection35.Add(register35); RegisterCollection registerCollection36 = registers; string name36 = "RegRxDelay"; int num212 = (int)num208; int num213 = 1; byte num214 = (byte)(num212 + num213); int num215 = 0; int num216 = 0; int num217 = 1; Register register36 = new Register(name36, (uint)num212, (uint)num215, num216 != 0, num217 != 0); registerCollection36.Add(register36); RegisterCollection registerCollection37 = registers; string name37 = "RegOsc"; int num218 = (int)num214; int num219 = 1; byte num220 = (byte)(num218 + num219); int num221 = 5; int num222 = 0; int num223 = 1; Register register37 = new Register(name37, (uint)num218, (uint)num221, num222 != 0, num223 != 0); registerCollection37.Add(register37); RegisterCollection registerCollection38 = registers; string name38 = "RegPreambleMsb"; int num224 = (int)num220; int num225 = 1; byte num226 = (byte)(num224 + num225); int num227 = 0; int num228 = 0; int num229 = 1; Register register38 = new Register(name38, (uint)num224, (uint)num227, num228 != 0, num229 != 0); registerCollection38.Add(register38); RegisterCollection registerCollection39 = registers; string name39 = "RegPreambleLsb"; int num230 = (int)num226; int num231 = 1; byte num232 = (byte)(num230 + num231); int num233 = 3; int num234 = 0; int num235 = 1; Register register39 = new Register(name39, (uint)num230, (uint)num233, num234 != 0, num235 != 0); registerCollection39.Add(register39); RegisterCollection registerCollection40 = registers; string name40 = "RegSyncConfig"; int num236 = (int)num232; int num237 = 1; byte num238 = (byte)(num236 + num237); int num239 = 147; int num240 = 0; int num241 = 1; Register register40 = new Register(name40, (uint)num236, (uint)num239, num240 != 0, num241 != 0); registerCollection40.Add(register40); RegisterCollection registerCollection41 = registers; string name41 = "RegSyncValue1"; int num242 = (int)num238; int num243 = 1; byte num244 = (byte)(num242 + num243); int num245 = 85; int num246 = 0; int num247 = 1; Register register41 = new Register(name41, (uint)num242, (uint)num245, num246 != 0, num247 != 0); registerCollection41.Add(register41); RegisterCollection registerCollection42 = registers; string name42 = "RegSyncValue2"; int num248 = (int)num244; int num249 = 1; byte num250 = (byte)(num248 + num249); int num251 = 85; int num252 = 0; int num253 = 1; Register register42 = new Register(name42, (uint)num248, (uint)num251, num252 != 0, num253 != 0); registerCollection42.Add(register42); RegisterCollection registerCollection43 = registers; string name43 = "RegSyncValue3"; int num254 = (int)num250; int num255 = 1; byte num256 = (byte)(num254 + num255); int num257 = 85; int num258 = 0; int num259 = 1; Register register43 = new Register(name43, (uint)num254, (uint)num257, num258 != 0, num259 != 0); registerCollection43.Add(register43); RegisterCollection registerCollection44 = registers; string name44 = "RegSyncValue4"; int num260 = (int)num256; int num261 = 1; byte num262 = (byte)(num260 + num261); int num263 = 85; int num264 = 0; int num265 = 1; Register register44 = new Register(name44, (uint)num260, (uint)num263, num264 != 0, num265 != 0); registerCollection44.Add(register44); RegisterCollection registerCollection45 = registers; string name45 = "RegSyncValue5"; int num266 = (int)num262; int num267 = 1; byte num268 = (byte)(num266 + num267); int num269 = 85; int num270 = 0; int num271 = 1; Register register45 = new Register(name45, (uint)num266, (uint)num269, num270 != 0, num271 != 0); registerCollection45.Add(register45); RegisterCollection registerCollection46 = registers; string name46 = "RegSyncValue6"; int num272 = (int)num268; int num273 = 1; byte num274 = (byte)(num272 + num273); int num275 = 85; int num276 = 0; int num277 = 1; Register register46 = new Register(name46, (uint)num272, (uint)num275, num276 != 0, num277 != 0); registerCollection46.Add(register46); RegisterCollection registerCollection47 = registers; string name47 = "RegSyncValue7"; int num278 = (int)num274; int num279 = 1; byte num280 = (byte)(num278 + num279); int num281 = 85; int num282 = 0; int num283 = 1; Register register47 = new Register(name47, (uint)num278, (uint)num281, num282 != 0, num283 != 0); registerCollection47.Add(register47); RegisterCollection registerCollection48 = registers; string name48 = "RegSyncValue8"; int num284 = (int)num280; int num285 = 1; byte num286 = (byte)(num284 + num285); int num287 = 85; int num288 = 0; int num289 = 1; Register register48 = new Register(name48, (uint)num284, (uint)num287, num288 != 0, num289 != 0); registerCollection48.Add(register48); RegisterCollection registerCollection49 = registers; string name49 = "RegPacketConfig1"; int num290 = (int)num286; int num291 = 1; byte num292 = (byte)(num290 + num291); int num293 = 144; int num294 = 0; int num295 = 1; Register register49 = new Register(name49, (uint)num290, (uint)num293, num294 != 0, num295 != 0); registerCollection49.Add(register49); RegisterCollection registerCollection50 = registers; string name50 = "RegPacketConfig2"; int num296 = (int)num292; int num297 = 1; byte num298 = (byte)(num296 + num297); int num299 = 64; int num300 = 0; int num301 = 1; Register register50 = new Register(name50, (uint)num296, (uint)num299, num300 != 0, num301 != 0); registerCollection50.Add(register50); RegisterCollection registerCollection51 = registers; string name51 = "RegPayloadLength"; int num302 = (int)num298; int num303 = 1; byte num304 = (byte)(num302 + num303); int num305 = 64; int num306 = 0; int num307 = 1; Register register51 = new Register(name51, (uint)num302, (uint)num305, num306 != 0, num307 != 0); registerCollection51.Add(register51); RegisterCollection registerCollection52 = registers; string name52 = "RegNodeAdrs"; int num308 = (int)num304; int num309 = 1; byte num310 = (byte)(num308 + num309); int num311 = 0; int num312 = 0; int num313 = 1; Register register52 = new Register(name52, (uint)num308, (uint)num311, num312 != 0, num313 != 0); registerCollection52.Add(register52); RegisterCollection registerCollection53 = registers; string name53 = "RegBroadcastAdrs"; int num314 = (int)num310; int num315 = 1; byte num316 = (byte)(num314 + num315); int num317 = 0; int num318 = 0; int num319 = 1; Register register53 = new Register(name53, (uint)num314, (uint)num317, num318 != 0, num319 != 0); registerCollection53.Add(register53); RegisterCollection registerCollection54 = registers; string name54 = "RegFifoThresh"; int num320 = (int)num316; int num321 = 1; byte num322 = (byte)(num320 + num321); int num323 = 15; int num324 = 0; int num325 = 1; Register register54 = new Register(name54, (uint)num320, (uint)num323, num324 != 0, num325 != 0); registerCollection54.Add(register54); RegisterCollection registerCollection55 = registers; string name55 = "RegSeqConfig1"; int num326 = (int)num322; int num327 = 1; byte num328 = (byte)(num326 + num327); int num329 = 0; int num330 = 0; int num331 = 1; Register register55 = new Register(name55, (uint)num326, (uint)num329, num330 != 0, num331 != 0); registerCollection55.Add(register55); RegisterCollection registerCollection56 = registers; string name56 = "RegSeqConfig2"; int num332 = (int)num328; int num333 = 1; byte num334 = (byte)(num332 + num333); int num335 = 0; int num336 = 0; int num337 = 1; Register register56 = new Register(name56, (uint)num332, (uint)num335, num336 != 0, num337 != 0); registerCollection56.Add(register56); RegisterCollection registerCollection57 = registers; string name57 = "RegTimerResol"; int num338 = (int)num334; int num339 = 1; byte num340 = (byte)(num338 + num339); int num341 = 0; int num342 = 0; int num343 = 1; Register register57 = new Register(name57, (uint)num338, (uint)num341, num342 != 0, num343 != 0); registerCollection57.Add(register57); RegisterCollection registerCollection58 = registers; string name58 = "RegTimer1Coef"; int num344 = (int)num340; int num345 = 1; byte num346 = (byte)(num344 + num345); int num347 = 245; int num348 = 0; int num349 = 1; Register register58 = new Register(name58, (uint)num344, (uint)num347, num348 != 0, num349 != 0); registerCollection58.Add(register58); RegisterCollection registerCollection59 = registers; string name59 = "RegTimer2Coef"; int num350 = (int)num346; int num351 = 1; byte num352 = (byte)(num350 + num351); int num353 = 32; int num354 = 0; int num355 = 1; Register register59 = new Register(name59, (uint)num350, (uint)num353, num354 != 0, num355 != 0); registerCollection59.Add(register59); RegisterCollection registerCollection60 = registers; string name60 = "RegImageCal"; int num356 = (int)num352; int num357 = 1; byte num358 = (byte)(num356 + num357); int num359 = 130; int num360 = 0; int num361 = 1; Register register60 = new Register(name60, (uint)num356, (uint)num359, num360 != 0, num361 != 0); registerCollection60.Add(register60); RegisterCollection registerCollection61 = registers; string name61 = "RegTemp"; int num362 = (int)num358; int num363 = 1; byte num364 = (byte)(num362 + num363); int num365 = 0; int num366 = 0; int num367 = 1; Register register61 = new Register(name61, (uint)num362, (uint)num365, num366 != 0, num367 != 0); registerCollection61.Add(register61); RegisterCollection registerCollection62 = registers; string name62 = "RegLowBat"; int num368 = (int)num364; int num369 = 1; byte num370 = (byte)(num368 + num369); int num371 = 2; int num372 = 0; int num373 = 1; Register register62 = new Register(name62, (uint)num368, (uint)num371, num372 != 0, num373 != 0); registerCollection62.Add(register62); RegisterCollection registerCollection63 = registers; string name63 = "RegIrqFlags1"; int num374 = (int)num370; int num375 = 1; byte num376 = (byte)(num374 + num375); int num377 = 128; int num378 = 0; int num379 = 1; Register register63 = new Register(name63, (uint)num374, (uint)num377, num378 != 0, num379 != 0); registerCollection63.Add(register63); RegisterCollection registerCollection64 = registers; string name64 = "RegIrqFlags2"; int num380 = (int)num376; int num381 = 1; byte num382 = (byte)(num380 + num381); int num383 = 64; int num384 = 0; int num385 = 1; Register register64 = new Register(name64, (uint)num380, (uint)num383, num384 != 0, num385 != 0); registerCollection64.Add(register64); RegisterCollection registerCollection65 = registers; string name65 = "RegDioMapping1"; int num386 = (int)num382; int num387 = 1; byte num388 = (byte)(num386 + num387); int num389 = 0; int num390 = 0; int num391 = 1; Register register65 = new Register(name65, (uint)num386, (uint)num389, num390 != 0, num391 != 0); registerCollection65.Add(register65); RegisterCollection registerCollection66 = registers; string name66 = "RegDioMapping2"; int num392 = (int)num388; int num393 = 1; byte num394 = (byte)(num392 + num393); int num395 = 0; int num396 = 0; int num397 = 1; Register register66 = new Register(name66, (uint)num392, (uint)num395, num396 != 0, num397 != 0); registerCollection66.Add(register66); RegisterCollection registerCollection67 = registers; string name67 = "RegVersion"; int num398 = (int)num394; int num399 = 1; byte num400 = (byte)(num398 + num399); int num401 = 17; int num402 = 0; int num403 = 1; Register register67 = new Register(name67, (uint)num398, (uint)num401, num402 != 0, num403 != 0); registerCollection67.Add(register67); for (int index = 67; index < 68; ++index) registers.Add(new Register("RegTest" + num400.ToString("X02"), (uint)num400++, 0U, false, true)); RegisterCollection registerCollection68 = registers; string name68 = "RegPllHop"; int num404 = (int)num400; int num405 = 1; byte num406 = (byte)(num404 + num405); int num407 = 45; int num408 = 0; int num409 = 1; Register register68 = new Register(name68, (uint)num404, (uint)num407, num408 != 0, num409 != 0); registerCollection68.Add(register68); for (int index = 69; index < 75; ++index) registers.Add(new Register("RegTest" + num406.ToString("X02"), (uint)num406++, 0U, false, true)); RegisterCollection registerCollection69 = registers; string name69 = "RegTcxo"; int num410 = (int)num406; int num411 = 1; byte num412 = (byte)(num410 + num411); int num413 = 9; int num414 = 0; int num415 = 1; Register register69 = new Register(name69, (uint)num410, (uint)num413, num414 != 0, num415 != 0); registerCollection69.Add(register69); RegisterCollection registerCollection70 = registers; string name70 = "RegTest4C"; int num416 = (int)num412; int num417 = 1; byte num418 = (byte)(num416 + num417); int num419 = 0; int num420 = 0; int num421 = 1; Register register70 = new Register(name70, (uint)num416, (uint)num419, num420 != 0, num421 != 0); registerCollection70.Add(register70); RegisterCollection registerCollection71 = registers; string name71 = "RegPaDac"; int num422 = (int)num418; int num423 = 1; byte num424 = (byte)(num422 + num423); int num425 = 132; int num426 = 0; int num427 = 1; Register register71 = new Register(name71, (uint)num422, (uint)num425, num426 != 0, num427 != 0); registerCollection71.Add(register71); for (int index = 78; index < 91; ++index) registers.Add(new Register("RegTest" + num424.ToString("X02"), (uint)num424++, 0U, false, true)); RegisterCollection registerCollection72 = registers; string name72 = "RegFormerTemp"; int num428 = (int)num424; int num429 = 1; byte num430 = (byte)(num428 + num429); int num431 = 0; int num432 = 0; int num433 = 1; Register register72 = new Register(name72, (uint)num428, (uint)num431, num432 != 0, num433 != 0); registerCollection72.Add(register72); RegisterCollection registerCollection73 = registers; string name73 = "RegTest5C"; int num434 = (int)num430; int num435 = 1; byte num436 = (byte)(num434 + num435); int num437 = 0; int num438 = 0; int num439 = 1; Register register73 = new Register(name73, (uint)num434, (uint)num437, num438 != 0, num439 != 0); registerCollection73.Add(register73); RegisterCollection registerCollection74 = registers; string name74 = "RegBitrateFrac"; int num440 = (int)num436; int num441 = 1; byte num442 = (byte)(num440 + num441); int num443 = 0; int num444 = 0; int num445 = 1; Register register74 = new Register(name74, (uint)num440, (uint)num443, num444 != 0, num445 != 0); registerCollection74.Add(register74); for (int index = 94; index < 97; ++index) registers.Add(new Register("RegTest" + num442.ToString("X02"), (uint)num442++, 0U, false, true)); RegisterCollection registerCollection75 = registers; string name75 = "RegAgcRef"; int num446 = (int)num442; int num447 = 1; byte num448 = (byte)(num446 + num447); int num449 = 25; int num450 = 0; int num451 = 1; Register register75 = new Register(name75, (uint)num446, (uint)num449, num450 != 0, num451 != 0); registerCollection75.Add(register75); RegisterCollection registerCollection76 = registers; string name76 = "RegAgcThresh1"; int num452 = (int)num448; int num453 = 1; byte num454 = (byte)(num452 + num453); int num455 = 12; int num456 = 0; int num457 = 1; Register register76 = new Register(name76, (uint)num452, (uint)num455, num456 != 0, num457 != 0); registerCollection76.Add(register76); RegisterCollection registerCollection77 = registers; string name77 = "RegAgcThresh2"; int num458 = (int)num454; int num459 = 1; byte num460 = (byte)(num458 + num459); int num461 = 75; int num462 = 0; int num463 = 1; Register register77 = new Register(name77, (uint)num458, (uint)num461, num462 != 0, num463 != 0); registerCollection77.Add(register77); RegisterCollection registerCollection78 = registers; string name78 = "RegAgcThresh3"; int num464 = (int)num460; int num465 = 1; byte num466 = (byte)(num464 + num465); int num467 = 204; int num468 = 0; int num469 = 1; Register register78 = new Register(name78, (uint)num464, (uint)num467, num468 != 0, num469 != 0); registerCollection78.Add(register78); for (int index = 101; index < 112; ++index) registers.Add(new Register("RegTest" + num466.ToString("X02"), (uint)num466++, 0U, false, true)); RegisterCollection registerCollection79 = registers; string name79 = "RegPll"; int num470 = (int)num466; int num471 = 1; byte num472 = (byte)(num470 + num471); int num473 = 208; int num474 = 0; int num475 = 1; Register register79 = new Register(name79, (uint)num470, (uint)num473, num474 != 0, num475 != 0); registerCollection79.Add(register79); for (int index = 113; index < 128; ++index) registers.Add(new Register("RegTest" + num472.ToString("X02"), (uint)num472++, 0U, false, true)); foreach (Register register80 in registers) register80.PropertyChanged += new PropertyChangedEventHandler(registers_PropertyChanged); Packet = new Packet(); }
private bool ReadRegister(Register reg, ref byte data) { bool flag; lock (syncThread) { try { readLock++; if (!Read((byte)reg.Address, ref data)) throw new Exception("Unable to read register: " + reg.Name); reg.Value = data; flag = true; } catch (Exception exception) { OnError(1, exception.Message); flag = false; } finally { readLock--; } } return flag; }
public bool WriteRegister(Register r, byte data) { lock (syncThread) { try { ++writeLock; if (!Write((byte)r.Address, data)) throw new Exception("Unable to read register: " + r.Name); return true; } catch (Exception exception_0) { OnError((byte)1, exception_0.Message); return false; } finally { --writeLock; } } }
public void AddRange(Register[] value) { for (int index = 0; index < value.Length; ++index) Add(value[index]); }
public void CopyTo(Register[] array, int index) { List.CopyTo((Array)array, index); }
public void Remove(Register value) { try { List.Remove((object)value); --Capacity; } catch { } }
public RegisterCollection(Register[] value) { AddRange(value); }
public bool Contains(Register value) { return base.List.Contains(value); }
public void CopyTo(Register[] array, int index) { base.List.CopyTo(array, index); }
public int Add(Register value) { return base.List.Add(value); }
public void AddRange(Register[] value) { for (int i = 0; i < value.Length; i++) Add(value[i]); }
private void UpdateRegisterValue(Register r) { switch (r.Name) { case "RegOpMode": LowFrequencyModeOn = ((int)(r.Value >> 3) & 1) == 1; Console.WriteLine("RegOpMode (URV): 0x{0}", r.Value.ToString("X02")); Mode = (registers["RegModemConfig2"].Value & 8) != 8 || (r.Value & 7) != 3 ? (OperatingModeEnum)((int)r.Value & 7) : OperatingModeEnum.TxContinuous; if (registers["RegPayloadLength"].Value != (uint)PayloadLength) registers["RegPayloadLength"].Value = (uint)PayloadLength; lock (syncThread) { SetModeLeds(Mode); break; } case "RegFdevMsb": Band = (BandEnum)((registers["RegFdevMsb"].Value >> 6) & 3); break; case "RegFrfMsb": case "RegFrfMid": case "RegFrfLsb": FrequencyRf = (Decimal)(registers["RegFrfMsb"].Value << 16 | registers["RegFrfMid"].Value << 8 | registers["RegFrfLsb"].Value) * FrequencyStep; BandwidthCheck(Bandwidth); break; case "RegPaConfig": PaSelect = (r.Value & 128) == 128 ? PaSelectEnum.PA_BOOST : PaSelectEnum.RFO; if (PaSelect == PaSelectEnum.RFO) { maxOutputPower = new Decimal(108, 0, 0, false, 1) + new Decimal(6, 0, 0, false, 1) * (Decimal)(r.Value >> 4 & 7U); outputPower = MaxOutputPower - new Decimal(150, 0, 0, false, 1) - (Decimal)(r.Value & 15U); } else if (!Pa20dBm) { maxOutputPower = new Decimal(17); outputPower = new Decimal(17) - new Decimal(150, 0, 0, false, 1) - (Decimal)(r.Value & 15U); } else { maxOutputPower = new Decimal(20); outputPower = new Decimal(20) - new Decimal(150, 0, 0, false, 1) - (Decimal)(r.Value & 15U); } OnPropertyChanged("MaxOutputPower"); OnPropertyChanged("OutputPower"); break; case "RegPaRamp": ForceTxBandLowFrequencyOn = ((int)(r.Value >> 4) & 1) == 1; PaRamp = (PaRampEnum)((int)r.Value & 15); break; case "RegOcp": OcpOn = ((int)(r.Value >> 5) & 1) == 1; OcpTrim = (r.Value & 31U) > 15U ? ((r.Value & 31U) <= 15U || (r.Value & 31U) > 27U ? new Decimal(2400, 0, 0, false, 1) : (Decimal)(-30L + (long)(uint)(10 * ((int)r.Value & 31)))) : (Decimal)((uint)(45 + 5 * ((int)r.Value & 15))); if (!OcpOn) break; OcpTrimCheck(OcpTrim); break; case "RegLna": LnaGain = (LnaGainEnum)((int)(r.Value >> 5) & 7); ForceRxBandLowFrequencyOn = ((int)(r.Value >> 2) & 1) == 1; LnaBoost = ((int)r.Value & 3) == 3; if (!isDebugOn || !isReceiving) break; pktLnaValues.Add((int)LnaGain); break; case "RegFifoAddrPtr": FifoAddrPtr = (byte)r.Value; break; case "RegFifoTxBaseAddr": FifoTxBaseAddr = (byte)r.Value; break; case "RegFifoRxBaseAddr": FifoRxBaseAddr = (byte)r.Value; break; case "RegFifoRxCurrentAddr": fifoRxCurrentAddr = (byte)r.Value; OnPropertyChanged("FifoRxCurrentAddr"); break; case "RegIrqFlagsMask": RxTimeoutMask = ((int)(r.Value >> 7) & 1) == 1; RxDoneMask = ((int)(r.Value >> 6) & 1) == 1; PayloadCrcErrorMask = ((int)(r.Value >> 5) & 1) == 1; ValidHeaderMask = ((int)(r.Value >> 4) & 1) == 1; TxDoneMask = ((int)(r.Value >> 3) & 1) == 1; CadDoneMask = ((int)(r.Value >> 2) & 1) == 1; FhssChangeChannelMask = ((int)(r.Value >> 1) & 1) == 1; CadDetectedMask = ((int)r.Value & 1) == 1; break; case "RegIrqFlags": rxTimeout = ((int)(r.Value >> 7) & 1) == 1; OnPropertyChanged("RxTimeout"); rxDone = ((int)(r.Value >> 6) & 1) == 1; OnPropertyChanged("RxDone"); payloadCrcError = ((int)(r.Value >> 5) & 1) == 1; OnPropertyChanged("PayloadCrcError"); validHeader = ((int)(r.Value >> 4) & 1) == 1; OnPropertyChanged("ValidHeader"); txDone = ((int)(r.Value >> 3) & 1) == 1; OnPropertyChanged("TxDone"); cadDone = ((int)(r.Value >> 2) & 1) == 1; OnPropertyChanged("CadDone"); fhssChangeChannel = ((int)(r.Value >> 1) & 1) == 1; OnPropertyChanged("FhssChangeChannel"); cadDetected = ((int)r.Value & 1) == 1; OnPropertyChanged("CadDetected"); if (isDebugOn && ValidHeader) isReceiving = true; if (!isDebugOn || !RxDone) break; isReceiving = false; break; case "RegRxNbBytes": rxNbBytes = (byte)r.Value; OnPropertyChanged("RxNbBytes"); break; case "RegRxHeaderCntValueMsb": case "RegRxHeaderCntValueLsb": validHeaderCnt = (ushort)(registers["RegRxHeaderCntValueMsb"].Value << 8 | registers["RegRxHeaderCntValueLsb"].Value); OnPropertyChanged("ValidHeaderCnt"); break; case "RegRxPacketCntValueMsb": case "RegRxPacketCntValueLsb": validPacketCnt = (ushort)(registers["RegRxPacketCntValueMsb"].Value << 8 | registers["RegRxPacketCntValueLsb"].Value); OnPropertyChanged("ValidPacketCnt"); break; case "RegModemStat": rxPayloadCodingRate = (byte)((r.Value & 224U) >> 5); OnPropertyChanged("RxPayloadCodingRate"); modemClear = ((int)(r.Value >> 4) & 1) == 1; OnPropertyChanged("ModemClear"); headerInfoValid = ((int)(r.Value >> 3) & 1) == 1; OnPropertyChanged("HeaderInfoValid"); rxOnGoing = ((int)(r.Value >> 2) & 1) == 1; OnPropertyChanged("RxOnGoing"); signalSynchronized = ((int)(r.Value >> 1) & 1) == 1; OnPropertyChanged("SignalSynchronized"); signalDetected = ((int)r.Value & 1) == 1; OnPropertyChanged("SignalDetected"); break; case "RegPktSnrValue": byte num = (byte)r.Value; if ((num & 0x80) == 0x80) { // pktSnrValue = (sbyte)(((int)~num + 1 & (int)byte.MaxValue) >> 2); // pktSnrValue = -pktSnrValue; pktSnrValue = (sbyte)(((~num + 1) & 0xFF) >> 2); pktSnrValue = (sbyte)(-pktSnrValue); } else pktSnrValue = (sbyte)((num & 0xFF) >> 2); if (!isDebugOn) { pktRssiValue = (int)pktSnrValue >= 0 ? (!LowFrequencyModeOn ? (Decimal)(-157L + (long)registers["RegPktRssiValue"].Value + (long)(registers["RegPktRssiValue"].Value >> 4)) : (Decimal)(-164L + (long)registers["RegPktRssiValue"].Value + (long)(registers["RegPktRssiValue"].Value >> 4))) : (!LowFrequencyModeOn ? (Decimal)(-157L + (long)registers["RegPktRssiValue"].Value + (long)(registers["RegPktRssiValue"].Value >> 4) + (long)pktSnrValue) : (Decimal)(-164L + (long)registers["RegPktRssiValue"].Value + (long)(registers["RegPktRssiValue"].Value >> 4) + (long)pktSnrValue)); OnPropertyChanged("PktRssiValue"); } OnPropertyChanged("PktSnrValue"); break; case "RegPktRssiValue": if (!isDebugOn) { if ((int)pktSnrValue < 0) break; pktRssiValue = !LowFrequencyModeOn ? (Decimal)(-157L + (long)r.Value + (long)(r.Value >> 4)) : (Decimal)(-164L + (long)r.Value + (long)(r.Value >> 4)); OnPropertyChanged("PktRssiValue"); break; } pktRssiValue = (Decimal)r.Value; OnPropertyChanged("PktRssiValue"); break; case "RegRssiValue": prevRssiValue = rssiValue; rssiValue = isDebugOn ? (Decimal)r.Value : (!LowFrequencyModeOn ? (Decimal)(-157L + (long)r.Value) : (Decimal)(-164L + (long)r.Value)); if (RfPaSwitchEnabled != 0) { if (RfPaSwitchSel == RfPaSwitchSelEnum.RF_IO_RFIO) { if (RfPaSwitchEnabled == 1) rfPaRssiValue = new Decimal(1277, 0, 0, true, 1); rfIoRssiValue = rssiValue; OnPropertyChanged("RfIoRssiValue"); } else if (RfPaSwitchSel == RfPaSwitchSelEnum.RF_IO_PA_BOOST) { if (RfPaSwitchEnabled == 1) rfIoRssiValue = new Decimal(1277, 0, 0, true, 1); rfPaRssiValue = rssiValue; OnPropertyChanged("RfPaRssiValue"); } } spectrumRssiValue = rssiValue; if (isDebugOn && isReceiving) pktRssiValues.Add((double)rssiValue); OnPropertyChanged("RssiValue"); OnPropertyChanged("SpectrumData"); break; case "RegHopChannel": pllTimeout = ((int)(r.Value >> 7) & 1) == 1; OnPropertyChanged("PllTimeout"); rxPayloadCrcOn = ((int)(r.Value >> 6) & 1) == 1; OnPropertyChanged("RxPayloadCrcOn"); hopChannel = (byte)(r.Value & 63U); OnPropertyChanged("HopChannel"); break; case "RegModemConfig1": Bandwidth = (byte)(r.Value >> 4 & 15U); CodingRate = (byte)(r.Value >> 1 & 7U); ImplicitHeaderModeOn = ((int)r.Value & 1) == 1; OnPropertyChanged("SymbolRate"); OnPropertyChanged("SymbolTime"); break; case "RegModemConfig2": SpreadingFactor = (byte)(r.Value >> 4 & 15U); OnPropertyChanged("SymbolRate"); OnPropertyChanged("SymbolTime"); TxContinuousModeOn = ((int)(r.Value >> 3) & 1) == 1; PayloadCrcOn = ((int)(r.Value >> 2) & 1) == 1; SymbTimeout = (Decimal)((uint)(((int)r.Value & 3) << 8) | registers["RegSymbTimeoutLsb"].Value) * SymbolTime; break; case "RegSymbTimeoutLsb": SymbTimeout = (Decimal)((uint)(((int)registers["RegModemConfig2"].Value & 3) << 8) | registers["RegSymbTimeoutLsb"].Value) * SymbolTime; break; case "RegPreambleMsb": case "RegPreambleLsb": PreambleLength = (ushort)(((int)registers["RegPreambleMsb"].Value << 8 | (int)registers["RegPreambleLsb"].Value) + 4); break; case "RegPayloadLength": PayloadLength = (byte)r.Value; break; case "RegPayloadMaxLength": PayloadMaxLength = (byte)r.Value; break; case "RegHopPeriod": FreqHoppingPeriod = (byte)r.Value; break; case "RegModemConfig3": LowDatarateOptimize = ((int)(r.Value >> 3) & 1) == 1; AgcAutoOn = ((int)(r.Value >> 2) & 1) == 1; break; case "RegDioMapping1": Dio0Mapping = (DioMappingEnum)((int)(r.Value >> 6) & 3); Dio1Mapping = (DioMappingEnum)((int)(r.Value >> 4) & 3); Dio2Mapping = (DioMappingEnum)((int)(r.Value >> 2) & 3); Dio3Mapping = (DioMappingEnum)((int)r.Value & 3); break; case "RegDioMapping2": Dio4Mapping = (DioMappingEnum)((int)(r.Value >> 6) & 3); Dio5Mapping = (DioMappingEnum)((int)(r.Value >> 4) & 3); break; case "RegVersion": Version = new Version((int)((r.Value & 240U) >> 4), (int)r.Value & 15); break; case "RegPllHop": FastHopOn = ((int)r.Value & 128) == 128; break; case "RegTcxo": TcxoInputOn = ((int)r.Value & 16) == 16; break; case "RegPaDac": Pa20dBm = ((int)r.Value & 7) == 7; ReadRegister(registers["RegPaConfig"]); break; case "RegAgcRef": AgcReferenceLevel = (byte)(r.Value & 63U); OnPropertyChanged("AgcReference"); OnPropertyChanged("AgcThresh1"); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegAgcThresh1": AgcStep1 = (byte)(r.Value & 31U); OnPropertyChanged("AgcThresh1"); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegAgcThresh2": AgcStep2 = (byte)(r.Value >> 4); AgcStep3 = (byte)(r.Value & 15U); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegAgcThresh3": AgcStep4 = (byte)(r.Value >> 4); AgcStep5 = (byte)(r.Value & 15U); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegPll": PllBandwidth = (Decimal)((uint)(((int)(r.Value >> 6) + 1) * 75000)); break; } }
private bool WriteRegister(Register r, byte data) { bool flag; lock (syncThread) { try { writeLock++; if (!Write((byte)r.Address, data)) throw new Exception("Unable to read register: " + r.Name); flag = true; } catch (Exception exception) { OnError(1, exception.Message); flag = false; } finally { writeLock--; } } return flag; }
private void UpdateRegisterValue(Register reg) { int mant; switch (reg.Name) { case "RegOpMode": { Sequencer = (reg.Value & 0x80) != 0x80; ListenMode = (reg.Value & 0x40) == 0x40; byte num = (byte)((reg.Value >> 2) & 7); if (num > 4) num = 0; Mode = (OperatingModeEnum)num; if (m_packet.Mode != Mode) m_packet.Mode = Mode; if (m_registers["RegPayloadLength"].Value != m_packet.PayloadLength) m_registers["RegPayloadLength"].Value = m_packet.PayloadLength; lock (syncThread) { SetModeLeds(Mode); return; } } case "RegDataModul": break; case "RegBitrateMsb": case "RegBitrateLsb": if (((m_registers["RegBitrateMsb"].Value << 8) | m_registers["RegBitrateLsb"].Value) == 0) m_registers["RegBitrateLsb"].Value = 1; BitRate = frequencyXo / ((m_registers["RegBitrateMsb"].Value << 8) | m_registers["RegBitrateLsb"].Value); return; case "RegFdevMsb": case "RegFdevLsb": Fdev = ((m_registers["RegFdevMsb"].Value << 8) | m_registers["RegFdevLsb"].Value) * FrequencyStep; return; case "RegFrfMsb": case "RegFrfMid": case "RegFrfLsb": FrequencyRf = ( (m_registers["RegFrfMsb"].Value << 0x10) | (m_registers["RegFrfMid"].Value << 8) | m_registers["RegFrfLsb"].Value ) * FrequencyStep; return; case "RegOsc1": m_rcCalDone = ((reg.Value >> 6) & 1) == 1; OnPropertyChanged("RcCalDone"); return; case "RegOsc2": case "RegAfcCtrl": if (Version != "2.1") { AfcLowBetaOn = ((reg.Value >> 5) & 1) == 1; if (Version != "2.3") return; SetDagcOn(DagcOn); } return; case "RegLowBat": lowBatMonitor = ((reg.Value >> 4) & 1) == 1; OnPropertyChanged("LowBatMonitor"); LowBatOn = ((reg.Value >> 3) & 1) == 1; LowBatTrim = ((LowBatTrimEnum)reg.Value) & LowBatTrimEnum.Trim2_185; return; case "RegListen1": if ((reg.Value & 0xc0) == 0) reg.Value = (byte)((reg.Value & 0x3f) | 0x40); if ((reg.Value & 0x30) == 0) reg.Value = (byte)((reg.Value & 0xcf) | 0x10); if ((reg.Value & 6) == 6) reg.Value = (byte)((reg.Value & 0xf9) | 2); ListenResolIdle = ((ListenResolEnum)((reg.Value >> 6) - 1)) & (ListenResolEnum.Res262000 | ListenResolEnum.Res004100); ListenResolRx = ((ListenResolEnum)((reg.Value >> 4) - 1)) & (ListenResolEnum.Res262000 | ListenResolEnum.Res004100); ListenCriteria = ((ListenCriteriaEnum)(reg.Value >> 3)) & ListenCriteriaEnum.RssiThreshSyncAddress; ListenEnd = ((ListenEndEnum)(reg.Value >> 1)) & ListenEndEnum.Reserved; return; case "RegListen2": switch (ListenResolIdle) { case ListenResolEnum.Res000064: ListenCoefIdle = reg.Value * 0.064M; return; case ListenResolEnum.Res004100: ListenCoefIdle = reg.Value * 4.1M; return; case ListenResolEnum.Res262000: ListenCoefIdle = reg.Value * 262M; return; } return; case "RegListen3": switch (ListenResolRx) { case ListenResolEnum.Res000064: ListenCoefRx = reg.Value * 0.064M; return; case ListenResolEnum.Res004100: ListenCoefRx = reg.Value * 4.1M; return; case ListenResolEnum.Res262000: ListenCoefRx = reg.Value * 262M; return; } return; case "RegVersion": Version = ((reg.Value & 0xF0) >> 4).ToString() + "." + (reg.Value & 0x0F).ToString(); return; case "RegPaLevel": if ((reg.Value & 0xE0) != 0x80 && (reg.Value & 0xe0) != 0x40 && (reg.Value & 0xe0) != 0x60 ) reg.Value = (reg.Value & 0x1F) | 0x80; switch ((reg.Value >> 5) & 0x07) { case 2: PaMode = PaModeEnum.PA1; break; case 3: PaMode = PaModeEnum.PA1_PA2; break; case 4: PaMode = PaModeEnum.PA0; break; } if (PaMode != PaModeEnum.PA1_PA2) { OutputPower = -18.0M + (reg.Value & 0x1f); return; } OutputPower = -14.0M + (reg.Value & 0x1f); return; case "RegPaRamp": PaRamp = ((PaRampEnum)reg.Value) & PaRampEnum.PaRamp_10; return; case "RegOcp": OcpOn = ((reg.Value >> 4) & 1) == 1; OcpTrim = 0x2d + (5 * (reg.Value & 15)); return; case "RegAgcRef": case "Reserved14": AgcAutoRefOn = ((reg.Value >> 6) & 1) == 1; AgcRefLevel = (int)(18446744073709551536L - (reg.Value & 0x3f)); OnPropertyChanged("AgcReference"); OnPropertyChanged("AgcThresh1"); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); return; case "RegAgcThresh1": case "Reserved15": AgcSnrMargin = (byte)(reg.Value >> 5); AgcStep1 = (byte)(reg.Value & 0x1f); OnPropertyChanged("AgcReference"); OnPropertyChanged("AgcThresh1"); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); return; case "RegAgcThresh2": case "Reserved16": AgcStep2 = (byte)(reg.Value >> 4); AgcStep3 = (byte)(reg.Value & 15); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); return; case "RegAgcThresh3": case "Reserved17": AgcStep4 = (byte)(reg.Value >> 4); AgcStep5 = (byte)(reg.Value & 15); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); return; case "RegLna": LnaZin = ((reg.Value & 0x80) == 0x80) ? LnaZinEnum.ZIN_200 : LnaZinEnum.ZIN_50; LnaLowPowerOn = (reg.Value & 0x40) == 0x40; LnaCurrentGain = (LnaGainEnum)((reg.Value & 0x38) >> 3); LnaGainSelect = ((LnaGainEnum)reg.Value) & LnaGainEnum.Reserved; return; case "RegRxBw": mant = 0; switch (((uint)((reg.Value & 0x18) >> 3))) { case 0: mant = 0x10; break; case 1: mant = 20; break; case 2: mant = 0x18; break; default: throw new Exception("Invalid RxBwMant parameter"); } rxBw = ComputeRxBw(frequencyXo, modulationType, mant, ((int)reg.Value) & 7); OnPropertyChanged("DccFreqMin"); OnPropertyChanged("DccFreqMax"); OnPropertyChanged("RxBwMin"); OnPropertyChanged("RxBwMax"); OnPropertyChanged("RxBw"); OnPropertyChanged("AgcReference"); OnPropertyChanged("AgcThresh1"); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); DccFreq = ComputeDccFreq(rxBw, reg.Value); return; case "RegAfcBw": mant = 0; switch ((reg.Value & 0x18) >> 3) { case 0: mant = 0x10; break; case 1: mant = 0x14; break; case 2: mant = 0x18; break; default: throw new Exception("Invalid RxBwMant parameter"); } afcRxBw = ComputeRxBw(frequencyXo, modulationType, mant, ((int)reg.Value) & 7); OnPropertyChanged("AfcDccFreqMin"); OnPropertyChanged("AfcDccFreqMax"); OnPropertyChanged("AfcRxBwMin"); OnPropertyChanged("AfcRxBwMax"); OnPropertyChanged("AfcRxBw"); AfcDccFreq = ComputeDccFreq(afcRxBw, reg.Value); return; case "RegOokPeak": OokThreshType = (OokThreshTypeEnum)(reg.Value >> 6); OokPeakThreshStep = OoPeakThreshStepTable[(int)((IntPtr)((reg.Value & 0x38) >> 3))]; OokPeakThreshDec = ((OokPeakThreshDecEnum)reg.Value) & OokPeakThreshDecEnum.EVERY_1_CHIPS_16_TIMES; return; case "RegOokAvg": OokAverageThreshFilt = (OokAverageThreshFiltEnum)(reg.Value >> 6); return; case "RegOokFix": OokFixedThresh = (byte)reg.Value; return; case "RegAfcFei": feiDone = ((reg.Value >> 6) & 1) == 1; OnPropertyChanged("FeiDone"); afcDone = ((reg.Value >> 4) & 1) == 1; OnPropertyChanged("AfcDone"); AfcAutoClearOn = ((reg.Value >> 3) & 1) == 1; AfcAutoOn = ((reg.Value >> 2) & 1) == 1; return; case "RegAfcMsb": case "RegAfcLsb": AfcValue = ((short)((m_registers["RegAfcMsb"].Value << 8) | m_registers["RegAfcLsb"].Value)) * FrequencyStep; return; case "RegFeiMsb": case "RegFeiLsb": FeiValue = ((short)((m_registers["RegFeiMsb"].Value << 8) | m_registers["RegFeiLsb"].Value)) * FrequencyStep; return; case "RegRssiConfig": FastRx = ((reg.Value >> 3) & 1) == 1; rssiDone = ((reg.Value >> 1) & 1) == 1; OnPropertyChanged("RssiDone"); return; case "RegRssiValue": prevRssiValue = rssiValue; rssiValue = -reg.Value / 2.0M; if (RfPaSwitchEnabled != 0) { if (RfPaSwitchSel != RfPaSwitchSelEnum.RF_IO_RFIO) { if (RfPaSwitchSel == RfPaSwitchSelEnum.RF_IO_PA_BOOST) { if (RfPaSwitchEnabled == 1) rfIoRssiValue = -127.7M; rfPaRssiValue = rssiValue; OnPropertyChanged("RfPaRssiValue"); } } else { if (RfPaSwitchEnabled == 1) rfPaRssiValue = -127.7M; rfIoRssiValue = rssiValue; OnPropertyChanged("RfIoRssiValue"); } } spectrumRssiValue = rssiValue; OnPropertyChanged("RssiValue"); OnPropertyChanged("SpectrumData"); return; case "RegDioMapping1": Dio0Mapping = ((DioMappingEnum)(reg.Value >> 6)) & DioMappingEnum.DIO_MAP_11; Dio1Mapping = ((DioMappingEnum)(reg.Value >> 4)) & DioMappingEnum.DIO_MAP_11; Dio2Mapping = ((DioMappingEnum)(reg.Value >> 2)) & DioMappingEnum.DIO_MAP_11; Dio3Mapping = ((DioMappingEnum)reg.Value) & DioMappingEnum.DIO_MAP_11; return; case "RegDioMapping2": Dio4Mapping = ((DioMappingEnum)(reg.Value >> 6)) & DioMappingEnum.DIO_MAP_11; Dio5Mapping = ((DioMappingEnum)(reg.Value >> 4)) & DioMappingEnum.DIO_MAP_11; ClockOut = ((ClockOutEnum)reg.Value) & ClockOutEnum.CLOCK_OUT_111; return; case "RegIrqFlags1": { modeReady = ((reg.Value >> 7) & 1) == 1; OnPropertyChanged("ModeReady"); bool flag = ((reg.Value >> 6) & 1) == 1; if (!rxReady && flag) restartRx = true; rxReady = flag; OnPropertyChanged("RxReady"); txReady = ((reg.Value >> 5) & 1) == 1; OnPropertyChanged("TxReady"); m_pllLock = ((reg.Value >> 4) & 1) == 1; OnPropertyChanged("PllLock"); rssi = ((reg.Value >> 3) & 1) == 1; OnPropertyChanged("Rssi"); timeout = ((reg.Value >> 2) & 1) == 1; OnPropertyChanged("Timeout"); autoMode = ((reg.Value >> 1) & 1) == 1; OnPropertyChanged("AutoMode"); syncAddressMatch = (reg.Value & 1) == 1; OnPropertyChanged("SyncAddressMatch"); return; } case "RegIrqFlags2": fifoFull = ((reg.Value >> 7) & 1) == 1; OnPropertyChanged("FifoFull"); fifoNotEmpty = ((reg.Value >> 6) & 1) == 1; OnPropertyChanged("FifoNotEmpty"); fifoLevel = ((reg.Value >> 5) & 1) == 1; OnPropertyChanged("FifoLevel"); fifoOverrun = ((reg.Value >> 4) & 1) == 1; OnPropertyChanged("FifoOverrun"); packetSent = ((reg.Value >> 3) & 1) == 1; OnPropertyChanged("PacketSent"); m_payloadReady = ((reg.Value >> 2) & 1) == 1; OnPropertyChanged("PayloadReady"); crcOk = ((reg.Value >> 1) & 1) == 1; OnPropertyChanged("CrcOk"); lowBat = (reg.Value & 1) == 1; OnPropertyChanged("LowBat"); return; case "RegRssiThresh": RssiThresh = -reg.Value / 2.0M; return; case "RegRxTimeout1": TimeoutRxStart = (reg.Value * (16M / BitRate)) * 1000M; return; case "RegRxTimeout2": TimeoutRssiThresh = (reg.Value * (16M / BitRate)) * 1000M; return; case "RegPreambleMsb": case "RegPreambleLsb": m_packet.PreambleSize = (int)((m_registers["RegPreambleMsb"].Value << 8) | m_registers["RegPreambleLsb"].Value); return; case "RegSyncConfig": m_packet.SyncOn = ((reg.Value >> 7) & 1) == 1; m_packet.FifoFillCondition = (((reg.Value >> 6) & 1) == 1) ? FifoFillConditionEnum.Allways : FifoFillConditionEnum.OnSyncAddressIrq; m_packet.SyncSize = (byte)(((reg.Value & 0x38) >> 3) + 1); UpdateSyncValue(); m_packet.SyncTol = (byte)(reg.Value & 7); return; case "RegSyncValue1": case "RegSyncValue2": case "RegSyncValue3": case "RegSyncValue4": case "RegSyncValue5": case "RegSyncValue6": case "RegSyncValue7": case "RegSyncValue8": UpdateSyncValue(); return; case "RegPacketConfig1": m_packet.PacketFormat = (((reg.Value >> 7) & 1) == 1) ? PacketFormatEnum.Variable : PacketFormatEnum.Fixed; m_packet.DcFree = ((DcFreeEnum)(reg.Value >> 5)) & DcFreeEnum.Reserved; m_packet.CrcOn = ((reg.Value >> 4) & 1) == 1; m_packet.CrcAutoClearOff = ((reg.Value >> 3) & 1) == 1; m_packet.AddressFiltering = ((AddressFilteringEnum)(reg.Value >> 1)) & AddressFilteringEnum.Reserved; return; case "RegPayloadLength": m_packet.PayloadLength = (byte)reg.Value; return; case "RegNodeAdrs": m_packet.NodeAddress = (byte)reg.Value; return; case "RegBroadcastAdrs": m_packet.BroadcastAddress = (byte)reg.Value; return; case "RegAutoModes": m_packet.EnterCondition = (EnterConditionEnum)((reg.Value & 0xe0) >> 5); m_packet.ExitCondition = (ExitConditionEnum)((reg.Value & 0x1c) >> 2); m_packet.IntermediateMode = ((IntermediateModeEnum)reg.Value) & IntermediateModeEnum.Tx; return; case "RegFifoThresh": m_packet.TxStartCondition = ((reg.Value >> 7) & 1) == 1; m_packet.FifoThreshold = (byte)(reg.Value & 0x7f); return; case "RegPacketConfig2": m_packet.InterPacketRxDelay = (int)(reg.Value >> 4); m_packet.AutoRxRestartOn = ((reg.Value >> 1) & 1) == 1; m_packet.AesOn = (reg.Value & 1) == 1; return; case "RegAesKey1": case "RegAesKey2": case "RegAesKey3": case "RegAesKey4": case "RegAesKey5": case "RegAesKey6": case "RegAesKey7": case "RegAesKey8": case "RegAesKey9": case "RegAesKey10": case "RegAesKey11": case "RegAesKey12": case "RegAesKey13": case "RegAesKey14": case "RegAesKey15": case "RegAesKey16": UpdateAesKey(); return; case "RegTemp1": AdcLowPowerOn = (reg.Value & 1) == 1; return; case "RegTemp2": tempValue = (-((byte)reg.Value) + tempValueRoom) + tempValueCal; OnPropertyChanged("TempValue"); return; case "RegTestLna": SensitivityBoostOn = reg.Value == 0x2d; return; case "RegTestDagc": DagcOn = ((reg.Value & 0x30) == 0x30) || ((reg.Value & 0x10) == 0x10); return; case "RegTestAfc": LowBetaAfcOffset = ((sbyte)reg.Value) * 488.0M; return; default: return; } if ((reg.Value & 0x60) == 0x20) reg.Value &= 0x9F; if ((reg.Value & 0x18) == 0x10 || (reg.Value & 0x18) == 0x18) reg.Value &= 0xE7; DataMode = ((DataModeEnum)(reg.Value >> 5)) & DataModeEnum.Continuous; ModulationType = ((ModulationTypeEnum)(reg.Value >> 3)) & ModulationTypeEnum.Reserved; ModulationShaping = (byte)(reg.Value & 0x03); UpdateReceiverData(); BitRateFdevCheck(bitRate, fdev); }
private void UpdateRegisterValue(Register r) { switch (r.Name) { case "RegOpMode": if (((int)r.Value & 96) == 64 || ((int)r.Value & 96) == 96) r.Value &= 159U; ModulationType = (ModulationTypeEnum)((int)(r.Value >> 5) & 3); UpdateReceiverData(); BitrateFdevCheck(bitrate, fdev); LowFrequencyModeOn = ((int)(r.Value >> 3) & 1) == 1; byte num2 = (byte)(r.Value & 7U); if ((int)num2 > 5) num2 = (byte)0; Mode = (OperatingModeEnum)num2; if (packet.Mode != Mode) packet.Mode = Mode; if ((long)((uint)(((int)registers["RegPacketConfig2"].Value & 7) << 8) | registers["RegPayloadLength"].Value) != (long)packet.PayloadLength) { registers["RegPacketConfig2"].Value = registers["RegPacketConfig2"].Value | (uint)(byte)((int)packet.PayloadLength >> 8 & 7); registers["RegPayloadLength"].Value = (uint)(byte)packet.PayloadLength; } lock (syncThread) { SetModeLeds(Mode); break; } case "RegBitrateMsb": case "RegBitrateLsb": if (((int)registers["RegBitrateMsb"].Value << 8 | (int)registers["RegBitrateLsb"].Value) == 0) registers["RegBitrateLsb"].Value = 1U; if (ModulationType == ModulationTypeEnum.FSK) { Bitrate = frequencyXo / ((Decimal)(registers["RegBitrateMsb"].Value << 8 | registers["RegBitrateLsb"].Value) + (Decimal)registers["RegBitrateFrac"].Value / new Decimal(160, 0, 0, false, (byte)1)); break; } Bitrate = frequencyXo / (Decimal)(registers["RegBitrateMsb"].Value << 8 | registers["RegBitrateLsb"].Value); break; case "RegFdevMsb": case "RegFdevLsb": Band = (BandEnum)((int)(registers["RegFdevMsb"].Value >> 6) & 3); Fdev = (Decimal)((uint)(((int)registers["RegFdevMsb"].Value & 63) << 8) | registers["RegFdevLsb"].Value) * FrequencyStep; break; case "RegFrfMsb": case "RegFrfMid": case "RegFrfLsb": FrequencyRf = (Decimal)((uint)((int)registers["RegFrfMsb"].Value << 16 | (int)registers["RegFrfMid"].Value << 8) | registers["RegFrfLsb"].Value) * FrequencyStep; break; case "RegPaConfig": PaSelect = ((int)r.Value & 128) == 128 ? PaSelectEnum.PA_BOOST : PaSelectEnum.RFO; if (PaSelect == PaSelectEnum.RFO) { maxOutputPower = new Decimal(108, 0, 0, false, (byte)1) + new Decimal(6, 0, 0, false, (byte)1) * (Decimal)(r.Value >> 4 & 7U); outputPower = MaxOutputPower - new Decimal(150, 0, 0, false, (byte)1) - (Decimal)(r.Value & 15U); } else if (!Pa20dBm) { maxOutputPower = new Decimal(17); outputPower = new Decimal(17) - new Decimal(150, 0, 0, false, (byte)1) - (Decimal)(r.Value & 15U); } else { maxOutputPower = new Decimal(20); outputPower = new Decimal(20) - new Decimal(150, 0, 0, false, (byte)1) - (Decimal)(r.Value & 15U); } OnPropertyChanged("MaxOutputPower"); OnPropertyChanged("OutputPower"); break; case "RegPaRamp": ModulationShaping = (byte)(r.Value >> 5 & 3U); ForceTxBandLowFrequencyOn = ((int)(r.Value >> 4) & 1) == 1; PaRamp = (PaRampEnum)((int)r.Value & 15); break; case "RegOcp": OcpOn = ((int)(r.Value >> 5) & 1) == 1; OcpTrim = (r.Value & 31U) > 15U ? ((r.Value & 31U) <= 15U || (r.Value & 31U) > 27U ? new Decimal(2400, 0, 0, false, (byte)1) : (Decimal)(-30L + (long)(uint)(10 * ((int)r.Value & 31)))) : (Decimal)((uint)(45 + 5 * ((int)r.Value & 15))); if (!OcpOn) break; OcpTrimCheck(OcpTrim); break; case "RegLna": LnaGain = (LnaGainEnum)((int)(r.Value >> 5) & 7); ForceRxBandLowFrequencyOn = ((int)(r.Value >> 2) & 1) == 1; LnaBoost = ((int)r.Value & 3) == 3; break; case "RegRxConfig": RestartRxOnCollision = ((int)(r.Value >> 7) & 1) == 1; AfcAutoOn = ((int)(r.Value >> 4) & 1) == 1; AgcAutoOn = ((int)(r.Value >> 3) & 1) == 1; switch (r.Value & 7U) { case 1U: RxTrigger = RxTriggerEnum.RX_TRIGER_001; return; case 6U: RxTrigger = RxTriggerEnum.RX_TRIGER_110; return; case 7U: RxTrigger = RxTriggerEnum.RX_TRIGER_111; return; default: RxTrigger = RxTriggerEnum.RX_TRIGER_000; return; } case "RegRssiConfig": sbyte num3 = (sbyte)(r.Value >> 3); if ((num3 & 0x10) == 0x10) num3 = (sbyte)(-(sbyte)((int)(sbyte)((int)~num3 & 31) + 1)); RssiOffset = (Decimal)num3; RssiSmoothing = (Decimal)Math.Pow(2.0, (double)(uint)(((int)r.Value & 7) + 1)); break; case "RegRssiCollision": RssiCollisionThreshold = (Decimal)r.Value; break; case "RegRssiThresh": RssiThreshold = -(Decimal)r.Value / new Decimal(20, 0, 0, false, (byte)1); break; case "RegRssiValue": prevRssiValue = rssiValue; rssiValue = -(Decimal)r.Value / new Decimal(20, 0, 0, false, (byte)1); if (RfPaSwitchEnabled != 0) { if (RfPaSwitchSel == RfPaSwitchSelEnum.RF_IO_RFIO) { if (RfPaSwitchEnabled == 1) rfPaRssiValue = new Decimal(1277, 0, 0, true, (byte)1); rfIoRssiValue = rssiValue; OnPropertyChanged("RfIoRssiValue"); } else if (RfPaSwitchSel == RfPaSwitchSelEnum.RF_IO_PA_BOOST) { if (RfPaSwitchEnabled == 1) rfIoRssiValue = new Decimal(1277, 0, 0, true, (byte)1); rfPaRssiValue = rssiValue; OnPropertyChanged("RfPaRssiValue"); } } spectrumRssiValue = rssiValue; OnPropertyChanged("RssiValue"); OnPropertyChanged("SpectrumData"); break; case "RegRxBw": int mant1; switch ((r.Value & 24U) >> 3) { case 0U: mant1 = 16; break; case 1U: mant1 = 20; break; case 2U: mant1 = 24; break; default: throw new Exception("Invalid RxBwMant parameter"); } rxBw = SX1276.ComputeRxBw(frequencyXo, modulationType, mant1, (int)r.Value & 7); OnPropertyChanged("RxBwMin"); OnPropertyChanged("RxBwMax"); OnPropertyChanged("RxBw"); OnPropertyChanged("AgcReference"); OnPropertyChanged("AgcThresh1"); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegAfcBw": int mant2; switch ((r.Value & 24U) >> 3) { case 0U: mant2 = 16; break; case 1U: mant2 = 20; break; case 2U: mant2 = 24; break; default: throw new Exception("Invalid RxBwMant parameter"); } afcRxBw = SX1276.ComputeRxBw(frequencyXo, modulationType, mant2, (int)r.Value & 7); OnPropertyChanged("AfcRxBwMin"); OnPropertyChanged("AfcRxBwMax"); OnPropertyChanged("AfcRxBw"); break; case "RegOokPeak": BitSyncOn = ((int)(r.Value >> 5) & 1) == 1; OokThreshType = (OokThreshTypeEnum)((int)(r.Value >> 3) & 3); OokPeakThreshStep = OoPeakThreshStepTable[r.Value & 0x07]; break; case "RegOokFix": OokFixedThreshold = (byte)r.Value; break; case "RegOokAvg": OokPeakThreshDec = (OokPeakThreshDecEnum)((int)(r.Value >> 5) & 7); OokAverageOffset = (Decimal)((uint)(((int)(r.Value >> 2) & 3) * 2)); OokAverageThreshFilt = (OokAverageThreshFiltEnum)((int)r.Value & 3); break; case "RegAfcFei": AfcAutoClearOn = ((int)r.Value & 1) == 1; break; case "RegAfcMsb": case "RegAfcLsb": AfcValue = (Decimal)((short)((int)registers["RegAfcMsb"].Value << 8 | (int)registers["RegAfcLsb"].Value)) * FrequencyStep; break; case "RegFeiMsb": case "RegFeiLsb": FeiValue = (Decimal)((short)((int)registers["RegFeiMsb"].Value << 8 | (int)registers["RegFeiLsb"].Value)) * FrequencyStep; break; case "RegPreambleDetect": PreambleDetectorOn = ((int)(r.Value >> 7) & 1) == 1; PreambleDetectorSize = (byte)(((int)(r.Value >> 5) & 3) + 1); PreambleDetectorTol = (byte)(r.Value & 31U); break; case "RegRxTimeout1": TimeoutRxRssi = (Decimal)r.Value * new Decimal(16) * Tbit * new Decimal(1000); break; case "RegRxTimeout2": TimeoutRxPreamble = (Decimal)r.Value * new Decimal(16) * Tbit * new Decimal(1000); break; case "RegRxTimeout3": TimeoutSignalSync = (Decimal)r.Value * new Decimal(16) * Tbit * new Decimal(1000); break; case "RegRxDelay": InterPacketRxDelay = (Decimal)r.Value * new Decimal(4) * Tbit * new Decimal(1000); break; case "RegOsc": ClockOut = (ClockOutEnum)((int)r.Value & 7); break; case "RegPreambleMsb": case "RegPreambleLsb": packet.PreambleSize = (int)registers["RegPreambleMsb"].Value << 8 | (int)registers["RegPreambleLsb"].Value; break; case "RegSyncConfig": packet.AutoRestartRxOn = (AutoRestartRxEnum)((int)(r.Value >> 6) & 3); packet.PreamblePolarity = (PreamblePolarityEnum)((int)(r.Value >> 5) & 1); packet.SyncOn = ((int)(r.Value >> 4) & 1) == 1; packet.FifoFillCondition = (FifoFillConditionEnum)((int)(r.Value >> 3) & 1); packet.SyncSize = Mode != OperatingModeEnum.Rx || !packet.IoHomeOn ? (byte)(((int)r.Value & 7) + 1) : (byte)(r.Value & 7U); UpdateSyncValue(); break; case "RegSyncValue1": case "RegSyncValue2": case "RegSyncValue3": case "RegSyncValue4": case "RegSyncValue5": case "RegSyncValue6": case "RegSyncValue7": case "RegSyncValue8": UpdateSyncValue(); break; case "RegPacketConfig1": packet.PacketFormat = ((int)(r.Value >> 7) & 1) == 1 ? PacketFormatEnum.Variable : PacketFormatEnum.Fixed; packet.DcFree = (DcFreeEnum)((int)(r.Value >> 5) & 3); packet.CrcOn = ((int)(r.Value >> 4) & 1) == 1; packet.CrcAutoClearOff = ((int)(r.Value >> 3) & 1) == 1; packet.AddressFiltering = (AddressFilteringEnum)((int)(r.Value >> 1) & 3); packet.CrcIbmOn = ((int)r.Value & 1) == 1; break; case "RegPacketConfig2": packet.DataMode = (DataModeEnum)((int)(r.Value >> 6) & 1); packet.IoHomeOn = ((int)(r.Value >> 5) & 1) == 1; packet.SyncSize = Mode != OperatingModeEnum.Rx || !packet.IoHomeOn ? (byte)(((int)Registers["RegSyncConfig"].Value & 7) + 1) : (byte)(Registers["RegSyncConfig"].Value & 7U); UpdateSyncValue(); packet.IoHomePwrFrameOn = ((int)(r.Value >> 4) & 1) == 1; packet.BeaconOn = ((int)(r.Value >> 3) & 1) == 1; packet.PayloadLength = (short)((int)packet.PayloadLength & (int)byte.MaxValue | ((int)r.Value & 7) << 8); OnPropertyChanged("Crc"); break; case "RegPayloadLength": packet.PayloadLength = (short)((int)packet.PayloadLength & 1792 | (int)r.Value); break; case "RegNodeAdrs": packet.NodeAddress = (byte)r.Value; break; case "RegBroadcastAdrs": packet.BroadcastAddress = (byte)r.Value; break; case "RegFifoThresh": packet.TxStartCondition = ((int)(r.Value >> 7) & 1) == 1; packet.FifoThreshold = (byte)(r.Value & (uint)sbyte.MaxValue); break; case "RegSeqConfig1": IdleMode = (IdleMode)((int)(r.Value >> 5) & 1); FromStart = (FromStart)((int)(r.Value >> 3) & 3); LowPowerSelection = (LowPowerSelection)((int)(r.Value >> 2) & 1); FromIdle = (FromIdle)((int)(r.Value >> 1) & 1); FromTransmit = (FromTransmit)((int)r.Value & 1); break; case "RegSeqConfig2": FromReceive = (FromReceive)((int)(r.Value >> 5) & 7); FromRxTimeout = (FromRxTimeout)((int)(r.Value >> 3) & 3); FromPacketReceived = (FromPacketReceived)((int)r.Value & 7); break; case "RegTimerResol": Timer1Resolution = (TimerResolution)((int)(r.Value >> 2) & 3); Timer2Resolution = (TimerResolution)((int)r.Value & 3); break; case "RegTimer1Coef": Timer1Coef = (byte)r.Value; break; case "RegTimer2Coef": Timer2Coef = (byte)r.Value; break; case "RegImageCal": AutoImageCalOn = ((int)(r.Value >> 7) & 1) == 1; imageCalRunning = ((int)(r.Value >> 5) & 1) == 0; OnPropertyChanged("ImageCalRunning"); tempChange = ((int)(r.Value >> 3) & 1) == 1; OnPropertyChanged("TempChange"); TempThreshold = (TempThresholdEnum)((r.Value & 6U) >> 1); TempMonitorOff = ((int)r.Value & 1) == 1; break; case "RegTemp": tempValue = (Decimal)((byte)(r.Value & (uint)sbyte.MaxValue)); if (((int)r.Value & 128) == 128) tempValue *= new Decimal(-1); tempDelta = tempValue - formerTemp; OnPropertyChanged("TempDelta"); tempValue += tempValueRoom - tempValueCal; OnPropertyChanged("TempValue"); break; case "RegLowBat": LowBatOn = ((int)(r.Value >> 3) & 1) == 1; LowBatTrim = (LowBatTrimEnum)((int)r.Value & 7); break; case "RegIrqFlags1": modeReady = ((int)(r.Value >> 7) & 1) == 1; OnPropertyChanged("ModeReady"); bool flag = ((int)(r.Value >> 6) & 1) == 1; if (!rxReady && flag) restartRx = true; rxReady = flag; OnPropertyChanged("RxReady"); txReady = ((int)(r.Value >> 5) & 1) == 1; OnPropertyChanged("TxReady"); pllLock = ((int)(r.Value >> 4) & 1) == 1; OnPropertyChanged("PllLock"); rssi = ((int)(r.Value >> 3) & 1) == 1; OnPropertyChanged("Rssi"); timeout = ((int)(r.Value >> 2) & 1) == 1; OnPropertyChanged("Timeout"); preambleDetect = ((int)(r.Value >> 1) & 1) == 1; OnPropertyChanged("PreambleDetect"); syncAddressMatch = ((int)r.Value & 1) == 1; OnPropertyChanged("SyncAddressMatch"); break; case "RegIrqFlags2": fifoFull = ((int)(r.Value >> 7) & 1) == 1; OnPropertyChanged("FifoFull"); fifoEmpty = ((int)(r.Value >> 6) & 1) == 1; OnPropertyChanged("FifoEmpty"); fifoLevel = ((int)(r.Value >> 5) & 1) == 1; OnPropertyChanged("FifoLevel"); fifoOverrun = ((int)(r.Value >> 4) & 1) == 1; OnPropertyChanged("FifoOverrun"); packetSent = ((int)(r.Value >> 3) & 1) == 1; OnPropertyChanged("PacketSent"); payloadReady = ((int)(r.Value >> 2) & 1) == 1; OnPropertyChanged("PayloadReady"); crcOk = ((int)(r.Value >> 1) & 1) == 1; OnPropertyChanged("CrcOk"); lowBat = ((int)r.Value & 1) == 1; OnPropertyChanged("LowBat"); break; case "RegDioMapping1": Dio0Mapping = (DioMappingEnum)((int)(r.Value >> 6) & 3); Dio1Mapping = (DioMappingEnum)((int)(r.Value >> 4) & 3); Dio2Mapping = (DioMappingEnum)((int)(r.Value >> 2) & 3); Dio3Mapping = (DioMappingEnum)((int)r.Value & 3); break; case "RegDioMapping2": Dio4Mapping = (DioMappingEnum)((int)(r.Value >> 6) & 3); Dio5Mapping = (DioMappingEnum)((int)(r.Value >> 4) & 3); MapPreambleDetect = ((int)r.Value & 1) == 1; break; case "RegVersion": Version = new Version((int)((r.Value & 240U) >> 4), (int)r.Value & 15); break; case "RegPllHop": FastHopOn = ((int)r.Value & 128) == 128; break; case "RegTcxo": TcxoInputOn = ((int)r.Value & 16) == 16; break; case "RegPaDac": Pa20dBm = ((int)r.Value & 7) == 7; ReadRegister(registers["RegPaConfig"]); break; case "RegFormerTemp": formerTemp = (Decimal)((byte)(r.Value & (uint)sbyte.MaxValue)); if (((int)r.Value & 128) == 128) formerTemp *= new Decimal(-1); Decimal num4 = (Decimal)((byte)(registers["RegTemp"].Value & (uint)sbyte.MaxValue)); if (((int)registers["RegTemp"].Value & 128) == 128) num4 *= new Decimal(-1); tempDelta = num4 - formerTemp; OnPropertyChanged("TempDelta"); OnPropertyChanged("FormerTemp"); break; case "RegBitrateFrac": BitrateFrac = (Decimal)(r.Value & 15U); if (ModulationType == ModulationTypeEnum.FSK) { Bitrate = frequencyXo / ((Decimal)(registers["RegBitrateMsb"].Value << 8 | registers["RegBitrateLsb"].Value) + (Decimal)registers["RegBitrateFrac"].Value / new Decimal(160, 0, 0, false, (byte)1)); break; } Bitrate = frequencyXo / (Decimal)(registers["RegBitrateMsb"].Value << 8 | registers["RegBitrateLsb"].Value); break; case "RegAgcRef": AgcReferenceLevel = (byte)(r.Value & 63U); OnPropertyChanged("AgcReference"); OnPropertyChanged("AgcThresh1"); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegAgcThresh1": AgcStep1 = (byte)(r.Value & 31U); OnPropertyChanged("AgcThresh1"); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegAgcThresh2": AgcStep2 = (byte)(r.Value >> 4); AgcStep3 = (byte)(r.Value & 15U); OnPropertyChanged("AgcThresh2"); OnPropertyChanged("AgcThresh3"); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegAgcThresh3": AgcStep4 = (byte)(r.Value >> 4); AgcStep5 = (byte)(r.Value & 15U); OnPropertyChanged("AgcThresh4"); OnPropertyChanged("AgcThresh5"); break; case "RegPll": PllBandwidth = (Decimal)((uint)(((int)(r.Value >> 6) + 1) * 75000)); break; } }
public int IndexOf(Register value) { return base.List.IndexOf(value); }
public void Insert(int index, Register value) { List.Insert(index, (object)value); }
public void Insert(int index, Register value) { base.List.Insert(index, value); }
public void RemoveRange(Register[] value) { for (int index = 0; index < value.Length; ++index) Remove(value[index]); }
public void Remove(Register value) { base.Capacity--; base.List.Remove(value); }
public int Add(Register value) { return List.Add((object)value); }
public bool ReadRegister(Register r) { byte data = (byte)0; return ReadRegister(r, ref data); }
public bool Contains(Register value) { return List.Contains((object)value); }
public bool ReadRegister(Register r, ref byte data) { lock (syncThread) { try { ++readLock; if (IsOpen) { if (!Read((byte)r.Address, ref data)) throw new Exception("Unable to read register: " + r.Name); r.Value = (uint)data; } else UpdateRegisterValue(r); return true; } catch (Exception exception_0) { OnError((byte)1, exception_0.Message); return false; } finally { --readLock; } } }
public int IndexOf(Register value) { return List.IndexOf((object)value); }
private bool ReadRegister(Register r) { byte data = 0; return ReadRegister(r, ref data); }