A31L12x F/W Packages  1.4.0
ABOV Cortex-M0+ Core based MCUs Integrated Driver
A31L12x_hal_dmacn.c
Go to the documentation of this file.
1 /***************************************************************************//****************************************************************************/
34 
35 /* Includes ----------------------------------------------------------------- */
36 //******************************************************************************
37 // Include
38 //******************************************************************************
39 
40 #include "A31L12x_hal_dmacn.h"
41 
42 //******************************************************************************
43 // Variable
44 //******************************************************************************
45 
46 uint16_t PeripheralAddress[] =
47 {
48  0x0,
49  PAR_ADC,
50  PAR_SPI0_Rx,
51  PAR_SPI0_Tx,
52  PAR_SPI1_Rx,
53  PAR_SPI1_Tx,
54  PAR_USART10_Rx,
55  PAR_USART10_Tx,
56  PAR_I2C0_Rx,
57  PAR_I2C0_Tx,
58  PAR_I2C1_Rx,
59  PAR_I2C1_Tx,
60  PAR_UART0_Rx,
61  PAR_UART0_Tx,
62  PAR_UART1_Rx,
63  PAR_UART1_Tx,
64  PAR_LPUART_Rx,
65  PAR_LPUART_Tx,
66  PAR_SC0_Rx,
67  PAR_SC0_Tx,
68  PAR_SC1_Rx,
69  PAR_SC1_Tx,
70 };
71 
72 /* Public Functions --------------------------------------------------------- */
73 //******************************************************************************
74 // Function
75 //******************************************************************************
76 
77 /*-------------------------------------------------------------------------*//*-------------------------------------------------------------------------*/
127 HAL_Status_Type HAL_DMAC_Init( DMACn_Type* DMACx, uint8_t PERSEL, uint8_t DIR, uint8_t SIZE, uint8_t ERFGSTP )
128 {
129  /* Check DMAC handle */
130  if( DMACx == NULL )
131  {
132  return HAL_ERROR;
133  }
134 
135  // enable peripheral clock and reset peripheral
136  if( SCUCG->PPCLKEN2_b.DMACLKE == 0 )
137  {
138  // enable peripheral clock
139  SCUCG->PPCLKEN2_b.DMACLKE = 1; // DMACLKE[31:31] [0] in [0(disable clock) 1(enable)]
140 
141  // reset peripheral
142  SCUCG->PPRST2_b.DMARST = 1; // DMARST[31:31] [0] in [0(no effect) 1(reset; reset by w0)]
143  SCUCG->PPRST2_b.DMARST = 0; // DMARST[31:31] [0] in [0(no effect) 1(reset; reset by w0)]
144  }
145 
146  // select peripheral address: PAR
147  DMACx->PAR = PeripheralAddress[PERSEL];
148 
149  // select peripheral: PERSEL
150  DMACx->CR_b.PERSEL = PERSEL;
151 
152  // select direction: DIR
153  DMACx->CR_b.DIR = DIR;
154 
155  // select size: SIZE
156  DMACx->CR_b.SIZE = SIZE;
157 
158  // select ERFGSTP: ERFGSTP
159  DMACx->CR_b.ERFGSTP = ERFGSTP; // ERFGSTP[15:15] [0] in [0(disable DMA Stop Function by an error of peripheral) 1(enable)]
160 
161  return HAL_OK;
162 }
163 
164 /*-------------------------------------------------------------------------*//*-------------------------------------------------------------------------*/
171 HAL_Status_Type HAL_DMAC_DeInit( DMACn_Type* DMACx )
172 {
173  /* Check DMAC handle */
174  if( DMACx == NULL )
175  {
176  return HAL_ERROR;
177  }
178 
179  return HAL_OK;
180 }
181 
182 /*-------------------------------------------------------------------------*//*-------------------------------------------------------------------------*/
199 HAL_Status_Type HAL_DMAC_Setup( DMACn_Type* DMACx, uint32_t MAR, uint16_t TRANSCNT )
200 {
201  /* Check DMAC handle */
202  if( DMACx == NULL )
203  {
204  return HAL_ERROR;
205  }
206 
207  // select memory address: MAR
208  DMACx->MAR = MAR;
209 
210  // select count: TRANSCNT
211  DMACx->CR_b.TRANSCNT = TRANSCNT;
212 
213  // enable channel
214  DMACx->CR_b.CHnEN = 1; // CHnEN[00:00] [0] in [0(disable channel n) 1(enable; reset by transfer complete or error)]
215 
216  return HAL_OK;
217 }
218 
HAL_Status_Type HAL_DMAC_DeInit(DMACn_Type *DMACx)
DeInitialize DMAC peripheral.
HAL_Status_Type
Contains all macro definitions and function prototypes support for dmacn firmware library on A31L12x.
HAL_Status_Type HAL_DMAC_Init(DMACn_Type *DMACx, uint8_t PERSEL, uint8_t DIR, uint8_t SIZE, uint8_t ERFGSTP)
Init the DMAC configuration with the specified values.
HAL_Status_Type HAL_DMAC_Setup(DMACn_Type *DMACx, uint32_t MAR, uint16_t TRANSCNT)
Enable the transfer.
uint16_t PeripheralAddress[]