説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

led.c 979B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * led.c
  3. *
  4. * Copyright (c) 2024 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #include "pico/stdlib.h"
  19. #include "led.h"
  20. #define LED_COUNT 4
  21. static const uint gpio_num[LED_COUNT] = {
  22. 12, 13, 14, 15,
  23. };
  24. void led_init(void) {
  25. for (uint i = 0; i < LED_COUNT; i++) {
  26. gpio_init(gpio_num[i]);
  27. gpio_set_dir(gpio_num[i], GPIO_IN);
  28. }
  29. }
  30. void led_set(uint32_t i, bool v) {
  31. i %= LED_COUNT;
  32. gpio_put(i, v);
  33. }