/**
 ******************************************************************************
 * @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

#define VELIKOST_DAT 1000
uint32_t data1[VELIKOST_DAT];

void prenosDat(uint32_t pocetIteraci)
{
	uint32_t data2[VELIKOST_DAT];

	for(uint32_t x = 0U; x < pocetIteraci; x++)
	{
		for(uint32_t y = 0U; y < VELIKOST_DAT; y++)
		{
			data1[y] = (data2[y])++;
		}
	}
}

int main(void)
{
	while(1)
	{
		// postupne nastavi vsech sedm moznych kmitoctu
		for(uint32_t kmitocet = 0U; kmitocet < 7; kmitocet++)
		{
			// reset
			RCC->ICSCR &= ~(RCC_ICSCR_MSIRANGE_Msk);

			// nastavi kmitocet vicerychlostniho oscilatoru
			RCC->ICSCR |= ((kmitocet << RCC_ICSCR_MSIRANGE_Pos) & RCC_ICSCR_MSIRANGE_Msk);

			// postupne nastavi vsechny tri napetove rozsahy
			for (uint32_t napetova_uroven = 1U; napetova_uroven < 4; napetova_uroven++)
			{
				// zapne periferii nastaveni napajeni
				RCC->APB1ENR |= RCC_APB1ENR_PWREN;

				// nastavi napetovou uroven
				PWR->CR = ((napetova_uroven << PWR_CR_VOS_Pos) | (PWR->CR & ~(PWR_CR_VOS_Msk)));

				// vypne periferii nastaveni napajeni
				RCC->APB1ENR &= ~RCC_APB1ENR_PWREN;

				// cekej, dokud se uroven nezmeni
				while((PWR->CSR & PWR_CSR_VOSF) == PWR_CSR_VOSF);

				prenosDat(((kmitocet * kmitocet) + 1) * 6);
			}
		}
	}
}




