mirror of https://gerrit.osmocom.org/simtrace2
firmware: octsimtest: Make slot mux configurable via USB
Change-Id: I4cdb250d2e1dbc5b8b0169f8b7c21e288b492e1d
This commit is contained in:
parent
3561fc4c8b
commit
d46f6bae2c
|
@ -109,6 +109,8 @@
|
|||
#define VCC_UV_THRESH_1V8 (1500000*47)/(47+30)
|
||||
#define VCC_UV_THRESH_3V (2500000*47)/(47+30)
|
||||
|
||||
#define HAVE_SLOT_MUX
|
||||
|
||||
/** Supported modes */
|
||||
/* SIMtrace board supports sniffer mode */
|
||||
//#define HAVE_SNIFFER
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
void mux_init(void);
|
||||
void mux_set_slot(uint8_t s);
|
||||
int mux_set_slot(uint8_t s);
|
||||
int mux_get_slot(void);
|
||||
void mux_set_freq(uint8_t s);
|
||||
|
||||
/* this reflects the wiring between U5 and U4 */
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "board.h"
|
||||
#include "mux.h"
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* 3-bit S0..S2 signal for slot selection */
|
||||
static const Pin pin_in_sel[3] = {
|
||||
|
@ -38,6 +39,8 @@ static const Pin pin_freq_sel[3] = {
|
|||
/* low-active output enable for all muxes */
|
||||
static const Pin pin_oe = { PIO_PA19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT };
|
||||
|
||||
static uint8_t g_mux_slot = 0;
|
||||
|
||||
/* initialize the external 1:8 multiplexers */
|
||||
void mux_init(void)
|
||||
{
|
||||
|
@ -49,10 +52,13 @@ void mux_init(void)
|
|||
}
|
||||
|
||||
/* set the slot selection mux */
|
||||
void mux_set_slot(uint8_t s)
|
||||
int mux_set_slot(uint8_t s)
|
||||
{
|
||||
printf("%s(%u)\r\n", __func__, s);
|
||||
|
||||
if (s > 7)
|
||||
return -EINVAL;
|
||||
|
||||
/* !OE = H: disconnect input and output of muxes */
|
||||
PIO_Set(&pin_oe);
|
||||
|
||||
|
@ -71,6 +77,14 @@ void mux_set_slot(uint8_t s)
|
|||
|
||||
/* !OE = L: (re-)enable the output of muxes */
|
||||
PIO_Clear(&pin_oe);
|
||||
|
||||
g_mux_slot = s;
|
||||
return s;
|
||||
}
|
||||
|
||||
int mux_get_slot(void)
|
||||
{
|
||||
return g_mux_slot;
|
||||
}
|
||||
|
||||
/* set the frequency divider mux */
|
||||
|
|
|
@ -269,6 +269,8 @@ struct cardemu_usb_msg_error {
|
|||
struct cardemu_usb_msg_config {
|
||||
/* bit-mask of CEMU_FEAT_F flags */
|
||||
uint32_t features;
|
||||
/* the selected slot number (if an external mux is present) */
|
||||
uint8_t slot_mux_nr;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
#include <osmocom/core/linuxlist.h>
|
||||
#include <osmocom/core/msgb.h>
|
||||
|
||||
#ifdef HAVE_SLOT_MUX
|
||||
#include "mux.h"
|
||||
#endif
|
||||
|
||||
#define NUM_SLOTS 2
|
||||
|
||||
|
@ -1079,6 +1082,12 @@ static void card_emu_report_config(struct card_handle *ch)
|
|||
|
||||
cfg = (struct cardemu_usb_msg_config *) msgb_put(msg, sizeof(*cfg));
|
||||
cfg->features = ch->features;
|
||||
#ifdef HAVE_SLOT_MUX
|
||||
cfg->slot_mux_nr = mux_get_slot();
|
||||
#else
|
||||
cfg->slot_mux_nr = 0;
|
||||
#endif
|
||||
|
||||
|
||||
usb_buf_upd_len_and_submit(msg);
|
||||
}
|
||||
|
@ -1241,6 +1250,12 @@ int card_emu_set_config(struct card_handle *ch, const struct cardemu_usb_msg_con
|
|||
if (scfg_len >= sizeof(uint32_t))
|
||||
ch->features = (scfg->features & SUPPORTED_FEATURES);
|
||||
|
||||
#ifdef HAVE_SLOT_MUX
|
||||
if (scfg_len >= sizeof(uint32_t)+sizeof(uint8_t)) {
|
||||
mux_set_slot(scfg->slot_mux_nr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* send back a report of our current configuration */
|
||||
card_emu_report_config(ch);
|
||||
|
||||
|
|
Loading…
Reference in New Issue