Steve Ravet
/
ticker_test5
short program to show a problem with spi and tickers
main.cpp
- Committer:
- sravet
- Date:
- 2010-10-20
- Revision:
- 0:85d990bd01f4
File content as of revision 0:85d990bd01f4:
#include "mbed.h" #include "pattern.h" SPI spi(p5, p6, p7); // mosi, miso, sclk DigitalOut cs(p8); DigitalOut blank(p11); DigitalOut xlat(p12); AnalogIn audio(p15); AnalogOut DAC(p18); Serial pc(USBTX, USBRX); // tx, rx Ticker refresh; void refresh_leds(void); pattern p1; int main() { int i,j,done=0,key,inc=10; int red,green,blue,sat,value; float f1,f2; // configure SPI to match TLC5947. 12 bit word, mode zero // frequency of 1 MHz. spi.format(12,0); spi.frequency(1000000); // attach the LED refresh function refresh.attach_us(refresh_leds,10000); //start the pattern isr p1.start(); while(1); } void refresh_leds(void) { int color,led,r,g,b,h,s,v; cs=1; for (led=0;led<24;led++){ spi.write(r); spi.write(b); spi.write(g); } xlat=1; xlat=0; if (blank) blank=0; cs=0; }