audio.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 AUDIO_H
  17. #define AUDIO_H
  18. #include <stdbool.h>
  19. #include <stdint.h>
  20. #include "bsp/dp32g030/gpio.h"
  21. #include "driver/gpio.h"
  22. enum BEEP_Type_t
  23. {
  24. BEEP_NONE = 0,
  25. BEEP_1KHZ_60MS_OPTIONAL,
  26. BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL,
  27. BEEP_440HZ_500MS,
  28. BEEP_880HZ_200MS,
  29. BEEP_880HZ_500MS,
  30. BEEP_500HZ_60MS_DOUBLE_BEEP,
  31. BEEP_440HZ_40MS_OPTIONAL,
  32. BEEP_880HZ_40MS_OPTIONAL,
  33. BEEP_880HZ_60MS_TRIPLE_BEEP
  34. };
  35. typedef enum BEEP_Type_t BEEP_Type_t;
  36. extern BEEP_Type_t gBeepToPlay;
  37. void AUDIO_PlayBeep(BEEP_Type_t Beep);
  38. enum
  39. {
  40. VOICE_ID_CHI_BASE = 0x10U,
  41. VOICE_ID_ENG_BASE = 0x60U,
  42. };
  43. enum VOICE_ID_t
  44. {
  45. VOICE_ID_0 = 0x00U,
  46. VOICE_ID_1 = 0x01U,
  47. VOICE_ID_2 = 0x02U,
  48. VOICE_ID_3 = 0x03U,
  49. VOICE_ID_4 = 0x04U,
  50. VOICE_ID_5 = 0x05U,
  51. VOICE_ID_6 = 0x06U,
  52. VOICE_ID_7 = 0x07U,
  53. VOICE_ID_8 = 0x08U,
  54. VOICE_ID_9 = 0x09U,
  55. VOICE_ID_10 = 0x0AU,
  56. VOICE_ID_100 = 0x0BU,
  57. VOICE_ID_WELCOME = 0x0CU,
  58. VOICE_ID_LOCK = 0x0DU,
  59. VOICE_ID_UNLOCK = 0x0EU,
  60. VOICE_ID_SCANNING_BEGIN = 0x0FU,
  61. VOICE_ID_SCANNING_STOP = 0x10U,
  62. VOICE_ID_SCRAMBLER_ON = 0x11U,
  63. VOICE_ID_SCRAMBLER_OFF = 0x12U,
  64. VOICE_ID_FUNCTION = 0x13U,
  65. VOICE_ID_CTCSS = 0x14U,
  66. VOICE_ID_DCS = 0x15U,
  67. VOICE_ID_POWER = 0x16U,
  68. VOICE_ID_SAVE_MODE = 0x17U,
  69. VOICE_ID_MEMORY_CHANNEL = 0x18U,
  70. VOICE_ID_DELETE_CHANNEL = 0x19U,
  71. VOICE_ID_FREQUENCY_STEP = 0x1AU,
  72. VOICE_ID_SQUELCH = 0x1BU,
  73. VOICE_ID_TRANSMIT_OVER_TIME = 0x1CU,
  74. VOICE_ID_BACKLIGHT_SELECTION = 0x1DU,
  75. VOICE_ID_VOX = 0x1EU,
  76. VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION = 0x1FU,
  77. VOICE_ID_TX_OFFSET_FREQUENCY = 0x20U,
  78. VOICE_ID_TRANSMITING_MEMORY = 0x21U,
  79. VOICE_ID_RECEIVING_MEMORY = 0x22U,
  80. VOICE_ID_EMERGENCY_CALL = 0x23U,
  81. VOICE_ID_LOW_VOLTAGE = 0x24U,
  82. VOICE_ID_CHANNEL_MODE = 0x25U,
  83. VOICE_ID_FREQUENCY_MODE = 0x26U,
  84. VOICE_ID_VOICE_PROMPT = 0x27U,
  85. VOICE_ID_BAND_SELECTION = 0x28U,
  86. VOICE_ID_DUAL_STANDBY = 0x29U,
  87. VOICE_ID_CHANNEL_BANDWIDTH = 0x2AU,
  88. VOICE_ID_OPTIONAL_SIGNAL = 0x2BU,
  89. VOICE_ID_MUTE_MODE = 0x2CU,
  90. VOICE_ID_BUSY_LOCKOUT = 0x2DU,
  91. VOICE_ID_BEEP_PROMPT = 0x2EU,
  92. VOICE_ID_ANI_CODE = 0x2FU,
  93. VOICE_ID_INITIALISATION = 0x30U,
  94. VOICE_ID_CONFIRM = 0x31U,
  95. VOICE_ID_CANCEL = 0x32U,
  96. VOICE_ID_ON = 0x33U,
  97. VOICE_ID_OFF = 0x34U,
  98. VOICE_ID_2_TONE = 0x35U,
  99. VOICE_ID_5_TONE = 0x36U,
  100. VOICE_ID_DIGITAL_SIGNAL = 0x37U,
  101. VOICE_ID_REPEATER = 0x38U,
  102. VOICE_ID_MENU = 0x39U,
  103. VOICE_ID_11 = 0x3AU,
  104. VOICE_ID_12 = 0x3BU,
  105. VOICE_ID_13 = 0x3CU,
  106. VOICE_ID_14 = 0x3DU,
  107. VOICE_ID_15 = 0x3EU,
  108. VOICE_ID_16 = 0x3FU,
  109. VOICE_ID_17 = 0x40U,
  110. VOICE_ID_18 = 0x41U,
  111. VOICE_ID_19 = 0x42U,
  112. VOICE_ID_20 = 0x43U,
  113. VOICE_ID_30 = 0x44U,
  114. VOICE_ID_40 = 0x45U,
  115. VOICE_ID_50 = 0x46U,
  116. VOICE_ID_60 = 0x47U,
  117. VOICE_ID_70 = 0x48U,
  118. VOICE_ID_80 = 0x49U,
  119. VOICE_ID_90 = 0x4AU,
  120. VOICE_ID_END = 0x4BU,
  121. VOICE_ID_INVALID = 0xFFU,
  122. };
  123. typedef enum VOICE_ID_t VOICE_ID_t;
  124. static inline void AUDIO_AudioPathOn(void) {
  125. GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
  126. }
  127. static inline void AUDIO_AudioPathOff(void) {
  128. GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
  129. }
  130. extern void AUDIO_meep(void);
  131. #ifdef ENABLE_VOICE
  132. extern VOICE_ID_t gVoiceID[8];
  133. extern uint8_t gVoiceReadIndex;
  134. extern uint8_t gVoiceWriteIndex;
  135. extern volatile uint16_t gCountdownToPlayNextVoice_10ms;
  136. extern volatile bool gFlagPlayQueuedVoice;
  137. extern VOICE_ID_t gAnotherVoiceID;
  138. void AUDIO_PlaySingleVoice(bool bFlag);
  139. void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID);
  140. uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value);
  141. void AUDIO_PlayQueuedVoice(void);
  142. #endif
  143. #endif