Driver - TLC 5940 NETMF driver

[title]TLC 5940 NETMF driver[/title]
http://code.tinyclr.com/project/425/tlc-5940-netmf-driver/
[line]
Driver to access a TLC 5940 16 channel 4096 grey scale PWM LED driver sinking the current.

The usage example is for a 4x4x4 led cube using the TLC 5940 to drive the 16 columns (cathodes). The anodes connected in each layer are driven by a TIP126 PNP darlington.

The usage example configures the SPI2 to be used to input the data to the serial interface of the TLC. Timer 3 of the LP2887 is used to generate the GSClk signal for the PWM functionality of the LED driver IC.
Changing the value of the timer3 prescale register allows to change the PWM clock. 300000 results in roughly 1Hz clock that you can see the different grey values to disappear one after the other. Range should then be 0 - 15. When reducing the prescaler value to around 3000 a refresh rate of the TLC is roughly 500- 800 Hz.
The GSclk is divided by a 4bit counter to allow currently for 16 grey values. Replacing the IC with a 12 bit counter allows all supported 4096 grey levels of the LED driver IC. Therefore the prescale value has to be reduced accordingly to achieve the same refresh rate. For a simple LED bar a refresh rate of 50 Hz is sufficient, when trying to drive a 8 layer LED cube the refresh rate should be increased to at least 400 Hz.
The divided GSClk is used to generate the necessary Blank and Xlat pulses for the LED driver - allowing to change the pattern. Also it is fed to Pin Di34 configured as Interrupt pin. The interrupt handler changes the pattern according to the next layer to come (only needed for a LED cube application).