@@ -82,18 +82,23 @@ void dds_init(long long int timestamp, int bus_channel, int channel)
82
82
83
83
/* Compensation to keep phase continuity when switching from absolute or tracking
84
84
* to continuous phase mode. */
85
- static unsigned int continuous_phase_comp [CONFIG_DDS_CHANNEL_COUNT ];
85
+ static unsigned int continuous_phase_comp [CONFIG_RTIO_DDS_COUNT ][ CONFIG_DDS_CHANNELS_PER_BUS ];
86
86
87
87
static void dds_set_one (long long int now , long long int ref_time ,
88
88
int bus_channel , int channel ,
89
89
unsigned int ftw , unsigned int pow , int phase_mode , unsigned int amplitude )
90
90
{
91
91
unsigned int channel_enc ;
92
92
93
- if (channel >= CONFIG_DDS_CHANNEL_COUNT ) {
93
+ if (( channel < 0 ) || ( channel >= CONFIG_DDS_CHANNELS_PER_BUS ) ) {
94
94
core_log ("Attempted to set invalid DDS channel\n" );
95
95
return ;
96
96
}
97
+ if ((bus_channel < CONFIG_RTIO_FIRST_DDS_CHANNEL )
98
+ || (bus_channel >= (CONFIG_RTIO_FIRST_DDS_CHANNEL + CONFIG_RTIO_DDS_COUNT ))) {
99
+ core_log ("Attempted to use invalid DDS bus\n" );
100
+ return ;
101
+ }
97
102
#ifdef CONFIG_DDS_ONEHOT_SEL
98
103
channel_enc = 1 << channel ;
99
104
#else
@@ -125,7 +130,7 @@ static void dds_set_one(long long int now, long long int ref_time,
125
130
/* Disable autoclear phase accumulator and enables OSK. */
126
131
DDS_WRITE (DDS_CFR1L , 0x0108 );
127
132
#endif
128
- pow += continuous_phase_comp [channel ];
133
+ pow += continuous_phase_comp [bus_channel - CONFIG_RTIO_FIRST_DDS_CHANNEL ][ channel ];
129
134
} else {
130
135
long long int fud_time ;
131
136
@@ -141,7 +146,7 @@ static void dds_set_one(long long int now, long long int ref_time,
141
146
pow -= (ref_time - fud_time )* CONFIG_DDS_RTIO_CLK_RATIO * ftw >> (32 - DDS_POW_WIDTH );
142
147
if (phase_mode == PHASE_MODE_TRACKING )
143
148
pow += ref_time * CONFIG_DDS_RTIO_CLK_RATIO * ftw >> (32 - DDS_POW_WIDTH );
144
- continuous_phase_comp [channel ] = pow ;
149
+ continuous_phase_comp [bus_channel - CONFIG_RTIO_FIRST_DDS_CHANNEL ][ channel ] = pow ;
145
150
}
146
151
147
152
#ifdef CONFIG_DDS_AD9858
0 commit comments