/* Start the channel selected. The channel start condition is: (EO or EP) and DO and (HO or HE). In this function HE is set. There're 2 cases to consider: */
int32_t sdma_channel_start(uint32_t channel)
/* Start the channel selected. The channel start condition is: (EO or EP) and DO and (HO or HE). In this function HE is set. There're 2 cases to consider: */
int32_t sdma_channel_start(uint32_t channel)
{
    if (channel >= SDMA_NUM_CHANNELS) {
        return SDMA_RETV_FAIL;
    }
    if (HW_SDMAARM_SDMA_CHNPRIn_RD(channel) == SDMA_CHANNEL_PRIORITY_FREE) {
        return SDMA_RETV_FAIL;
    }
    if ((HW_SDMAARM_HSTART_RD() & (1 << channel)) == 0) {
        HW_SDMAARM_HSTART_SET(1 << channel);
    }
    return SDMA_RETV_SUCCESS;
}