rt-thread posix接口之pin设备使用
今年年中时在线听RTT全国技术大会,当时有关于posix接口的内容,关于其posix接口,之前一直有使用文件系统接口以及网络socket接口,这次尝试一下用posix接口操作普通外设,就用pin设备来试试吧
实践
1、硬件板
自己很早之前网购的 落灰牌GD32f450开发板
2、软件版本
RT-Thread 4.1.1,使用官方IDE以导入bsp的方式导入了gd32f450的bsp
2.1 posix接口操作pin示例
#include <stdio.h>
#include <rtthread.h>
#include <dfs_posix.h> /* 当需要使用文件操作时,需要包含这个头文件 */
#include <sys/ioctl.h>
#include <rtdevice.h>
#include "drv_gpio.h"
#define LED_PIN GET_PIN(C, 0)
rt_uint16_t pin;
rt_uint16_t status;
typedef struct {
uint16_t pin;
uint16_t mode;
} pin_mode_t;
typedef struct {