source: PlatformSupport/CustomPeripherals/pcores/w3_clock_controller_v3_00_b/src/w3_clock_controller.h

Last change on this file was 1848, checked in by murphpo, 12 years ago

Added code to select RF ref buf input (on/off board) and fixed bugs in RF ref buf output/divider code

File size: 3.5 KB
Line 
1#ifndef WARP_CLOCK_CONTROLLER_H
2#define WARP_CLOCK_CONTROLLER_H
3
4#include "xbasic_types.h"
5#include "xstatus.h"
6#include "xil_io.h"
7
8#define WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET (0x00000000)
9#define WARP_CLOCK_CONTROLLER_SLV_REG0_OFFSET (WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET + 0x00000000)
10#define WARP_CLOCK_CONTROLLER_SLV_REG1_OFFSET (WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET + 0x00000004)
11#define WARP_CLOCK_CONTROLLER_SLV_REG2_OFFSET (WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET + 0x00000008)
12#define WARP_CLOCK_CONTROLLER_SLV_REG3_OFFSET (WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET + 0x0000000C)
13#define WARP_CLOCK_CONTROLLER_SLV_REG4_OFFSET (WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET + 0x00000010)
14#define WARP_CLOCK_CONTROLLER_SLV_REG5_OFFSET (WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET + 0x00000014)
15#define WARP_CLOCK_CONTROLLER_SLV_REG6_OFFSET (WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET + 0x00000018)
16#define WARP_CLOCK_CONTROLLER_SLV_REG7_OFFSET (WARP_CLOCK_CONTROLLER_USER_SLV_SPACE_OFFSET + 0x0000001C)
17
18/* Address map:
19    HDL is coded [MSB:LSB] = [0:31]
20    regX[0]  maps to 0x80000000 in C driver
21    regX[31] maps to 0x00000001 in C driver
22
230: Config: {clk_div_sel[2:0], 1'b0, samp_func, rfref_func, 26'b0}
24    [29:31] Clock divider bit sel (00=0.5*busclk, 01=0.25*busclk, ...) 0x00000003
25    [28   ] Reserved
26    [   27] samp buf reset (active low) 0x00000010
27    [   26] rf ref buf reset (active low) 0x00000020
28    [0 :25] Reserved
29
301: SPI Tx
31    [24:31] Tx data byte
32    [17:23] 7-bit register address (0x00 to 0xFF all valid)
33    [11:16] 6'b0 (always zero)
34    [ 9:10] Num bytes to Tx/Rx; must be 2'b0 for 1-byte Tx/Rx
35    [    8] RW# 1=Read, 0=Write
36    [    7] samp buf chip select mask
37    [    6] rf ref buf chip select mask
38    [ 0: 5] Reserved
39
402: SPI Rx: {samp_rxByte, rfref_rxByte, 16'b0}
41    [24:31] SPI Rx byte for samp buf 0x00FF
42    [16:23] SPI Rx byte for rf ref buf 0xFF00
43    [ 0:15] Reserved 0xFFFF0000
44   
453: RW: User reset outputs
46    [31] usr_reset0
47    [30] usr_reset1
48    [29] usr_reset2
49    [28] usr_reset3
50    [0:27] reserved
51
524: RO: User status inputs
53    [0:31] usr_status input
54
555-15: Reserved
56*/
57#define CLKCTRL_REG_CONFIG  WARP_CLOCK_CONTROLLER_SLV_REG0_OFFSET
58#define CLKCTRL_REG_SPITX   WARP_CLOCK_CONTROLLER_SLV_REG1_OFFSET
59#define CLKCTRL_REG_SPIRX   WARP_CLOCK_CONTROLLER_SLV_REG2_OFFSET
60
61#define CLKCTRL_REG_CONFIG_MASK_CLKDIV      0x03
62#define CLKCTRL_REG_CONFIG_MASK_SAMP_FUNC   0x10
63#define CLKCTRL_REG_CONFIG_MASK_RFREF_FUNC  0x20
64
65#define CLKCTRL_REG_SPITX_SAMP_CS   0x01000000
66#define CLKCTRL_REG_SPITX_RFREF_CS  0x02000000
67#define CLKCTRL_REG_SPITX_RNW       0x00800000
68
69#define CLK_SAMP_CS     CLKCTRL_REG_SPITX_SAMP_CS
70#define CLK_RFREF_CS    CLKCTRL_REG_SPITX_RFREF_CS
71
72#define CLK_SAMP_OUTSEL_FMC         0x01
73#define CLK_SAMP_OUTSEL_CLKMODHDR   0x02
74#define CLK_SAMP_OUTSEL_FPGA        0x04
75#define CLK_SAMP_OUTSEL_AD_RFA      0x08
76#define CLK_SAMP_OUTSEL_AD_RFB      0x10
77
78#define CLK_RFREF_OUTSEL_FMC        0x20
79#define CLK_RFREF_OUTSEL_CLKMODHDR  0x40
80#define CLK_RFREF_OUTSEL_RFAB       0x80
81
82#define CLK_OUTPUT_ON   1
83#define CLK_OUTPUT_OFF  2
84
85#define CLK_INSEL_ONBOARD 1
86#define CLK_INSEL_CLKMOD 2
87
88u32 clk_spi_read(u32 baseaddr,  u32 csMask, u8 regAddr);
89void clk_spi_write(u32 baseaddr, u32 csMask, u8 regAddr, u8 txByte);
90int clk_init(u32 baseaddr, u8 clkDiv);
91int clk_config_outputs(u32 baseaddr, u8 clkOutMode, u32 clkOutSel);
92int clk_config_dividers(u32 baseaddr, u8 clkDiv, u32 clkOutSel);
93int clk_config_input_rf_ref(u32 baseaddr, u8 clkInSel);
94
95#endif /** WARP_CLOCK_CONTROLLER_H */
Note: See TracBrowser for help on using the repository browser.