Skip to content

Commit a5660b2

Browse files
Packaged functions to set control of Front Panel Status LEDs, and get/read-back who/what (BSP/DSP) is controlling Front Panel Status LEDs - for ease of use
1 parent eb8c8df commit a5660b2

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/skarab_definitions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
C_RD_MEZZANINE_STAT_ADDR = 0x10
3030
C_RD_USB_STAT_ADDR = 0x14
3131
C_RD_SOC_VERSION_ADDR = 0x18
32+
C_RD_DSP_OVERRIDE_ADDR = 0x34
3233
C_RD_THROUGHPUT_COUNTER = 0x58
3334
C_RD_NUM_PACKETS_CHECKED_0 = 0x5C
3435
C_RD_NUM_PACKETS_CHECKED_1 = 0x60
@@ -44,6 +45,7 @@
4445
C_WR_MEZZANINE_CTL_ADDR = 0x10
4546
C_WR_FRONT_PANEL_STAT_LED_ADDR = 0x14
4647
C_WR_BRD_CTL_STAT_1_ADDR = 0x18
48+
C_WR_DSP_OVERRIDE_ADDR = 0x34
4749
C_WR_RAMP_SOURCE_DESTINATION_IP_3_ADDR = 0x58
4850
C_WR_RAMP_CHECKER_SOURCE_IP_3_ADDR = 0x5C
4951
C_WR_RAMP_SOURCE_DESTINATION_IP_2_ADDR = 0x60

src/transport_skarab.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,48 @@ def front_panel_status_leds(self, led_0_on, led_1_on, led_2_on, led_3_on,
23152315
led_mask = led_mask | sd.FRONT_PANEL_STATUS_LED7
23162316
self.write_board_reg(sd.C_WR_FRONT_PANEL_STAT_LED_ADDR, led_mask)
23172317

2318+
def control_front_panel_leds_write(self, dsp_override=True):
2319+
"""
2320+
Neatly packaged command that switches control of FrontPanelStatus LEDs
2321+
between DSP and BSP control
2322+
- Controlled via BSP by default
2323+
:param dsp_override: Boolean - 1/0 - True/False
2324+
:return: Boolean - 1/0 - True/False
2325+
"""
2326+
2327+
# Easiest to just write the value, then check it
2328+
result = self.write_board_reg(sd.C_WR_DSP_OVERRIDE_ADDR, dsp_override)
2329+
2330+
if result.packet['reg_data_low'] != dsp_override:
2331+
# Problem
2332+
errmsg = 'Failed to switch control of FrontPanel LEDs...'
2333+
LOGGER.error(errmsg)
2334+
raise SkarabWriteFailed(errmsg)
2335+
2336+
# else: Success
2337+
led_controller = 'DSP Design' if dsp_override else 'Board Support Package'
2338+
debugmsg = 'Successfully changed control of FrontPanel LEDs to {}...'.format(led_controller)
2339+
LOGGER.debug(debugmsg)
2340+
print(debugmsg)
2341+
return True
2342+
2343+
def control_front_panel_leds_read(self):
2344+
"""
2345+
Neatly packaged command that checks who is controlling FrontPanelStatus LEDs
2346+
- Controlled via BSP by default
2347+
:return:
2348+
"""
2349+
result = self.read_board_reg(sd.C_RD_DSP_OVERRIDE_ADDR)
2350+
2351+
if result:
2352+
# Returned 1
2353+
debugmsg = 'DSP Design is controlling FrontPanel LEDs...'
2354+
else:
2355+
debugmsg = 'Board Support Package is controlling FrontPanel LEDs...'
2356+
2357+
LOGGER.debug(debugmsg)
2358+
print(debugmsg)
2359+
23182360
def _prepare_sdram_ram_for_programming(self):
23192361
"""
23202362
Prepares the sdram for programming with FPGA image

0 commit comments

Comments
 (0)