Skip to content

CC2540 firmware for the tiniest mechanical keyboard ever

Notifications You must be signed in to change notification settings

joric/cc2540-keyboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CC2540 Keyboard

Video

World's smallest keyboard

Hardware

  • $2.65 CC2540 module (RF-BM-S02) from Aliexpress (11.2 x 15.1 x 1.74 mm, onboard USB support)
  • $1.83 Arduino Nano from Aliexpress (to program the chip)
  • $0.92 Panasonic CR1216 lithium 3v battery (12.5 × 1.6 mm), 34 mAh
  • $0.00 Cherry MX Blue keychain (20 x 11 mm) from GeekKeys (actually $3.50 but I got it for free)

Software

Flashing

Build or download precompiled firmware from the repository (HIDEmuKbd.hex), use CCLoader and Arduino Nano to flash it.

Build and upload CCLoader sketch (CCLoader.ino) to Arduino Nano using Arduino IDE.

Hook up CC2540 to Arduino Nano digital pins D4-D6 as shown in the table (don't forget about 3.3V VCC and GND):

Signal CC254x CCLoader
DEBUG_CLOCK P2_1 D6
DEBUG_DATA P2_2 D5
RESET RES D4

Convert firmware.hex to firmware.bin using hex to bin converter.

hex2bin.exe firmware.hex

Run CCLoader client on PC. E.g. for COM6 and Arduino Nano (Device 0) use:

CCLoader.exe 6 firmware.bin 0

That's it, the cc2540 module should accept the new firmware and start working right away (after bluetooth pairing).

The keyboard button is attached to P0_1 (P01) and GND pins. It sends WinKey keycode, you may modify the code to send any key or a key sequence of your choice. The battery (3V) is attached to VCC and GND pins.

Building

This keyboard uses modified HIDEmuKbd sample from the CC2540 SDK.

Copy provided files to the corresponding BLE-CC254x-1.4.0 SDK folders.

Run IAR, open .eww, hit Make. You may also try precompiled firmware from the repository.

Compilation Errors

  • Error[e16]: Segment ISTACK (size: 0xc0 align: 0) is too long for segment definition. At least 0xe more bytes needed. The problem occurred while processing the segment

You got to set number of virtual registers to 8 (in Project - Options - General Options).

Experimental USB mode

This section is pure experimental and it's not related to the keyboard above, you may skip it.

As you know, CC2540 supports USB (CC2541 doesn't), and can be used as USB-HID, USB Serial or USB Mass Storage Device.

  • HIDAdvRemoteDongle sample for the USB HID device.
  • HostTestApp sample for the BTool-compatible serial device.
  • util/UBL sample for the USB Mass Storage device

To run USB firmware and to detect USB on this module, U+ needs to be pulled to +3.3v via 1.5k resistor.

Sadly, USB Mass Storage doesn't work (yet) on this RF-BM-S02 module. It sometimes shows removable drive and even shows DEFAULT.CFG file but never opens it. Not sure if it is software or hardware problem (looks like it opens slightly faster on a low speed USB 2.0). The module uses CC254XF256 so memory should be enough. Probably software problem, because USB HID works just fine.

Official SDK Hardware

You don't really need official CC2540 SDK hardware (Keyfob and USB Dongle) but you could need schematics and defines.

CC2540 buttons and LEDs for Keyfob and Dongle development kits (defined in hal_board_cfg.h):

Define Keyfob Dongle
HAL_KEY_SW_1 P0_0 P1_2
HAL_KEY_SW_2 P0_1 P1_3
HAL_LED_1 P1_0 P0_0
HAL_LED_2 P1_1 P1_1

Note that P0_0 pin is not available on RF-BM-S02

Pictures

Arduino Nano as CCLoader

Arduino Nano as CCLoader

Breadboard rig with attached USB

Breadboard rig with attached USB

RF-BM-S02 Pinout

RF-BM-S02

RF-BM-S02 Dimensions

RF-BM-S02 Dimensions

RF-BM-S02 Schematics

RF-BM-S02 Schematics

Official CC2540 SDK Hardware

CC2540 Keyfob CC2540 Keyfob Schematics

CC2540 USB Dongle CC2540 USB Dongle Schematics

More Pictures

See the full album here: https://imgur.com/a/OkwEb

References

About

CC2540 firmware for the tiniest mechanical keyboard ever

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published