|
* Q; U. O% D! o0 A
寄存器初始化那里就给出来了啊,如果DSP要发数据给FPGA, 那么CLOCK是由DSP去控制的,如果DSP要接收FPGA的数据,则CLOCK是由FPGA控制的,START跟ENABLE信号是用来控制发送使能的。这是我的初始化配置(我是用8位宽度通信的,对于DSP来说,B是发送,A是接收):
3 G+ l. K# z3 m5 Wstatic void UPPInit(void)
2 E7 q1 u& W9 w$ y{
" Y' D, k' }; ]( ]7 L/ ?& s unsigned int temp_reg = 0;
# U @6 {& y, {! ?% L5 a+ `
C5 |- W B6 ?( H2 P# y3 Z- W // Channel B params
! M, J) d# A+ n: [# c3 O9 [ CSL_FINST(temp_reg, UPP_UPCTL_DPFB, LJZF); //Left-justified, zero filled
2 x& v3 k; K$ i( @6 S0 o' \0 w CSL_FINST(temp_reg, UPP_UPCTL_IWB, 8BIT); //8-bit interface x2 i- m' D( Y
CSL_FINST(temp_reg, UPP_UPCTL_DPWB, FULL); //Channel B bit width = 8, V5 f4 d" s6 X( n _$ b% x
CSL_FINST(temp_reg, UPP_UPCTL_DRB, SINGLE); //Single data rate8 x, V, Z. h+ R) H9 A
* T5 J1 J3 w0 H // Channel A params! ]0 l. d! B- R1 n9 H* ~2 `
CSL_FINST(temp_reg, UPP_UPCTL_DPFA, LJZF); //Left-justified, zero filled- B. I( O2 D: ?5 L; s4 ]
CSL_FINST(temp_reg, UPP_UPCTL_IWA, 8BIT); //8-bit interface- t, j3 [3 T1 G, x& u+ X
CSL_FINST(temp_reg, UPP_UPCTL_DPWA, FULL); //Channel A bit width = 8$ @$ L) M9 b7 J8 w L7 S
CSL_FINST(temp_reg, UPP_UPCTL_DRA, SINGLE); //Single data rate
% m/ S1 h2 N& F, p6 U! h \# S7 ]+ q
( z- ~5 b* d h% h4 @ CSL_FINST(temp_reg, UPP_UPCTL_CHN, TWO); //Channel A and Channel B are both active.1 d. k5 K. ?# b# ]
CSL_FINST(temp_reg, UPP_UPCTL_MODE, DUPLEX0); //Channel B transmit Channel A receive. h3 G$ j1 R; i9 W2 f/ }
( j+ V8 s* L3 R: T' D9 M
upp_reg_hdl->UPCTL = temp_reg; C: s; v& m/ R
" S o5 s4 K) B O0 W; j+ @
temp_reg = 0;
+ h9 f5 r3 C& j1 F
6 A4 y) \+ S( R5 {& D8 L // Channel A params1 F$ g$ c, P$ }5 {! P2 D
//CSL_FINST(temp_reg, UPP_UPICR_TRISA, ENABLE); //Channel A data pins are in a high-impedance state while idle7 ]( V# m5 t+ {9 \, } z
//CSL_FINS(temp_reg, UPP_UPICR_CLKDIVA, UPP_CLOCK_DIV); //Clock divisor# Z) ]0 s; K2 s) m! [
CSL_FINST(temp_reg, UPP_UPICR_STARTA, ENABLE); //Channel A START Signal Enable.9 ~" x0 I& P7 B7 Y! h! H5 Z
CSL_FINST(temp_reg, UPP_UPICR_ENAA, ENABLE); //Channel A ENABLE Signal Enable
; I7 f. k3 m& x$ S2 o. P! d/ @, y3 B6 C& o7 M" }4 O( \
// Channel B params
8 h( \. k8 S+ _, w, I7 X- [ CSL_FINS(temp_reg, UPP_UPICR_CLKDIVB, UPP_CLOCK_DIV);/ C+ \1 P2 r+ [: @2 ?( m) v/ X+ g
CSL_FINST(temp_reg, UPP_UPICR_STARTB, ENABLE); //Channel B START Signal Enable.7 x; P! L, O4 O: w/ y
CSL_FINST(temp_reg, UPP_UPICR_ENAB, ENABLE); //Channel B ENABLE Signal Enable
, H1 j3 d. B# r% _( E
v( Y* ^: i0 J# {, x upp_reg_hdl->UPICR = temp_reg;# D, d( K; Y& ]! A
) q7 e6 Y! e4 Y( U2 V
//temp_reg = 0;
* ?; v& a: d+ t
" c( o# t E# g6 Z& F& {1 l# _ //CSL_FINS(temp_reg, UPP_UPIVR_VALB, 0x7b7b); //Channel B idle value
6 Q2 ]/ i/ s4 r3 ~' H% }& }: P //CSL_FINS(temp_reg, UPP_UPIVR_VALA, 0x7f7f); //Channel A idle value! s f! {8 U$ e
+ w$ f+ d p, ?: M! v6 y9 [ //upp_reg_hdl->UPIVR = temp_reg;
4 f$ B% R9 x' z/ A. r d/ n) l# I/ I8 q# G
//temp_reg = 0;
1 w/ ~. x @ N i
2 ~' W( C/ V1 R# H //CSL_FINST(temp_reg, UPP_UPTCR_RDSIZEI, 256B); //set 256B DMA I
# d4 I) l$ J- B //upp_reg_hdl->UPTCR = temp_reg;4 A: k0 q; i% y5 ^0 S
$ A1 C C6 {9 f( f- U9 ~
//temp_reg = 0;# u! v5 q4 g+ u7 N; {( ~, t- U
//CSL_FINST(temp_reg, UPP_UPDLB_BA, ENABLE); //B to A loopback mode enable; _; c$ }+ K3 l: Y" l
//upp_reg_hdl->UPDLB = temp_reg;
$ M, J7 _- ^1 R# Q/ j
7 E! L$ J' L( E8 e+ S0 D} |
|