/* ===================================================================*/ void GPIO2_ToggleFieldBits(LDD_TDeviceData *DeviceDataPtr, LDD_GPIO_TBitField Field, GPIO2_TFieldValue Mask) { (void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */ switch (Field) { /* no break */ case I2C_DAT: { /* bit field #0 */ GPIO_PDD_TogglePortDataOutputMask(GPIO2_MODULE_BASE_ADDRESS, ((GPIO2_TPortValue)GPIO2_I2C_DAT_MASK) & ((GPIO2_TPortValue)(Mask << GPIO2_I2C_DAT_START_BIT)) ); break; } case I2C_CLK: { /* bit field #1 */ GPIO_PDD_TogglePortDataOutputMask(GPIO2_MODULE_BASE_ADDRESS, ((GPIO2_TPortValue)GPIO2_I2C_CLK_MASK) & ((GPIO2_TPortValue)(Mask << GPIO2_I2C_CLK_START_BIT)) ); break; } default: break; /* Invalid Field is not treated, result is undefined */ } /* switch (Field) */ }
/* ** =================================================================== ** Method : BitsIoLdd4_PutVal (component BitsIO_LDD) ** ** Description : ** Specified value is passed to the Input/Output component. If ** the direction is [input] saves the value to a memory or a ** register, this value will be written to the pins after ** switching to the output mode - using [SetDir(TRUE)] (see ** <Safe mode> property for limitations). If the direction is ** [output] it writes the value to the pins. (Method is ** available only if the Direction = _[output]_ or ** _[input/output]_). ** Parameters : ** NAME - DESCRIPTION ** * DeviceDataPtr - Device data structure ** pointer returned by <Init> method. ** Val - Output value ** Returns : Nothing ** =================================================================== */ void BitsIoLdd4_PutVal(LDD_TDeviceData *DeviceDataPtr, dword Val) { /* Store the raw value of the port, set according to the offset of the first allocated pin */ dword rawVal; (void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */ /* Calculate the raw data to be set (i.e. shifted to left according to the first allocated pin) */ rawVal = (Val & BitsIoLdd4_PORT_VALID_VALUE_MASK) << BitsIoLdd4_PIN_ALLOC_0_INDEX; /* Mask and shift output value */ /* Set port data by toggling the different bits only */ GPIO_PDD_TogglePortDataOutputMask(BitsIoLdd4_MODULE_BASE_ADDRESS, (GPIO_PDD_GetPortDataOutput(BitsIoLdd4_MODULE_BASE_ADDRESS) ^ rawVal) & BitsIoLdd4_PORT_MASK); }
/* ===================================================================*/ void LEDRed_ToggleFieldBits(LDD_TDeviceData *DeviceDataPtr, LDD_GPIO_TBitField Field, LEDRed_TFieldValue Mask) { (void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */ switch (Field) { /* no break */ case LED_RED: { /* bit field #0 */ GPIO_PDD_TogglePortDataOutputMask(LEDRed_MODULE_BASE_ADDRESS, ((LEDRed_TPortValue)LEDRed_LED_RED_MASK) & ((LEDRed_TPortValue)(Mask << LEDRed_LED_RED_START_BIT)) ); break; } default: break; /* Invalid Field is not treated, result is undefined */ } /* switch (Field) */ }
/* ** =================================================================== ** Method : BitsIoLdd4_NegBit (component BitsIO_LDD) ** ** Description : ** Negates (inverts) the specified bit of the Input/Output ** component. It is the same as [PutBit(Bit,!GetBit(Bit))]. ** (Method is available only if the Direction = _[output]_ or ** _[input/output]_). ** Parameters : ** NAME - DESCRIPTION ** * DeviceDataPtr - Pointer to device data ** structure pointer. ** Bit - Bit/pin number to invert ** Returns : ** --- - Error code, possible values: ** ERR_OK - OK ** ERR_PARAM_MASK - Invalid pin mask ** =================================================================== */ LDD_TError BitsIoLdd4_NegBit(LDD_TDeviceData *DeviceDataPtr, byte Bit) { uint32_t mask = 0; (void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */ /* Bit number value - this test can be disabled by setting the "Ignore range checking" property to the "yes" value in the "Configuration inspector" */ if (Bit > 3U) { return ERR_PARAM_MASK; } mask = BitsIoLdd4_PIN_MASK_MAP[Bit]; GPIO_PDD_TogglePortDataOutputMask(BitsIoLdd4_MODULE_BASE_ADDRESS, mask); return ERR_OK; }
/* ===================================================================*/ void BitIoLdd2_NegVal(LDD_TDeviceData *DeviceDataPtr) { (void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */ GPIO_PDD_TogglePortDataOutputMask(BitIoLdd2_MODULE_BASE_ADDRESS, BitIoLdd2_PORT_MASK); }