Can somebody provide MAX6955 or 6954 initialization routine. I need to drive 8 X 16-Segment displays.
Edit: I found this C++ Code. Can somebody translate it to C Code? I found this code at mbed.com
https://mbed.org/users/lonesometraveler/code/MAX6955/rev/
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| #include "MAX6955.h"
MAX6955::MAX6955(PinName sda, PinName scl, char driver): i2c_(sda, scl), driver_(driver){}
int MAX6955::write(char command, char data){
char i2cData[2];
i2cData[0] = command;
i2cData[1] = data;
int result = i2c_.write(driver_, i2cData, 2);
wait(0.07);
return result;
}
int MAX6955::writeS(char* buffer){
int result = i2c_.write(driver_, (char *) buffer, 8);
wait(0.07);
return result;
}
int MAX6955::init(){
int result = 0;
result = result + write(reg_decodeMode, 0x00);
result = result + write(reg_scanLimit, 0x07);
result = result + write(reg_configuration, 0x21);
result = result + write(reg_globalIntensity, 0x08);
result = result + write(reg_digitType, 0xFF);
result = result + write(reg_displayTest, 0x00);
return result;
} |
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
| #ifndef MAX6955_H
#define MAX6955_H
#include "mbed.h"
#define reg_noOp 0x00
#define reg_decodeMode 0x01
#define reg_globalIntensity 0x02
#define reg_scanLimit 0x03
#define reg_configuration 0x04
#define reg_displayTest 0x07
#define reg_digitType 0x0C
#define reg_intensity10 0x10
#define reg_intensity32 0x11
#define reg_intensity54 0x12
#define reg_intensity76 0x13
#define reg_intensity10a 0x14
#define reg_intensity32a 0x15
#define reg_intensity54a 0x16
#define reg_intensity76a 0x17
#define USE_GLOBAL 0x00
#define USE_DISCRETE 0x40
#define RUN 0x01
#define SHUTDOWN 0x00
#define reg_digit0 0x60
#define reg_digit1 0x61
#define reg_digit2 0x62
#define reg_digit3 0x63
#define reg_digit4 0x64
#define reg_digit5 0x65
#define reg_digit6 0x66
#define reg_digit7 0x67
#define reg_digit0a 0x68
#define reg_digit1a 0x69
#define reg_digit2a 0x6A
#define reg_digit3a 0x6B
#define reg_digit4a 0x6C
#define reg_digit5a 0x6D
#define reg_digit6a 0x6E
#define reg_digit7a 0x6F
class MAX6955{
public:
/*
* @param sda mbed pin for I2C SDA
* @param scl mbed pin for I2C SCL
* @param driver I2C device address
*/
MAX6955(PinName sda, PinName scl, char driver);
int write(char command, char data);
int writeS(char* buffer);
int init(void);
private:
I2C i2c_;
char driver_;
};
#endif |
Somebody please explain these lines.
Code C++ - [expand] |
1
2
3
4
5
6
7
| MAX6955::MAX6955(PinName sda, PinName scl, char driver): i2c_(sda, scl), driver_(driver){}
int result = i2c_.write(driver_, i2cData, 2);
private:
I2C i2c_;
char driver_; |
Edit:
I got CCS C Code. Can somebody translate this to mikroC Code?
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| #define MAX6955BaseAddress 0b11000000
#define reg_noOp 0x00
#define reg_decodeMode 0x01
#define reg_globalIntensity 0x02
#define reg_scanLimit 0x03
#define reg_configuration 0x04
#define reg_displayTest 0x07
#define reg_digitType 0x0C
#define reg_intensity10 0x10
#define reg_intensity32 0x11
#define reg_intensity54 0x12
#define reg_intensity76 0x13
#define reg_intensity10a 0x14
#define reg_intensity32a 0x15
#define reg_intensity54a 0x16
#define reg_intensity76a 0x17
#define USE_GLOBAL 0x00
#define USE_DISCRETE 0x40
#define RUN 0x01
#define SHUTDOWN 0x00
#define reg_digit0 0x60
#define reg_digit1 0x61
#define reg_digit2 0x62
#define reg_digit3 0x63
#define reg_digit4 0x64
#define reg_digit5 0x65
#define reg_digit6 0x66
#define reg_digit7 0x67
#define reg_digit0a 0x68
#define reg_digit1a 0x69
#define reg_digit2a 0x6A
#define reg_digit3a 0x6B
#define reg_digit4a 0x6C
#define reg_digit5a 0x6D
#define reg_digit6a 0x6E
#define reg_digit7a 0x6F
void writeMAX6955(unsigned char, unsigned char, unsigned char);
void initMAX6955(unsigned char);
void writeMAX6955(unsigned char driver, unsigned char command, unsigned char data)
{
i2c_start();
i2c_write(MAX6955BaseAddress + (driver<<1));
i2c_write(command);
i2c_write(data);
i2c_stop();
}
void initMAX6955(unsigned char driver)
{
writeMAX6955(driver, reg_decodeMode, 0x00);
writeMAX6955(driver, reg_scanLimit, 0x07);
writeMAX6955(driver, reg_configuration, (RUN|USE_DISCRETE));
writeMAX6955(driver, reg_globalIntensity, 0x0F);
writeMAX6955(driver, reg_digitType, 0x00);
writeMAX6955(driver, reg_displayTest, 0x01);
delay_ms(1000);
writeMAX6955(driver, reg_displayTest, 0x00);
} |
Can somebody tell what should be the values of driver, command, and data? I need to display HI on 16 segment displays. I also need the connections.