Skip to content

Commit

Permalink
Calibration and download parameters separated from signal gen. Direct…
Browse files Browse the repository at this point in the history
… FPGA signal generator register access enabled.
  • Loading branch information
dashpi committed Jun 7, 2014
1 parent 2823ea6 commit c192f70
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 31 deletions.
2 changes: 2 additions & 0 deletions Applications/calscope/src/generate.h
Expand Up @@ -45,4 +45,6 @@ int generate_exit(void);

int generate_update(rp_app_params_t *params);

void dir_gen_fpga_set(uint32_t ch, int param, uint32_t value);

#endif // __GENERATE_H
33 changes: 22 additions & 11 deletions Applications/calscope/src/main.c
Expand Up @@ -158,7 +158,14 @@ static rp_app_params_t rp_main_params[PARAMS_NUM+1] = {
"scale_ch1", 0, 0, 1, -1000, 1000 },
{ /* scale_ch2 - Jumper & probe attenuation dependent Y scaling factor for Channel 2 */
"scale_ch2", 0, 0, 1, -1000, 1000 },

{ /* dc_cal - DC offset calibration button (toggled) */
"dc_cal", 0, 1, 0, 0, 1 },
{ /* req_trc - Data trace download button (toggled) */
"req_trc", 0, 1, 0, 0, 1 },
{ /* dc_calout1 - DC offset calibration button for out 1 (toggled) */
"dc_calout1", 0, 1, 0, 0, 1 },
{ /* dc_calout2 - DC offset calibration button for out 2 (toggled) */
"dc_calout2", 0, 1, 0, 0, 1 },
/* Arbitrary Waveform Generator parameters from here on */

{ /* gen_trig_mod_ch1 - Selects the trigger mode for channel 1:
Expand Down Expand Up @@ -217,10 +224,6 @@ static rp_app_params_t rp_main_params[PARAMS_NUM+1] = {
* 2 - Refresh Channel 2
*/
"gen_awg_refresh", 0, 0, 0, 0, 2 },
{ /* dc_cal - DC offset calibration button (toggled) */
"dc_cal", 0, 1, 0, 0, 1 },
{ /* req_trc - Data trace download button (toggled) */
"req_trc", 0, 1, 0, 0, 1 },
{ /* Must be last! */
NULL, 0.0, -1, -1, 0.0, 0.0 }
};
Expand Down Expand Up @@ -261,7 +264,7 @@ int rp_app_init(void)
return -1;
}

rp_set_params(&rp_main_params[0], PARAMS_NUM);
rp_set_params(&rp_main_params[0], PARAMS_NUM ,0);


return 0;
Expand Down Expand Up @@ -530,9 +533,9 @@ void transform_from_iface_units(rp_app_params_t *p)
p[GEN_DC_NORM_1].value = p[GEN_DC_OFFS_1].value / scale1;
p[GEN_DC_NORM_2].value = p[GEN_DC_OFFS_2].value / scale2;
}

int rp_set_params(rp_app_params_t *p, int len)
{
int rp_set_params(rp_app_params_t *p, int len, int internal_flag)
{ // This "internal_flag" tells who is requesting param. set (0 client, 1 app. on server)
int i;
int fpga_update = 1;
int params_change = 0;
Expand Down Expand Up @@ -776,7 +779,7 @@ int rp_set_params(rp_app_params_t *p, int len)
}
}

if(awg_params_change) {
if(awg_params_change || (internal_flag==1)) {

/* Correct frequencies if needed */
rp_main_params[GEN_SIG_FREQ_CH1].value =
Expand Down Expand Up @@ -1017,7 +1020,7 @@ int rp_update_main_params(rp_app_params_t *params)
}
pthread_mutex_unlock(&rp_main_params_mutex);
params_init = 0;
rp_set_params(&rp_main_params[0], PARAMS_NUM);
rp_set_params(&rp_main_params[0], PARAMS_NUM, 1);

return 0;
}
Expand All @@ -1043,6 +1046,14 @@ int rp_update_meas_data(rp_osc_meas_res_t ch1_meas, rp_osc_meas_res_t ch2_meas)
return 0;
}

