Formula of rotation in terms of gyro / accelerometer

May I have the formula for direction of rotation always pointing to gravity, using gyro / accelerometer expressions? I do not understand the detail of the gyro xy / accelerometer xy readings.

Thanks to lucky.andrei and I worked out a formula, which still have space of improvement.