gpio.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Copyright 2023 Dual Tachyon
  2. * https://github.com/DualTachyon
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef DRIVER_GPIO_H
  17. #define DRIVER_GPIO_H
  18. #include <stdint.h>
  19. enum GPIOA_PINS {
  20. GPIOA_PIN_KEYBOARD_0 = 3,
  21. GPIOA_PIN_KEYBOARD_1 = 4,
  22. GPIOA_PIN_KEYBOARD_2 = 5,
  23. GPIOA_PIN_KEYBOARD_3 = 6,
  24. GPIOA_PIN_KEYBOARD_4 = 10, // Shared with I2C!
  25. GPIOA_PIN_KEYBOARD_5 = 11, // Shared with I2C!
  26. GPIOA_PIN_KEYBOARD_6 = 12, // Shared with voice chip!
  27. GPIOA_PIN_KEYBOARD_7 = 13, // Shared with voice chip!
  28. GPIOA_PIN_I2C_SCL = 10, // Shared with keyboard!
  29. GPIOA_PIN_I2C_SDA = 11, // Shared with keyboard!
  30. GPIOA_PIN_VOICE_0 = 12, // Shared with keyboard!
  31. GPIOA_PIN_VOICE_1 = 13 // Shared with keyboard!
  32. };
  33. enum GPIOB_PINS {
  34. GPIOB_PIN_BACKLIGHT = 6,
  35. GPIOB_PIN_ST7565_A0 = 9,
  36. GPIOB_PIN_ST7565_RES = 11, // Shared with SWD!
  37. GPIOB_PIN_SWD_IO = 11, // Shared with ST7565!
  38. GPIOB_PIN_SWD_CLK = 14,
  39. GPIOB_PIN_BK1080 = 15
  40. };
  41. enum GPIOC_PINS {
  42. GPIOC_PIN_BK4819_SCN = 0,
  43. GPIOC_PIN_BK4819_SCL = 1,
  44. GPIOC_PIN_BK4819_SDA = 2,
  45. GPIOC_PIN_FLASHLIGHT = 3,
  46. GPIOC_PIN_AUDIO_PATH = 4,
  47. GPIOC_PIN_PTT = 5
  48. };
  49. static inline void GPIO_ClearBit(volatile uint32_t *pReg, uint8_t Bit) {
  50. *pReg &= ~(1U << Bit);
  51. }
  52. static inline uint8_t GPIO_CheckBit(volatile uint32_t *pReg, uint8_t Bit) {
  53. return (*pReg >> Bit) & 1U;
  54. }
  55. static inline void GPIO_FlipBit(volatile uint32_t *pReg, uint8_t Bit) {
  56. *pReg ^= 1U << Bit;
  57. }
  58. static inline void GPIO_SetBit(volatile uint32_t *pReg, uint8_t Bit) {
  59. *pReg |= 1U << Bit;
  60. }
  61. #endif