Skip to content

Commit f9e0169

Browse files
committed
hosted/ftdi: jtagtap_cycle: Express divmod by 8 as shift and mask
1 parent d095eae commit f9e0169

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/platforms/hosted/ftdi_jtag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static void ftdi_jtag_cycle(const bool tms, const bool tdi, const size_t clock_c
166166
* 0x8f CLK_BYTES: Length of 0..n will generate 1..1+n byte cycles,
167167
* i.e. emit 8..8*(n+1) clocks, so adjust clock_bytes down by 1.
168168
*/
169-
size_t clock_bytes = clock_cycles / 8U;
169+
size_t clock_bytes = clock_cycles >> 3U;
170170
if (clock_bytes > 0) {
171171
clock_bytes--;
172172
const uint8_t cmd8[3U] = {
@@ -177,7 +177,7 @@ static void ftdi_jtag_cycle(const bool tms, const bool tdi, const size_t clock_c
177177
ftdi_buffer_write_arr(cmd8);
178178
}
179179
/* 0x8e CLK_BITS: Length of 0..7 will emit 1..8 clocks */
180-
const uint8_t clock_bits = clock_cycles % 8U - 1U;
180+
const uint8_t clock_bits = (clock_cycles & 7U) - 1U;
181181
if (clock_bits >= 8U)
182182
return;
183183
const uint8_t cmd1[2U] = {

0 commit comments

Comments
 (0)