/*
 * pribors.h
 *
 *  Created on: 6 сент. 2024 г.
 *      Author: user
 */

#include "stdint.h"

#ifndef INC_PRIBORS_H_
#define INC_PRIBORS_H_

#define PRIBOR_PRDN1 		0x00
#define PRIBOR_PRDN2 		0x04
#define PRIBOR_PRDN3 		0x08
#define PRIBOR_PRDN4  		0x0C
#define PRIBOR_PRDV1  		0x01
#define PRIBOR_PRDV2		0x05
#define PRIBOR_PRDV3		0x09
#define PRIBOR_PRDV4		0x0D
#define PRIBOR_PRDK1  		0x02
#define PRIBOR_PRDK2		0x06
#define PRIBOR_PRDK3		0x0A
#define PRIBOR_PRDK4		0x0E
#define PRIBOR_UF			0x1B


#define IP_PRIBOR_PRDN1 	"10.1.1.11"
#define IP_PRIBOR_PRDN2 	"10.1.1.21"
#define IP_PRIBOR_PRDN3 	"10.1.1.31"
#define IP_PRIBOR_PRDN4  	"10.1.1.41"
#define IP_PRIBOR_PRDV1  	"10.1.1.12"
#define IP_PRIBOR_PRDV2		"10.1.1.22"
#define IP_PRIBOR_PRDV3		"10.1.1.32"
#define IP_PRIBOR_PRDV4		"10.1.1.42"
#define IP_PRIBOR_PRDK1  	"10.1.1.13"
#define IP_PRIBOR_PRDK2		"10.1.1.23"
#define IP_PRIBOR_PRDK3		"10.1.1.33"
#define IP_PRIBOR_PRDK4		"10.1.1.43"
#define IP_PRIBOR_UF		"10.1.1.52"
#define IP_PRIBOR_DEFAULT	"10.1.1.70"

#define PORT_PRIBOR_PRDN1 	11
#define PORT_PRIBOR_PRDN2 	21
#define PORT_PRIBOR_PRDN3 	31
#define PORT_PRIBOR_PRDN4  	41
#define PORT_PRIBOR_PRDV1  	12
#define PORT_PRIBOR_PRDV2	22
#define PORT_PRIBOR_PRDV3	32
#define PORT_PRIBOR_PRDV4	42
#define PORT_PRIBOR_PRDK1  	13
#define PORT_PRIBOR_PRDK2	23
#define PORT_PRIBOR_PRDK3	33
#define PORT_PRIBOR_PRDK4	43
#define PORT_PRIBOR_UF		52
#define PORT_PRIBOR_DEFAULT	70

#define BASE_ADDR_UG		0x100
#define BASE_ADDR_UKP0		0x130
#define BASE_ADDR_UKP1		0x140
#define BASE_ADDR_EMS_G		0x120
#define BASE_ADDR_EMS_B0	0x110
#define BASE_ADDR_EMS_B1	0x120
#define BASE_ADDR_KEMS_B	0x130

uint32_t get_ip(void);
uint16_t get_port(void);
uint16_t set_status(unsigned char *buf, uint32_t pribor);
uint16_t set_status_prd(unsigned char *buf);
uint16_t set_status_uf(unsigned char *buf);
unsigned char set_bit(unsigned char bits, unsigned char index, _Bool val);
extern void write_isa(uint16_t addr, uint16_t data);
extern uint16_t read_isa(uint16_t addr);

enum
{
	 	IN_PROGRESS = 0,
		NO_ERROR,
		ERR_SIZE,

		ERR_UNKNOW_COMMAND = 255
};
enum
{
	 	PRIBOR_TYPE_PRD = 0,
		PRIBOR_TYPE_UF,
		PRIBOR_TYPE_DEFAULT,

};
#endif /* INC_PRIBORS_H_ */


