Subversion Repositories FlightCtrl

Rev

Rev 2047 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

#include<inttypes.h>
#include "attitude.h"

/*
 * Angular unit scaling: Number of units per degree
 */

#define MATH_DRG_FACTOR GYRO_DEG_FACTOR_PITCHROLL

/*
 * Fix-point decimal scaling: Number of units for 1 (so if sin(something)
 * returns UNIT_FACTOR * 0.8, the result is to be understood as 0.8)
 * a * sin(b) = (a * int_sin(b * DRG_FACTOR)) / UNIT_FACTOR
 */

//#define MATH_UNIT_FACTOR 8192
// Changed: We want to be able to multiply 2 sines/cosines and still stay comfortably (factor 100) within 31 bits.
// 4096 = 12 bits, square = 24 bits, 7 bits to spare.
#define LOG_MATH_UNIT_FACTOR 12
#define MATH_UNIT_FACTOR (1L<<LOG_MATH_UNIT_FACTOR)

int16_t sin_360(int16_t arg);
int16_t cos_360(int16_t arg);
int16_t tan_360(int16_t arg);

void intervalWrap(int32_t *number, int32_t limit);