Hello Hussain,
After a quick scan through your code...
The module powers up in 8-bit mode
The first write needs to be an 8-bit one
the top nibble needs to be 0x02, then you toggle E
Now you are in 4-bit mode
Then you do a 4-bit write to the same register of 0x28 to set 4-bit again and two line
then carry on setting the other registers in 4-bit mode.
You seem to have two errors initially (I have not bothered to look further)
1. you make the first write in 4-bit style
2. you send 0x38 rather than 0x28