Porrey.Uwp.IoT.Devices.Ds1307.SetControlRegister C# (CSharp) Method

SetControlRegister() protected method

protected SetControlRegister ( GpioPinValue outBit, bool sqweBit, Frequency frequency ) : System.Threading.Tasks.Task
outBit GpioPinValue
sqweBit bool
frequency Frequency
return System.Threading.Tasks.Task
		protected async Task SetControlRegister(GpioPinValue outBit, bool sqweBit, Frequency frequency)
		{
			byte writeValue = 0;

			// ***
			// *** Bit 7
			// ***
			if (outBit == GpioPinValue.High)
			{
				writeValue |= 0x80;
			}

			// ***
			// *** Bit 4
			// ***
			if (sqweBit)
			{
				writeValue |= 0x10;
			}

			// ***
			// *** Bits 1 & 0
			// ***
			switch (frequency)
			{
				case Frequency.None:
				case Frequency.OneHertz:
					writeValue |= 0x0;
					break;
				case Frequency.FourKiloHertz:
					writeValue |= 0x1;
					break;
				case Frequency.EightKiloHertz:
					writeValue |= 0x2;
					break;
				case Frequency.ThirtyTwoKiloHertz:
					writeValue |= 0x3;
					break;
			}

			byte[] writeBuffer = new byte[] { CONTROL_ADDRESS, writeValue };
			await this.WriteAsync(writeBuffer);
		}