~aleteoryx/muditaos

ref: 317baa04e949a32ef1e72b2dd2b61c1e7a97ca25 muditaos/module-bsp/board/rt1051/eMMC/eMMC.hpp -rw-r--r-- 1.8 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
57
58
59
60
61
62
63
64
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#ifndef MODULE_BSP_EMMC_HPP
#define MODULE_BSP_EMMC_HPP

#include <stdint.h>
#include <memory>

#if defined(TARGET_RT1051)
#include "board/rt1051/bsp/eMMC/fsl_mmc.h"
#include "drivers/pll/DriverPLL.hpp"
#else
#error "Unsupported target"
#endif

#include "bsp/common.hpp"
#include "drivers/usdhc/DriverUSDHC.hpp"

namespace bsp
{
    class eMMC
    {
      public:
        enum class Partition
        {
            UserArea        = 0U, /*!< No access to boot partition (default), normal partition */
            Boot1           = 1U, /*!< Read/Write boot partition 1 */
            Boot2           = 2U, /*!< Read/Write boot partition 2*/
            RPMB            = 3U, /*!< Replay protected mem block */
            GeneralPurpose1 = 4U, /*!< access to general purpose partition 1 */
            GeneralPurpose2 = 5U, /*!< access to general purpose partition 2 */
            GeneralPurpose3 = 6U, /*!< access to general purpose partition 3 */
            GeneralPurpose4 = 7U, /*!< access to general purpose partition 4 */

        };

        eMMC()
        {}
        ~eMMC()
        {}

        RetCode Init();
        RetCode DeInit();
        RetCode ReadBlocks(uint8_t *buffer, uint32_t startBlock, uint32_t blockCount);
        RetCode WriteBlocks(const uint8_t *buffer, uint32_t startBlock, uint32_t blockCount);
        RetCode SwitchPartition(Partition partition);

        uint32_t userPartitionBlocks;

      protected:
      private:
#if defined(TARGET_RT1051)
        std::shared_ptr<drivers::DriverPLL> pll;
        mmc_card_t mmcCard;
#else
#error "Unsupported target"
#endif
        std::shared_ptr<drivers::DriverUSDHC> driverUSDHC;
    };

} // namespace bsp

#endif // MODULE_BSP_EMMC_HPP