Skip to content

Commit 62c0cab

Browse files
STM32 reorg: Abstract UART definition (#713)
* Abstrat UART definition
1 parent 79f2f2b commit 62c0cab

38 files changed

Lines changed: 141 additions & 117 deletions

src/config/hardware.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static char * const AUDIO_PLAYER[AUDIO_LAST] = {
3535
[AUDIO_DF_PLAYER] = "dfplayer",
3636
};
3737
#endif
38-
#if HAS_AUDIO_UART5
38+
#if HAS_AUDIO_UART
3939
const char UART5_ENABLE[] = "voice-uart5";
4040
#endif
4141
/* Section: TX Module */
@@ -97,10 +97,10 @@ static int ini_handler(void* user, const char* section, const char* name, const
9797
}
9898
}
9999
#endif
100-
#if HAS_AUDIO_UART5
100+
#if HAS_AUDIO_UART
101101
if (MATCH_KEY(UART5_ENABLE)) {
102102
if (value_int)
103-
Transmitter.audio_uart5 = 1;
103+
Transmitter.audio_uart = 1;
104104
}
105105
#endif
106106
if(MATCH_KEY("txid")) {

src/config/tx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ void CONFIG_LoadTx()
339339
Transmitter.audio_player = AUDIO_NONE;
340340
Transmitter.audio_vol = 10;
341341
#endif
342-
#if HAS_AUDIO_UART5
343-
Transmitter.audio_uart5 = 0;
342+
#if HAS_AUDIO_UART
343+
Transmitter.audio_uart = 0;
344344
#endif
345345
#if HAS_EXTRA_BUTTONS
346346
CHAN_SetButtonCfg("");

src/config/tx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ struct Transmitter {
5959
enum AudioPlayers audio_player;
6060
u8 audio_vol;
6161
#endif
62-
#if HAS_AUDIO_UART5
63-
u8 audio_uart5;
62+
#if HAS_AUDIO_UART
63+
u8 audio_uart;
6464
#endif
6565
enum Mode mode;
6666
u16 batt_alarm;

src/extended_audio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ void AUDIO_Init() {
4444
}
4545
printf("Voice: Initializing UART for extended-audio\n");
4646

47-
#if HAS_AUDIO_UART5
48-
if (Transmitter.audio_uart5) {
47+
#if HAS_AUDIO_UART
48+
if (Transmitter.audio_uart) {
4949
printf("Voice: UART5 already initialized\n");
5050
return;
5151
}
@@ -143,8 +143,8 @@ int AUDIO_Play(u16 music) {
143143

144144
void AUDIO_SetVolume() {
145145
#ifndef _DEVO12_TARGET_H_
146-
#if HAS_AUDIO_UART5
147-
if ( !Transmitter.audio_uart5 && (PPMin_Mode() || Model.protocol == PROTOCOL_PPM) ) { // don't send volume command when using PPM port
146+
#if HAS_AUDIO_UART
147+
if ( !Transmitter.audio_uart && (PPMin_Mode() || Model.protocol == PROTOCOL_PPM) ) { // don't send volume command when using PPM port
148148
#else
149149
if ( PPMin_Mode() || Model.protocol == PROTOCOL_PPM ) { // don't send volume command when using PPM port
150150
#endif
@@ -190,8 +190,8 @@ void AUDIO_CheckQueue() {
190190

191191
int AUDIO_VoiceAvailable() {
192192
#ifndef _DEVO12_TARGET_H_
193-
#if HAS_AUDIO_UART5
194-
if ( !Transmitter.audio_uart5 && (PPMin_Mode() || Model.protocol == PROTOCOL_PPM) ) { // don't send play command when using PPM port
193+
#if HAS_AUDIO_UART
194+
if ( !Transmitter.audio_uart && (PPMin_Mode() || Model.protocol == PROTOCOL_PPM) ) { // don't send play command when using PPM port
195195
#else
196196
if ( PPMin_Mode() || Model.protocol == PROTOCOL_PPM ) { // don't send play command when using PPM port
197197
#endif

src/protocol/crsf_uart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ static void initialize()
329329
return;
330330
}
331331
#if HAS_EXTENDED_AUDIO
332-
#if HAS_AUDIO_UART5
333-
if (!Transmitter.audio_uart5)
332+
#if HAS_AUDIO_UART
333+
if (!Transmitter.audio_uart)
334334
#endif
335335
Transmitter.audio_player = AUDIO_DISABLED; // disable voice commands on serial port
336336
#endif

src/protocol/frskyx_cc2500.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ static void setup_serial_port() {
333333
if ( Model.proto_opts[PROTO_OPTS_SPORTOUT] ) {
334334
UART_SetDataRate(57600); // set for s.port compatibility
335335
#if HAS_EXTENDED_AUDIO
336-
#if HAS_AUDIO_UART5
337-
if (Transmitter.audio_uart5) return;
336+
#if HAS_AUDIO_UART
337+
if (Transmitter.audio_uart) return;
338338
#endif
339339
Transmitter.audio_player = AUDIO_DISABLED; // disable voice commands on serial port
340340
#endif

src/protocol/pxxout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ static void initialize(u8 bind)
290290
return;
291291

292292
#if HAS_EXTENDED_AUDIO
293-
#if HAS_AUDIO_UART5
294-
if (!Transmitter.audio_uart5)
293+
#if HAS_AUDIO_UART
294+
if (!Transmitter.audio_uart)
295295
#endif
296296
Transmitter.audio_player = AUDIO_DISABLED; // disable voice commands on serial port
297297
#endif

src/protocol/sbus_uart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ static void initialize()
128128
return;
129129
}
130130
#if HAS_EXTENDED_AUDIO
131-
#if HAS_AUDIO_UART5
132-
if (!Transmitter.audio_uart5)
131+
#if HAS_AUDIO_UART
132+
if (!Transmitter.audio_uart)
133133
#endif
134134
Transmitter.audio_player = AUDIO_DISABLED; // disable voice commands on serial port
135135
#endif

src/protocol/testser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ static void initialize()
136136
return;
137137
}
138138
#if HAS_EXTENDED_AUDIO
139-
#if HAS_AUDIO_UART5
140-
if (!Transmitter.audio_uart5)
139+
#if HAS_AUDIO_UART
140+
if (!Transmitter.audio_uart)
141141
#endif
142142
Transmitter.audio_player = AUDIO_DISABLED; // disable voice commands on serial port
143143
#endif

src/target/drivers/mcu/stm32/f1/nvic.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <libopencm3/cm3/nvic.h>
55
#include <libopencm3/stm32/dma.h>
6+
#include <libopencm3/stm32/usart.h>
67

78
static inline uint32_t get_nvic_dma_irq(struct dma_config dma)
89
{
@@ -31,4 +32,13 @@ static inline uint32_t get_nvic_dma_irq(struct dma_config dma)
3132
}
3233
return irq;
3334
}
35+
36+
static inline uint32_t get_nvic_irq(uint32_t port)
37+
{
38+
switch (port) {
39+
case USART1: return NVIC_USART1_IRQ;
40+
default: ltassert(); return 0;
41+
}
42+
}
43+
3444
#endif // _DTX_STM32F1_NVIC_H_

0 commit comments

Comments
 (0)