Skip to content

Commit 1eaf56d

Browse files
committed
Added support for 1 Mbps serial data transfers
Switchable at compile time. Default is standard 115200 bps baud rate.
1 parent 9f57337 commit 1eaf56d

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

firmware/nRF51/core/openbeacon/inc/uart.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@
2727

2828
#ifndef CONFIG_UART_BUFFER
2929
#define CONFIG_UART_BUFFER 128
30-
#endif/*CONFIG_UART_BUFFER*/
30+
#endif
3131

32-
#ifdef CONFIG_UART_BAUDRATE
32+
#ifndef CONFIG_UART_FORCE_POWERED
33+
#define CONFIG_UART_FORCE_POWERED 0
34+
#endif
35+
36+
#ifdef CONFIG_UART_BAUDRATE
3337
extern void uart_init(void);
38+
extern int uart_enable(int enable);
3439
extern BOOL uart_tx(uint8_t data);
3540
extern int uart_rx(void);
36-
#endif/*CONFIG_UART_BAUDRATE*/
41+
#endif
3742

38-
#endif/*__UART_H__*/
43+
#endif /*__UART_H__*/

firmware/nRF51/core/openbeacon/src/uart.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@ void uart_init(void)
8080
NRF_UART0->EVENTS_RXDRDY = 0;
8181
#else
8282
NRF_UART0->ENABLE = 0;
83-
#endif/*CONFIG_UART_RXD_PIN*/
83+
#endif /*CONFIG_UART_RXD_PIN*/
84+
}
85+
86+
inline int uart_enable(int enable)
87+
{
88+
#if CONFIG_UART_FORCE_POWERED
89+
NRF_UART0->ENABLE = (enable) ? (NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos) : 0;
90+
#endif
91+
return enable;
8492
}
8593

8694
#ifdef CONFIG_UART_TXD_PIN
@@ -132,7 +140,9 @@ void UART0_IRQ_Handler(void)
132140
if(!g_uart_buffer_count)
133141
{
134142
NRF_UART0->TASKS_STOPTX = 1;
143+
#if !CONFIG_UART_FORCE_POWERED
135144
NRF_UART0->ENABLE = 0;
145+
#endif
136146
}
137147
else
138148
{

firmware/nRF51/tag-proximity/inc/config.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,25 @@
4646
/* double blink on invalid epoch time */
4747
#define CONFIG_EPOCH_INVALID_BLINK 1
4848

49+
/* fast 1 Mbps UART data transfer vs standard 115200 bps speed */
50+
#define CONFIG_UART_FAST 0
51+
52+
4953
/* every CONFIG_PROX_SPACING-RANDOM(2^CONFIG_PROX_SPACING_RNG_BITS)
5054
* listen for CONFIG_PROX_LISTEN - all based on LF_FREQUENCY ticks */
5155
#define CONFIG_PROX_SPACING_RNG_BITS 9
5256
#define CONFIG_PROX_SPACING MILLISECONDS(25)
5357
#define CONFIG_PROX_LISTEN_RATIO 10
5458
#define CONFIG_PROX_LISTEN MILLISECONDS(5)
5559

60+
#if CONFIG_UART_FAST
61+
#define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud1M
62+
#define CONFIG_UART_BUFFER 1024
63+
#define CONFIG_UART_FORCE_POWERED 1
64+
#else
5665
#define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200
66+
#endif
67+
5768
#define CONFIG_UART_TXD_PIN 9
5869
#ifdef CONFIG_UART_RX
5970
#define CONFIG_UART_RXD_PIN 8

firmware/nRF51/tag-proximity/src/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ void main_entry(void)
121121

122122
/* initialize UART */
123123
uart_init();
124+
uart_enable(1);
124125

125126
/* start timer */
126127
timer_init();
@@ -146,6 +147,8 @@ void main_entry(void)
146147
CONFIG_TRACKER_CHANNEL);
147148
radio_init(tag_id);
148149

150+
uart_enable(0);
151+
149152
/* enter main loop */
150153
blink_fast(5);
151154

@@ -175,8 +178,10 @@ void main_entry(void)
175178
blink_fast(10);
176179

177180
/* dump log data & status to serial */
181+
uart_enable(1);
178182
flash_log_dump();
179183
flash_log_status();
184+
uart_enable(0);
180185
#endif /* CONFIG_FLASH_LOGGING */
181186
} else if (keypress_duration > 500)
182187
{
@@ -190,7 +195,9 @@ void main_entry(void)
190195
#endif /* CONFIG_FLASH_LOGGING */
191196

192197
blink_fast(hibernate ? 3 : 6);
198+
uart_enable(1);
193199
debug_printf("\n\rhibernate -> %i", hibernate);
200+
uart_enable(0);
194201
}
195202
}
196203

0 commit comments

Comments
 (0)