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