fix #if in hardware/structs/dma.h (#9)

* fix #if in hardware/structs/dma.h

* move dma driver code from register definitions to dma drivers

Co-authored-by: Peter Lawrence <12226419+majbthrd@users.noreply.github.com>
This commit is contained in:
majbthrd 2021-01-27 12:22:26 -06:00 committed by Graham Sanderson
parent 76b385bc26
commit 92bd96a3b2
2 changed files with 19 additions and 20 deletions

View File

@ -10,13 +10,6 @@
#include "hardware/address_mapped.h" #include "hardware/address_mapped.h"
#include "hardware/platform_defs.h" #include "hardware/platform_defs.h"
#include "hardware/regs/dma.h" #include "hardware/regs/dma.h"
#include "pico/assert.h"
// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_DMA, Enable/disable DMA assertions, type=bool, default=0, group=hardware_dma
#ifndef PARAM_ASSERTIONS_ENABLED_DMA
#define PARAM_ASSERTIONS_ENABLED_DMA 0
#endif
typedef struct { typedef struct {
io_rw_32 read_addr; io_rw_32 read_addr;
@ -68,17 +61,4 @@ typedef struct {
#define dma_hw ((dma_hw_t *const)DMA_BASE) #define dma_hw ((dma_hw_t *const)DMA_BASE)
#define dma_debug_hw ((dma_debug_hw_t *const)(DMA_BASE + DMA_CH0_DBG_CTDREQ_OFFSET)) #define dma_debug_hw ((dma_debug_hw_t *const)(DMA_BASE + DMA_CH0_DBG_CTDREQ_OFFSET))
static inline void check_dma_channel_param(uint channel) {
#if PARAM_ASSERTIONS_ENABLED(DMA)
// this method is used a lot by inline functions so avoid code bloat by deferring to function
extern void check_dma_channel_param_impl(uint channel);
check_dma_channel_param_impl(channel);
#endif
}
inline static dma_channel_hw_t *dma_channel_hw_addr(uint channel) {
check_dma_channel_param(channel);
return &dma_hw->ch[channel];
}
#endif #endif

View File

@ -10,6 +10,7 @@
#include "pico.h" #include "pico.h"
#include "hardware/structs/dma.h" #include "hardware/structs/dma.h"
#include "hardware/regs/dreq.h" #include "hardware/regs/dreq.h"
#include "pico/assert.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -36,6 +37,24 @@ extern "C" {
// this is not defined in generated dreq.h // this is not defined in generated dreq.h
#define DREQ_FORCE 63 #define DREQ_FORCE 63
// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_DMA, Enable/disable DMA assertions, type=bool, default=0, group=hardware_dma
#ifndef PARAM_ASSERTIONS_ENABLED_DMA
#define PARAM_ASSERTIONS_ENABLED_DMA 0
#endif
static inline void check_dma_channel_param(uint channel) {
#if PARAM_ASSERTIONS_ENABLED(DMA)
// this method is used a lot by inline functions so avoid code bloat by deferring to function
extern void check_dma_channel_param_impl(uint channel);
check_dma_channel_param_impl(channel);
#endif
}
inline static dma_channel_hw_t *dma_channel_hw_addr(uint channel) {
check_dma_channel_param(channel);
return &dma_hw->ch[channel];
}
/*! \brief Mark a dma channel as used /*! \brief Mark a dma channel as used
* \ingroup hardware_dma * \ingroup hardware_dma
* *