I was trying to play with the drivers for the McBSP and to create a self test function i wanted to configure the device in internal loopback, but only if this function was called, and then after the self test disable the loopback again.
To do this i found the mcbspControlChan() function but it did not work. The call is like this:
uint32_t arg; arg = Mcbsp_Loopback_ENABLE; mcbspControlChan(hMcbspRxChan, Mcbsp_IOCTL_LOOPBACK, (void*)&arg);
After some debugging i realised it was not setting the bit 15 from SPCR:
and after some further debugging i found this in the file mcbsp_ioctl.c from the sdk:
else if (Mcbsp_IOCTL_LOOPBACK == cmd) { if (NULL != arg) { if (Mcbsp_Loopback_DISABLE == (Mcbsp_Loopback)(*(uint32_t *)arg)) { instHandle->hwInfo.regs->SPCR |= (CSL_MCBSP_SPCR_DLB_MASK); } else { instHandle->hwInfo.regs->SPCR &= (~CSL_MCBSP_SPCR_DLB_MASK); } } else { status = MCBSP_ERR_BADARGS; } }
In there if arg is Mcbsp_Loopback_DISABLE, then it sets the bit 15 in SPCR, i guess this is not ok, and when i call the function mcbspControlChan with arg = Mcbsp_Loopback_DISABLE the loopback is enabled.
Maybe i am not supposed to use this function like this, but i'd say the IF clause should be:
if (Mcbsp_Loopback_DISABLE != (Mcbsp_Loopback)(*(uint32_t *)arg)) { ...