@@ -112,10 +112,10 @@ void SetupSpi(int mode)
112
112
}
113
113
114
114
//-----------------------------------------------------------------------------
115
- // Set up the synchronous serial port, with the one set of options that we
116
- // always use when we are talking to the FPGA. Both RX and TX are enabled.
115
+ // Set up the synchronous serial port with the set of options that fits
116
+ // the FPGA mode . Both RX and TX are always enabled.
117
117
//-----------------------------------------------------------------------------
118
- void FpgaSetupSsc (void )
118
+ void FpgaSetupSsc (uint8_t FPGA_mode )
119
119
{
120
120
// First configure the GPIOs, and get ourselves a clock.
121
121
AT91C_BASE_PIOA -> PIO_ASR =
@@ -134,11 +134,15 @@ void FpgaSetupSsc(void)
134
134
// on RX clock rising edge, sampled on falling edge
135
135
AT91C_BASE_SSC -> SSC_RCMR = SSC_CLOCK_MODE_SELECT (1 ) | SSC_CLOCK_MODE_START (1 );
136
136
137
- // 8 bits per transfer, no loopback, MSB first, 1 transfer per sync
137
+ // 8, 16 or 32 bits per transfer, no loopback, MSB first, 1 transfer per sync
138
138
// pulse, no output sync
139
- AT91C_BASE_SSC -> SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD (8 ) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER (0 );
139
+ if ((FPGA_mode & 0xe0 ) == FPGA_MAJOR_MODE_HF_READER_RX_XCORR ) {
140
+ AT91C_BASE_SSC -> SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD (16 ) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER (0 );
141
+ } else {
142
+ AT91C_BASE_SSC -> SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD (8 ) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER (0 );
143
+ }
140
144
141
- // clock comes from TK pin, no clock output, outputs change on falling
145
+ // TX clock comes from TK pin, no clock output, outputs change on falling
142
146
// edge of TK, sample on rising edge of TK, start on positive-going edge of sync
143
147
AT91C_BASE_SSC -> SSC_TCMR = SSC_CLOCK_MODE_SELECT (2 ) | SSC_CLOCK_MODE_START (5 );
144
148
@@ -154,16 +158,15 @@ void FpgaSetupSsc(void)
154
158
// ourselves, not to another buffer). The stuff to manipulate those buffers
155
159
// is in apps.h, because it should be inlined, for speed.
156
160
//-----------------------------------------------------------------------------
157
- bool FpgaSetupSscDma (uint8_t * buf , int len )
161
+ bool FpgaSetupSscDma (uint8_t * buf , uint16_t sample_count )
158
162
{
159
163
if (buf == NULL ) return false;
160
164
161
- AT91C_BASE_PDC_SSC -> PDC_PTCR = AT91C_PDC_RXTDIS ; // Disable DMA Transfer
162
- AT91C_BASE_PDC_SSC -> PDC_RPR = (uint32_t ) buf ; // transfer to this memory address
163
- AT91C_BASE_PDC_SSC -> PDC_RCR = len ; // transfer this many bytes
164
- AT91C_BASE_PDC_SSC -> PDC_RNPR = (uint32_t ) buf ; // next transfer to same memory address
165
- AT91C_BASE_PDC_SSC -> PDC_RNCR = len ; // ... with same number of bytes
166
- AT91C_BASE_PDC_SSC -> PDC_PTCR = AT91C_PDC_RXTEN ; // go!
165
+ AT91C_BASE_PDC_SSC -> PDC_PTCR = AT91C_PDC_RXTDIS ; // Disable DMA Transfer
166
+ AT91C_BASE_PDC_SSC -> PDC_RPR = (uint32_t ) buf ; // transfer to this memory address
167
+ AT91C_BASE_PDC_SSC -> PDC_RCR = sample_count ; // transfer this many samples
168
+ AT91C_BASE_PDC_SSC -> PDC_RNPR = (uint32_t ) buf ; // next transfer to same memory address
169
+ AT91C_BASE_PDC_SSC -> PDC_RNCR = sample_count ; // ... with same number of samples AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTEN; // go!
167
170
168
171
return true;
169
172
}
0 commit comments