/*
 * myapp.h
 *
 *  Created on: 26. 10. 2021
 *      Author: student
 */

#ifndef INC_MYAPP_H_
#define INC_MYAPP_H_

/*
 * Struktura pripravena pro cil DMA prenosu z ADC dualni sekvence
 */

#define rawADCsmpNum 3 // pocet dualnich prevodu ADC

#define  N_SMP 200
#define PI 3.14159
#define ASR 1.8 //360 / 3600 = 0.1

typedef union {
	uint32_t uWData[rawADCsmpNum];
	uint16_t usData[rawADCsmpNum*2];
	uint8_t ubData[rawADCsmpNum*4];
	struct {
	int16_t Iph3;     // Sample 1 MST
	int16_t Vph1;     // Sample 1 SLV
	uint16_t VDC2;    // Sample 2 MST
	uint16_t VDC1;    // Sample 2 SLV
	uint16_t Vrefint; // Sample 3 MST
	uint16_t Pot;     // Sample 3 SLV
	}in;
}rawADCData_typedef;

/*
 * Struktura pro realne veliciny
 */
typedef struct {
	float Vdc1;      // napeti Ud pred nabijecim rezistorem [V]
	float Vdc2;      // napeti Ud za nabijecim rezistorem   [V]
	float Vc;       // napeti na fazi 1: vystupni napeti LC filtru  [V]
	float Ia;       // proud fazi3: proud tlumivkou   [A]
	float Vrefadc; //  nepouziva se (zatim)           [V]
	float Pot;     // Poloha potenciometru (0..1)
}analogData_typedef;

/*
 *  Deklarace externich promenych
 */
//extern rawADCData_typedef rawADCData;
//extern analogData_typedef analogData;


/*
 * Prototypy funkci
 */
void myInit(void);
void myPeriodicISR(void);
/*
 * Prototypy funkci pro sin měnič
 */
void myInit(void);
void NewSMP(void);
void SinCalc(void);

void prijem_I2C(void);
void zpracovani_Dat();
void DAC_SetOutputVoltage(uint16_t);

#endif /* INC_MYAPP_H_ */
