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.
I2CDriver.h
00001 #ifndef MBED_I2CDRIVER_H 00002 #define MBED_I2CDRIVER_H 00003 00004 #include "mbed.h" 00005 #include "LedCube.h" 00006 00007 class I2CDriver 00008 { 00009 public: 00010 I2CDriver(PinName pin1, PinName pin2, const char addr); 00011 ~I2CDriver(); 00012 uint8_t read(void); 00013 uint8_t read(char* dat, int lengte); 00014 int receive(void); 00015 void pollForInput(LedCube* ledc); 00016 00017 enum RxStatus { 00018 NoData = 0, 00019 ReadAddressed = 1, 00020 WriteGeneral = 2, 00021 WriteAddressed = 3 00022 }; 00023 private: 00024 I2CSlave slave; 00025 static const int SIZE = 512; 00026 char databuffer[SIZE]; 00027 }; 00028 #endif
Generated on Thu Aug 25 2022 12:14:09 by
1.7.2