Initial commit - sync AliceRC to Gitea
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file gpio.h
|
||||
* @brief GPIO 模式配置和读写
|
||||
* STC8H 端口模式由 PxM0/PxM1 控制:
|
||||
* 00: 准双向口 (弱上拉)
|
||||
* 01: 推挽输出
|
||||
* 10: 高阻输入
|
||||
* 11: 开漏输出
|
||||
*/
|
||||
#ifndef __GPIO_H
|
||||
#define __GPIO_H
|
||||
|
||||
#include "stc8h.h"
|
||||
|
||||
typedef enum {
|
||||
GPIO_MODE_BIDIR = 0x00, /* 准双向 */
|
||||
GPIO_MODE_PUSHPULL = 0x01, /* 推挽输出 */
|
||||
GPIO_MODE_INPUT = 0x02, /* 高阻输入 */
|
||||
GPIO_MODE_OD = 0x03, /* 开漏输出 */
|
||||
} GPIOMode_e;
|
||||
|
||||
void gpio_set_mode(uint8_t port, uint8_t pin, GPIOMode_e mode);
|
||||
void gpio_write(uint8_t port, uint8_t pin, uint8_t val);
|
||||
uint8_t gpio_read(uint8_t port, uint8_t pin);
|
||||
void gpio_toggle(uint8_t port, uint8_t pin);
|
||||
|
||||
/* 端口编号 */
|
||||
#define PORT_P0 0
|
||||
#define PORT_P1 1
|
||||
#define PORT_P2 2
|
||||
#define PORT_P3 3
|
||||
#define PORT_P4 4
|
||||
#define PORT_P5 5
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user