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.
MAX7221/Max7221.h
- Committer:
- jakowisp
- Date:
- 2013-08-06
- Revision:
- 1:d8589d1f368c
- Child:
- 2:828c62cc1861
File content as of revision 1:d8589d1f368c:
#ifndef Max7221_H
#define Max7221_H
// define max7219/max7221 registers
#define max7219_reg_noop 0x00
#define max7219_reg_digit0 0x01
#define max7219_reg_digit1 0x02
#define max7219_reg_digit2 0x03
#define max7219_reg_digit3 0x04
#define max7219_reg_digit4 0x05
#define max7219_reg_digit5 0x06
#define max7219_reg_digit6 0x07
#define max7219_reg_digit7 0x08
#define max7219_reg_decodeMode 0x09
#define max7219_reg_intensity 0x0a
#define max7219_reg_scanLimit 0x0b
#define max7219_reg_shutdown 0x0c
#define max7219_reg_displayTest 0x0f
#define LOW 0
#define HIGH 1
#define MHZ 1000000
#define NUMDIGITS 8
#ifdef NUMDIGITS
#define UPPERBOUND 99999999
#define LOWERBOUND -9999999
#endif
class Max7221 {
public:
Max7221(PinName msoi=p5, PinName mclk=p7, PinName load=p8);
void Write( unsigned int reg, unsigned int col);
void WriteInt( int value );
void WriteFloat( float value);
Max7221& operator= (int value){
WriteInt(value);
return *this;
};
Max7221& operator= (float value){
WriteFloat(value);
return *this;
};
void Setup (void);
static void WriteAll (unsigned int reg, unsigned int col);
static void SetupAll (void);
private:
SPI *max72_spi;
DigitalOut *load;
int id;
int *maxInUse;
static SPI *spi1;
static SPI *spi2;
static DigitalOut *load1;
static DigitalOut *load2;
static int maxInUseSPI1;
static int maxInUseSPI2;
};
#endif
MAX7221