mirror of
				https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
				synced 2025-10-30 18:55:21 +00:00 
			
		
		
		
	FrSkyR9: TQLY = percentage of telemetry frames per second
This commit is contained in:
		
							parent
							
								
									78421748ba
								
							
						
					
					
						commit
						84132678cc
					
				| @ -90,8 +90,6 @@ uint16_t initAFHDS2A_Rx() | |||||||
| 
 | 
 | ||||||
| uint16_t AFHDS2A_Rx_callback() | uint16_t AFHDS2A_Rx_callback() | ||||||
| { | { | ||||||
| 	static uint32_t pps_timer = 0; |  | ||||||
| 	static uint16_t pps_counter = 0; |  | ||||||
| 	static int8_t read_retry; | 	static int8_t read_retry; | ||||||
| 	int16_t temp; | 	int16_t temp; | ||||||
| 	uint8_t i; | 	uint8_t i; | ||||||
|  | |||||||
| @ -126,8 +126,6 @@ uint16_t Bayang_Rx_callback() | |||||||
| { | { | ||||||
| 	uint8_t i; | 	uint8_t i; | ||||||
| 	static int8_t read_retry; | 	static int8_t read_retry; | ||||||
| 	static uint16_t pps_counter; |  | ||||||
| 	static uint32_t pps_timer = 0; |  | ||||||
| 
 | 
 | ||||||
| 	switch (phase) { | 	switch (phase) { | ||||||
| 	case BAYANG_RX_BIND: | 	case BAYANG_RX_BIND: | ||||||
|  | |||||||
| @ -209,8 +209,6 @@ uint16_t DSM_Rx_callback() | |||||||
| { | { | ||||||
| 	uint8_t rx_status; | 	uint8_t rx_status; | ||||||
| 	static uint8_t read_retry=0; | 	static uint8_t read_retry=0; | ||||||
| 	static uint16_t pps_counter; |  | ||||||
| 	static uint32_t pps_timer = 0; |  | ||||||
| 
 | 
 | ||||||
| 	switch (phase) | 	switch (phase) | ||||||
| 	{ | 	{ | ||||||
|  | |||||||
| @ -381,7 +381,7 @@ void Frsky_init_clone(void) | |||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if defined(FRSKYX_CC2500_INO) || defined(FRSKYL_CC2500_INO) || defined(FRSKYR9_SX1276_INO) | #if defined(FRSKYX_CC2500_INO) || defined(FRSKYR9_SX1276_INO) | ||||||
| uint8_t FrSkyX_TX_Seq, FrSkyX_TX_IN_Seq; | uint8_t FrSkyX_TX_Seq, FrSkyX_TX_IN_Seq; | ||||||
| uint8_t FrSkyX_RX_Seq ; | uint8_t FrSkyX_RX_Seq ; | ||||||
| 
 | 
 | ||||||
| @ -394,6 +394,20 @@ uint8_t FrSkyX_RX_Seq ; | |||||||
| 		// Store FrskyX telemetry
 | 		// Store FrskyX telemetry
 | ||||||
| 		struct t_FrSkyX_TX_Frame FrSkyX_TX_Frames[4] ; | 		struct t_FrSkyX_TX_Frame FrSkyX_TX_Frames[4] ; | ||||||
| 	#endif | 	#endif | ||||||
|  | 
 | ||||||
|  | static void __attribute__((unused)) FrSkyX_telem_init(void) | ||||||
|  | { | ||||||
|  | 	FrSkyX_TX_Seq = 0x08 ;				// Request init
 | ||||||
|  | 	#ifdef SPORT_SEND | ||||||
|  | 		FrSkyX_TX_IN_Seq = 0xFF ;		// No sequence received yet
 | ||||||
|  | 		for(uint8_t i=0;i<4;i++) | ||||||
|  | 			FrSkyX_TX_Frames[i].count=0;// discard frames in current output buffer
 | ||||||
|  | 		SportHead=SportTail=0;			// empty data buffer
 | ||||||
|  | 	#endif | ||||||
|  | 	FrSkyX_RX_Seq = 0 ;					// Seq 0 to start with
 | ||||||
|  | 	telemetry_lost=1; | ||||||
|  | 	telemetry_link=0;					//Stop sending telemetry
 | ||||||
|  | } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if defined(FRSKYX_CC2500_INO) || defined(FRSKYL_CC2500_INO) | #if defined(FRSKYX_CC2500_INO) || defined(FRSKYL_CC2500_INO) | ||||||
|  | |||||||
| @ -113,17 +113,9 @@ uint16_t initFrSkyR9() | |||||||
| 	SX1276_SetPaDac(true); | 	SX1276_SetPaDac(true); | ||||||
| 	SX1276_SetTxRxMode(TX_EN);			// Set RF switch to TX
 | 	SX1276_SetTxRxMode(TX_EN);			// Set RF switch to TX
 | ||||||
| 
 | 
 | ||||||
| 	FrSkyX_TX_Seq = 0x08 ;					// Request init
 | 	FrSkyX_telem_init(); | ||||||
| 	FrSkyX_TX_IN_Seq = 0xFF ;				// No sequence received yet
 |  | ||||||
| 	#ifdef SPORT_SEND |  | ||||||
| 		for(uint8_t i=0;i<4;i++) |  | ||||||
| 			FrSkyX_TX_Frames[i].count=0;	// discard frames in current output buffer
 |  | ||||||
| 		SportHead=SportTail=0;				// empty data buffer
 |  | ||||||
| 	#endif |  | ||||||
| 	FrSkyX_RX_Seq = 0 ;						// Seq 0 to start with
 |  | ||||||
| 	 | 	 | ||||||
| 	phase=FRSKYR9_FREQ; | 	phase=FRSKYR9_FREQ; | ||||||
| 
 |  | ||||||
| 	return 20000;						// start calling FrSkyR9_callback in 20 milliseconds
 | 	return 20000;						// start calling FrSkyR9_callback in 20 milliseconds
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -176,7 +168,6 @@ uint16_t FrSkyR9_callback() | |||||||
| 			phase++; | 			phase++; | ||||||
| 			return 7400; | 			return 7400; | ||||||
| 		case FRSKYR9_RX2: | 		case FRSKYR9_RX2: | ||||||
| 			telemetry_link=0; |  | ||||||
| 			if( (SX1276_ReadReg(SX1276_12_REGIRQFLAGS)&0xF0) == (_BV(SX1276_REGIRQFLAGS_RXDONE) | _BV(SX1276_REGIRQFLAGS_VALIDHEADER)) ) | 			if( (SX1276_ReadReg(SX1276_12_REGIRQFLAGS)&0xF0) == (_BV(SX1276_REGIRQFLAGS_RXDONE) | _BV(SX1276_REGIRQFLAGS_VALIDHEADER)) ) | ||||||
| 			{ | 			{ | ||||||
| 				if(SX1276_ReadReg(SX1276_13_REGRXNBBYTES)==13) | 				if(SX1276_ReadReg(SX1276_13_REGRXNBBYTES)==13) | ||||||
| @ -188,34 +179,27 @@ uint16_t FrSkyR9_callback() | |||||||
| 							RX_RSSI=packet_in[0]<<1; | 							RX_RSSI=packet_in[0]<<1; | ||||||
| 						else | 						else | ||||||
| 							v_lipo1=(packet_in[0]<<1)+1; | 							v_lipo1=(packet_in[0]<<1)+1; | ||||||
| 						TX_LQI=~(SX1276_ReadReg(SX1276_19_PACKETSNR)>>2)+1; | 						//TX_LQI=~(SX1276_ReadReg(SX1276_19_PACKETSNR)>>2)+1;
 | ||||||
| 						TX_RSSI=SX1276_ReadReg(SX1276_1A_PACKETRSSI)-157; | 						TX_RSSI=SX1276_ReadReg(SX1276_1A_PACKETRSSI)-157; | ||||||
| 						for(uint8_t i=0;i<9;i++) | 						for(uint8_t i=0;i<9;i++) | ||||||
| 							packet[4+i]=packet_in[i];		//Adjust buffer to match FrSkyX
 | 							packet[4+i]=packet_in[i];		//Adjust buffer to match FrSkyX
 | ||||||
| 						frsky_process_telemetry(packet,len);	//Check and parse telemetry packets
 | 						frsky_process_telemetry(packet,len);	//Check and parse telemetry packets
 | ||||||
|  | 						pps_counter++; | ||||||
|  | 						if(TX_LQI==0) | ||||||
|  | 							TX_LQI++;						//Recover telemetry right away
 | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			if(!telemetry_link) | 			if (millis() - pps_timer >= 1000) | ||||||
| 			{ | 			{//50pps @20ms
 | ||||||
| 				packet_count++; | 				pps_timer = millis(); | ||||||
| 				//debugln("M %d",packet_count);
 | 				debugln("%d pps", pps_counter); | ||||||
| 				// restart sequence on missed packet - might need count or timeout instead of one missed
 | 				TX_LQI = pps_counter<<1;					// Max=100pps
 | ||||||
| 				if(packet_count>100) | 				pps_counter = 0; | ||||||
| 				{//~1sec
 |  | ||||||
| 					FrSkyX_TX_Seq = 0x08 ;					//Request init
 |  | ||||||
| 					FrSkyX_TX_IN_Seq = 0xFF ;				//No sequence received yet
 |  | ||||||
| 					#ifdef SPORT_SEND |  | ||||||
| 						for(uint8_t i=0;i<4;i++) |  | ||||||
| 							FrSkyX_TX_Frames[i].count=0;	//Discard frames in current output buffer
 |  | ||||||
| 					#endif |  | ||||||
| 					packet_count=0; |  | ||||||
| 					telemetry_lost=1; |  | ||||||
| 					telemetry_link=0;						//Stop sending telemetry
 |  | ||||||
| 			} | 			} | ||||||
| 				CC2500_Strobe(CC2500_SFRX);					//Flush the RXFIFO
 | 			if(TX_LQI==0) | ||||||
| 			} | 				FrSkyX_telem_init(); | ||||||
| 			if(!telemetry_lost) | 			else | ||||||
| 				telemetry_link=1;							// Send telemetry out anyway
 | 				telemetry_link=1;							// Send telemetry out anyway
 | ||||||
| 			//Clear all flags
 | 			//Clear all flags
 | ||||||
| 			SX1276_WriteReg(SX1276_12_REGIRQFLAGS,0xFF); | 			SX1276_WriteReg(SX1276_12_REGIRQFLAGS,0xFF); | ||||||
|  | |||||||
| @ -275,7 +275,6 @@ uint16_t ReadFrSkyX() | |||||||
| 			#endif | 			#endif | ||||||
| 			#if defined TELEMETRY | 			#if defined TELEMETRY | ||||||
| 				telemetry_link=1;										//Send telemetry out anyway
 | 				telemetry_link=1;										//Send telemetry out anyway
 | ||||||
| 			#endif |  | ||||||
| 				len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;	 | 				len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;	 | ||||||
| 				if (len && len <= 17)										//Telemetry frame is 17 bytes
 | 				if (len && len <= 17)										//Telemetry frame is 17 bytes
 | ||||||
| 				{ | 				{ | ||||||
| @ -290,7 +289,6 @@ uint16_t ReadFrSkyX() | |||||||
| 							len=17; | 							len=17; | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| 				#if defined TELEMETRY |  | ||||||
| 						if(len==17 && (protocol==PROTO_FRSKYX || (protocol==PROTO_FRSKYX2 && (packet_in[len-1] & 0x80))) ) | 						if(len==17 && (protocol==PROTO_FRSKYX || (protocol==PROTO_FRSKYX2 && (packet_in[len-1] & 0x80))) ) | ||||||
| 						{//Telemetry received with valid crc for FRSKYX2
 | 						{//Telemetry received with valid crc for FRSKYX2
 | ||||||
| 							//Debug
 | 							//Debug
 | ||||||
| @ -301,7 +299,6 @@ uint16_t ReadFrSkyX() | |||||||
| 							else | 							else | ||||||
| 								len=0;										// bad
 | 								len=0;										// bad
 | ||||||
| 						} | 						} | ||||||
| 				#endif |  | ||||||
| 					//debugln("");
 | 					//debugln("");
 | ||||||
| 				} | 				} | ||||||
| 				if(len!=17) | 				if(len!=17) | ||||||
| @ -309,22 +306,11 @@ uint16_t ReadFrSkyX() | |||||||
| 					packet_count++; | 					packet_count++; | ||||||
| 					//debugln("M %d",packet_count);
 | 					//debugln("M %d",packet_count);
 | ||||||
| 					// restart sequence on missed packet - might need count or timeout instead of one missed
 | 					// restart sequence on missed packet - might need count or timeout instead of one missed
 | ||||||
| 				if(packet_count>100) | 					if(packet_count>100)//~1sec
 | ||||||
| 				{//~1sec
 | 						FrSkyX_telem_init(); | ||||||
| 					FrSkyX_TX_Seq = 0x08 ;								//Request init
 |  | ||||||
| 					FrSkyX_TX_IN_Seq = 0xFF ;							//No sequence received yet
 |  | ||||||
| 					#ifdef SPORT_SEND |  | ||||||
| 						for(uint8_t i=0;i<4;i++) |  | ||||||
| 							FrSkyX_TX_Frames[i].count=0;				//Discard frames in current output buffer
 |  | ||||||
| 					#endif |  | ||||||
| 					packet_count=0; |  | ||||||
| 					#if defined TELEMETRY |  | ||||||
| 						telemetry_lost=1; |  | ||||||
| 						telemetry_link=0;								//Stop sending telemetry
 |  | ||||||
| 					#endif |  | ||||||
| 				} | 				} | ||||||
|  | 			#endif | ||||||
| 			CC2500_Strobe(CC2500_SFRX);								//Flush the RXFIFO
 | 			CC2500_Strobe(CC2500_SFRX);								//Flush the RXFIFO
 | ||||||
| 			} |  | ||||||
| 			state = FRSKY_DATA1; | 			state = FRSKY_DATA1; | ||||||
| 			return 400;	// FCC & LBT
 | 			return 400;	// FCC & LBT
 | ||||||
| 	} | 	} | ||||||
| @ -370,14 +356,7 @@ uint16_t initFrSkyX() | |||||||
| 		state = FRSKY_DATA1; | 		state = FRSKY_DATA1; | ||||||
| 		FrSkyX_initialize_data(0); | 		FrSkyX_initialize_data(0); | ||||||
| 	} | 	} | ||||||
| 	FrSkyX_TX_Seq = 0x08 ;					// Request init
 | 	FrSkyX_telem_init(); | ||||||
| 	FrSkyX_TX_IN_Seq = 0xFF ;				// No sequence received yet
 |  | ||||||
| 	#ifdef SPORT_SEND |  | ||||||
| 		for(uint8_t i=0;i<4;i++) |  | ||||||
| 			FrSkyX_TX_Frames[i].count=0;	// discard frames in current output buffer
 |  | ||||||
| 		SportHead=SportTail=0;				// empty data buffer
 |  | ||||||
| 	#endif |  | ||||||
| 	FrSkyX_RX_Seq = 0 ;						// Seq 0 to start with
 |  | ||||||
| 	return 10000; | 	return 10000; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  | |||||||
| @ -379,8 +379,6 @@ uint16_t initFrSky_Rx() | |||||||
| 
 | 
 | ||||||
| uint16_t FrSky_Rx_callback() | uint16_t FrSky_Rx_callback() | ||||||
| { | { | ||||||
| 	static uint32_t pps_timer=0; |  | ||||||
| 	static uint8_t pps_counter=0; |  | ||||||
| 	static int8_t read_retry = 0; | 	static int8_t read_retry = 0; | ||||||
| 	static int8_t tune_low, tune_high; | 	static int8_t tune_low, tune_high; | ||||||
| 	uint8_t len, ch; | 	uint8_t len, ch; | ||||||
|  | |||||||
| @ -274,10 +274,6 @@ static void __attribute__((unused)) HOTT_prep_data_packet() | |||||||
| 
 | 
 | ||||||
| uint16_t ReadHOTT() | uint16_t ReadHOTT() | ||||||
| { | { | ||||||
| 	#ifdef HOTT_FW_TELEMETRY |  | ||||||
| 		static uint8_t pps_counter=0; |  | ||||||
| 	#endif |  | ||||||
| 
 |  | ||||||
| 	switch(phase) | 	switch(phase) | ||||||
| 	{ | 	{ | ||||||
| 		case HOTT_START: | 		case HOTT_START: | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ | |||||||
| #define VERSION_MAJOR		1 | #define VERSION_MAJOR		1 | ||||||
| #define VERSION_MINOR		3 | #define VERSION_MINOR		3 | ||||||
| #define VERSION_REVISION	1 | #define VERSION_REVISION	1 | ||||||
| #define VERSION_PATCH_LEVEL	33 | #define VERSION_PATCH_LEVEL	34 | ||||||
| 
 | 
 | ||||||
| //******************
 | //******************
 | ||||||
| // Protocols
 | // Protocols
 | ||||||
|  | |||||||
| @ -119,6 +119,8 @@ uint16_t state; | |||||||
| uint8_t  len; | uint8_t  len; | ||||||
| uint8_t  armed, arm_flags, arm_channel_previous; | uint8_t  armed, arm_flags, arm_channel_previous; | ||||||
| uint8_t  num_ch; | uint8_t  num_ch; | ||||||
|  | uint32_t pps_timer = 0; | ||||||
|  | uint16_t pps_counter = 0; | ||||||
| 
 | 
 | ||||||
| #ifdef CC2500_INSTALLED | #ifdef CC2500_INSTALLED | ||||||
| 	#ifdef SCANNER_CC2500_INO | 	#ifdef SCANNER_CC2500_INO | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user