-
Notifications
You must be signed in to change notification settings - Fork 1
/
OneWire_GPIO_Definitions.h
48 lines (39 loc) · 1.28 KB
/
OneWire_GPIO_Definitions.h
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
#ifndef OneWire_Direct_GPIO_h
#define OneWire_Direct_GPIO_h
#include "ch32v003fun.h"
// This header should ONLY be included by OneWire.cpp. These defines are
// meant to be private, used within OneWire.cpp, other libraries which may
// include OneWire.h.
#include <stdint.h>
// Platform specific I/O definitions
static inline __attribute__((always_inline))
uint8_t directRead()
{
return GPIO_digitalRead(GPIOv_from_PORT_PIN(GPIO_port_C, 4));
}
static inline __attribute__((always_inline))
void directModeInput()
{
GPIO_pinMode(GPIOv_from_PORT_PIN(GPIO_port_C, 4), GPIO_pinMode_I_floating, GPIO_Speed_50MHz);
}
static inline __attribute__((always_inline))
void directModeOutput()
{
GPIO_pinMode(GPIOv_from_PORT_PIN(GPIO_port_C, 4), GPIO_pinMode_O_pushPull, GPIO_Speed_50MHz);
}
static inline __attribute__((always_inline))
void directWriteLow()
{
GPIO_digitalWrite_lo(GPIOv_from_PORT_PIN(GPIO_port_C, 4));
}
static inline __attribute__((always_inline))
void directWriteHigh()
{
GPIO_digitalWrite_hi(GPIOv_from_PORT_PIN(GPIO_port_C, 4));
}
#define DIRECT_READ() directRead()
#define DIRECT_WRITE_LOW() directWriteLow()
#define DIRECT_WRITE_HIGH() directWriteHigh()
#define DIRECT_MODE_INPUT() directModeInput()
#define DIRECT_MODE_OUTPUT() directModeOutput()
#endif