This is a driver for a project I made in school. It involves a Raspberry Pi connected to the MBED, which in turn is connected to a Ledcube. The MBED delivers data for the leds to the Ledcube continuously at a 100 Hz rate, using SPI. This data is read from an internal buffer. For animations, the Raspberry Pi just sends data when the current "image" has to change, using I2C.

Dependencies:   mbed mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SPIDriver.h Source File

SPIDriver.h

00001 #ifndef MBED_SPIDriver_H
00002 #define MBED_SPIDriver_H
00003 
00004 #include "mbed.h"
00005 #include "LedCube.h"
00006 
00007 class SPIDriver{
00008     public: 
00009         SPIDriver(PinName pin1, PinName pin2, PinName pin3, PinName latchpin, PinName cspin, const int freq);
00010         ~SPIDriver();
00011         void write(uint8_t ledcolor);
00012         void reversedwrite(uint8_t ledcolor);
00013         void pulseLatch();
00014         void sendLayer(LedCube* ledc);
00015         void sendFrame(LedCube* ledc);
00016         void sendTestFrame(LedCube* ledc);
00017         void sendTest(LedCube* ledc, int frames);
00018         void testPhase(int xframes);
00019         uint8_t reverse_byte(uint8_t byte);
00020         
00021     private: 
00022         SPI spi;
00023         DigitalOut *latch;
00024         DigitalOut *cs;
00025 };
00026 #endif
00027