~aleteoryx/muditaos

ref: 317baa04e949a32ef1e72b2dd2b61c1e7a97ca25 muditaos/module-bsp/board/rt1051/drivers/RT1051DriverDMA.hpp -rw-r--r-- 1.6 KiB
317baa04 — Wojtek Rzepecki [BH-872] Fix encoder hadnling 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#ifndef PUREPHONE_RT1051DRIVERDMA_HPP
#define PUREPHONE_RT1051DRIVERDMA_HPP

#include "drivers/dma/DriverDMA.hpp"
#include "../fsl_drivers/fsl_edma.h"
#include <map>
#include "mutex.hpp"

namespace drivers
{

    void edmaCallback(struct _edma_handle *handle, void *userData, bool transferDone, uint32_t tcds);

    class RT1051DriverDMAHandle : public DriverDMAHandle
    {
        friend void edmaCallback(struct _edma_handle *handle, void *userData, bool transferDone, uint32_t tcds);

      public:
        RT1051DriverDMAHandle(const DMA_Type *base, const uint32_t channel, std::function<void()> callback);
        ~RT1051DriverDMAHandle();

        void *GetHandle()
        {
            return &handle;
        }

      private:
        edma_handle_t handle;
        std::function<void()> callback;
    };

    class RT1051DriverDMA : public DriverDMA
    {

        friend void edmaCallback(struct _edma_handle *handle, void *userData, bool transferDone, uint32_t tcds);

      public:
        RT1051DriverDMA(const DMAInstances &inst, const DriverDMAParams &params);

        ~RT1051DriverDMA();

        std::unique_ptr<DriverDMAHandle> CreateHandle(const uint32_t channel,
                                                      std::function<void()> callback = nullptr) override final;

      private:
        cpp_freertos::MutexStandard mutex;
        DMAInstances instance;
        DMA_Type *base;
    };

} // namespace drivers

#endif // PUREPHONE_RT1051DRIVERDMA_HPP