mirror of
				https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
				synced 2025-10-31 11:21:06 +00:00 
			
		
		
		
	Global def for the common RX variables
This commit is contained in:
		
							parent
							
								
									e0e51eb187
								
							
						
					
					
						commit
						5ae4f0288b
					
				| @ -21,9 +21,6 @@ | ||||
| #define AFHDS2A_RX_RXPACKET_SIZE	37 | ||||
| #define AFHDS2A_RX_NUMFREQ			16 | ||||
| 
 | ||||
| static uint8_t afhds2a_rx_data_started; | ||||
| static uint8_t afhds2a_rx_disable_lna; | ||||
| 
 | ||||
| enum { | ||||
| 	AFHDS2A_RX_BIND1, | ||||
| 	AFHDS2A_RX_BIND2, | ||||
| @ -70,9 +67,9 @@ uint16_t initAFHDS2A_Rx() | ||||
| 	A7105_Init(); | ||||
| 	hopping_frequency_no = 0; | ||||
| 	packet_count = 0; | ||||
| 	afhds2a_rx_data_started = 0; | ||||
| 	afhds2a_rx_disable_lna = IS_POWER_FLAG_on; | ||||
| 	CC2500_SetTxRxMode(afhds2a_rx_disable_lna ? TXRX_OFF : RX_EN); | ||||
| 	rx_data_started = 0; | ||||
| 	rx_disable_lna = IS_POWER_FLAG_on; | ||||
| 	CC2500_SetTxRxMode(rx_disable_lna ? TXRX_OFF : RX_EN); | ||||
| 	A7105_Strobe(A7105_RX); | ||||
| 
 | ||||
| 	if (IS_BIND_IN_PROGRESS) { | ||||
| @ -102,9 +99,9 @@ uint16_t AFHDS2A_Rx_callback() | ||||
| #ifndef FORCE_AFHDS2A_TUNING | ||||
| 	A7105_AdjustLOBaseFreq(1); | ||||
| #endif | ||||
| 	if (afhds2a_rx_disable_lna != IS_POWER_FLAG_on) { | ||||
| 		afhds2a_rx_disable_lna = IS_POWER_FLAG_on; | ||||
| 		CC2500_SetTxRxMode(afhds2a_rx_disable_lna ? TXRX_OFF : RX_EN); | ||||
| 	if (rx_disable_lna != IS_POWER_FLAG_on) { | ||||
| 		rx_disable_lna = IS_POWER_FLAG_on; | ||||
| 		CC2500_SetTxRxMode(rx_disable_lna ? TXRX_OFF : RX_EN); | ||||
| 	} | ||||
| 
 | ||||
| 	switch(phase) { | ||||
| @ -155,7 +152,7 @@ uint16_t AFHDS2A_Rx_callback() | ||||
| 	case AFHDS2A_RX_BIND2 | AFHDS2A_RX_WAIT_WRITE: | ||||
| 		//Wait for TX completion
 | ||||
| 		pps_timer = micros(); | ||||
| 		while (micros() - pps_timer < 700) // Wait max 700µs, using serial+telemetry exit in about 120µs
 | ||||
| 		while (micros() - pps_timer < 700) // Wait max 700µs, using serial+telemetry exit in about 120µs
 | ||||
| 			if (!(A7105_ReadReg(A7105_00_MODE) & 0x01)) | ||||
| 				break; | ||||
| 		A7105_Strobe(A7105_RX); | ||||
| @ -172,7 +169,7 @@ uint16_t AFHDS2A_Rx_callback() | ||||
| 					AFHDS2A_Rx_build_telemetry_packet(); | ||||
| 					telemetry_link = 1; | ||||
| 				} | ||||
| 				afhds2a_rx_data_started = 1; | ||||
| 				rx_data_started = 1; | ||||
| 				read_retry = 10; // hop to next channel
 | ||||
| 				pps_counter++; | ||||
| 			} | ||||
| @ -193,7 +190,7 @@ uint16_t AFHDS2A_Rx_callback() | ||||
| 				hopping_frequency_no = 0; | ||||
| 			A7105_WriteReg(A7105_0F_PLL_I, hopping_frequency[hopping_frequency_no]); | ||||
| 			A7105_Strobe(A7105_RX); | ||||
| 			if (afhds2a_rx_data_started) | ||||
| 			if (rx_data_started) | ||||
| 				read_retry = 0; | ||||
| 			else | ||||
| 				read_retry = -127; // retry longer until first packet is catched
 | ||||
|  | ||||
| @ -30,10 +30,7 @@ | ||||
|  }; | ||||
| 
 | ||||
| static uint8_t frsky_rx_chanskip; | ||||
|  static uint8_t frsky_rx_disable_lna; | ||||
|  static uint8_t frsky_rx_data_started; | ||||
| static int8_t  frsky_rx_finetune; | ||||
|  static uint16_t frsky_rx_rc_chan[16]; | ||||
| 
 | ||||
| static void __attribute__((unused)) frsky_rx_strobe_rx() | ||||
| { | ||||
| @ -60,8 +57,8 @@ static void __attribute__((unused)) frsky_rx_initialise() { | ||||
| 		CC2500_WriteReg(CC2500_23_FSCAL3, 0x89); // fixed FSCAL3 ?
 | ||||
| 		break; | ||||
| 	} | ||||
| 	frsky_rx_disable_lna = IS_POWER_FLAG_on; | ||||
| 	CC2500_SetTxRxMode(frsky_rx_disable_lna ? TXRX_OFF : RX_EN); // lna disable / enable
 | ||||
| 	rx_disable_lna = IS_POWER_FLAG_on; | ||||
| 	CC2500_SetTxRxMode(rx_disable_lna ? TXRX_OFF : RX_EN); // lna disable / enable
 | ||||
| 	frsky_rx_strobe_rx(); | ||||
| 	delayMicroseconds(1000); // wait for RX to activate
 | ||||
| } | ||||
| @ -121,9 +118,9 @@ static void __attribute__((unused)) frsky_rx_build_telemetry_packet() | ||||
| 			uint8_t shifted = (raw_channel[i] & 0x800)>0; | ||||
| 			uint16_t channel_value = raw_channel[i] & 0x7FF; | ||||
| 			if (channel_value < 64) | ||||
| 				frsky_rx_rc_chan[shifted ? i + 8 : i] = 0; | ||||
| 				rx_rc_chan[shifted ? i + 8 : i] = 0; | ||||
| 			else | ||||
| 				frsky_rx_rc_chan[shifted ? i + 8 : i] = min(((channel_value - 64) << 4) / 15, 2047); | ||||
| 				rx_rc_chan[shifted ? i + 8 : i] = min(((channel_value - 64) << 4) / 15, 2047); | ||||
| 		} | ||||
| 	} | ||||
| 	else { | ||||
| @ -139,7 +136,7 @@ static void __attribute__((unused)) frsky_rx_build_telemetry_packet() | ||||
| 		for (i = 0; i < 8; i++) { | ||||
| 			if (raw_channel[i] < 1290) | ||||
| 				raw_channel[i] = 1290; | ||||
| 			frsky_rx_rc_chan[i] = min(((raw_channel[i] - 1290) << 4) / 15, 2047); | ||||
| 			rx_rc_chan[i] = min(((raw_channel[i] - 1290) << 4) / 15, 2047); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| @ -151,7 +148,7 @@ static void __attribute__((unused)) frsky_rx_build_telemetry_packet() | ||||
| 
 | ||||
| 	// pack channels
 | ||||
| 	for (i = 0; i < packet_in[3]; i++) { | ||||
| 		bits |= ((uint32_t)frsky_rx_rc_chan[i]) << bitsavailable; | ||||
| 		bits |= ((uint32_t)rx_rc_chan[i]) << bitsavailable; | ||||
| 		bitsavailable += 11; | ||||
| 		while (bitsavailable >= 8) { | ||||
| 			packet_in[idx++] = bits & 0xff; | ||||
| @ -169,11 +166,9 @@ uint16_t initFrSky_Rx() | ||||
| 	state = 0; | ||||
| 	frsky_rx_chanskip = 1; | ||||
| 	hopping_frequency_no = 0; | ||||
| 	frsky_rx_data_started = 0; | ||||
| 	rx_data_started = 0; | ||||
| 	frsky_rx_finetune = 0; | ||||
| 	telemetry_link = 0; | ||||
| 	for(uint8_t ch=0; ch<16; ch++) | ||||
| 		frsky_rx_rc_chan[ch] = 1023; | ||||
| 	if (IS_BIND_IN_PROGRESS) { | ||||
| 		phase = FRSKY_RX_TUNE_START; | ||||
| 	} | ||||
| @ -217,9 +212,9 @@ uint16_t FrSky_Rx_callback() | ||||
| 		prev_option = option; | ||||
| 	} | ||||
| 
 | ||||
| 	if (frsky_rx_disable_lna != IS_POWER_FLAG_on) { | ||||
| 		frsky_rx_disable_lna = IS_POWER_FLAG_on; | ||||
| 		CC2500_SetTxRxMode(frsky_rx_disable_lna ? TXRX_OFF : RX_EN); | ||||
| 	if (rx_disable_lna != IS_POWER_FLAG_on) { | ||||
| 		rx_disable_lna = IS_POWER_FLAG_on; | ||||
| 		CC2500_SetTxRxMode(rx_disable_lna ? TXRX_OFF : RX_EN); | ||||
| 	} | ||||
| 
 | ||||
| 	len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F; | ||||
| @ -334,7 +329,7 @@ uint16_t FrSky_Rx_callback() | ||||
| 						frsky_rx_build_telemetry_packet(); | ||||
| 						telemetry_link = 1; | ||||
| 				} | ||||
| 				frsky_rx_data_started = 1; | ||||
| 				rx_data_started = 1; | ||||
| 				read_retry = 0; | ||||
| 				pps_counter++; | ||||
| 			} | ||||
| @ -352,7 +347,7 @@ uint16_t FrSky_Rx_callback() | ||||
| 		if (read_retry++ >= 9) { | ||||
| 			hopping_frequency_no = (hopping_frequency_no + frsky_rx_chanskip) % 47; | ||||
| 			frsky_rx_set_channel(hopping_frequency_no); | ||||
| 			if(frsky_rx_data_started) | ||||
| 			if(rx_data_started) | ||||
| 				read_retry = 0; | ||||
| 			else | ||||
| 				read_retry = -50; // retry longer until first packet is catched
 | ||||
|  | ||||
| @ -19,7 +19,7 @@ | ||||
| #define VERSION_MAJOR		1 | ||||
| #define VERSION_MINOR		3 | ||||
| #define VERSION_REVISION	0 | ||||
| #define VERSION_PATCH_LEVEL	14 | ||||
| #define VERSION_PATCH_LEVEL	15 | ||||
| 
 | ||||
| //******************
 | ||||
| // Protocols
 | ||||
|  | ||||
| @ -217,6 +217,13 @@ uint8_t packet_in[TELEMETRY_BUFFER_SIZE];//telemetry receiving packets | ||||
| 		uint8_t	SportData[MAX_SPORT_BUFFER]; | ||||
| 		uint8_t	SportHead=0, SportTail=0; | ||||
| 	#endif | ||||
| 
 | ||||
| 	//RX protocols
 | ||||
| 	#if defined(AFHDS2A_RX_A7105_INO) || defined(FRSKY_RX_CC2500_INO) | ||||
| 		uint8_t rx_data_started; | ||||
| 		uint8_t rx_disable_lna; | ||||
| 		uint16_t rx_rc_chan[16]; | ||||
| 	#endif | ||||
| #endif // TELEMETRY
 | ||||
| 
 | ||||
| // Callback
 | ||||
| @ -955,6 +962,10 @@ static void protocol_init() | ||||
| 			TX_RX_PAUSE_off; | ||||
| 			TX_MAIN_PAUSE_off; | ||||
| 			tx_resume(); | ||||
| 			#if defined(AFHDS2A_RX_A7105_INO) || defined(FRSKY_RX_CC2500_INO) | ||||
| 				for(uint8_t ch=0; ch<16; ch++) | ||||
| 					rx_rc_chan[ch] = 1024; | ||||
| 			#endif | ||||
| 		#endif | ||||
| 
 | ||||
| 		//Set global ID and rx_tx_addr
 | ||||
|  | ||||
| @ -309,7 +309,7 @@ | ||||
| 	#if not defined(DSM_CYRF6936_INO) | ||||
| 		#undef DSM_TELEMETRY | ||||
| 	#endif | ||||
| 	#if not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) | ||||
| 	#if not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) | ||||
| 		#undef TELEMETRY | ||||
| 		#undef INVERT_TELEMETRY | ||||
| 	#endif | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user