Revision 620c5db0 usrp2/firmware/lib/db_dbsrx.c
| b/usrp2/firmware/lib/db_dbsrx.c | ||
|---|---|---|
| 107 | 107 |
bool |
| 108 | 108 |
db_dbsrx_init(struct db_base *dbb){
|
| 109 | 109 |
struct db_dbsrx_dummy *db = (struct db_dbsrx_dummy *) dbb; |
| 110 |
db->base.set_gain(dbb, (db->base.gain_max - db->base.gain_min)/2);
|
|
| 110 |
db->base.set_gain(dbb, (db->base.gain_max + db->base.gain_min)/2);
|
|
| 111 | 111 |
clocks_enable_rx_dboard(true, REFCLK_DIVISOR); // Gives 4 MHz clock |
| 112 | 112 |
return true; |
| 113 | 113 |
} |
| ... | ... | |
| 115 | 115 |
/************************************************** |
| 116 | 116 |
* Registers |
| 117 | 117 |
**************************************************/ |
| 118 |
int |
|
| 118 |
static int
|
|
| 119 | 119 |
_read_adc (void){
|
| 120 | 120 |
unsigned char readback[2]; |
| 121 | 121 |
i2c_read(I2C_ADDR, readback, 2*sizeof(unsigned char)); |
| ... | ... | |
| 125 | 125 |
return adc_val; |
| 126 | 126 |
} |
| 127 | 127 |
|
| 128 |
void |
|
| 128 |
static void
|
|
| 129 | 129 |
_write_reg (int regno, int v){
|
| 130 | 130 |
//regno is in [0,5], v is value to write to register""" |
| 131 | 131 |
unsigned char args[2]; |
| ... | ... | |
| 135 | 135 |
printf("Reg %d, Val %x\n",regno,v);
|
| 136 | 136 |
} |
| 137 | 137 |
|
| 138 |
void _send_reg_0(struct db_dbsrx_dummy *db){
|
|
| 138 |
static void _send_reg_0(struct db_dbsrx_dummy *db){
|
|
| 139 | 139 |
_write_reg(0,(db->common.d_div2<<7) + (db->common.d_n>>8)); |
| 140 | 140 |
} |
| 141 | 141 |
|
| 142 |
void _send_reg_1(struct db_dbsrx_dummy *db){
|
|
| 142 |
static void _send_reg_1(struct db_dbsrx_dummy *db){
|
|
| 143 | 143 |
_write_reg(1,db->common.d_n & 255); |
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 |
void _send_reg_2(struct db_dbsrx_dummy *db){
|
|
| 146 |
static void _send_reg_2(struct db_dbsrx_dummy *db){
|
|
| 147 | 147 |
_write_reg(2,db->common.d_osc + (db->common.d_cp<<3) + (db->common.d_r_reg<<5)); |
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 |
void _send_reg_3(struct db_dbsrx_dummy *db){
|
|
| 150 |
static void _send_reg_3(struct db_dbsrx_dummy *db){
|
|
| 151 | 151 |
_write_reg(3,db->common.d_fdac); |
| 152 | 152 |
} |
| 153 | 153 |
|
| 154 |
void _send_reg_4(struct db_dbsrx_dummy *db){
|
|
| 154 |
static void _send_reg_4(struct db_dbsrx_dummy *db){
|
|
| 155 | 155 |
_write_reg(4,db->common.d_m + (db->common.d_dl<<5) + (db->common.d_ade<<6) + (db->common.d_adl<<7)); |
| 156 | 156 |
} |
| 157 | 157 |
|
| 158 |
void _send_reg_5(struct db_dbsrx_dummy *db){
|
|
| 158 |
static void _send_reg_5(struct db_dbsrx_dummy *db){
|
|
| 159 | 159 |
_write_reg(5,db->common.d_gc2 + (db->common.d_diag<<5)); |
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 | 162 |
/************************************************** |
| 163 | 163 |
* Helpers for setting the freq |
| 164 | 164 |
**************************************************/ |
| 165 |
void |
|
| 165 |
static void
|
|
| 166 | 166 |
_set_div2(struct db_dbsrx_dummy *db, int div2){
|
| 167 | 167 |
db->common.d_div2 = div2; |
| 168 | 168 |
_send_reg_0(db); |
| 169 | 169 |
} |
| 170 | 170 |
|
| 171 | 171 |
// FIXME How do we handle ADE and ADL properly? |
| 172 |
void |
|
| 172 |
static void
|
|
| 173 | 173 |
_set_ade(struct db_dbsrx_dummy *db, int ade){
|
| 174 | 174 |
db->common.d_ade = ade; |
| 175 | 175 |
_send_reg_4(db); |
| 176 | 176 |
} |
| 177 | 177 |
|
| 178 |
void |
|
| 178 |
static void
|
|
| 179 | 179 |
_set_r(struct db_dbsrx_dummy *db, int r){
|
| 180 | 180 |
db->common.d_r_reg = r; |
| 181 | 181 |
_send_reg_2(db); |
| 182 | 182 |
} |
| 183 | 183 |
|
| 184 |
void |
|
| 184 |
static void
|
|
| 185 | 185 |
_set_n(struct db_dbsrx_dummy *db, int n){
|
| 186 | 186 |
db->common.d_n = n; |
| 187 | 187 |
_send_reg_0(db); |
| 188 | 188 |
_send_reg_1(db); |
| 189 | 189 |
} |
| 190 | 190 |
|
| 191 |
void |
|
| 191 |
static void
|
|
| 192 | 192 |
_set_osc(struct db_dbsrx_dummy *db, int osc){
|
| 193 | 193 |
db->common.d_osc = osc; |
| 194 | 194 |
_send_reg_2(db); |
| 195 | 195 |
} |
| 196 | 196 |
|
| 197 |
void |
|
| 197 |
static void
|
|
| 198 | 198 |
_set_cp(struct db_dbsrx_dummy *db, int cp){
|
| 199 | 199 |
db->common.d_cp = cp; |
| 200 | 200 |
_send_reg_2(db); |
| ... | ... | |
| 330 | 330 |
* Helpers for setting the gain |
| 331 | 331 |
**************************************************/ |
| 332 | 332 |
|
| 333 |
void |
|
| 333 |
static void
|
|
| 334 | 334 |
_set_gc2(struct db_dbsrx_dummy *db, int gc2){
|
| 335 | 335 |
db->common.d_gc2 = gc2; |
| 336 | 336 |
_send_reg_5(db); |
| ... | ... | |
| 380 | 380 |
/************************************************** |
| 381 | 381 |
* Helpers for setting the bw |
| 382 | 382 |
**************************************************/ |
| 383 |
void |
|
| 383 |
static void
|
|
| 384 | 384 |
_set_m(struct db_dbsrx_dummy *db, int m){
|
| 385 | 385 |
db->common.d_m = m; |
| 386 | 386 |
_send_reg_4(db); |
| 387 | 387 |
} |
| 388 | 388 |
|
| 389 |
void |
|
| 389 |
static void
|
|
| 390 | 390 |
_set_fdac(struct db_dbsrx_dummy *db, int fdac){
|
| 391 | 391 |
db->common.d_fdac = fdac; |
| 392 | 392 |
_send_reg_3(db); |
Also available in: Unified diff