Protect code from STM32CubeMX by putting it between comments
This commit is contained in:
		
					parent
					
						
							
								53e237f6ea
							
						
					
				
			
			
				commit
				
					
						72da832192
					
				
			
		
					 1 changed files with 35 additions and 35 deletions
				
			
		
							
								
								
									
										70
									
								
								Src/main.c
									
										
									
									
									
								
							
							
						
						
									
										70
									
								
								Src/main.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -63,8 +63,6 @@ static void MX_NVIC_Init(void);
 | 
			
		|||
/* Private user code ---------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN 0 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
typedef struct config_s {
 | 
			
		||||
    const uint8_t address;
 | 
			
		||||
    const uint8_t write_read;
 | 
			
		||||
| 
						 | 
				
			
			@ -72,42 +70,44 @@ typedef struct config_s {
 | 
			
		|||
} Config;
 | 
			
		||||
 | 
			
		||||
void configure_sensor() {
 | 
			
		||||
    const uint16_t size_msg = 2; {
 | 
			
		||||
        const uint8_t wakeup_cmd = 1;
 | 
			
		||||
        const uint8_t data[] = { config_reg, wakeup_cmd };
 | 
			
		||||
        HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, data, size_msg, 6);
 | 
			
		||||
    }
 | 
			
		||||
    HAL_Delay(6); {
 | 
			
		||||
        const uint8_t data[] = { mbit_trim_reg, 0x0C };
 | 
			
		||||
        HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, data, size_msg, 6);
 | 
			
		||||
    }
 | 
			
		||||
    HAL_Delay(6); {
 | 
			
		||||
        const uint8_t data[] = { bias_trim_top_reg, 0x0C };
 | 
			
		||||
        HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, data, size_msg, 6);
 | 
			
		||||
    }
 | 
			
		||||
    HAL_Delay(6); {
 | 
			
		||||
        const uint8_t data[] = { bias_trim_bot_reg, 0x0C };
 | 
			
		||||
        HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, data, size_msg, 6);
 | 
			
		||||
    }
 | 
			
		||||
    HAL_Delay(6); {
 | 
			
		||||
        const uint8_t data[] = { clk_trim_reg, 0x14 };
 | 
			
		||||
        HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, data, size_msg, 6);
 | 
			
		||||
    }
 | 
			
		||||
    HAL_Delay(6); {
 | 
			
		||||
        const uint8_t data[] = { bpa_trim_top_reg, 0x0C };
 | 
			
		||||
        HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, data, size_msg, 6);
 | 
			
		||||
    }
 | 
			
		||||
    HAL_Delay(6); {
 | 
			
		||||
        const uint8_t data[] = { bpa_trim_bot_reg, 0x0C };
 | 
			
		||||
        HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, data, size_msg, 6);
 | 
			
		||||
    }
 | 
			
		||||
    HAL_Delay(6); {
 | 
			
		||||
        const uint8_t data[] = { pu_reg, 0x88 };
 | 
			
		||||
        HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, data, size_msg, 6);
 | 
			
		||||
    }
 | 
			
		||||
    uint8_t data = 1;
 | 
			
		||||
 | 
			
		||||
    HAL_I2C_Mem_Write(&hi2c1, sensor_addr, config_reg, 1, &data, 1, 6);
 | 
			
		||||
    HAL_Delay(6);
 | 
			
		||||
 | 
			
		||||
    data = 0x0C;
 | 
			
		||||
    HAL_I2C_Mem_Write(&hi2c1, sensor_addr, mbit_trim_reg, 1, &data, 1, 5);
 | 
			
		||||
    HAL_Delay(6);
 | 
			
		||||
 | 
			
		||||
    data = 0x0C;
 | 
			
		||||
    HAL_I2C_Mem_Write(&hi2c1, sensor_addr, bias_trim_top_reg, 1, &data, 1, 5);
 | 
			
		||||
    HAL_Delay(6);
 | 
			
		||||
 | 
			
		||||
    data = 0x0C;
 | 
			
		||||
    HAL_I2C_Mem_Write(&hi2c1, sensor_addr, bias_trim_bot_reg, 1, &data, 1, 5);
 | 
			
		||||
    HAL_Delay(6);
 | 
			
		||||
 | 
			
		||||
    data = 0x14;
 | 
			
		||||
    HAL_I2C_Mem_Write(&hi2c1, sensor_addr, clk_trim_reg, 1, &data, 1, 5);
 | 
			
		||||
    HAL_Delay(6);
 | 
			
		||||
 | 
			
		||||
    data = 0x0C;
 | 
			
		||||
    HAL_I2C_Mem_Write(&hi2c1, sensor_addr, bpa_trim_top_reg, 1, &data, 1, 5);
 | 
			
		||||
    HAL_Delay(6);
 | 
			
		||||
 | 
			
		||||
    data = 0x0C;
 | 
			
		||||
    HAL_I2C_Mem_Write(&hi2c1, sensor_addr, bpa_trim_bot_reg, 1, &data, 1, 5);
 | 
			
		||||
    HAL_Delay(6);
 | 
			
		||||
 | 
			
		||||
    data = 0x88;
 | 
			
		||||
    HAL_I2C_Mem_Write(&hi2c1, sensor_addr, pu_reg, 1, &data, 1, 5);
 | 
			
		||||
    HAL_Delay(6);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) {}
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  The application entry point.
 | 
			
		||||
  * @retval int
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue