1: int32_t AG903_SSPMgrEnableTransfer(
AG903_SSPMgrHandle* handle)
2: {
3:
AG903_SSPPrmIntCtrl ictrl;
4:
AG903_SSPPrmCtrl2 ctrl2;
5: int32_t retval =
AG903_ENONE;
6: uint32_t status;
7: _Bool idle;
8: uint8_t ch;
9:
10: retval = SSPMgr_CheckHandle(handle, &ch);
11:
if(
AG903_ENONE != retval) {
12:
return -
AG903_EINVAL;
13: }
14: idle = SSPMgr_CheckIdle(ch);
15:
if(
true != idle) {
16:
return -
AG903_EBUSY;
17: }
18:
if( (0 != SspChStat[ch].dma) && (0 != SspChStat[ch].pio) ) {
19:
return -
AG903_EPERM;
20: }
21:
if( (0 == SspChStat[ch].dma) && (0 == SspChStat[ch].pio) ) {
22:
return -
AG903_EPERM;
23: }
24:
25:
AG903_SSPPrmGetIntStatus(ch, &status);
26:
27:
AG903_SSPPrmGetIntControl(ch, &ictrl);
28:
AG903_SSPPrmGetControl2(ch, &ctrl2);
29:
30:
if(0 != SspChStat[ch].dma) {
31: ictrl.rfthien = 0;
32: ictrl.rforien = 0;
33: ictrl.tfthien = 0;
34: ictrl.tfurien = 0;
35:
if(AG903_SSP_DMA_RECEIVE & SspChStat[ch].dma) {
36: ctrl2.txdoe = 0;
37: ictrl.tfdmaen = 0;
38: ictrl.rfdmaen = 1;
39: ctrl2.txen = 0;
40: ctrl2.rxen = 1;
41: }
42:
if(AG903_SSP_DMA_SEND & SspChStat[ch].dma) {
43: ctrl2.txdoe = 1;
44: ictrl.tfdmaen = 1;
45: ictrl.rfdmaen = 0;
46: ctrl2.txen = 1;
47: ctrl2.rxen = 0;
48: }
49: }
50:
else {
51: ictrl.tfdmaen = 0;
52: ictrl.rfdmaen = 0;
53:
if(AG903_SSP_ENABLE_RECEIVE & SspChStat[ch].pio) {
54: ctrl2.txdoe = 0;
55: ctrl2.txen = 0;
56: ctrl2.rxen = 1;
57: ictrl.tfthien = 0;
58: ictrl.tfurien = 0;
59: ictrl.rfthien = 1;
60: ictrl.rforien = 1;
61: }
62:
if(AG903_SSP_ENABLE_SEND & SspChStat[ch].pio) {
63: ctrl2.txdoe = 1;
64: ctrl2.txen = 1;
65: ctrl2.rxen = 0;
66: ictrl.tfthien = 1;
67: ictrl.tfurien = 1;
68: ictrl.rfthien = 0;
69: ictrl.rforien = 0;
70: }
71: }
72:
73: ctrl2.sspen = 1;
74:
75:
AG903_SSPPrmSetIntControl(ch, &ictrl);
76:
AG903_SSPPrmSetControl2(ch, &ctrl2);
77:
78:
return retval;
79: }