m65s.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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(B10);
  17. }
  18. #define LED_PIN_ON_STATE 1
  19. void led_init_ports(void) {
  20. /** If the OPENDRAIN_INDICATORS option is not defined in config.h, the indicator
  21. pins default to push-pull output. Else, they are defined as open-drain. The
  22. pin mode configuration is done through the INDICATOR_PIN_MODE which is
  23. attributed right at the beggining. **/
  24. #ifndef OPENDRAIN_INDICATORS
  25. # define INDICATOR_PIN_MODE PAL_MODE_OUTPUT_PUSHPULL
  26. #else
  27. # define INDICATOR_PIN_MODE PAL_MODE_OUTPUT_OPENDRAIN
  28. #endif
  29. #ifdef LED_NUM_LOCK_PIN
  30. palSetLineMode(LED_NUM_LOCK_PIN, INDICATOR_PIN_MODE);
  31. #endif
  32. #ifdef LED_CAPS_LOCK_PIN
  33. palSetLineMode(LED_CAPS_LOCK_PIN, INDICATOR_PIN_MODE);
  34. #endif
  35. #ifdef LED_SCROLL_LOCK_PIN
  36. palSetLineMode(LED_SCROLL_LOCK_PIN, INDICATOR_PIN_MODE);
  37. #endif
  38. #ifdef LED_COMPOSE_PIN
  39. palSetLineMode(LED_COMPOSE_PIN, INDICATOR_PIN_MODE);
  40. #endif
  41. #ifdef LED_KANA_PIN
  42. palSetLineMode(LED_KANA_PIN, INDICATOR_PIN_MODE);
  43. #endif
  44. }
  45. bool led_update_kb(led_t led_state) {
  46. bool res = led_update_user(led_state);
  47. if(res) {
  48. // writePin sets the pin high for 1 and low for 0.
  49. // In this example the pins are inverted, setting
  50. // it low/0 turns it on, and high/1 turns the LED off.
  51. // This behavior depends on whether the LED is between the pin
  52. // and VCC or the pin and GND.
  53. writePin(LED_CAPS_LOCK_PIN, !led_state.caps_lock);
  54. }
  55. return res;
  56. }