1 // 2 // Copyright (c) 2010-2019 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using System; 8 using Antmicro.Renode.Utilities; 9 10 namespace Antmicro.Renode.Peripherals.Wireless.IEEE802_15_4 11 { 12 public class PHYHeader802154 13 { 14 // Definitions taken from: http://www.ti.com/lit/ug/swru346b/swru346b.pdf (page 46 and page 55) PHYHeader802154(byte byteA, byte byteB, PHYType type)15 public PHYHeader802154(byte byteA, byte byteB, PHYType type) 16 { 17 if(type == PHYType.Header802154) 18 { 19 Length = byteA; 20 Address = byteB; // This is TI CC1200 specific byte, normally 802.15.4 has just Length 21 } 22 else 23 { 24 Length = byteB + ((byteA & 0x7u) << 8); 25 DataWhitening = BitHelper.IsBitSet(byteA, 3); 26 FCS2Byte = BitHelper.IsBitSet(byteA, 4); 27 ModeSwitch = BitHelper.IsBitSet(byteA, 7); 28 } 29 } 30 31 // 802.15.4 Packet [Length, Address] 32 public uint Address { get; } 33 34 // 802.15.4g Packet [PHRA, PHRB] 35 public uint Length { get; } 36 public bool DataWhitening { get; } 37 public bool FCS2Byte { get; } 38 public bool ModeSwitch { get; } 39 40 // PHY Header Type 41 public enum PHYType 42 { 43 Header802154, 44 Header802154g, 45 }; 46 } 47 } 48