Skip to content

Commit

Permalink
fixup! cpu/dg32v: add periph_i2c support
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Jan 31, 2023
1 parent 213f3e6 commit b946a5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
9 changes: 5 additions & 4 deletions cpu/gd32v/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "cpu.h"
#include "clic.h"
#include "kernel_defines.h"
#include "macros/units.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -243,10 +244,10 @@ typedef struct {
*/
#define HAVE_I2C_SPEED_T
typedef enum {
I2C_SPEED_LOW, /**< low speed mode: ~10kit/s */
I2C_SPEED_NORMAL, /**< normal mode: ~100kbit/s */
I2C_SPEED_FAST, /**< fast mode: ~400kbit/s */
I2C_SPEED_FAST_PLUS, /**< fast plus mode: ~1Mbit/s */
I2C_SPEED_LOW = KHZ(10), /**< low speed mode: ~10kit/s */
I2C_SPEED_NORMAL = KHZ(100), /**< normal mode: ~100kbit/s */
I2C_SPEED_FAST = KHZ(400), /**< fast mode: ~400kbit/s */
I2C_SPEED_FAST_PLUS = MHZ(1), /**< fast plus mode: ~1Mbit/s */
} i2c_speed_t;
/** @} */
#endif /* ndef DOXYGEN */
Expand Down
15 changes: 1 addition & 14 deletions cpu/gd32v/periph/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,7 @@ static void _init(i2c_t dev)
i2c->CTL0 &= ~I2C_CTL0_SRESET_Msk;

/* configure I2C clock */
switch (i2c_config[dev].speed) {
case I2C_SPEED_LOW:
_init_clk(i2c, KHZ(10));
break;
case I2C_SPEED_NORMAL:
_init_clk(i2c, KHZ(100));
break;
case I2C_SPEED_FAST:
_init_clk(i2c, KHZ(400));
break;
case I2C_SPEED_FAST_PLUS:
_init_clk(i2c, MHZ(1));
break;
}
_init_clk(i2c, i2c_config[dev].speed);
}

static void _deinit_pins(i2c_t dev)
Expand Down

0 comments on commit b946a5a

Please sign in to comment.