STM/Modbus/Baremetal/UART_RS485_Modbus_Slave/Source/Modbus/Slave/Modbus_Slave.c
void AppendBitsToRegisters(unsigned int StAddr, unsigned int count,
		unsigned char *inreg, volatile unsigned char *outreg)
{
	for (unsigned int c = 0; c < count; c++)
	{
		if (*(inreg + ((StAddr + c) / 8u))
				& (1 << ((StAddr + c) - (((StAddr + c) / 8u) * 8u))))//if in outreg array, bit is 1?
		{
			*(outreg + 3 + (c / 8)) |= (1 << (c - ((c / 8) * 8)));//then set bit 1 in target array
		}
		else
			*(outreg + 3 + (c / 8)) &= ~(1 << (c - ((c / 8) * 8)));	//else clear the bit in target array
	}
}
//C function to append array bits to modbus pDU

C function to append array bits to modbus pDU
C function to append array bits to modbus pDU
void AppendBitsToRegisters(unsigned int StAddr, unsigned int count,
		unsigned char *inreg, volatile unsigned char *outreg)
{
	for (unsigned int c = 0; c < count; c++)
	{
		if (*(inreg + ((StAddr + c) / 8u))
				& (1 << ((StAddr + c) - (((StAddr + c) / 8u) * 8u))))
		{
			*(outreg + 3 + (c / 8)) |= (1 << (c - ((c / 8) * 8)));
		}
		else
			*(outreg + 3 + (c / 8)) &= ~(1 << (c - ((c / 8) * 8)));	
	}
}
void AppendBitsToRegisters ( unsigned int StAddr , unsigned int count , unsigned char * inreg , volatile unsigned char * outreg ) { for ( unsigned int c = 0 ; c < count ; c ++ ) { if ( * ( inreg + ( ( StAddr + c ) / 8u ) ) & ( 1 << ( ( StAddr + c ) - ( ( ( StAddr + c ) / 8u ) * 8u ) ) ) ) { * ( outreg + 3 + ( c / 8 ) ) |= ( 1 << ( c - ( ( c / 8 ) * 8 ) ) ) ; } else * ( outreg + 3 + ( c / 8 ) ) &= ~ ( 1 << ( c - ( ( c / 8 ) * 8 ) ) ) ; } }
C function to append array bits to modbus pDU
C function to append array bits to modbus pDU
//if in outreg array, bit is 1?
 //then set bit 1 in target array
 //else clear the bit in target array
