/**
 ******************************************************************************
 * @file           : main.c
 * @author         : Auto-generated by STM32CubeIDE
 * @brief          : Main program body
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
 * All rights reserved.</center></h2>
 *
 * This software component is licensed by ST under BSD 3-Clause license,
 * the "License"; You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                        opensource.org/licenses/BSD-3-Clause
 *
 ******************************************************************************
 */

#include "stm32l073xx.h"

#if !defined(__SOFT_FP__) && defined(__ARM_FP)
  #warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif

int main(void)
{
	// zapne periferii nastaveni napajeni
	RCC->APB1ENR |= RCC_APB1ENR_PWREN;

	// reset nastaveni rychlosti MSI
	RCC->ICSCR &= ~RCC_ICSCR_MSIRANGE_Msk;

	// nastavi MSI rychlost 1 -> 131 KHz
	RCC->ICSCR |= ((1 << RCC_ICSCR_MSIRANGE_Pos) & RCC_ICSCR_MSIRANGE_Msk);

	// prepne regulator napeti do usporneho rezimu
	PWR->CR |= PWR_CR_LPSDSR;

	// vypne pamet programu Flash
	FLASH->ACR |= FLASH_ACR_SLEEP_PD;

	// zapne spici rezim probuzeny prerusenim
	asm("wfi");
}
