Skip to content

Commit 1ebe0d7

Browse files
committed
hdl: nios: devices_rfic: add rfic_command_{write,read}_immed() commands
These are intended for use within headless applications, where doing queuing is unnecessary, and where the command/channel aren't simply packed into the address.
1 parent 3bb8ad6 commit 1ebe0d7

File tree

3 files changed

+77
-24
lines changed

3 files changed

+77
-24
lines changed

hdl/fpga/platforms/common/bladerf/software/bladeRF_nios/src/devices.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,12 @@ void rfic_command_init(void);
592592
void rfic_command_work(void);
593593

594594
/**
595-
* RFIC command write
595+
* RFIC command write (queuing)
596596
*
597-
* @param addr Address
598-
* @param data Value
597+
* @param[in] addr The address value from the packet
598+
* @param[in] data The data value from the packet
599+
*
600+
* @see rfic_command_write_immed()
599601
*
600602
* @return bool (true = success)
601603
*/
@@ -604,8 +606,10 @@ bool rfic_command_write(uint16_t addr, uint64_t data);
604606
/**
605607
* RFIC command read
606608
*
607-
* @param addr Address
608-
* @param data Value (out)
609+
* @param[in] addr The address value from the packet
610+
* @param[out] data Return payload
611+
*
612+
* @see rfic_command_read_immed()
609613
*
610614
* @return bool (true = success)
611615
*/

hdl/fpga/platforms/common/bladerf/software/bladeRF_nios/src/devices_rfic.c

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,14 +1258,6 @@ static void rfic_command_work_wq(struct rfic_queue *q)
12581258
}
12591259
}
12601260

1261-
/**
1262-
* @brief Write command dispatcher
1263-
*
1264-
* @param[in] addr The address value from the packet
1265-
* @param[in] data The data value from the packet
1266-
*
1267-
* @return True if successfully enqueued, False otherwise.
1268-
*/
12691261
bool rfic_command_write(uint16_t addr, uint64_t data)
12701262
{
12711263
uint8_t cmd = _rfic_unpack_cmd(addr);
@@ -1285,18 +1277,38 @@ bool rfic_command_write(uint16_t addr, uint64_t data)
12851277
return rv;
12861278
}
12871279

1288-
/**
1289-
* @brief Read command dispatcher
1290-
*
1291-
* @param[in] addr The address value from the packet
1292-
* @param[out] data Return payload
1293-
*
1294-
* @return True if read was successful and data is valid, False otherwise.
1295-
*/
1280+
bool rfic_command_write_immed(bladerf_rfic_command cmd,
1281+
bladerf_channel ch,
1282+
uint64_t data)
1283+
{
1284+
struct rfic_command_fns const *f = _get_cmd_ptr(cmd);
1285+
1286+
bool rv = false;
1287+
1288+
if (NULL == f || !_check_validity(f, ch)) {
1289+
rv = false;
1290+
} else if (NULL != f->write64) {
1291+
rv = f->write64(ch, data);
1292+
} else if (NULL != f->write32) {
1293+
rv = f->write32(ch, (uint32_t)data);
1294+
}
1295+
1296+
RFIC_DBG("WR!", _rfic_cmdstr(cmd), _rfic_chanstr(ch), rv ? "OK " : "BAD",
1297+
addr, data);
1298+
1299+
return rv;
1300+
}
1301+
12961302
bool rfic_command_read(uint16_t addr, uint64_t *data)
12971303
{
1298-
uint8_t cmd = _rfic_unpack_cmd(addr);
1299-
uint8_t ch = _rfic_unpack_chan(addr);
1304+
return rfic_command_read_immed(_rfic_unpack_cmd(addr),
1305+
_rfic_unpack_chan(addr), data);
1306+
}
1307+
1308+
bool rfic_command_read_immed(bladerf_rfic_command cmd,
1309+
bladerf_channel ch,
1310+
uint64_t *data)
1311+
{
13001312
struct rfic_command_fns const *f = _get_cmd_ptr(cmd);
13011313
bool rv = false;
13021314

@@ -1317,7 +1329,7 @@ bool rfic_command_read(uint16_t addr, uint64_t *data)
13171329
}
13181330
}
13191331

1320-
RFIC_DBG("RD ", _rfic_cmdstr(cmd), _rfic_chanstr(ch), rv ? "OK " : "BAD",
1332+
RFIC_DBG("RD!", _rfic_cmdstr(cmd), _rfic_chanstr(ch), rv ? "OK " : "BAD",
13211333
addr, *data);
13221334

13231335
return rv;

hdl/fpga/platforms/common/bladerf/software/bladeRF_nios/src/devices_rfic.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,43 @@ struct rfic_queue_entry *rfic_queue_peek(struct rfic_queue *q);
140140

141141
void rfic_queue_reset(struct rfic_queue *q);
142142

143+
/**
144+
* RFIC command read (immediate)
145+
*
146+
* @param command Command to execute
147+
* @param channel Channel to apply command to
148+
* @param data Response from command
149+
*
150+
* @return bool (true = success)
151+
*/
152+
bool rfic_command_read_immed(bladerf_rfic_command command,
153+
bladerf_channel channel,
154+
uint64_t *data);
155+
156+
/**
157+
* RFIC command write (immediate)
158+
*
159+
* @param command Command to execute
160+
* @param channel Channel to apply command to
161+
* @param data Argument for command
162+
*
163+
* @return bool (true = success)
164+
*/
165+
bool rfic_command_write_immed(bladerf_rfic_command command,
166+
bladerf_channel channel,
167+
uint64_t data);
168+
169+
/**
170+
* Invalidate the LO frequency state for a given module
171+
*
172+
* If anything affecting the tuning frequency of the RFIC is performed
173+
* without using the ad9361_* functions, call this function to indicate
174+
* that the state is invalid. Attempts to get the LO frequency will fail,
175+
* until the LO frequency is set with a BLADERF_RFIC_COMMAND_FREQUENCY
176+
* command.
177+
*
178+
* @param[in] module The module
179+
*/
143180
void rfic_invalidate_frequency(bladerf_module module);
144181

145182
static inline bool _rfic_chan_is_system(uint8_t ch)

0 commit comments

Comments
 (0)