Initial commit
This commit is contained in:
34
Source/BSP/Inc/imu.h
Normal file
34
Source/BSP/Inc/imu.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef IMU_H
|
||||
#define IMU_H
|
||||
|
||||
#include "stm32g431xx.h"
|
||||
|
||||
#define ICM_ADDR 0x68
|
||||
#define REG_PWR_MGMT_1 0x06
|
||||
#define REG_BANK_SEL 0x7F
|
||||
#define REG_GYRO_CONFIG_1 0x01
|
||||
#define REG_ACCEL_CONFIG 0x14
|
||||
#define IMU_RATE_HZ 1000 // 1 ms
|
||||
#define IMU_DT 0.002f // 2 ms
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t ax, ay, az; // lsb
|
||||
int16_t gx, gy, gz; // lsb
|
||||
} imu_raw_t;
|
||||
|
||||
void i2c_gpio_init();
|
||||
|
||||
void i2c1_init();
|
||||
|
||||
void icm_init();
|
||||
|
||||
void i2c_read(uint8_t addr, uint8_t reg, uint8_t* buf, uint8_t len);
|
||||
|
||||
void i2c_write(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
|
||||
void icm_read_raw(imu_raw_t* data);
|
||||
|
||||
static void i2c_wait_idle(I2C_TypeDef* i2c);
|
||||
|
||||
#endif
|
||||
23
Source/BSP/Inc/imu_processing.h
Normal file
23
Source/BSP/Inc/imu_processing.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef IMU_PROCESSING_H
|
||||
#define IMU_PROCESSING_H
|
||||
|
||||
#include "imu.h"
|
||||
|
||||
|
||||
#define ACCEL_SENS_SCALE_FACTOR 8192.0f
|
||||
#define GYRO_SENS_SCALE_FACTOR 16.4f
|
||||
#define PI 3.14159265359f
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float ax, ay, az; // g
|
||||
float gx, gy, gz; // dps
|
||||
} imu_scaled_t;
|
||||
|
||||
void imu_processing_init();
|
||||
|
||||
void imu_read_scaled(imu_scaled_t* out);
|
||||
|
||||
void imu_calibrate();
|
||||
|
||||
#endif
|
||||
0
Source/BSP/Inc/lidar.h
Normal file
0
Source/BSP/Inc/lidar.h
Normal file
24
Source/BSP/Inc/motors.h
Normal file
24
Source/BSP/Inc/motors.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef MOTORS_H
|
||||
#define MOTORS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "pid.h"
|
||||
|
||||
void motors_init();
|
||||
void motor_gpio_tim1_ch3_init();
|
||||
void motor_gpio_tim1_ch4_init();
|
||||
void motors_tim1_ch3_4_init();
|
||||
|
||||
void motor_gpio_tim2_ch1_init();
|
||||
void motor_gpio_tim2_ch2_init();
|
||||
void motors_tim2_ch1_2_init();
|
||||
|
||||
void motors_set_throttle_mix(const int16_t throttle, const control_channels_t* chs, const int8_t armed);
|
||||
void motor_set_throttle(int8_t motor_number, int16_t us, int8_t armed);
|
||||
void motors_turn_off();
|
||||
void motor1_set_throttle(int16_t us);
|
||||
void motor2_set_throttle(int16_t us);
|
||||
void motor3_set_throttle(int16_t us);
|
||||
void motor4_set_throttle(int16_t us);
|
||||
|
||||
#endif
|
||||
34
Source/BSP/Inc/radio_receiver.h
Normal file
34
Source/BSP/Inc/radio_receiver.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef RADIO_RECEIVER_H
|
||||
#define RADIO_RECEIVER_H
|
||||
|
||||
#include "stm32g431xx.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define SBUS_FRAME_SIZE 25
|
||||
#define SBUS_START_BYTE 0X0F
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t rc_roll; // -500 - 500
|
||||
int16_t rc_pitch; // -500 - 500
|
||||
int16_t rc_throttle; // 1000 - 2000
|
||||
int16_t rc_yaw; // -500 - 500
|
||||
int16_t rc_armed; // 0/1
|
||||
} rc_channels;
|
||||
|
||||
void receiver_gpio_init();
|
||||
void receiver_lpuart_clock_init();
|
||||
void receiver_uart_init();
|
||||
void receiver_init();
|
||||
void LPUART1_IRQHandler();
|
||||
void receiver_update(rc_channels* chs);
|
||||
void receiver_parse_frame();
|
||||
rc_channels normalize_channels(rc_channels chs);
|
||||
int16_t int_mapping(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max);
|
||||
int8_t bool_mapping_gt(int16_t x, int16_t boundary);
|
||||
|
||||
|
||||
void led_init();
|
||||
void toggle_led();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user