| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #include <string.h>
- #include <stdio.h>
- #include "gpio.h"
- #include "rtdbg.h"
- #if 1
- #define LOGD LOG_D
- #define LOGE LOG_E
- #else
- #define LOGD printf
- #define LOGE printf
- #endif
- int gpio_init(int gpio, int io, int hl)
- {
- if(io==GPIO_IN) {
- rt_pin_mode(gpio, PIN_MODE_OUTPUT);
- }
- else {
- rt_pin_mode(gpio, PIN_MODE_OUTPUT);
- rt_pin_write(gpio, (hl>0)?PIN_HIGH:PIN_LOW);
- }
-
- return 0;
- }
- int gpio_deinit(int fd)
- {
- return 0;
- }
- int gpio_set(int gpio, int hl)
- {
- rt_pin_write(gpio, (hl>0)?PIN_HIGH:PIN_LOW);
- return 0;
- }
- int gpio_get(int gpio)
- {
- rt_ssize_t r = rt_pin_read(gpio);
- return (r==PIN_HIGH)?1:0;
- }
|