Fix gain, DC offset
This commit is contained in:
		
							parent
							
								
									347582cfc1
								
							
						
					
					
						commit
						1fe4633601
					
				
					 2 changed files with 14 additions and 12 deletions
				
			
		|  | @ -374,7 +374,7 @@ blocks: | |||
|     freq7: 100e6 | ||||
|     freq8: 100e6 | ||||
|     freq9: 100e6 | ||||
|     gain0: '0' | ||||
|     gain0: '30' | ||||
|     gain1: '10' | ||||
|     gain10: '10' | ||||
|     gain11: '10' | ||||
|  |  | |||
							
								
								
									
										24
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/main.c
									
									
									
									
									
								
							|  | @ -22,7 +22,7 @@ | |||
| #include <stdlib.h> | ||||
| 
 | ||||
| #define VREG_VOLTAGE VREG_VOLTAGE_1_20 | ||||
| #define CLK_SYS_HZ (288 * MHZ) | ||||
| #define CLK_SYS_HZ (300 * MHZ) | ||||
| 
 | ||||
| #define INIT_SAMPLE_RATE 200000 | ||||
| #define INIT_FREQ 94600000 | ||||
|  | @ -559,11 +559,13 @@ inline static struct IQ next_sample() | |||
| 	I *= gain; | ||||
| 	I /= 1024; | ||||
| 	I *= max_amplitude_mul; | ||||
| 	I += 127.4 * (1 << 16); | ||||
| 	I /= (1 << 16); | ||||
| 
 | ||||
| 	Q *= gain; | ||||
| 	Q /= 1024; | ||||
| 	Q *= max_amplitude_mul; | ||||
| 	Q += 127.4 * (1 << 16); | ||||
| 	Q /= (1 << 16); | ||||
| 
 | ||||
| 	return (struct IQ){ I, Q }; | ||||
|  | @ -586,19 +588,19 @@ static void rf_rx(void) | |||
| 			int64_t I = IQ.I; | ||||
| 			int64_t Q = IQ.Q; | ||||
| 
 | ||||
| 			if (I > 127) | ||||
| 				I = 127; | ||||
| 			else if (I < -128) | ||||
| 				I = -128; | ||||
| 			if (I < 0) | ||||
| 				I = 0; | ||||
| 			else if (I > 255) | ||||
| 				I = 255; | ||||
| 
 | ||||
| 			*blockptr++ = (uint8_t)I + 128; | ||||
| 			*blockptr++ = I; | ||||
| 
 | ||||
| 			if (Q > 127) | ||||
| 				Q = 127; | ||||
| 			else if (Q < -128) | ||||
| 				Q = -128; | ||||
| 			if (Q < 0) | ||||
| 				Q = 0; | ||||
| 			else if (Q > 255) | ||||
| 				Q = 255; | ||||
| 
 | ||||
| 			*blockptr++ = (uint8_t)Q + 128; | ||||
| 			*blockptr++ = Q; | ||||
| 		} | ||||
| 
 | ||||
| 		if (queue_try_add(&iq_queue, &block)) { | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue