diff options
| author | Ryan | 2024-11-14 19:00:02 +0100 |
|---|---|---|
| committer | GitHub | 2024-11-14 19:00:02 +0100 |
| commit | 46236ce3de8385f27e3f13a9921abee7e1e0fa57 (patch) | |
| tree | 0d5dfc4c40f2b590de0d493324a308d488bda02a /docs/drivers/i2c.md | |
| parent | a8a47c40114c72a042516c1f93384f228685eb3e (diff) | |
[docs] Improve halconf/mcuconf code examples (#24597)
Diffstat (limited to 'docs/drivers/i2c.md')
| -rw-r--r-- | docs/drivers/i2c.md | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/docs/drivers/i2c.md b/docs/drivers/i2c.md index 10949ed59e..c806a090c5 100644 --- a/docs/drivers/i2c.md +++ b/docs/drivers/i2c.md @@ -54,18 +54,25 @@ The ATmega16/32U2 does not possess I2C functionality, and so cannot use this dri You'll need to determine which pins can be used for I2C -- a an example, STM32 parts generally have multiple I2C peripherals, labeled I2C1, I2C2, I2C3 etc. -To enable I2C, modify your board's `halconf.h` to enable I2C: +To enable I2C, modify your board's `halconf.h` to enable I2C, then modify your board's `mcuconf.h` to enable the peripheral you've chosen: -```c -#define HAL_USE_I2C TRUE +::: code-group +```c [halconf.h] +#pragma once + +#define HAL_USE_I2C TRUE // [!code focus] + +#include_next <halconf.h> ``` +```c [mcuconf.h] +#pragma once -Then, modify your board's `mcuconf.h` to enable the peripheral you've chosen, for example: +#include_next <mcuconf.h> -```c -#undef STM32_I2C_USE_I2C2 -#define STM32_I2C_USE_I2C2 TRUE +#undef STM32_I2C_USE_I2C2 // [!code focus] +#define STM32_I2C_USE_I2C2 TRUE // [!code focus] ``` +::: |`mcuconf.h` Setting |Description |Default| |----------------------------|----------------------------------------------------------------------------------|-------| |