libmaple/stm32f2-f4/dma.c
static int postconfig_check(dma_tube_reg_map *dummy, dma_tube_config *cfg) {
    /* TODO add dma_get_[mem,per]_size() and use them here */
    /* msize and psize are in bytes here: */
    uint32 scr = dummy->SCR;
    uint32 msize = 1U << ((scr >> 13) & 0x3);
    uint32 psize = 1U << ((scr >> 11) & 0x3);

    /* Ensure NDT will work with PSIZE/MSIZE.
     *
     * RM0033 specifies that PSIZE, MSIZE, and NDT must be such that
     * the last transfer completes; i.e. that if PSIZE < MSIZE, then
     * NDT is a multiple of MSIZE/PSIZE.  See e.g. Table 27. */
    if ((psize < msize) && (cfg->tube_nr_xfers % (msize / psize))) {
        return -DMA_TUBE_CFG_ENDATA;
    }

    /* Direct mode is only possible if MSIZE == PSIZE. */
    if ((msize != psize) && !(dummy->SFCR & DMA_SFCR_DMDIS)) {
        return -DMA_TUBE_CFG_ESIZE;
    }

    return DMA_TUBE_CFG_SUCCESS;
}
/* Final checks we can only perform when fully configured */
Final checks we can only perform when fully configured
Final checks we can only perform when fully configured
static int postconfig_check(dma_tube_reg_map *dummy, dma_tube_config *cfg) {
    uint32 scr = dummy->SCR;
    uint32 msize = 1U << ((scr >> 13) & 0x3);
    uint32 psize = 1U << ((scr >> 11) & 0x3);
    if ((psize < msize) && (cfg->tube_nr_xfers % (msize / psize))) {
        return -DMA_TUBE_CFG_ENDATA;
    }
    if ((msize != psize) && !(dummy->SFCR & DMA_SFCR_DMDIS)) {
        return -DMA_TUBE_CFG_ESIZE;
    }
    return DMA_TUBE_CFG_SUCCESS;
}
static int postconfig_check ( dma_tube_reg_map * dummy , dma_tube_config * cfg ) { uint32 scr = dummy -> SCR ; uint32 msize = 1U << ( ( scr >> 13 ) & 0x3 ) ; uint32 psize = 1U << ( ( scr >> 11 ) & 0x3 ) ; if ( ( psize < msize ) && ( cfg -> tube_nr_xfers % ( msize / psize ) ) ) { return - DMA_TUBE_CFG_ENDATA ; } if ( ( msize != psize ) && ! ( dummy -> SFCR & DMA_SFCR_DMDIS ) ) { return - DMA_TUBE_CFG_ESIZE ; } return DMA_TUBE_CFG_SUCCESS ; }
Final checks we can only perform when fully configured
Final checks we can only perform when fully configured
/* TODO add dma_get_[mem,per]_size() and use them here */ /* msize and psize are in bytes here: */ /* Ensure NDT will work with PSIZE/MSIZE.
     *
     * RM0033 specifies that PSIZE, MSIZE, and NDT must be such that
     * the last transfer completes; i.e. that if PSIZE < MSIZE, then
     * NDT is a multiple of MSIZE/PSIZE.  See e.g. Table 27. */ /* Direct mode is only possible if MSIZE == PSIZE. */