// This function enables direct signal generator FPGA register access from worker.c

void dir_gen_set(int ch, int param, int value)
{
dir_gen_fpga_set(ch, param, value);
}


float rp_gen_limit_freq(float freq, float gen_type)
{
int type = (int)gen_type;
Expand Down
46 changes: 26 additions & 20 deletions Applications/calscope/src/main.h
Expand Up @@ -45,7 +45,7 @@ typedef struct rp_osc_meas_res_s {

/* Parameters indexes - these defines should be in the same order as
* rp_app_params_t structure defined in main.c */
#define PARAMS_NUM 59
#define PARAMS_NUM 61
#define MIN_GUI_PARAM 0
#define MAX_GUI_PARAM 1
#define TRIG_MODE_PARAM 2
Expand Down Expand Up @@ -88,28 +88,32 @@ typedef struct rp_osc_meas_res_s {
#define GEN_DC_NORM_2 39
#define SCALE_CH1 40
#define SCALE_CH2 41
#define DC_CAL 42
#define REQ_TRC 43
#define DC_CALOUT1 44
#define DC_CALOUT2 45
/* AWG parameters */
#define GEN_TRIG_MODE_CH1 42
#define GEN_SIG_TYPE_CH1 43
#define GEN_ENABLE_CH1 44
#define GEN_SINGLE_CH1 45
#define GEN_SIG_AMP_CH1 46
#define GEN_SIG_FREQ_CH1 47
#define GEN_SIG_DCOFF_CH1 48
#define GEN_TRIG_MODE_CH2 49
#define GEN_SIG_TYPE_CH2 50
#define GEN_ENABLE_CH2 51
#define GEN_SINGLE_CH2 52
#define GEN_SIG_AMP_CH2 53
#define GEN_SIG_FREQ_CH2 54
#define GEN_SIG_DCOFF_CH2 55
#define GEN_AWG_REFRESH 56
#define DC_CAL 57
#define REQ_TRC 58
#define GEN_TRIG_MODE_CH1 46
#define GEN_SIG_TYPE_CH1 47
#define GEN_ENABLE_CH1 48
#define GEN_SINGLE_CH1 49
#define GEN_SIG_AMP_CH1 50
#define GEN_SIG_FREQ_CH1 51
#define GEN_SIG_DCOFF_CH1 52
#define GEN_TRIG_MODE_CH2 53
#define GEN_SIG_TYPE_CH2 54
#define GEN_ENABLE_CH2 55
#define GEN_SINGLE_CH2 56
#define GEN_SIG_AMP_CH2 57
#define GEN_SIG_FREQ_CH2 58
#define GEN_SIG_DCOFF_CH2 59
#define GEN_AWG_REFRESH 60



/* Defines from which parameters on are AWG parameters (used in set_param() to
* trigger update only on needed part - either Oscilloscope or AWG */
#define PARAMS_AWG_PARAMS 42
#define PARAMS_AWG_PARAMS 46

/* Output signals */
#define SIGNAL_LENGTH (1024) /* Must be 2^n! */
Expand All @@ -119,7 +123,7 @@ typedef struct rp_osc_meas_res_s {
/* module entry points */
int rp_app_init(void);
int rp_app_exit(void);
int rp_set_params(rp_app_params_t *p, int len);
int rp_set_params(rp_app_params_t *p, int len, int internal_flag);
int rp_get_params(rp_app_params_t **p);
int rp_get_signals(float ***s, int *sig_num, int *sig_len);

Expand Down Expand Up @@ -151,4 +155,6 @@ int rp_update_meas_data(rp_osc_meas_res_t ch1_meas, rp_osc_meas_res_t ch2_meas);
/* Waveform generator frequency limiter. */
float rp_gen_limit_freq(float freq, float gen_type);

void dir_gen_set(int ch, int param, int value);

#endif /* __MAIN_H */

0 comments on commit c192f70

Please sign in to comment.