+ regw_u32(I2C_CR1, 0x1, 0, OWRITE); // enable
+
+}
+
+static void start_condition() {
+
+ regw_u32(I2C_CR1, 0x1, 8, SETBIT); //start
+
+}
+
+static void stop_condition() {
+
+ regw_u32(I2C_CR1, 0x1, 9, SETBIT); //stop
+}
+
+int ack_recv() {
+
+ int cnt = 0;
+ while(!(*I2C_SR1 & 0x1)) {
+ cnt++;
+ if (cnt > TIMEOUT)
+ return 0;
+ }
+
+ return 1;
+
+}
+
+int delay() {
+
+ int a = 0;
+ for (int i = 0; i < TIMEOUT; i++)
+ a++;
+}
+
+void tm1637_start() {
+
+// regw_u32(I2C_CR1, 0x1, 8, SETBIT);
+// uint32_t read_status = *I2C_SR1;
+
+// regw_u32(I2C_DR, DATASET, 0, OWRITE);
+ // conform DATA
+// read_status = *I2C_SR1;
+// read_status = *I2C_SR2;
+
+ uint32_t statusr;
+
+ start_condition();
+ //uint32_t statusr = *I2C_SR1; // clear start_signal
+ regw_u32(I2C_DR, 0x40, 0, OWRITE); // write to address CMD
+ if(!ack_recv())
+ cputs("TIMEOUT!");
+ //statusr = *I2C_SR1;
+ //statusr = *I2C_SR2;
+ stop_condition();
+
+ //delay();
+
+ start_condition();
+ //statusr = *I2C_SR1; // clear start_signal
+ regw_u32(I2C_DR, 0xC1, 0, OWRITE);
+ if(!ack_recv())
+ cputs("TIMEOUT2!");
+ //statusr = *I2C_SR1;
+ //statusr = *I2C_SR2;
+ regw_u32(I2C_DR, 0x7D, 0, OWRITE);
+ if(!ack_recv())
+ cputs("TIMEOUT3!");
+ stop_condition();
+
+ delay();
+
+ start_condition();
+ statusr = *I2C_SR1;
+ regw_u32(I2C_DR, DISPLAY_ON, 0, OWRITE);
+ if(!ack_recv())
+ cputs("TIMEOUT4!");
+ stop_condition();
+
+
+ /* regw_u32(I2C_CR1, 0x1, 8, SETBIT); //start
+ uint32_t read_status = *I2C_SR1;
+ regw_u32(I2C_DR, 0x40, 0, OWRITE); // write to address CMD
+ read_status = *I2C_SR1;
+ read_status = *I2C_SR2;
+ regw_u32(I2C_CR1, 0x1, 9, SETBIT); //stop
+ read_status = *I2C_SR1;
+
+ regw_u32(I2C_CR1, 0x1, 8, SETBIT); //start
+ read_status = *I2C_SR1;
+ regw_u32(I2C_DR, 0xC1, 0, OWRITE); // segment address
+ read_status = *I2C_SR1;
+ read_status = *I2C_SR2;
+ regw_u32(I2C_DR, 0x7D, 0, OWRITE); // write a six
+
+ regw_u32(I2C_CR1, 0x1, 9, SETBIT); //stop
+ read_status = *I2C_SR1;
+
+ regw_u32(I2C_CR1, 0x1, 8, SETBIT); //start
+ read_status = *I2C_SR1;
+
+ regw_u32(I2C_DR, DISPLAY_ON, 0, OWRITE);
+ read_status = *I2C_SR1;
+ regw_u32(I2C_CR1, 0x1, 9, SETBIT); //stop */