Jelajahi Sumber

Fix compiler warnings: sketch/tmc2130.cpp: In function 'void tmc2130_goto_step(uint8_t, uint8_t, uint8_t, uint16_t, uint16_t)':

sketch/tmc2130.cpp:795:94: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
sketch/tmc2130.cpp:807:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
sketch/tmc2130.cpp: In function 'void tmc2130_get_wave(uint8_t, uint8_t*, __file*)':
sketch/tmc2130.cpp:839:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Marek Bel 6 tahun lalu
induk
melakukan
9f68681a1b
1 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 3 3
      Firmware/tmc2130.cpp

+ 3 - 3
Firmware/tmc2130.cpp

@@ -792,7 +792,7 @@ void tmc2130_do_steps(uint8_t axis, uint16_t steps, uint8_t dir, uint16_t delay_
 void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_us, uint16_t microstep_resolution)
 {
 	printf_P(PSTR("tmc2130_goto_step %d %d %d %d \n"), axis, step, dir, delay_us, microstep_resolution);
-	uint8_t shift; for (shift = 0; shift < 8; shift++) if (microstep_resolution == (256 >> shift)) break;
+	uint8_t shift; for (shift = 0; shift < 8; shift++) if (microstep_resolution == (256u >> shift)) break;
 	uint16_t cnt = 4 * (1 << (8 - shift));
 	uint16_t mscnt = tmc2130_rd_MSCNT(axis);
 	if (dir == 2)
@@ -804,7 +804,7 @@ void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_u
 			dir ^= 1;
 			steps = -steps;
 		}
-		if (steps > (cnt / 2))
+		if (steps > static_cast<int>(cnt / 2))
 		{
 			dir ^= 1;
 			steps = cnt - steps;
@@ -829,7 +829,7 @@ void tmc2130_get_wave(uint8_t axis, uint8_t* data, FILE* stream)
 	tmc2130_setup_chopper(axis, tmc2130_usteps2mres(256), tmc2130_current_h[axis], tmc2130_current_r[axis]);
 	tmc2130_goto_step(axis, 0, 2, 100, 256);
 	tmc2130_set_dir(axis, tmc2130_get_inv(axis)?0:1);
-	for (int i = 0; i <= 255; i++)
+	for (unsigned int i = 0; i <= 255; i++)
 	{
 		uint32_t val = tmc2130_rd_MSCURACT(axis);
 		uint16_t mscnt = tmc2130_rd_MSCNT(axis);