
#include "opora.h"
#include "LCD.h"
#include "font.h"
#include "LCD_b.h"
#include "config.h"
#include "adc.h"

uint8_t str1[] = {"Цифровой код на входе"};
uint8_t str2[] = {"АЦП, которому соот-"};
uint8_t str3[] = {"ветствует напряжение"};
uint8_t str4[] = {"на резисторе R14:"};
uint8_t str5[] = {"Канал 2:"};
uint32_t CurrentResult, LastResult;

int main()
{
	ClkConfig();
	PortConfig();
	LCDInit();
	ADCInit();
	
	PrintConstText(str1,0,0,0);
	PrintConstText(str2,1,0,0);
	PrintConstText(str3,2,0,0);
	PrintConstText(str4,3,0,0);
	PrintConstText(str5,5,0,0);

	CurrentResult = 0;
	while(1)
	{
		ADC->ADC1_CFG |= (1<<1);	//start of ADC
		
		while((ADC->ADC1_STATUS&(1<<2))!=(1<<2));
		CurrentResult = (uint16_t)ADC->ADC1_RESULT&0xFFF8;

		if(CurrentResult != LastResult)
		{
			ClearPageAtTo(48,127,5);
			PrintText(" %",CurrentResult,5,48,0,hex);	//выводит строку
			
			LastResult = CurrentResult;
		}
	}
}

