35 lines
633 B
C
35 lines
633 B
C
#include <common.h>
|
|
#include "../common/nbhw_fpga_prog.h"
|
|
|
|
#define SIM_CTRL (0x0040)
|
|
|
|
void connect_sim_to_slot(int sim, int slot) {
|
|
uint16_t sim_ctrl;
|
|
uint16_t sim_shift;
|
|
uint16_t slot_sel;
|
|
|
|
if (sim > 1) {
|
|
printf("Invalid sim %d selected, can't connect slot %d\n", sim, slot);
|
|
return;
|
|
}
|
|
|
|
if (slot < 0)
|
|
slot_sel = 0;
|
|
else if (slot <= 4) {
|
|
slot_sel = slot + 1;
|
|
}
|
|
else {
|
|
printf("Invalid slot %d selected, can't connect sim %d\n", slot, sim);
|
|
return;
|
|
}
|
|
|
|
sim_shift = sim * 4;
|
|
|
|
sim_ctrl = FPGA_REG(SIM_CTRL);
|
|
|
|
sim_ctrl &= ~(0xF << sim_shift);
|
|
sim_ctrl |= slot_sel << sim_shift;
|
|
|
|
FPGA_REG(SIM_CTRL) = sim_ctrl;
|
|
}
|