1: int32_t AG903_SSPMgrReset(
AG903_SSPMgrHandle* handle)
2: {
3:
AG903_SSPPrmIntCtrl ictrl_clr = {0};
4:
AG903_SSPPrmCtrl2 ctrl2_clr = {0};
5: AG903_SSPMgrDmaStat dma_clr = {0};
6:
AG903_SSPMgrSpiParam spi_clr = {0};
7: int32_t retval =
AG903_ENONE;
8: _Bool busy;
9: uint8_t ch;
10:
11: retval = SSPMgr_CheckHandle(handle, &ch);
12:
if(
AG903_ENONE != retval) {
13:
return -
AG903_EINVAL;
14: }
15: busy = SSPMgr_CheckBusy(ch);
16:
if(
true == busy) {
17:
return -
AG903_EBUSY;
18: }
19:
20: SSPMgr_DisableTransfer(ch);
21:
AG903_SSPPrmClearTxFifo(ch);
22:
AG903_SSPPrmClearRxFifo(ch);
23:
24:
AG903_SSPPrmReset(ch);
25: SspChStat[ch].tx.buf = NULL;
26: SspChStat[ch].tx.size = 0;
27: SspChStat[ch].tx.cnt = 0;
28: SspChStat[ch].rx.buf = NULL;
29: SspChStat[ch].rx.size = 0;
30: SspChStat[ch].rx.cnt = 0;
31: SspRegStat[ch].ictrl = ictrl_clr;
32: SspRegStat[ch].ctrl2 = ctrl2_clr;
33: SspDmaStatTx[ch] = dma_clr;
34: SspDmaStatRx[ch] = dma_clr;
35: SspSpiParam[ch] = spi_clr;
36: SSPMgr_ClearTxQue(ch);
37: SSPMgr_ClearRxQue(ch);
38:
39:
return retval;
40: }