• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include "hal_config.h"
22 #include "dma_hw.h"
23 #include "dma_ll.h"
24 #include <driver/hal/hal_dma_types.h>
25 
26 typedef struct {
27     dma_hw_t *hw;
28     dma_unit_t id;
29 } dma_hal_t;
30 
31 #define dma_hal_clear_half_finish_interrupt_status(hal, id) dma_ll_clear_half_finish_interrupt_status((hal)->hw, (id))
32 #define dma_hal_clear_finish_interrupt_status(hal, id) dma_ll_clear_finish_interrupt_status((hal)->hw, (id))
33 #define dma_hal_is_half_finish_interrupt_triggered(hal, id) dma_ll_is_half_finish_interrupt_triggered((hal)->hw, id)
34 #define dma_hal_is_finish_interrupt_triggered(hal, id) dma_ll_is_finish_interrupt_triggered((hal)->hw, id)
35 #define dma_hal_enable_finish_interrupt(hal, id) dma_ll_enable_finish_interrupt((hal)->hw, id)
36 #define dma_hal_disable_finish_interrupt(hal, id) dma_ll_disable_finish_interrupt((hal)->hw, id)
37 #define dma_hal_enable_half_finish_interrupt(hal, id) dma_ll_enable_half_finish_interrupt((hal)->hw, id)
38 #define dma_hal_disable_half_finish_interrupt(hal, id) dma_ll_disable_half_finish_interrupt((hal)->hw, id)
39 
40 #define dma_hal_reset_config_to_default(hal, id) dma_ll_reset_config_to_default((hal)->hw, (id))
41 #define dma_hal_is_id_started(hal, id) dma_ll_is_id_started((hal)->hw, (id))
42 #define dma_hal_set_transfer_len(hal, id, tran_len) dma_ll_set_transfer_len((hal)->hw, id, tran_len)
43 #define dma_hal_get_remain_len(hal, id) dma_ll_get_remain_len((hal)->hw, (id))
44 #define dma_hal_set_prio_mode(hal, prio_mode) dma_ll_set_prio_mode((hal)->hw, prio_mode)
45 #define dma_hal_get_enable_status(hal, id) dma_ll_get_enable_status((hal)->hw, id)
46 
47 #define dma_hal_set_src_start_addr(hal, id, addr) dma_ll_set_src_start_addr((hal)->hw, id, addr)
48 #define dma_hal_set_dest_start_addr(hal, id, addr) dma_ll_set_dest_start_addr((hal)->hw, id, addr)
49 #define dma_hal_set_src_loop_addr(hal, id, start_addr, end_addr) dma_ll_set_src_loop_addr((hal)->hw, id, start_addr, end_addr)
50 #define dma_hal_set_dest_loop_addr(hal, id, start_addr, end_addr) dma_ll_set_dest_loop_addr((hal)->hw, id, start_addr, end_addr)
51 #define dma_hal_enable_src_addr_inc(hal, id) dma_ll_enable_src_addr_inc((hal)->hw, id)
52 #define dma_hal_disable_src_addr_inc(hal, id) dma_ll_disable_src_addr_inc((hal)->hw, id)
53 #define dma_hal_enable_dest_addr_inc(hal, id) dma_ll_enable_dest_addr_inc((hal)->hw, id)
54 #define dma_hal_disable_dest_addr_inc(hal, id) dma_ll_disable_dest_addr_inc((hal)->hw, id)
55 #define dma_hal_enable_src_addr_loop(hal, id) dma_ll_enable_src_addr_loop((hal)->hw, id)
56 #define dma_hal_disable_src_addr_loop(hal, id) dma_ll_disable_src_addr_loop((hal)->hw, id)
57 #define dma_hal_enable_dest_addr_loop(hal, id) dma_ll_enable_dest_addr_loop((hal)->hw, id)
58 #define dma_hal_disable_dest_addr_loop(hal, id) dma_ll_disable_dest_addr_loop((hal)->hw, id)
59 
60 #define dma_hal_set_src_pause_addr(hal, id, addr) dma_ll_set_src_pause_addr((hal)->hw, id, addr)
61 #define dma_hal_set_dest_pause_addr(hal, id, addr) dma_ll_set_dest_pause_addr((hal)->hw, id, addr)
62 #define dma_hal_get_src_read_addr(hal, id) dma_ll_get_src_read_addr((hal)->hw, id)
63 #define dma_hal_get_dest_write_addr(hal, id) dma_ll_get_dest_write_addr((hal)->hw, id)
64 
65 #define dma_hal_set_src_data_width(hal, id, data_width) dma_ll_set_src_data_width((hal)->hw, id, data_width)
66 #define dma_hal_set_dest_data_width(hal, id, data_width) dma_ll_set_dest_data_width((hal)->hw, id, data_width)
67 
68 bk_err_t dma_hal_init(dma_hal_t *hal);
69 bk_err_t dma_hal_init_dma(dma_hal_t *hal, dma_id_t id, const dma_config_t *config);
70 bk_err_t dma_hal_start_common(dma_hal_t *hal, dma_id_t id);
71 bk_err_t dma_hal_stop_common(dma_hal_t *hal, dma_id_t id);
72 
73 #if CFG_HAL_DEBUG_DMA
74 void dma_struct_dump(dma_id_t id);
75 #else
76 #define dma_struct_dump(id)
77 #endif
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 
84