aboutsummaryrefslogtreecommitdiff
path: root/projects/cli-test/mgmt-cli.h
diff options
context:
space:
mode:
authorFredrik Thulin <fredrik@thulin.net>2016-06-02 14:56:56 +0200
committerFredrik Thulin <fredrik@thulin.net>2016-06-02 14:56:56 +0200
commitae1ecf87f6b8d7c34b32af0547f118ff7697c2ef (patch)
treead7923423ba64b3a40f2646b210617340d96eaf2 /projects/cli-test/mgmt-cli.h
parent1b3870dd4e0429e1809ce40b70a8f558ffb5df3a (diff)
Use DMA for UART RX instead of interrupts.
DMA is more efficient and less prone to miss characters than interrupts. An open question is if circular mode is really the best. If someone copy-pastes more than the RX buffer size of configuration into the CLI, we risk the DMA controller catching up with the reader and overwriting data not yet read. Since we don't have flow control back to the users terminal, we will always fail if too much data is entered before we can process it. The question is if failing to stuff new data at the end of a buffer might be better than data being overwritten - thus messing up the commands in unpredictable ways.
Diffstat (limited to 'projects/cli-test/mgmt-cli.h')
-rw-r--r--projects/cli-test/mgmt-cli.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/projects/cli-test/mgmt-cli.h b/projects/cli-test/mgmt-cli.h
index 3b7f503..16c9fbd98 100644
--- a/projects/cli-test/mgmt-cli.h
+++ b/projects/cli-test/mgmt-cli.h
@@ -71,11 +71,16 @@
#define CLI_UART_RECVBUF_SIZE 256 /* This must be a power of 2 */
#define CLI_UART_RECVBUF_MASK (CLI_UART_RECVBUF_SIZE - 1)
+enum mgmt_cli_dma_state {
+ DMA_RX_STOP,
+ DMA_RX_START,
+};
+
extern void uart_cli_print(struct cli_def *cli __attribute__ ((unused)), const char *buf);
extern int uart_cli_read(struct cli_def *cli __attribute__ ((unused)), void *buf, size_t count);
extern int uart_cli_write(struct cli_def *cli __attribute__ ((unused)), const void *buf, size_t count);
extern int embedded_cli_loop(struct cli_def *cli);
extern void mgmt_cli_init(struct cli_def *cli);
-extern void mgmt_cli_uart_isr(const uint8_t *buf, size_t count);
+extern int control_mgmt_uart_dma_rx(enum mgmt_cli_dma_state state);
#endif /* __STM32_MGMT_CLI_H */