Небольшие изменения
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
#define ACCEL_SENS_SCALE_FACTOR 4096.0f
|
||||
#define GYRO_SENS_SCALE_FACTOR 16.4f
|
||||
#define GYRO_SENS_SCALE_FACTOR 16.384f
|
||||
#define PI 3.14159265359f
|
||||
#define DEG2RAD PI / 180.0f
|
||||
|
||||
|
||||
@@ -25,26 +25,11 @@ control_channels_t ctrl_chs;
|
||||
|
||||
Vector3 euler;
|
||||
|
||||
volatile uint32_t us_ticks = 0;
|
||||
|
||||
void SysTick_Handler()
|
||||
{
|
||||
us_ticks++;
|
||||
}
|
||||
|
||||
float micros()
|
||||
{
|
||||
return (float)us_ticks;
|
||||
}
|
||||
|
||||
static float last_time = 0;
|
||||
|
||||
void imu_callback(uint8_t* buf);
|
||||
void delay_ms(uint32_t ms);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
last_time = micros();
|
||||
|
||||
__enable_irq();
|
||||
|
||||
@@ -75,25 +60,6 @@ int main(void)
|
||||
receiver_update(&rx_chs_raw);
|
||||
rx_chs_normalized = normalize_channels(rx_chs_raw);
|
||||
|
||||
/*if (irs_update_flag)
|
||||
{
|
||||
irs_update_flag = 0;
|
||||
|
||||
imu_read_scaled(&imu, &allowed_calib);
|
||||
|
||||
irs.gyro.x = imu.gx;
|
||||
irs.gyro.y = imu.gy;
|
||||
irs.gyro.z = imu.gz;
|
||||
|
||||
irs.accel.x = imu.ax;
|
||||
irs.accel.y = imu.ay;
|
||||
irs.accel.z = imu.az;
|
||||
|
||||
IRS_update(&irs, IMU_DT);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
if (control_update_flag)
|
||||
{
|
||||
control_update_flag = 0;
|
||||
@@ -136,11 +102,6 @@ void imu_callback(uint8_t* buf)
|
||||
|
||||
imu_process_raw(&imu, &imu_raw, &allowed_calib);
|
||||
|
||||
float now = micros();
|
||||
float dt = (now - last_time) * 1e-6f;
|
||||
if (dt <= 0.0f || dt > 0.1f) dt = IMU_DT;
|
||||
last_time = now;
|
||||
|
||||
irs.gyro.x = imu.gx;
|
||||
irs.gyro.y = imu.gy;
|
||||
irs.gyro.z = imu.gz;
|
||||
@@ -154,11 +115,14 @@ void imu_callback(uint8_t* buf)
|
||||
euler = QuatToEuler(&irs.q);
|
||||
}
|
||||
|
||||
static uint8_t div = 0;
|
||||
|
||||
void TIM6_DAC_IRQHandler()
|
||||
{
|
||||
if (TIM6->SR & TIM_SR_UIF)
|
||||
{
|
||||
TIM6->SR &= ~TIM_SR_UIF;
|
||||
|
||||
i2c_read_async(ICM_ADDR, 0x2D, 12, imu_callback);
|
||||
control_update_flag = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user