]> git.gir.st - tmk_keyboard.git/blob - keyboard/hhkb_rn42/MEMO.txt
11f64b8c4c43d751ca251e62f52b6c40db894338
[tmk_keyboard.git] / keyboard / hhkb_rn42 / MEMO.txt
1 Roving RN-42
2 ============
3
4 TODO
5 ----
6 Bug:
7 - with Nexus5 keyboard and mouse are very laggy.
8
9 Power saving:
10 - 8MHz clock
11 - When not connected in a few minutes get into deep sleep to save battery life
12 - CTS is needed for waking up from deep sleep? How deep sleep is activated?
13 - firmware controlled 3.3V DC converter to switch on/off BT module
14 - sleep MCU and BT module(keyboard is not used)
15 - deep sleep MCU and BT module(keyboard is not used for long time)
16 - deep sleep MCU and turn off BT module(keyboard is not used and not connected)
17 - Battery ADC; switching, high resistance
18
19 Improving:
20 - BT LED; connecting, linked, sleeping, deep sleeping
21 - Battry LED; blink(using timer?)
22 - move rn42 to protocol directory when it becomes reusable stack
23 - LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256).
24
25 Testing:
26 - Factroy reset doesn't work; need to **test again** 10K pull-up is too high?
27 - Lipo voltage ADC value is not stabilized
28 - DCDC converter: squeaky inducter; try other inductors
29
30 - Keymap layer bug: during space is pressed(mousekey) press Fn(HHKB) then release space before Fn, in result HHKB layer is locked(toggled) unintentionally.
31
32
33 Done:
34 - low battery alert(solid light) 09/04
35
36
37 Power routing
38 -------------
39 Current:
40 (USB) +---(Lipo)
41 | | |
42 | | +------+ DPDT
43 | | |Switch/-----------------------+
44 | | +------+ |
45 | +-------+ | |
46 +-|Charger| | |
47 | +-------+ | +---+ |
48 | | |MCU| |
49 | | +---+ |
50 | | | |
51 | | | |
52 +--------------+ +-----+ +------+ +---/--+ +-----+
53 |Power Selector|--|DC 5V|--|DC3.3V|---|Switch|----|RN-42|
54 +--------------+ +-----+ +------+ +------+ +-----+
55 USB Power is boosted unnecessarily, not harmful?
56
57 Idea 1:
58 (USB) +---(Lipo)
59 | | |
60 | | +------+ DPDT
61 | | |Switch/----------+
62 | | +------+ |
63 | +-------+ | |
64 +-|Charger| | |
65 | +-------+ | +---+ |
66 | +-----+ |MCU| |
67 | |DC 5V| +---+ |
68 | +-----+ | |
69 | | | |
70 +--------------+ | +---/--+ +------+ +-----+
71 |Power Selector|-----+---|Switch|----|DC3.3V|-----|RN-42|
72 +--------------+ +------+ +------+ +-----+
73 To enable BT when USB powered it still needs to turn siwtch on, Lipo consumes quinscent current at 5V converter in vain.(Not good)
74
75 Idea 2:
76 (USB) +---(Lipo)
77 | | |
78 | | +------+
79 | | |Switch|
80 | | +------+
81 | +-------+ |
82 +-|Charger| |
83 | +-------+ | +---+
84 | +-----+ |MCU|----+ Controlled by firmware
85 | |DC 5V| +---+ | On: Lipo powered
86 | +-----+ | | Off: USB powered
87 | | | |enable
88 +--------------+ | +------+ +-----+
89 |Power Selector|-----+---|DC3.3V|-----|RN-42|
90 +--------------+ +------+ +-----+
91 MCU can controlled power of RN-42 without hardware switch.
92 When USB powered and switch is on Lipo consumes quinscent current at 5V converter in vain.(Not good)
93
94 Idea 3:
95 (USB) +---(Lipo)
96 | | |
97 | | +------+
98 | | |Switch|SPST(or without)
99 | | +------+
100 | +-------+ |
101 +-|Charger| |
102 | +-------+ | +---+
103 | | |MCU|----+ Controlled by firmware
104 | | +---+ | On: Lipo powered
105 | | | | Off: USB powered
106 | | | |enable
107 +--------------+ +-----+ +------+ +-----+
108 |Power Selector|-|DC 5V|-|DC3.3V|-----|RN-42|
109 +--------------+ +-----+ +------+ +-----+
110 Switch is needed to save Lipo when not used because decent power saving is not available now. If firmware can turn off BT module completely and make MCU deep sleep the switch will be not even needed.
111
112
113
114
115
116 DONE:
117 - BT_INDICATOR LED turns on wrongly when touching line or pin. -- pull-up enabled on PF6/GPIO2 08/30
118 - Lipo charger configuration: fast charge time: USB charger spec? -- used 2kohm
119 - use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB
120 - Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done
121 - CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done
122 - add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24
123 - LINKED: add trace on PIO2 to PF6 07.24
124 - Lipo voltage ADC sensing
125 - Lipo charger MCP73831: needs capacitor 4.7uF *2
126 - USB connection check - 07.01
127 - BT on/off check: whether RX line is pulled up? - checking RTS 07.01
128 - USB/BT switching BT is on -> BT, BT is off -> USB - 07.01
129 - Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V 07.01
130 - Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough 07.01
131 - Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04
132
133
134
135 TROUBLE SHOOT
136 -------------
137 07/16 After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive.
138 Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before.
139
140 07/18 On Linux, had an USB related trouble; keyobard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it.
141
142
143
144 Lipo
145 ----
146 850mA lasts around 9 hours(07/28)
147
148 Sparkfun Polymer Lithium Ion Battery 850mAh:
149 https://www.sparkfun.com/products/341
150 Lipo Cell spec:
151 https://www.sparkfun.com/datasheets/Batteries/063048%20Li-polymer.pdf
152 Protection spec:
153 http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/BatteryProtection.pdf
154 min typical max
155 over-charge 4.255 4.280 4.305
156 over-charge discover? 4.030 4.080 4.130
157 over-discharge 2.827 2.900 2.973
158 over-discharge discover 3.022 3.100 3.178
159
160 ADC voltage monitor: voltage divider 10K+10K(0.5)
161 ADC=V*0.5/2.56*1024
162
163 V ADC
164 ------------------
165 4.20 0x347(839)
166 3.10 0x26b(619)
167
168
169
170
171 Configuration
172 -------------
173 Ver 6.15 04/26/2013
174 (c) Roving Networks
175 ***Settings***
176 BTA=0006664B3AE3
177 BTName=tmkBT-3AE3
178 Baudrt(SW4)=115K
179 Mode =DTR
180 Authen=2
181 Bonded=0
182 Rem=000000000000
183 ***ADVANCED Settings***
184 SrvName= keyboard/mouse
185 SrvClass=0000
186 DevClass=0000
187 InqWindw=0100
188 PagWindw=0100
189 CfgTimer=255
190 StatuStr=NULL
191 HidFlags=3c
192 DTRtimer=8
193 KeySwapr=0
194 ***OTHER Settings***
195 Profile= HID
196 CfgChar= $
197 SniffEna=8010
198 LowPower=0
199 TX Power=0
200 IOPorts= 0
201 IOValues=0
202 Sleeptmr=0
203 DebugMod=0
204 RoleSwch=0
205
206
207
208 Serial connection
209 -----------------
210 Serial line: 115200bps, 8bit, 1-stopbit, non-parity, no flow control
211 SSP: 115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth)
212
213 To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD')
214 To exit type '---'(you will see 'END') and '+' to get local echo.
215
216
217
218 Setting command mode
219 --------------------
220 S-,tmkBT // Device name
221 SS,keyboard/mouse // service name
222 SM,4 // Auto Connect DTR mode
223 SW,8010 // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save
224 S~,6 // HID profile
225 SH,003C // HID register
226 SY,0004 // Transmit power
227
228
229
230
231 Other options:
232 SC,0000 // COD: 000005C0 (see HID spec/Bluegiga doc)
233 SD,05C0 // bit 12-8 7 6 5-0
234 // 00101 1 1 0
235 // peripheral pointing keybaord joystick, gamepad, ...
236 SM,6 // Pairing mode: auto connect
237 SM,4 // Master mode: Connection can be controled with GPIO6
238
239
240
241
242 HID profile
243 -----------
244 S~,6 HID profile
245 S~,0 SPP profile
246 R,1 reboot
247
248
249 Apple iOS
250 ---------
251 Keyboard can be used with iPhone, but mouse cannot.
252 To operate iOS with keyboard is not so useful, though.
253 There may be iOS specific scancodes?
254
255
256 HID flag register
257 -----------------
258 SH,0200
259 GH
260
261 10 0000 0000(0200) default
262 00 0011 1000(0038) Combo
263 || | | |\_\____ number of paired devices to which the module can reconnect
264 || | | \_______ send out reports over UART (0xFF <len> <data>)
265 || \__\_________ descriptor type
266 |\______________ toggle virtual keyboard on iOS when first connected
267 \_______________ Force HID mode if GPIO11 is high on power-up
268
269 Descriptor type:
270 0000: keybaord
271 0001: Game Pad
272 0010: Mouse
273 0011: Combo
274 0100: Joystick
275 1xxx: reserved
276
277
278 Out report - Indicator
279 ----------------------
280 0xFE 0x02 0x01 <LED_state>
281
282
283 LED Status
284 ----------
285 Configuring 10 times per sec
286 Startup/configuration timer 2 times per sec
287 Discoverable/Inquiring/Idle once per sec
288 Connected solid on
289
290
291 Pairing
292 -------
293 First, host initiates pairing process and once it is done, auto connect will work thereafter.
294 SM,3 Master mode
295 SM,4 Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR)
296 confirm: auto connect works and control connection with GPIO6
297 SM,5 Auto Connect ANY Mode (Mode =ANY)
298 each time GPIO is set, make inquiry and connect to the first found device
299 SM,6 automatically reconnect(Mode =Pair)
300 confirm: auto connect works well but difficult to enter command mode.
301
302
303 Fast data mode
304 --------------
305 The module enters fast data mode after 'remote configuration timer' window is passed from power on.
306 In this mode the module does not accept '$$$' to enter command mode.
307
308 Power Management
309 ----------------
310 Inquiry and Page window Idle or Active (3.1.1)
311 Downside: delay in discovery or connection time
312 SI, // set inquiry scan window(discovery) on/off duty?
313 SJ, // set page scan window(connection)
314 This reduces averaege power >20mA to 5mA(3mA in Sniff mode)
315
316 Sniff mode Transmit
317 Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA)
318 In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA)
319 SW,<val> // set interval timer(*0.625ms) 0000-7FFF
320
321 Deep sleep Idle (3.1.2)
322 In this mode the module shuts down completly and only draws about 300uA. To enable this set the most signifant bit(0x8000) of Sniff interaval timer.
323 SW,8320 // deep sleep enable(interval=0x320*0.625=500ms)
324 In normal sleep the firmware is still running in idle mode, and wakes up about 20 times per second to check ports, update LEDs, etc. During deep sleep, the firmware actually stops runnig some tasks and the LEDs only update about once per second.
325 To wake from deep sleep there are three ways: (in worst case wake up takes 5ms)
326 *send a charactor to the UART(first charactor will be lost)
327 *toggle CTS low to high and wait 5ms
328 *wake automatically every slot time(<val>*0.625ms)
329 Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again.
330 Downside: latency and data loss
331
332 Disable Output driver Idle or Active (3.1.3)
333 S%,1000 // set all GPIO pins(0-11) to inputs.
334
335 Lower Transmit Power Idle or Active (3.1.4)
336 SY,<hex> // transmit power setting(takes effect after a power cycle and reboot)
337 Downside: reducing effective range
338
339
340 Optimizig for Latency
341 ---------------------
342 By default the firmware is optimized for throughput.
343 SQ,16 // set latency bit
344 SQ,0 // unset latency bit
345
346
347 Configuration timer settings
348 ----------------------------
349 Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
350
351 The module has remote configuration timer to allow remote configuration over Bluetooth after power up in Slave mode. In Master modes the remote configuration timer is set to 0(no remote configuration). (In Trigger Master mode the timer is used as an idle timer to break the connection after time expires with no charactors receive.)
352 ST,0 // no remote, no local when connected
353 ST,<1-252> // local and remote with timeout in seconds from power up
354 ST,253 // local only without timeout
355 ST,254 // remote only without timeout
356 ST,255 // local and remote without timeout
357
358
359 Android
360 -------
361 3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
362
363
364 Commands
365 --------
366 SC,
367 SM,<val>
368 SD,
369 SP,<string> Pin code(alpahnumeric)
370 SQ,<mask> Special configuration(GPIO, discovery mode, low latency, reboot, UART)
371 SR,<hex> Store remote address
372 SR,Z Erase all address
373 SS,<string> Set service name(1-20)**
374 ST,<val> Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer)
375 SU,<val> UART baud rate
376 SW,<val> low-power sniff mode** deep sleep and wake up every 625us * <val>
377 SX,<0|1> bonding enable only acceps device that matches the stored address
378 SY,<hex> power setting**
379 SZ,<val> non-standard raw baud rate <val>=baud*0.004096
380 S~,<val> Profile 0:SPP, 5:APL, 6:HID
381 S-,<string> Device name -15 alphanumeric charactors
382 S?,<0|1> role switch enable
383 S$,<char> command mode char
384 $|,<hex> low-power connect mode deep sleep/active(discoverable and connectable) cycle
385 D display basic setting
386 E display extended setting
387 GB display the device's Bluetooth address
388 GF display Bluetooth address of connected device
389 GK show connection status
390 GR show remote address for reconnecting
391 G& show GPIO pin
392 G<char> show stored setting
393 + toggle local echo on/off
394 & show GPIO 3,4,6,7(DIP switch)
395 C connect to stored remote address
396 C,<address> connect last address
397 CFI connect and go into fast data mode
398 CFR connect and go into fast data mode
399 CT,<address>,<val> connect to the address and disconnect after val?
400 F,1 fast data mod:
401 H display help
402 I,<time>,<cod> inquiry scan with <cod>
403 IN
404 IQ scan
405 IS inquiry scan with 001F00
406 J hide pin code
407 K, kill disconnects current connection
408 L link quality
409 M show modem signlal status
410 O display other settings
411 P,<car> pass through?
412 Q quiet mode make the module not discoverable
413 Q,0 discoverable and connectable
414 Q,1 not discoverable and not connectable
415 Q,2 not discoverable and connectable
416 Q,? display current quiet mode
417 R,1 reboot
418 T,<0|1> pass received data while in command mode
419 U,<baud>,<parity> change UART setting tentatively
420 V display firmware version
421 W wake from quiet mode enable discovery and connection
422 Z deep sleep mode(<2mA)
423
424
425
426 help
427 ----
428 *** SET COMMANDS ***
429 SA,<3,0> - Authentication
430 SC,<hex> - Service Class
431 SD,<hex> - Device Class
432 SE,<1-16> - UUID
433 SF,1 - Factory Defaults
434 SH,<hex> - HID flags
435 SI,<hex> - Inquiry Scan Window
436 SJ,<hex> - Page Scan Window
437 SL,<E,O,N> - Parity
438 SM,<0-5> - Mode (0=slav,1=mstr,2=trig,3=auto,4=DTR,5=Any)
439 SN,<name> - Name
440 SO,<text> - conn/discon Status
441 SP,<text> - Pin Code
442 SR,<adr> - Remote Address
443 SS,<text> - Service Name
444 ST,<num> - Config Timer
445 SU,<rate> - Baudrate
446 SW,<hex> - Sniff Rate
447 SX,<1,0> - Bonding
448 SY,<hex> - TX power
449 SZ,<num> - Raw Baudrate
450 S~,<0-6> - Profile (0=SPP,1=DCE,2=DTE,3=MDM,4=D&S,6=HID
451 S?,<0-1> - role switch
452 S$,<char> - CMD mode char
453 S@,<hex> - io port dir
454 S&,<hex> - io port val
455 S%,<hex> - io boot dir
456 S^,<hex> - io boot val
457 S*,<hex> - pio(8-11) set
458 S|,<hex> - low power timers
459 S+,<num> - DTR timer
460 S=,<hex> - Key mapper
461 S:,<num> - sleep timer
462 *** DISPLAY ***
463 D - Basic Settings
464 E - Extended Settings
465 G<X> - Stored setting
466 GB - BT Address
467 GF - BT Address of Last Connection
468 GK - Connect Status
469 G& - I/O Ports
470 V - Firmare version
471 *** OTHER ***
472 C,<adr> - Connect
473 F,1 - Fast Mode
474 I,<time>,<cod> - Device Scan Inquiry
475 J - Hide Pin Code
476 K, - Kill (disconnect)
477 L, - toggle local echo
478 P,<text> - Pass Thru
479 Q - Quiet (no discovery)
480 R,1 - Reboot
481 T,<0,1> - send data in CMD mode
482 U,<rate>,<E,O,N> - Temp Uart Change
483 Z - low power sleep
484 & - Read switches
Imprint / Impressum