aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/serial_driver.md1
-rw-r--r--drivers/chibios/serial_usart.c13
-rw-r--r--readme.md6
3 files changed, 15 insertions, 5 deletions
diff --git a/docs/serial_driver.md b/docs/serial_driver.md
index bc376b6dd..c98f4c117 100644
--- a/docs/serial_driver.md
+++ b/docs/serial_driver.md
@@ -60,6 +60,7 @@ Configure the hardware via your config.h:
60 // 5: about 19200 baud 60 // 5: about 19200 baud
61#define SERIAL_USART_DRIVER SD1 // USART driver of TX pin. default: SD1 61#define SERIAL_USART_DRIVER SD1 // USART driver of TX pin. default: SD1
62#define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7 62#define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7
63#define SERIAL_USART_TIMEOUT 100 // USART driver timeout. default 100
63``` 64```
64 65
65You must also enable the ChibiOS `SERIAL` feature: 66You must also enable the ChibiOS `SERIAL` feature:
diff --git a/drivers/chibios/serial_usart.c b/drivers/chibios/serial_usart.c
index 62b4913cb..72fcaed0c 100644
--- a/drivers/chibios/serial_usart.c
+++ b/drivers/chibios/serial_usart.c
@@ -58,7 +58,10 @@
58# error invalid SELECT_SOFT_SERIAL_SPEED value 58# error invalid SELECT_SOFT_SERIAL_SPEED value
59#endif 59#endif
60 60
61#define TIMEOUT 100 61#ifndef SERIAL_USART_TIMEOUT
62# define SERIAL_USART_TIMEOUT 100
63#endif
64
62#define HANDSHAKE_MAGIC 7 65#define HANDSHAKE_MAGIC 7
63 66
64static inline msg_t sdWriteHalfDuplex(SerialDriver* driver, uint8_t* data, uint8_t size) { 67static inline msg_t sdWriteHalfDuplex(SerialDriver* driver, uint8_t* data, uint8_t size) {
@@ -201,21 +204,21 @@ int soft_serial_transaction(int index) {
201 sdClear(&SERIAL_USART_DRIVER); 204 sdClear(&SERIAL_USART_DRIVER);
202 205
203 // First chunk is always transaction id 206 // First chunk is always transaction id
204 sdWriteTimeout(&SERIAL_USART_DRIVER, &sstd_index, sizeof(sstd_index), TIME_MS2I(TIMEOUT)); 207 sdWriteTimeout(&SERIAL_USART_DRIVER, &sstd_index, sizeof(sstd_index), TIME_MS2I(SERIAL_USART_TIMEOUT));
205 208
206 uint8_t sstd_index_shake = 0xFF; 209 uint8_t sstd_index_shake = 0xFF;
207 210
208 // Which we always read back first so that we can error out correctly 211 // Which we always read back first so that we can error out correctly
209 // - due to the half duplex limitations on return codes, we always have to read *something* 212 // - due to the half duplex limitations on return codes, we always have to read *something*
210 // - without the read, write only transactions *always* succeed, even during the boot process where the slave is not ready 213 // - without the read, write only transactions *always* succeed, even during the boot process where the slave is not ready
211 res = sdReadTimeout(&SERIAL_USART_DRIVER, &sstd_index_shake, sizeof(sstd_index_shake), TIME_MS2I(TIMEOUT)); 214 res = sdReadTimeout(&SERIAL_USART_DRIVER, &sstd_index_shake, sizeof(sstd_index_shake), TIME_MS2I(SERIAL_USART_TIMEOUT));
212 if (res < 0 || (sstd_index_shake != (sstd_index ^ HANDSHAKE_MAGIC))) { 215 if (res < 0 || (sstd_index_shake != (sstd_index ^ HANDSHAKE_MAGIC))) {
213 dprintf("serial::usart_shake NO_RESPONSE\n"); 216 dprintf("serial::usart_shake NO_RESPONSE\n");
214 return TRANSACTION_NO_RESPONSE; 217 return TRANSACTION_NO_RESPONSE;
215 } 218 }
216 219
217 if (trans->initiator2target_buffer_size) { 220 if (trans->initiator2target_buffer_size) {
218 res = sdWriteTimeout(&SERIAL_USART_DRIVER, trans->initiator2target_buffer, trans->initiator2target_buffer_size, TIME_MS2I(TIMEOUT)); 221 res = sdWriteTimeout(&SERIAL_USART_DRIVER, trans->initiator2target_buffer, trans->initiator2target_buffer_size, TIME_MS2I(SERIAL_USART_TIMEOUT));
219 if (res < 0) { 222 if (res < 0) {
220 dprintf("serial::usart_transmit NO_RESPONSE\n"); 223 dprintf("serial::usart_transmit NO_RESPONSE\n");
221 return TRANSACTION_NO_RESPONSE; 224 return TRANSACTION_NO_RESPONSE;
@@ -223,7 +226,7 @@ int soft_serial_transaction(int index) {
223 } 226 }
224 227
225 if (trans->target2initiator_buffer_size) { 228 if (trans->target2initiator_buffer_size) {
226 res = sdReadTimeout(&SERIAL_USART_DRIVER, trans->target2initiator_buffer, trans->target2initiator_buffer_size, TIME_MS2I(TIMEOUT)); 229 res = sdReadTimeout(&SERIAL_USART_DRIVER, trans->target2initiator_buffer, trans->target2initiator_buffer_size, TIME_MS2I(SERIAL_USART_TIMEOUT));
227 if (res < 0) { 230 if (res < 0) {
228 dprintf("serial::usart_receive NO_RESPONSE\n"); 231 dprintf("serial::usart_receive NO_RESPONSE\n");
229 return TRANSACTION_NO_RESPONSE; 232 return TRANSACTION_NO_RESPONSE;
diff --git a/readme.md b/readme.md
index 6092f209b..6321681a9 100644
--- a/readme.md
+++ b/readme.md
@@ -7,6 +7,12 @@
7[![GitHub contributors](https://img.shields.io/github/contributors/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/pulse/monthly) 7[![GitHub contributors](https://img.shields.io/github/contributors/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/pulse/monthly)
8[![GitHub forks](https://img.shields.io/github/forks/qmk/qmk_firmware.svg?style=social&label=Fork)](https://github.com/qmk/qmk_firmware/) 8[![GitHub forks](https://img.shields.io/github/forks/qmk/qmk_firmware.svg?style=social&label=Fork)](https://github.com/qmk/qmk_firmware/)
9 9
10# THIS IS THE DEVELOP BRANCH
11
12Warning- This is the `develop` branch of QMK Firmware. You may encounter broken code here. Please see [Breaking Changes](https://docs.qmk.fm/#/breaking_changes) for more information.
13
14# Original readme continues
15
10This is a keyboard firmware based on the [tmk\_keyboard firmware](https://github.com/tmk/tmk_keyboard) with some useful features for Atmel AVR and ARM controllers, and more specifically, the [OLKB product line](https://olkb.com), the [ErgoDox EZ](https://ergodox-ez.com) keyboard, and the [Clueboard product line](https://clueboard.co). 16This is a keyboard firmware based on the [tmk\_keyboard firmware](https://github.com/tmk/tmk_keyboard) with some useful features for Atmel AVR and ARM controllers, and more specifically, the [OLKB product line](https://olkb.com), the [ErgoDox EZ](https://ergodox-ez.com) keyboard, and the [Clueboard product line](https://clueboard.co).
11 17
12## Documentation 18## Documentation