| 122 |
122 |
|
| 123 |
123 |
void lock_device(bool lock){
|
| 124 |
124 |
if (lock){
|
| 125 |
|
this->get_reg<boost::uint32_t, USRP2_REG_ACTION_FW_POKE32>(U2_FW_REG_LOCK_GPID, boost::uint32_t(get_gpid()));
|
|
125 |
this->pokefw(U2_FW_REG_LOCK_GPID, boost::uint32_t(get_gpid()));
|
| 126 |
126 |
_lock_task = task::make(boost::bind(&usrp2_iface_impl::lock_task, this));
|
| 127 |
127 |
}
|
| 128 |
128 |
else{
|
| 129 |
129 |
_lock_task.reset(); //shutdown the task
|
| 130 |
|
this->get_reg<boost::uint32_t, USRP2_REG_ACTION_FW_POKE32>(U2_FW_REG_LOCK_TIME, 0); //unlock
|
|
130 |
this->pokefw(U2_FW_REG_LOCK_TIME, 0); //unlock
|
| 131 |
131 |
}
|
| 132 |
132 |
}
|
| 133 |
133 |
|
| ... | ... | |
| 135 |
135 |
//never assume lock with fpga image mismatch
|
| 136 |
136 |
if ((this->peek32(U2_REG_COMPAT_NUM_RB) >> 16) != USRP2_FPGA_COMPAT_NUM) return false;
|
| 137 |
137 |
|
| 138 |
|
boost::uint32_t lock_time = this->get_reg<boost::uint32_t, USRP2_REG_ACTION_FW_PEEK32>(U2_FW_REG_LOCK_TIME);
|
| 139 |
|
boost::uint32_t lock_gpid = this->get_reg<boost::uint32_t, USRP2_REG_ACTION_FW_PEEK32>(U2_FW_REG_LOCK_GPID);
|
|
138 |
boost::uint32_t lock_time = this->peekfw(U2_FW_REG_LOCK_TIME);
|
|
139 |
boost::uint32_t lock_gpid = this->peekfw(U2_FW_REG_LOCK_GPID);
|
| 140 |
140 |
|
| 141 |
141 |
//may not be the right tick rate, but this is ok for locking purposes
|
| 142 |
142 |
const boost::uint32_t lock_timeout_time = boost::uint32_t(3*100e6);
|
| ... | ... | |
| 152 |
152 |
|
| 153 |
153 |
void lock_task(void){
|
| 154 |
154 |
//re-lock in task
|
| 155 |
|
this->get_reg<boost::uint32_t, USRP2_REG_ACTION_FW_POKE32>(U2_FW_REG_LOCK_TIME, this->get_curr_time());
|
|
155 |
this->pokefw(U2_FW_REG_LOCK_TIME, this->get_curr_time());
|
| 156 |
156 |
//sleep for a bit
|
| 157 |
157 |
boost::this_thread::sleep(boost::posix_time::milliseconds(1500));
|
| 158 |
158 |
}
|
| ... | ... | |
| 180 |
180 |
return this->get_reg<boost::uint16_t, USRP2_REG_ACTION_FPGA_PEEK16>(addr);
|
| 181 |
181 |
}
|
| 182 |
182 |
|
|
183 |
void pokefw(wb_addr_type addr, boost::uint32_t data)
|
|
184 |
{
|
|
185 |
this->get_reg<boost::uint32_t, USRP2_REG_ACTION_FW_POKE32>(addr, data);
|
|
186 |
}
|
|
187 |
|
|
188 |
boost::uint32_t peekfw(wb_addr_type addr)
|
|
189 |
{
|
|
190 |
return this->get_reg<boost::uint32_t, USRP2_REG_ACTION_FW_PEEK32>(addr);
|
|
191 |
}
|
|
192 |
|
| 183 |
193 |
template <class T, usrp2_reg_action_t action>
|
| 184 |
194 |
T get_reg(wb_addr_type addr, T data = 0){
|
| 185 |
195 |
//setup the out data
|