Explains how to send values to the 7-digit module over I2C.
#include <stm32f4xx.h>
#define SAA1064_SUBADDR_0 0x00
#define SAA1064_ADD_12mA (1<<6)
#define SAA1064_ADD_9mA (11<<4)
#define SAA1064_ADD_6mA (1<<5)
#define SAA1064_ADD_3mA (1<<4)
#define SAA1064_SEGTEST (1<<3)
#define SAA1064_ENA24 (1<<2)
#define SAA1064_ENA13 (1<<1)
#define SAA1064_DYNMODE (1<<0)
uint8_t hex2sevenSeg[] = {
0x3F , 0x06 , 0x5B , 0x4F ,
0x66 , 0x6D , 0x7D , 0x07 ,
0x7F , 0x6F , 0x77 , 0x7C ,
0x39 , 0x5E , 0x79 , 0x71 ,
};
static __IO uint32_t TimingDelay;
void Delay(__IO uint32_t nTime) {
TimingDelay = nTime;
while (TimingDelay != 0);
}
void SysTick_Handler(void) {
if (TimingDelay) {
TimingDelay--;
}
}
int main(void) {
uint16_t count = 0;
uint8_t i2c_value[5];
if (SysTick_Config(SystemCoreClock / 1000)) {
while (1);
}
i2c_value[0] = SAA1064_ADD_12mA | SAA1064_ENA24 | SAA1064_ENA13 | SAA1064_DYNMODE;
i2c_value[1] = 0;
i2c_value[2] = 0;
i2c_value[3] = 0;
i2c_value[4] = 0;
for (;;) {
i2c_value[1] = hex2sevenSeg[(count % 0x10000) / 0x1000];
i2c_value[2] = hex2sevenSeg[(count % 0x1000) / 0x100];
i2c_value[3] = hex2sevenSeg[(count % 0x100) / 0x10];
i2c_value[4] = hex2sevenSeg[(count % 0x10) / 0x1];
count++;
Delay(250);
}
return 0;
}