Skip to content

Commit 1f2901e

Browse files
committed
fix conflict of BIT() macro
1 parent d192868 commit 1f2901e

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/class/cdc/cdc_host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ static int32_t ch341_set_baudrate (cdch_interface_t* p_cdc, uint32_t baud_rate,
13581358
* inverted.
13591359
*/
13601360
if ( p_cdc->ch34x.version > 0x27 ) {
1361-
val = (val | BIT(7));
1361+
val = (val | TU_BIT(7));
13621362
}
13631363

13641364
return ch341_write_reg ( p_cdc, CH341_REG_DIVISOR << 8 | CH341_REG_PRESCALER, val, complete_cb, user_data );

src/class/cdc/serial/ch34x.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include <stdint.h>
3131

32-
#define BIT(nr) ( (uint32_t)1 << (nr) )
32+
//#define BIT(nr) ( (uint32_t)1 << (nr) )
3333

3434
#define CH34X_BUFFER_SIZE 2
3535

@@ -93,20 +93,17 @@
9393
#define CH341_LCR_CS6 0x01
9494
#define CH341_LCR_CS5 0x00
9595

96-
#define CH341_QUIRK_LIMITED_PRESCALER BIT(0)
97-
#define CH341_QUIRK_SIMULATE_BREAK BIT(1)
96+
#define CH341_QUIRK_LIMITED_PRESCALER TU_BIT(0)
97+
#define CH341_QUIRK_SIMULATE_BREAK TU_BIT(1)
9898

9999
#define CH341_CLKRATE 48000000
100100
#define CH341_CLK_DIV(ps, fact) (1 << (12 - 3 * (ps) - (fact)))
101101
#define CH341_MIN_RATE(ps) (CH341_CLKRATE / (CH341_CLK_DIV((ps), 1) * 512))
102102

103103
/* Supported range is 46 to 3000000 bps. */
104-
#define CH341_MIN_BPS DIV_ROUND_UP(CH341_CLKRATE, CH341_CLK_DIV(0, 0) * 256)
104+
#define CH341_MIN_BPS TU_DIV_CEIL(CH341_CLKRATE, CH341_CLK_DIV(0, 0) * 256)
105105
#define CH341_MAX_BPS (CH341_CLKRATE / (CH341_CLK_DIV(3, 0) * 2))
106106

107-
#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
108-
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
109-
110107
// error codes
111108
#define EINVAL 22 /* Invalid argument */
112109

src/common/tusb_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define TU_ARRAY_SIZE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
3838
#define TU_MIN(_x, _y) ( ( (_x) < (_y) ) ? (_x) : (_y) )
3939
#define TU_MAX(_x, _y) ( ( (_x) > (_y) ) ? (_x) : (_y) )
40+
#define TU_DIV_CEIL(n, d) (((n) + (d) - 1) / (d))
4041

4142
#define TU_U16(_high, _low) ((uint16_t) (((_high) << 8) | (_low)))
4243
#define TU_U16_HIGH(_u16) ((uint8_t) (((_u16) >> 8) & 0x00ff))

0 commit comments

Comments
 (0)