Luka Elmir

Dependencies:   mbed

Committer:
tim003
Date:
Mon Jun 02 15:35:11 2014 +0000
Revision:
6:dd675b967b60
Parent:
3:43648fa57d55
LIE26

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim003 2:e4d483d82cd8 1 #include "mbed.h"
tim003 2:e4d483d82cd8 2
tim003 2:e4d483d82cd8 3 #ifndef MATRIXSPI_H
tim003 2:e4d483d82cd8 4 #define MATRIXSPI_H
tim003 2:e4d483d82cd8 5
tim003 2:e4d483d82cd8 6 #define LOW 0
tim003 2:e4d483d82cd8 7 #define HIGH 1
tim003 2:e4d483d82cd8 8 #define MHZ 1000000
tim003 2:e4d483d82cd8 9
tim003 2:e4d483d82cd8 10 class MatrixSPI
tim003 2:e4d483d82cd8 11 {
tim003 2:e4d483d82cd8 12
tim003 2:e4d483d82cd8 13 public:
tim003 2:e4d483d82cd8 14 const static int NOOP = 0x00;
tim003 2:e4d483d82cd8 15 const static int digit0 = 0x01;
tim003 2:e4d483d82cd8 16 const static int digit1 = 0x02;
tim003 2:e4d483d82cd8 17 const static int digit2 = 0x03;
tim003 2:e4d483d82cd8 18 const static int digit3 = 0x04;
tim003 2:e4d483d82cd8 19 const static int digit4 = 0x05;
tim003 2:e4d483d82cd8 20 const static int digit5 = 0x06;
tim003 2:e4d483d82cd8 21 const static int digit6 = 0x07;
tim003 2:e4d483d82cd8 22 const static int digit7 = 0x08;
tim003 2:e4d483d82cd8 23 const static int decodeMode = 0x09;
tim003 2:e4d483d82cd8 24 const static int intensity = 0x0a;
tim003 2:e4d483d82cd8 25 const static int scanLimit = 0x0b;
tim003 2:e4d483d82cd8 26 const static int shutdown = 0x0c;
tim003 2:e4d483d82cd8 27 const static int displayTest = 0x0f;
tim003 2:e4d483d82cd8 28
tim003 2:e4d483d82cd8 29 MatrixSPI(PinName data_input = dp2, PinName clock = dp6, PinName loadcs = dp24)
tim003 2:e4d483d82cd8 30 :max72_spi(data_input, NC, clock), load(loadcs)
tim003 2:e4d483d82cd8 31 #warning ako ne radi- NC zamijeniti sa dp1
tim003 2:e4d483d82cd8 32 { setup(); }
tim003 2:e4d483d82cd8 33
tim003 2:e4d483d82cd8 34 void setup ();
tim003 2:e4d483d82cd8 35
tim003 3:43648fa57d55 36 void sendSingle(int reg, int data);
tim003 3:43648fa57d55 37 void sendCol(int col, int data);
tim003 3:43648fa57d55 38
tim003 2:e4d483d82cd8 39 void turnON(){
tim003 2:e4d483d82cd8 40 sendSingle(shutdown, 0x01); // not in shutdown mode
tim003 2:e4d483d82cd8 41 }
tim003 2:e4d483d82cd8 42
tim003 2:e4d483d82cd8 43 void turnOFF(){
tim003 2:e4d483d82cd8 44 sendSingle(shutdown, 0x00);
tim003 2:e4d483d82cd8 45 }
tim003 2:e4d483d82cd8 46
tim003 2:e4d483d82cd8 47 private:
tim003 2:e4d483d82cd8 48 SPI max72_spi;
tim003 2:e4d483d82cd8 49 DigitalOut load;
tim003 2:e4d483d82cd8 50 };
tim003 2:e4d483d82cd8 51
tim003 2:e4d483d82cd8 52 #endif // MATRIXSPI_H