Here is an app note from Texas Instruments explaining how to implement the Direct Cosine Matrix algorithm on a MSP430F5xx to integrate date form 3 sensors. A magnetometer, gyroscope, and a an accelerometer were integrated to provide a 9-axis sensor. [via]
When creating an AHRS, also known as Magnetic, Angular Rate, and Gravity sensor (MARG), a magnetometer, a gyroscope, and an accelerometer are required. The calibrated sensors readings are fed to the DCM algorithm, which provides a complete measurement of the orientation, relative to the earth’s magnetic field and the direction of gravity, expressed by the Euler (roll, yaw, and pitch) angles.
App note: Implementing a 9-axis sensor fussion on the MSP430F5xx – [Link]