~aleteoryx/muditaos

ref: 2276ceed679b93a3a891e4f5739ade9e13991c5a muditaos/module-bsp/board/rt1051/bsp/harness/rt1051_harness_gpio.cpp -rw-r--r-- 1.0 KiB
2276ceed — Radoslaw Wicik [EGD-3743] Update copyrights in fies 5 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
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "board.h"
#include "fsl_gpio.h"
#include "log/log.hpp"
#include "rt1051_harness.hpp"

using namespace bsp::harness::gpio;

void hwGpioWrite(Pin pin, uint32_t state)
{
    switch (pin) {
    case Pin::SIM_PRESENCE:
        GPIO_PinWrite(BSP_CELLULAR_SIM_CARD_PRESENCE_PORT, BSP_CELLULAR_SIM_CARD_PRESENCE_PIN, state);
        break;
    case Pin::SIM_SELECT:
        GPIO_PinWrite(BSP_CELLULAR_SIMSEL_PORT, BSP_CELLULAR_SIMSEL_PIN, state);
        break;
    default:
        LOG_ERROR("unhandled pin: %d", pin);
    }
}

bool hwGpioRead(Pin pin)
{
    switch (pin) {
    case Pin::SIM_PRESENCE:
        return GPIO_PinRead(BSP_CELLULAR_SIM_CARD_PRESENCE_PORT, BSP_CELLULAR_SIM_CARD_PRESENCE_PIN) > 0;
    case Pin::SIM_SELECT:
        return GPIO_PinRead(BSP_CELLULAR_SIMSEL_PORT, BSP_CELLULAR_SIMSEL_PIN) > 0;
    default:
        LOG_ERROR("Unhandled pin: %d", pin);
        return false;
    }
}