예제 #1
0
파일: ehwutl.c 프로젝트: bigrpg/evrcc
void xDispLw(Longword in)
{

	printf("0x");
	sprintf(line, "%4x", (in >> 16) & 0xffff);
	pHex(line, 4);
	printf(" ");
	sprintf(line, "%4x", in & 0xffff);
	pHex(line, 4);
	printf(" ");

}
예제 #2
0
파일: ehwutl.c 프로젝트: bigrpg/evrcc
void xDispSns(struct NormSw snsIn)
{

	printf("0x");
	sprintf(line, "%4x", snsIn.man);
	pHex(line, 4);
	printf(" ");

	sprintf(line, "%2d", snsIn.sh);
	pHex(line, 2);
	printf(" ");

}
예제 #3
0
파일: cc110x.cpp 프로젝트: LineF/AskSin
uint8_t CC110x::receiveData(uint8_t *buf) {												// read data packet from RX FIFO
	uint8_t rxBytes = readReg(CC1101_RXBYTES, CC1101_STATUS);							// how many bytes are in the buffer
	
	//Serial << rxBytes << F(" ");

	if ((rxBytes & 0x7F) && !(rxBytes & 0x80)) {										// any byte waiting to be read and no overflow?
		buf[0] = readReg(CC1101_RXFIFO, CC1101_CONFIG);									// read data length

		if (buf[0] > CC1101_DATA_LEN)													// if packet is too long
			buf[0] = 0;																	// discard packet
		else {
			readBurst(&buf[1], CC1101_RXFIFO, buf[0]);									// read data packet
			readReg(CC1101_RXFIFO, CC1101_CONFIG);										// read RSSI

			uint8_t val = readReg(CC1101_RXFIFO, CC1101_CONFIG);						// read LQI and CRC_OK
			lqi = val & 0x7F;
			crc_ok = bitRead(val, 7);
		}
	} else {
		buf[0] = 0;																		// nothing to do, or overflow
	}

	cmdStrobe(CC1101_SFRX);																// flush Rx FIFO
	cmdStrobe(CC1101_SIDLE);															// enter IDLE state
	cmdStrobe(CC1101_SRX);																// back to RX state
	cmdStrobe(CC1101_SWORRST);															// reset real time clock
//	trx868.rfState = RFSTATE_RX;														// declare to be in Rx state

	#if defined(CC_DBG)																	// debug message, string should be short, otherwise program stops
		if (buf[0] > 0) Serial; pHex(&buf[1], buf[0], SERIAL_DBG_MODE_LEN | SERIAL_DBG_PHEX_MODE_TIME);
	#endif

	return buf[0];																		// return the data buffer
}
예제 #4
0
파일: ehwutl.c 프로젝트: bigrpg/evrcc
void xDispSw(Shortword in)
{
	printf("0x");
	sprintf(line, "%4x", in);
	pHex(line, 4);
	printf(" ");
}
예제 #5
0
파일: Relay.cpp 프로젝트: kaiman1234/AskSin
void Relay::peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len) {
	// we received a peer event, in type you will find the marker if it was a switch(3E), remote(40) or sensor(41) event
	// appropriate answer is an ACK
	#ifdef DM_DBG
	Serial << F("peerMsgEvent, type: ")  << pHexB(type) << F(", data: ")  << pHex(data,len) << '\n';
	#endif
	
	//hm->send_ACK();
}
예제 #6
0
파일: Dummy.cpp 프로젝트: LineF/AskSin
void Dummy::peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len) {
	// we received a peer event, in type you will find the marker if it was a switch(3E), remote(40) or sensor(41) event
	// appropriate answer is an ACK
	#ifdef DM_DBG
		Serial << F("peerMsgEvent, type: "); pHexB(type);
		Serial << F(", data: "); pHex(data,len, SERIAL_DBG_PHEX_MODE_LF);
	#endif
	
	hm->send_ACK();
}
예제 #7
0
파일: cc110x.cpp 프로젝트: LineF/AskSin
uint8_t CC110x::sendData(uint8_t *buf, uint8_t burst) {									// send data packet via RF

	// Going from RX to TX does not work if there was a reception less than 0.5
	// sec ago. Due to CCA? Using IDLE helps to shorten this period(?)
	//ccStrobe(CC1100_SIDLE);
	//uint8_t cnt = 0xff;
	//while(cnt-- && (ccStrobe( CC1100_STX ) & 0x70) != 2)
	//my_delay_us(10);
 	cmdStrobe(CC1101_SIDLE);															// go to idle mode
	cmdStrobe(CC1101_SFRX );															// flush RX buffer
	cmdStrobe(CC1101_SFTX );															// flush TX buffer

	//Serial << F("tx\n");

	if (burst) {																		// BURST-bit set?
		cmdStrobe(CC1101_STX  );														// send a burst
		_delay_ms(359);																	// according to ELV, devices get activated every 300ms, so send burst for 360ms
		//Serial << F("send burst\n");
	}
	_delay_ms(1);																		// wait a short time to set TX mode

	writeBurst(CC1101_TXFIFO, buf, buf[0]+1);											// write in TX FIFO

	cmdStrobe(CC1101_SFRX);																// flush the RX buffer
	cmdStrobe(CC1101_STX);																// send a burst

	for(uint8_t i=0; i< 200;++i) {														// after sending out all bytes the chip should go automatically in RX mode
		if( readReg(CC1101_MARCSTATE, CC1101_STATUS) == MARCSTATE_RX)
			break;																		//now in RX mode, good
		if( readReg(CC1101_MARCSTATE, CC1101_STATUS) != MARCSTATE_TX) {
			break;																		//neither in RX nor TX, probably some error
		}
		_delay_us(10);
	}

	//uint8_t cnt = 0xff;
	//while(cnt-- && (sendSPI(CC1101_SRX) & 0x70) != 1)
	//delayMicroseconds(10);

	#if defined(CC_DBG)																	// some debug message
		Serial << F("<- "); pHex(&buf[0], buf[0]+1, SERIAL_DBG_MODE_LEN | SERIAL_DBG_PHEX_MODE_TIME);
	#endif

	//Serial << F("rx\n");
	return true;
}