2
* Copyright 2007,2008 Free Software Foundation, Inc.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
* Loopback SERDES to SERDES
26
#include "memory_map.h"
29
#include "buffer_pool.h"
33
#include "memset_wa.h"
42
// ----------------------------------------------------------------
44
#define SERDES_RX_BUF_0 0
45
#define SERDES_RX_BUF_1 1
48
* ================================================================
49
* configure SD RX double buffering state machine
50
* ================================================================
53
// receive from SERDES
54
buf_cmd_args_t sd_recv_args = {
61
buf_cmd_args_t sd_send_args = {
63
0, // starts with packet in line 0
64
0, // filled in from list_line register
67
dbsm_t sd_sm; // the state machine
72
// ----------------------------------------------------------------
76
check_packet(int *buf, int nlines)
80
for (i = 0; i < nlines; i++){
81
int expected = ((2*i + 0) << 16) | (2*i+1);
82
if (buf[i] != expected){
84
printf("buf[%d] = 0x%x expected = 0x%x\n", i, buf[i], expected);
91
zero_buffer(int bufno)
93
memset_wa(buffer_ram(bufno), 0, BP_NLINES * 4);
99
sd_rx_inspector(dbsm_t *sm, int buf_this)
101
hal_toggle_leds(0x2);
104
int last_line = buffer_pool_status->last_line[buf_this];
105
bool ok = check_packet(buffer_ram(buf_this), last_line);
114
if(good+bad == 10000) {
115
printf("Good %d\tBad %d\n",good,bad);
126
buffer_irq_handler(void)
128
uint32_t status = buffer_pool_status->status;
129
dbsm_process_status(&sd_sm, status);
138
putstr("\nsd_bounce\n");
140
// Get our clock from the mimo interface
141
clocks_mimo_config(MC_WE_LOCK_TO_MIMO);
143
dbsm_init(&sd_sm, SERDES_RX_BUF_0,
144
&sd_recv_args, &sd_send_args,
147
// kick off the state machine
151
buffer_irq_handler();