luat_pin_air101.c 502 B

123456789101112131415161718192021222324252627
  1. #include "wm_gpio_afsel.h"
  2. #include "luat_base.h"
  3. #include "luat_pin.h"
  4. #define LUAT_LOG_TAG "pin"
  5. #include "luat_log.h"
  6. int luat_pin_to_gpio(const char* pin_name) {
  7. int zone = 0;
  8. int index = 0;
  9. int re = 0;
  10. re = luat_pin_parse(pin_name, &zone, &index);
  11. if (re < 0) {
  12. return -1;
  13. }
  14. // PA00 ~ PA15
  15. if (zone == 0 && index < 16) {
  16. return index;
  17. }
  18. // PB00 ~ PB32
  19. if (zone == 1 && index < 32) {
  20. return index + 16;
  21. }
  22. return -1;
  23. }