Esempio n. 1
0
void write_E() {
	int i, j;
	IO004_SetPin(CE);
	delay(1000);
	for (i = 7; i > 2; i--) {
		for (j = 7; j > -1; j--) {
			if ((configuration[i] & (1 << j)) > 0)
				IO004_SetPin(DATA);
			else
				IO004_ResetPin(DATA);
			pulse_R();
		}
	}
	for (i = 0; i < BYTES_TO_SEND; i++) {
		for (j = 7; j > -1; j--) {
			if ((data_E[i] & (1 << j)) > 0)
				IO004_SetPin(DATA);
			else
				IO004_ResetPin(DATA);
			pulse_R();
		}
	} //termina de enviar dados
	IO004_ResetPin(CE);
	delay(5000);
}
Esempio n. 2
0
void configure_E() {
	/*Atribuicao de valores ao vetor de configuracao do transceptor*/
	configuration[0] = 0xC4; //RF_CH# e OP_MODE 0b11011110
	configuration[1] = 0x4F; //RX2_EN, CM, RFDR_SB13, X0_F, RF_PWR 0b01101111
	configuration[2] = 0xA3; //addr_w
	configuration[3] = 0xEE; //Comeco enderco CH1 00000001
	configuration[4] = 0xDD; //0b00000000
	configuration[5] = 0xCC; //0b11010100
	configuration[6] = 0xBB; //0b11011111
	configuration[7] = 0xAA; //Fim enderco CH1 0b11101010
	configuration[8] = 0b00000000; //Comeco enderco CH2
	configuration[9] = 0b00000000;
	configuration[10] = 0b00000000;
	configuration[11] = 0b00000000;
	configuration[12] = 0b00000000; //Fim enderco CH2
	configuration[13] = 0x28; //num bits enviados (1 byte nesse ex) TODO arrumar
	configuration[14] = 0b00000000;

	IO004_ResetPin(CE);
	IO004_SetPin(CS);
	int i, j;
	for (i = 14; i > -1; i--) {
		for (j = 7; j > -1; j--) {
			if ((configuration[i] & (1 << j)) > 0)
				IO004_SetPin(DATA);
			else
				IO004_ResetPin(DATA);
			;
			pulse_R();
		}
	}
	IO004_ResetPin(CS);
	delay(50000);
}
void IIC_Prot_Int_Handler(void)
{
	  I2C001_Handle0.I2CRegs->FMR = 0x00000002U  << USIC_CH_FMR_MTDV_Pos;	// clear TDV and TE
	  I2C001_Handle0.I2CRegs->TRBSCR = USIC_CH_TRBSCR_FLUSHTB_Msk;			// flush FIFO transmit buffer
	  I2C001_Handle0.I2CRegs->PSCR |= USIC_CH_PSCR_CST5_Msk;				// clear PSR.NACK flag
	  IO004_ResetPin(IO004_Handle0);
}
Esempio n. 4
0
void psxHandShake() {
	int psxByte = 0;

	IO004_SetPin(CMD);
	IO004_SetPin(CONT_CLK);
	IO004_ResetPin(ATT);
	delay(tempoInicio);

	psxByte = 1;
	psxTrocaByte(psxByte);

	psxByte = 0x42;
	psx_status = psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	IO004_SetPin(ATT);
}
Esempio n. 5
0
int psxTrocaByte(int byteDado) {
	int c;
	int aux = 0;
	for (c = 0; c <= 7; c++) {

		if (byteDado & (0x01 << c))
			IO004_SetPin(CMD);
		else
			IO004_ResetPin(CMD);
		IO004_ResetPin(CONT_CLK);
		delay(tempoClk);
		if (!IO004_ReadPin(CONT_DADO))
			aux = aux | (1 << c);
		IO004_SetPin(CONT_CLK);
		delay(tempoClk);
	}
	IO004_SetPin(CMD);
	delay(tempoEntreByte);
	return aux;
}
Esempio n. 6
0
void read_R() {
	int i;
	IO004_ResetPin(CE);
	delay(50000);
	uint8_t temp = 0;

	for (i = 7; i > -1; i--) {
		if (IO004_ReadPin(DATA))
			temp |= (1 << i);
		pulse_R();
	}
	data_R = temp;
	IO004_SetPin(CE);
	delay(50000);
}
Esempio n. 7
0
void psxLeControle() {
	int psxByte = 0;
	int psxCont;

	IO004_SetPin(CMD);
	IO004_SetPin(CONT_CLK);
	IO004_ResetPin(ATT);
	delay(tempoInicio);

	psxByte = 1;
	psxTrocaByte(psxByte);

	psxByte = 0x42;
	psx_status = psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	for (psxCont = 0; psxCont < 6; psxCont++)
		psxDado[psxCont] = psxTrocaByte(0);

	IO004_SetPin(ATT);
}
Esempio n. 8
0
void psxExitConfigMode() {
	int psxByte = 0;
	IO004_SetPin(CMD);
	IO004_SetPin(CONT_CLK);
	IO004_ResetPin(ATT);
	delay(tempoInicio);

	psxByte = 1;
	psxTrocaByte(psxByte);

	psxByte = 0x43;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	psxByte = 0x5A;
	psxTrocaByte(psxByte);

	psxByte = 0x5A;
	psxTrocaByte(psxByte);

	psxByte = 0x5A;
	psxTrocaByte(psxByte);

	psxByte = 0x5A;
	psxTrocaByte(psxByte);

	psxByte = 0x5A;
	psxTrocaByte(psxByte);

	IO004_SetPin(ATT);
}
Esempio n. 9
0
void psxSetAnalogMode() {
	int psxByte = 0;
	IO004_SetPin(CMD);
	IO004_SetPin(CONT_CLK);
	IO004_ResetPin(ATT);
	delay(tempoInicio);

	psxByte = 1;
	psxTrocaByte(psxByte);

	psxByte = 0x44;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	psxByte = 0x1;
	psxTrocaByte(psxByte);

	psxByte = 0x3;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	psxByte = 0;
	psxTrocaByte(psxByte);

	IO004_SetPin(ATT);
}
Esempio n. 10
0
void pulse_R() {
	delay(300);
	IO004_SetPin(CLK1);
	delay(300);
	IO004_ResetPin(CLK1);
}