Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MatrixSPI.h
- Committer:
- tim003
- Date:
- 2014-05-26
- Revision:
- 2:e4d483d82cd8
- Child:
- 3:43648fa57d55
File content as of revision 2:e4d483d82cd8:
#include "mbed.h"
#ifndef MATRIXSPI_H
#define MATRIXSPI_H
#define LOW 0
#define HIGH 1
#define MHZ 1000000
class MatrixSPI
{
public:
const static int NOOP = 0x00;
const static int digit0 = 0x01;
const static int digit1 = 0x02;
const static int digit2 = 0x03;
const static int digit3 = 0x04;
const static int digit4 = 0x05;
const static int digit5 = 0x06;
const static int digit6 = 0x07;
const static int digit7 = 0x08;
const static int decodeMode = 0x09;
const static int intensity = 0x0a;
const static int scanLimit = 0x0b;
const static int shutdown = 0x0c;
const static int displayTest = 0x0f;
MatrixSPI(PinName data_input = dp2, PinName clock = dp6, PinName loadcs = dp24)
:max72_spi(data_input, NC, clock), load(loadcs)
#warning ako ne radi- NC zamijeniti sa dp1
{ setup(); }
void setup ();
void sendSingle(int reg, int data) {
load = LOW; // begin
max72_spi.write(reg); // specify register
max72_spi.write(data); // put data
load = HIGH; // make sure data is loaded (on rising edge of LOAD/CS)
}
void turnON(){
sendSingle(shutdown, 0x01); // not in shutdown mode
}
void turnOFF(){
sendSingle(shutdown, 0x00);
}
private:
SPI max72_spi;
DigitalOut load;
};
#endif // MATRIXSPI_H