You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.1 KiB

  1. /*
  2. Copyright 2020 Álvaro "Gondolindrim" Volpato <alvaro.volpato@usp.br>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "m65s.h"
  15. void board_init(void) {
  16. setPinInput(B9);
  17. setPinInput(B10);
  18. }
  19. #define LED_PIN_ON_STATE 1
  20. void led_init_ports(void) {
  21. /** If the OPENDRAIN_INDICATORS option is not defined in config.h, the indicator
  22. pins default to push-pull output. Else, they are defined as open-drain. The
  23. pin mode configuration is done through the INDICATOR_PIN_MODE which is
  24. attributed right at the beggining. **/
  25. #ifndef OPENDRAIN_INDICATORS
  26. # define INDICATOR_PIN_MODE PAL_MODE_OUTPUT_PUSHPULL
  27. #else
  28. # define INDICATOR_PIN_MODE PAL_MODE_OUTPUT_OPENDRAIN
  29. #endif
  30. #ifdef LED_NUM_LOCK_PIN
  31. palSetLineMode(LED_NUM_LOCK_PIN, INDICATOR_PIN_MODE);
  32. #endif
  33. #ifdef LED_CAPS_LOCK_PIN
  34. palSetLineMode(LED_CAPS_LOCK_PIN, INDICATOR_PIN_MODE);
  35. #endif
  36. #ifdef LED_SCROLL_LOCK_PIN
  37. palSetLineMode(LED_SCROLL_LOCK_PIN, INDICATOR_PIN_MODE);
  38. #endif
  39. #ifdef LED_COMPOSE_PIN
  40. palSetLineMode(LED_COMPOSE_PIN, INDICATOR_PIN_MODE);
  41. #endif
  42. #ifdef LED_KANA_PIN
  43. palSetLineMode(LED_KANA_PIN, INDICATOR_PIN_MODE);
  44. #endif
  45. }
  46. bool led_update_kb(led_t led_state) {
  47. bool res = led_update_user(led_state);
  48. if(res) {
  49. // writePin sets the pin high for 1 and low for 0.
  50. // In this example the pins are inverted, setting
  51. // it low/0 turns it on, and high/1 turns the LED off.
  52. // This behavior depends on whether the LED is between the pin
  53. // and VCC or the pin and GND.
  54. writePin(LED_CAPS_LOCK_PIN, !led_state.caps_lock);
  55. }
  56. return res;
  57. }