Dio_PortLevelType Dio_ReadChannelGroup( const Dio_ChannelGroupType *channelGroupIdPtr) { Dio_PortLevelType level; VALIDATE_RV( DioGlobal.InitRun, DIO_READCHANNELGROUP_ID, DIO_E_UNINIT, (Dio_PortLevelType)0 ); /** @req SWS_Dio_00114 */ VALIDATE_RV( IS_VALID_CHANNELGROUP(channelGroupIdPtr), DIO_READCHANNELGROUP_ID, DIO_E_PARAM_INVALID_GROUP_ID, (Dio_PortLevelType)0 ); // Get masked values level = Dio_ReadPort(channelGroupIdPtr->port) & channelGroupIdPtr->mask; // Shift down level = level >> channelGroupIdPtr->offset; return level; }
Dio_PortLevelType Dio_ReadChannelGroup( const Dio_ChannelGroupType *channelGroupIdPtr) { Dio_LevelType level; VALIDATE_CHANNELGROUP(channelGroupIdPtr,DIO_READCHANNELGROUP_ID); // Get masked values level = Dio_ReadPort(channelGroupIdPtr->port) & channelGroupIdPtr->mask; // Shift down level = level >> channelGroupIdPtr->offset; #if ( DIO_DEV_ERROR_DETECT == STD_ON ) cleanup: #endif return level; }
Dio_LevelType Dio_ReadChannel(Dio_ChannelType channelId) { Dio_LevelType level; VALIDATE_RV( DioGlobal.InitRun, DIO_READCHANNEL_ID, DIO_E_UNINIT, (Dio_LevelType)0 ); /** @req SWS_Dio_00074 */ VALIDATE_RV( IS_VALID_CHANNEL(channelId), DIO_READCHANNEL_ID, DIO_E_PARAM_INVALID_CHANNEL_ID, (Dio_LevelType)0 ); Dio_PortLevelType portVal = Dio_ReadPort(DIO_GET_PORT_FROM_CHANNEL_ID(channelId)); Dio_PortLevelType bit = DIO_GET_BIT_FROM_CHANNEL_ID(channelId); if ((portVal & bit) != STD_LOW){ level = STD_HIGH; } else{ level = STD_LOW; } return (level); }
Dio_LevelType Dio_ReadChannel(Dio_ChannelType channelId) { Dio_LevelType level; VALIDATE_CHANNEL(channelId, DIO_READCHANNEL_ID); Dio_PortLevelType portVal = Dio_ReadPort(DIO_GET_PORT_FROM_CHANNEL_ID(channelId)); Dio_PortLevelType bit = DIO_GET_BIT_FROM_CHANNEL_ID(channelId); if ((portVal & bit) != STD_LOW){ level = STD_HIGH; } else { level = STD_LOW; } #if ( DIO_DEV_ERROR_DETECT == STD_ON ) cleanup: #endif return (level); }
void Dio_WriteChannel(Dio_ChannelType channelId, Dio_LevelType level) { VALIDATE_CHANNEL(channelId, DIO_WRITECHANNEL_ID); Dio_PortLevelType portVal = Dio_ReadPort(DIO_GET_PORT_FROM_CHANNEL_ID(channelId)); Dio_PortLevelType bit = DIO_GET_BIT_FROM_CHANNEL_ID(channelId); if(level == STD_HIGH){ portVal |= bit; } else { portVal &= ~bit; } Dio_WritePort(DIO_GET_PORT_FROM_CHANNEL_ID(channelId), portVal); #if ( DIO_DEV_ERROR_DETECT == STD_ON ) cleanup: #endif return; }
void Dio_WriteChannelGroup(const Dio_ChannelGroupType *channelGroupIdPtr, Dio_PortLevelType level) { VALIDATE_CHANNELGROUP(channelGroupIdPtr,DIO_WRITECHANNELGROUP_ID); // Shift up and apply mask so that no unwanted bits are affected level = (level << channelGroupIdPtr->offset) & channelGroupIdPtr->mask; // Read port and clear out masked bits Dio_PortLevelType portVal = Dio_ReadPort(channelGroupIdPtr->port) & (~channelGroupIdPtr->mask); // Or in the upshifted masked level portVal |= level; Dio_WritePort(channelGroupIdPtr->port, portVal); #if ( DIO_DEV_ERROR_DETECT == STD_ON ) cleanup: #endif return; }