aboutsummaryrefslogtreecommitdiff
path: root/protocol
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-08-26 17:39:04 +0900
committertmk <nobody@nowhere>2014-08-26 17:39:04 +0900
commitc672cbc31c67335050dc3ba9d54acb97e5d3da0c (patch)
treeb4fbcfc7f7c58781ee503e3e98ae31fce78de133 /protocol
parentc4530ab0a8d7cf09ec37b082695f8f17f02c2b00 (diff)
downloadqmk_firmware-c672cbc31c67335050dc3ba9d54acb97e5d3da0c.tar.gz
qmk_firmware-c672cbc31c67335050dc3ba9d54acb97e5d3da0c.zip
Add option 7bit data to serial_soft.c
Diffstat (limited to 'protocol')
-rw-r--r--protocol/serial_soft.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/protocol/serial_soft.c b/protocol/serial_soft.c
index e8870bcd7..44822b7e4 100644
--- a/protocol/serial_soft.c
+++ b/protocol/serial_soft.c
@@ -122,7 +122,11 @@ void serial_send(uint8_t data)
122 /* signal state: IDLE: ON, START: OFF, STOP: ON, DATA0: OFF, DATA1: ON */ 122 /* signal state: IDLE: ON, START: OFF, STOP: ON, DATA0: OFF, DATA1: ON */
123 123
124#ifdef SERIAL_SOFT_BIT_ORDER_MSB 124#ifdef SERIAL_SOFT_BIT_ORDER_MSB
125 #ifdef SERIAL_SOFT_DATA_7BIT
126 uint8_t mask = 0x40;
127 #else
125 uint8_t mask = 0x80; 128 uint8_t mask = 0x80;
129 #endif
126#else 130#else
127 uint8_t mask = 0x01; 131 uint8_t mask = 0x01;
128#endif 132#endif
@@ -133,7 +137,11 @@ void serial_send(uint8_t data)
133 SERIAL_SOFT_TXD_OFF(); 137 SERIAL_SOFT_TXD_OFF();
134 _delay_us(WAIT_US); 138 _delay_us(WAIT_US);
135 139
136 while (mask) { 140#ifdef SERIAL_SOFT_DATA_7BIT
141 while (mask&0x7F) {
142#else
143 while (mask&0xFF) {
144#endif
137 if (data&mask) { 145 if (data&mask) {
138 SERIAL_SOFT_TXD_ON(); 146 SERIAL_SOFT_TXD_ON();
139 parity ^= 1; 147 parity ^= 1;
@@ -173,7 +181,11 @@ ISR(SERIAL_SOFT_RXD_VECT)
173 uint8_t data = 0; 181 uint8_t data = 0;
174 182
175#ifdef SERIAL_SOFT_BIT_ORDER_MSB 183#ifdef SERIAL_SOFT_BIT_ORDER_MSB
184 #ifdef SERIAL_SOFT_DATA_7BIT
185 uint8_t mask = 0x40;
186 #else
176 uint8_t mask = 0x80; 187 uint8_t mask = 0x80;
188 #endif
177#else 189#else
178 uint8_t mask = 0x01; 190 uint8_t mask = 0x01;
179#endif 191#endif
@@ -197,7 +209,11 @@ ISR(SERIAL_SOFT_RXD_VECT)
197#else 209#else
198 mask <<= 1; 210 mask <<= 1;
199#endif 211#endif
200 } while (mask); 212#ifdef SERIAL_SOFT_DATA_7BIT
213 } while (mask&0x7F);
214#else
215 } while (mask&0xFF);
216#endif
201 217
202#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD) 218#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD)
203 /* to center of parity bit */ 219 /* to center of parity bit */