diff --git a/UAV-ControlSystem/inc/drivers/I2C.h b/UAV-ControlSystem/inc/drivers/I2C.h index 01c7e65..44fea89 100644 --- a/UAV-ControlSystem/inc/drivers/I2C.h +++ b/UAV-ControlSystem/inc/drivers/I2C.h @@ -68,8 +68,7 @@ int main(void) // Initialize the Hardware Abstraction Layer HAL_Init(); - // Configure the system clock to 100 MHz - system_clock_config(); + init_system(); I2C_HandleTypeDef i2c_profile; @@ -89,7 +88,8 @@ int main(void) uint8_t reset_pointer_data[1] = { 0b00000011 }; uint8_t response_data[6] = { 0x0 }; - + // This sequence starts the compass by first initializing it with the first 2 send + // The third is there to say that the system should be continous communication i2c_send(&i2c_profile, address, &start_request_1, 2); i2c_send(&i2c_profile, address, &start_request_2, 2); i2c_send(&i2c_profile, address, &start_request_3, 2); diff --git a/UAV-ControlSystem/src/drivers/I2C.c b/UAV-ControlSystem/src/drivers/I2C.c index f978e40..ed643b0 100644 --- a/UAV-ControlSystem/src/drivers/I2C.c +++ b/UAV-ControlSystem/src/drivers/I2C.c @@ -59,7 +59,7 @@ bool i2c_configure(I2C_TypeDef *i2c, GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = i2c_af; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + HAL_GPIO_Init(i2c_port, &GPIO_InitStruct); //Initialize I2C communication out_profile->Instance = i2c;