AnsweredAssumed Answered

How do I convert __HAL_LINKDMA() to "register language"?

Question asked by arnold_w on Mar 21, 2016
Latest reply on Mar 21, 2016 by FTITI.Walid
I am working with the Discovery Development Board and I have written some code on top of the HAL-layer, but I don't like it and would like to get rid of it and write to the registers directly. I'm not sure how I to convert the __HAL_LINKDMA-macro:

typedef struct __DMA_HandleTypeDef
{
  DMA_Stream_TypeDef         *Instance;                                                    /*!< Register base address                  */
  DMA_InitTypeDef            Init;                                                         /*!< DMA communication parameters           */
  HAL_LockTypeDef            Lock;                                                         /*!< DMA locking object                     */ 
  __IO HAL_DMA_StateTypeDef  State;                                                        /*!< DMA transfer state                     */
  void                       *Parent;                                                      /*!< Parent object state                    */ 
  void                       (* XferCpltCallback)( struct __DMA_HandleTypeDef * hdma);     /*!< DMA transfer complete callback         */
  void                       (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback    */
  void                       (* XferM1CpltCallback)( struct __DMA_HandleTypeDef * hdma);   /*!< DMA transfer complete Memory1 callback */
  void                       (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma);    /*!< DMA transfer error callback            */
 __IO uint32_t              ErrorCode;                                                    /*!< DMA Error code                          */
}DMA_HandleTypeDef;
 
typedef struct __SPI_HandleTypeDef
{
  SPI_TypeDef                *Instance;    /* SPI registers base address */
  SPI_InitTypeDef            Init;         /* SPI communication parameters */
  uint8_t                    *pTxBuffPtr;  /* Pointer to SPI Tx transfer Buffer */
  uint16_t                   TxXferSize;   /* SPI Tx transfer size */
  uint16_t                   TxXferCount;  /* SPI Tx Transfer Counter */
  uint8_t                    *pRxBuffPtr;  /* Pointer to SPI Rx transfer Buffer */
  uint16_t                   RxXferSize;   /* SPI Rx transfer size */
  uint16_t                   RxXferCount;  /* SPI Rx Transfer Counter */
  DMA_HandleTypeDef          *hdmatx;      /* SPI Tx DMA handle parameters */
  DMA_HandleTypeDef          *hdmarx;      /* SPI Rx DMA handle parameters */
  void                       (*RxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Rx ISR */
  void                       (*TxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Tx ISR */
  HAL_LockTypeDef            Lock;         /* SPI locking object */
  __IO HAL_SPI_StateTypeDef  State;        /* SPI communication state */
  __IO uint32_t              ErrorCode;    /* SPI Error code */
}SPI_HandleTypeDef;
 
DMA_HandleTypeDef hdma_spi2_rx;
SPI_HandleTypeDef hspi2;
 
    __HAL_LINKDMA(&hspi2, hdmarx, hdma_spi2_rx);

#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)               \
                        do{                                                      \
                              (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
                              (__DMA_HANDLE__).Parent = (__HANDLE__);             \
                          } while(0)

Can someone please help me?

Outcomes