@@ -25,11 +25,11 @@ static uint16_t read_year = 0;
2525static int peek_data = -1 ;
2626
2727const auto BCD2DEC = [](uint8_t num) -> uint8_t {
28- return ((num/ 16 * 10 ) + (num % 16 ));
28+ return ((num / 16 * 10 ) + (num % 16 ));
2929};
3030
3131const auto DEC2BCD = [](uint8_t num) -> uint8_t {
32- return ((num/ 10 * 16 ) + (num % 10 ));
32+ return ((num / 10 * 16 ) + (num % 10 ));
3333};
3434
3535void reset_read_values () {
@@ -49,7 +49,7 @@ void ds1307_start(void) {
4949 Wire.write (0x00 );
5050 Wire.endTransmission ();
5151 Wire.requestFrom (DS1307_ADDR, 1 );
52- sec = Wire.read () & 0x7F ; // Seconds without halt bit
52+ sec = Wire.read () & 0x7F ; // Seconds without halt bit
5353
5454 // Set seconds and start clock
5555 Wire.beginTransmission (DS1307_ADDR);
@@ -66,7 +66,7 @@ void ds1307_stop(void) {
6666 Wire.write (0x00 );
6767 Wire.endTransmission ();
6868 Wire.requestFrom (DS1307_ADDR, 1 );
69- sec = Wire.read () | 0x80 ; // Seconds with halt bit
69+ sec = Wire.read () | 0x80 ; // Seconds with halt bit
7070
7171 // Set seconds and halt clock
7272 Wire.beginTransmission (DS1307_ADDR);
@@ -75,8 +75,7 @@ void ds1307_stop(void) {
7575 Wire.endTransmission ();
7676}
7777
78- void ds1307_get_time (uint8_t *sec, uint8_t *min, uint8_t *hour, uint8_t *day, uint8_t *month, uint16_t *year)
79- {
78+ void ds1307_get_time (uint8_t *sec, uint8_t *min, uint8_t *hour, uint8_t *day, uint8_t *month, uint16_t *year) {
8079 // Get time
8180 Wire.beginTransmission (DS1307_ADDR);
8281 Wire.write (0x00 );
@@ -89,24 +88,22 @@ void ds1307_get_time(uint8_t *sec, uint8_t *min, uint8_t *hour, uint8_t *day, ui
8988 peek_data = Wire.peek ();
9089 }
9190
92- *sec = BCD2DEC (Wire.read () & 0x7F ); // Seconds without halt bit
91+ *sec = BCD2DEC (Wire.read () & 0x7F ); // Seconds without halt bit
9392 *min = BCD2DEC (Wire.read ());
9493 *hour = BCD2DEC (Wire.read () & 0x3F );
95- Wire.read (); // Ignore day of week
94+ Wire.read (); // Ignore day of week
9695 *day = BCD2DEC (Wire.read ());
9796 *month = BCD2DEC (Wire.read ());
9897 *year = BCD2DEC (Wire.read ()) + 2000 ;
9998}
10099
101-
102- void ds1307_set_time (uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, uint16_t year)
103- {
100+ void ds1307_set_time (uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, uint16_t year) {
104101 Wire.beginTransmission (DS1307_ADDR);
105102 Wire.write (0x00 );
106103 Wire.write (DEC2BCD (sec));
107104 Wire.write (DEC2BCD (min));
108105 Wire.write (DEC2BCD (hour));
109- Wire.write (DEC2BCD (0 )); // Ignore day of week
106+ Wire.write (DEC2BCD (0 )); // Ignore day of week
110107 Wire.write (DEC2BCD (day));
111108 Wire.write (DEC2BCD (month));
112109 Wire.write (DEC2BCD (year - 2000 ));
@@ -157,7 +154,7 @@ void rtc_run_clock() {
157154 ds1307_get_time (&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year);
158155
159156 // Check time
160- TEST_ASSERT_UINT8_WITHIN (2 , start_sec+ 5 , read_sec);
157+ TEST_ASSERT_UINT8_WITHIN (2 , start_sec + 5 , read_sec);
161158 TEST_ASSERT_EQUAL (start_min, read_min);
162159 TEST_ASSERT_EQUAL (start_hour, read_hour);
163160 TEST_ASSERT_EQUAL (start_day, read_day);
@@ -180,7 +177,7 @@ void rtc_run_clock() {
180177 TEST_ASSERT_EQUAL (start_year, read_year);
181178}
182179
183- void change_clock (){
180+ void change_clock () {
184181 // Get time
185182 ds1307_get_time (&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year);
186183
@@ -209,7 +206,7 @@ void change_clock(){
209206 TEST_ASSERT_EQUAL (start_year, read_year);
210207}
211208
212- void swap_pins (){
209+ void swap_pins () {
213210 Wire.setPins (SCL, SDA);
214211 Wire.begin ();
215212 // Set time
0 commit comments