This is the source code for my custom BLDC controller. A complete description and tutorial about how to use it can be found here: http://vedder.se/2014/01/a-custom-bldc-motor-controller/