#include "ClockPackTransf.h"
extern TIM_HandleTypeDef htim1;
extern int TIM3_Period;

struct bus message;

void Trans_bus(void)
{
	// transmit ADR and DATA
	GPIOA->ODR = ((message.ADR.value<<9) | message.DATA.value);

//	GPIOA->ODR |= message.DATA.value;

	// changing ADR and DATA
	message.ADR.value++;
	if (message.ADR.value > 7) message.ADR.value = 1;	
	message.DATA.value++;
	
	// wait yo pulse end and reset timer
	while(TIM1->CNT < TIM3_Period-10);
	TIM1->CR1 &= ~(1<<0);
	TIM1->CNT = TIM3_Period-1;
	// when pulse period is over clear ports
	GPIOA->ODR = 0;
		
}
