Update about NRF51822.
Failed to receive the stm32 for a while so I bought Segger J-LINK and dev board.
Segger:
http://www.ebay.com/itm/152132013811 just $15, reliable seller and fast shipping.
With Segger I was able to use nrf manual and Keil as here
https://devzone.nordicsemi.com/tutorials/2/Managed to flash
https://github.com/I0x0I/DIY-A-BLE-Keyboard and got a working bluetooth 4.0 keyboard (use nrf51sdk9).
It's a bit more expensive than stm32 but it's worth it.
Also (a slightly cheaper solution) is to buy an ST-Link.
Bought it here
http://www.ebay.com/itm/331803020521 just $3.20 from the same seller.
This is how it looks with Segger (it doesn't power up the chip so the board needs external power):
Just hook it up, run nRFgo Studio, flash softdevice, run Keil, flash firmware and you're good to go.
ST-LINK needs fewer wires. You may hook it up to the dev board (SWCLK - SWD, SWDIO - SWIO):
Or to the nrf51822 module directly (SWCLK - SCLK, SWDIO - SDO):
I haven't managed to set up Keil work with ST-Link, but it works fine with OpenOCD.
Download s110 softdevice.hex, build your app.hex in keil and put it somewhere (I used C:\Temp):
Commands:
cd openocd-0.10.0-dev-00247-g73b676c\bin-x64
openocd -f interface/stlink-v2.cfg -f target/nrf51.cfg
telnet 127.0.0.1 4444
nrf51 mass_erase
program C:/Temp/s110_nrf51822_8.0.0_softdevice.hex
program C:/Temp/nrf51422_xxac_s110.hex
reset
Program output:
openocd -f interface/stlink-v2.cfg -f target/nrf51.cfg
Open On-Chip Debugger 0.10.0-dev-00247-g73b676c (2016-03-12-15:05)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SW
adapter speed: 1000 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v21 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.258278
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
telnet 127.0.0.1 4444
> Open On-Chip Debugger
> nrf51 mass_erase
> program C:/Temp/s110_nrf51822_8.0.0_softdevice.hex
nrf51.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
auto erase enabled
Padding image section 0 with 2112 bytes
using fast async flash loader. This is currently supported
only with ST-Link and CMSIS-DAP. If you have issues, add
"set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
nrf51.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0xfffffffc
wrote 93184 bytes from file C:/Temp/s110_nrf51822_8.0.0_softdevice.hex in 3.923701s (23.192 KiB/s)
** Programming Finished **
> program C:/Temp/nrf51422_xxac_s110.hex
nrf51.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0
** Programming Started **
auto erase enabled
using fast async flash loader. This is currently supported
only with ST-Link and CMSIS-DAP. If you have issues, add
"set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
nrf51.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x000007c0
wrote 20480 bytes from file C:/Temp/nrf51422_xxac_s110.hex in 0.900467s (22.211 KiB/s)
** Programming Finished **
> reset
P.S. Dudes, who don't like the whole NRF51822 mess and Cortex-M0+ may flash cheap HC-06 modules into RN42 HID modules and control them from any MCU of your liking,
http://imgur.com/a/1LHSRP.P.S. For non-wireless dudes. If someone wants to use pro micro ($3) instead of teensy 2.0 ($20) for a 87-key matrix, apparently it's possible, see
https://hackaday.io/project/8282-alpen-clack/log/27395-matrix "It turns out that Pro Micro doesn't break out all the pins. In fact, it only breaks out 18 GPIO pins, and uses 2 more for build-in LEDs, leaving the remaining 5 pins unconnected. OK, with some delicate soldering I can reclaim the two LED pins - just remove the LEDs and solder wires in that place. That gives me 20 pins to work with. My keyboard has 88 keys. That means, that if I make a matrix 8×11, I can support them all with 19 pins, and even have one pin left".
P.P.P.S Also it's possible to make your own Bluetooth HID Relay (essentially,
http://handheldsci.com/kb, but much, much cheaper) using an arduino and converted HC-06 (unfortunately you'd still need to buy an USB host shield board):
http://hackaday.com/2016/09/04/convert-any-usb-keyboard-to-bluetooth/Upd: flashing HM-10 (Bluetooth 4.0) modules (
CHECK IT OUT):
https://geekhack.org/index.php?topic=62236.msg2300518#msg2300518