Align ChibiOS I2C defs with other drivers (#14399)
* Align ChibiOS I2C defs with other drivers * Update keyboards/xelus/valor_frl_tkl/config.h Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
parent
bb841087bb
commit
0fa217a5b7
@ -63,14 +63,11 @@ Then, modify your board's `mcuconf.h` to enable the peripheral you've chosen, fo
|
|||||||
Configuration-wise, you'll need to set up the peripheral as per your MCU's datasheet -- the defaults match the pins for a Proton-C, i.e. STM32F303.
|
Configuration-wise, you'll need to set up the peripheral as per your MCU's datasheet -- the defaults match the pins for a Proton-C, i.e. STM32F303.
|
||||||
|
|
||||||
|`config.h` Overrride |Description |Default|
|
|`config.h` Overrride |Description |Default|
|
||||||
|------------------------|-------------------------------------------------------------------------------------------|-------|
|
|------------------------|--------------------------------------------------------------|-------|
|
||||||
|`I2C_DRIVER` |I2C peripheral to use - I2C1 -> `I2CD1`, I2C2 -> `I2CD2` etc. |`I2CD1`|
|
|`I2C_DRIVER` |I2C peripheral to use - I2C1 -> `I2CD1`, I2C2 -> `I2CD2` etc. |`I2CD1`|
|
||||||
|`I2C1_BANK` (deprecated)|The bank of pins (`GPIOA`, `GPIOB`, `GPIOC`), superseded by `I2C1_SCL_BANK`/`I2C1_SDA_BANK`|`GPIOB`|
|
|`I2C1_SCL_PIN` |The pin definition for SCL |`B6` |
|
||||||
|`I2C1_SCL_BANK` |The bank of pins (`GPIOA`, `GPIOB`, `GPIOC`) to use for SCL |`GPIOB`|
|
|
||||||
|`I2C1_SCL` |The pin number for SCL (0-15) |`6` |
|
|
||||||
|`I2C1_SCL_PAL_MODE` |The alternate function mode for SCL |`4` |
|
|`I2C1_SCL_PAL_MODE` |The alternate function mode for SCL |`4` |
|
||||||
|`I2C1_SDA_BANK` |The bank of pins (`GPIOA`, `GPIOB`, `GPIOC`) to use for SDA |`GPIOB`|
|
|`I2C1_SDA_PIN` |The pin definition for SDA |`B7` |
|
||||||
|`I2C1_SDA` |The pin number for SDA (0-15) |`7` |
|
|
||||||
|`I2C1_SDA_PAL_MODE` |The alternate function mode for SDA |`4` |
|
|`I2C1_SDA_PAL_MODE` |The alternate function mode for SDA |`4` |
|
||||||
|
|
||||||
The following configuration values depend on the specific MCU in use.
|
The following configuration values depend on the specific MCU in use.
|
||||||
|
@ -80,12 +80,9 @@ ARM MCU 用の設定はしばしば非常に複雑です。これは、多くの
|
|||||||
STM32 MCU では、使用するハードウェアドライバにより、さまざまなピンを I2C ピンとして設定できます。標準では `B6`, `B7` ピンが I2C 用のピンです。 I2C 用のピンを設定するために次の定義が使えます:
|
STM32 MCU では、使用するハードウェアドライバにより、さまざまなピンを I2C ピンとして設定できます。標準では `B6`, `B7` ピンが I2C 用のピンです。 I2C 用のピンを設定するために次の定義が使えます:
|
||||||
|
|
||||||
| 変数 | 説明 | 既定値 |
|
| 変数 | 説明 | 既定値 |
|
||||||
|-----------------------|--------------------------------------------------------------------------------------------------|---------|
|
|-----------------------|-------------------------------------------------------------------------------------------|---------|
|
||||||
| `I2C1_SCL_BANK` | SCL に使うピンのバンク (`GPIOA`, `GPIOB`, `GPIOC`) | `GPIOB` |
|
| `I2C1_SCL_PIN` | SCL のピン番号 | `B6` |
|
||||||
| `I2C1_SDA_BANK` | SDA に使うピンのバンク (`GPIOA`, `GPIOB`, `GPIOC`) | `GPIOB` |
|
| `I2C1_SDA_PIN` | SDA のピン番号 | `B7` |
|
||||||
| `I2C1_SCL` | SCL のピン番号 (0-15) | `6` |
|
|
||||||
| `I2C1_SDA` | SDA のピン番号 (0-15) | `7` |
|
|
||||||
| `I2C1_BANK`(非推奨) | 使用するピンのバンク (`GPIOA`, `GPIOB`, `GPIOC`)。後継は `I2C1_SCL_BANK`, `I2C1_SDA_BANK` です。 | `GPIOB` |
|
|
||||||
|
|
||||||
ChibiOS I2C ドライバの設定項目は STM32 MCU の種類に依存します。
|
ChibiOS I2C ドライバの設定項目は STM32 MCU の種類に依存します。
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@
|
|||||||
#define LOCKING_RESYNC_ENABLE
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
// I2C setup
|
// I2C setup
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
#define I2C1_SCL_PAL_MODE 4
|
#define I2C1_SCL_PAL_MODE 4
|
||||||
#define I2C1_SDA_PAL_MODE 4
|
#define I2C1_SDA_PAL_MODE 4
|
||||||
#define I2C1_TIMINGR_PRESC 0U
|
#define I2C1_TIMINGR_PRESC 0U
|
||||||
|
@ -56,8 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define WS2812_EXTERNAL_PULLUP
|
#define WS2812_EXTERNAL_PULLUP
|
||||||
|
|
||||||
// I2C OLED defines
|
// I2C OLED defines
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
|
|
||||||
#define I2C1_SCL_PAL_MODE 1
|
#define I2C1_SCL_PAL_MODE 1
|
||||||
#define I2C1_SDA_PAL_MODE 1
|
#define I2C1_SDA_PAL_MODE 1
|
||||||
|
@ -53,9 +53,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
// I2C config
|
// I2C config
|
||||||
#define I2C_DRIVER I2CD1
|
#define I2C_DRIVER I2CD1
|
||||||
#define I2C1_SCL_BANK GPIOB
|
#define I2C1_SCL_PIN B6
|
||||||
#define I2C1_SCL 6
|
#define I2C1_SDA_PIN B7
|
||||||
#define I2C1_SDA 7
|
|
||||||
#define I2C1_SCL_PAL_MODE 1
|
#define I2C1_SCL_PAL_MODE 1
|
||||||
#define I2C1_SDA_PAL_MODE 1
|
#define I2C1_SDA_PAL_MODE 1
|
||||||
#define I2C1_TIMINGR_PRESC 0x00U
|
#define I2C1_TIMINGR_PRESC 0x00U
|
||||||
|
@ -77,8 +77,8 @@
|
|||||||
// 0b1110101 AD <-> SCL
|
// 0b1110101 AD <-> SCL
|
||||||
// 0b1110110 AD <-> SDA
|
// 0b1110110 AD <-> SDA
|
||||||
#define LED_DRIVER_ADDR_1 0b1110100
|
#define LED_DRIVER_ADDR_1 0b1110100
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
|
|
||||||
#define LED_DRIVER_COUNT 1
|
#define LED_DRIVER_COUNT 1
|
||||||
#define DRIVER_LED_TOTAL 71
|
#define DRIVER_LED_TOTAL 71
|
||||||
|
@ -46,8 +46,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
|
|
||||||
#define I2C1_SCL_PAL_MODE 1
|
#define I2C1_SCL_PAL_MODE 1
|
||||||
#define I2C1_SDA_PAL_MODE 1
|
#define I2C1_SDA_PAL_MODE 1
|
||||||
|
@ -83,9 +83,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define I2C1_CLOCK_SPEED 400000
|
#define I2C1_CLOCK_SPEED 400000
|
||||||
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
#define I2C1_BANK GPIOB
|
#define I2C1_SCL_PIN B0
|
||||||
#define I2C1_SCL 0
|
#define I2C1_SDA_PIN B1
|
||||||
#define I2C1_SDA 1
|
|
||||||
|
|
||||||
#ifdef ST7565_ENABLE
|
#ifdef ST7565_ENABLE
|
||||||
/* LCD driver */
|
/* LCD driver */
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// i2c_master defines
|
// i2c_master defines
|
||||||
#define I2C1_SCL 0 // A2 on pinout = B0
|
#define I2C1_SCL_PIN B0 // A2 on pinout = B0
|
||||||
#define I2C1_SDA 1 // A3 on pinout = B1
|
#define I2C1_SDA_PIN B1 // A3 on pinout = B1
|
||||||
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// i2c_master defines
|
// i2c_master defines
|
||||||
#define I2C1_SCL 0 // A2 on pinout = B0
|
#define I2C1_SCL_PIN B0 // A2 on pinout = B0
|
||||||
#define I2C1_SDA 1 // A3 on pinout = B1
|
#define I2C1_SDA_PIN B1 // A3 on pinout = B1
|
||||||
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
|
@ -67,10 +67,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
/* i2c settings */
|
/* i2c settings */
|
||||||
|
|
||||||
#define I2C_DRIVER I2CD2
|
#define I2C_DRIVER I2CD2
|
||||||
#define I2C1_SCL_BANK GPIOB
|
#define I2C1_SCL_PIN B10
|
||||||
#define I2C1_SCL 10
|
#define I2C1_SDA_PIN B11
|
||||||
#define I2C1_SDA_BANK GPIOB
|
|
||||||
#define I2C1_SDA 11
|
|
||||||
#define I2C1_TIMINGR_PRESC 2U
|
#define I2C1_TIMINGR_PRESC 2U
|
||||||
#define I2C1_TIMINGR_SCLDEL 1U
|
#define I2C1_TIMINGR_SCLDEL 1U
|
||||||
#define I2C1_TIMINGR_SDADEL 0U
|
#define I2C1_TIMINGR_SDADEL 0U
|
||||||
|
@ -59,11 +59,6 @@ extern i2c_status_t mcp23017_status;
|
|||||||
bool i2c_initialized = 0;
|
bool i2c_initialized = 0;
|
||||||
i2c_status_t mcp23017_status = I2C_ADDR;
|
i2c_status_t mcp23017_status = I2C_ADDR;
|
||||||
|
|
||||||
#define I2C2_SCL_BANK GPIOB
|
|
||||||
#define I2C2_SCL 10
|
|
||||||
#define I2C2_SDA_BANK GPIOB
|
|
||||||
#define I2C2_SDA 11
|
|
||||||
|
|
||||||
uint8_t init_mcp23017(void) {
|
uint8_t init_mcp23017(void) {
|
||||||
print("init mcp23017\n");
|
print("init mcp23017\n");
|
||||||
mcp23017_status = I2C_ADDR;
|
mcp23017_status = I2C_ADDR;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
// B9 is configured as I2C1_SDA in the board file; that function must be
|
// B9 is configured as I2C1_SDA_PIN in the board file; that function must be
|
||||||
// disabled before using B7 as I2C1_SDA.
|
// disabled before using B7 as I2C1_SDA.
|
||||||
setPinInputHigh(B9);
|
setPinInputHigh(B9);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#define UNUSED_PINS
|
#define UNUSED_PINS
|
||||||
|
|
||||||
// i2c_master defines
|
// i2c_master defines
|
||||||
#define I2C1_SCL 0 // A2 on pinout = B0
|
#define I2C1_SCL_PIN B0 // A2 on pinout = B0
|
||||||
#define I2C1_SDA 1 // A3 on pinout = B1
|
#define I2C1_SDA_PIN B1 // A3 on pinout = B1
|
||||||
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#define UNUSED_PINS
|
#define UNUSED_PINS
|
||||||
|
|
||||||
// i2c_master defines
|
// i2c_master defines
|
||||||
#define I2C1_SCL 0 // A2 on pinout = B0
|
#define I2C1_SCL_PIN B0 // A2 on pinout = B0
|
||||||
#define I2C1_SDA 1 // A3 on pinout = B1
|
#define I2C1_SDA_PIN B1 // A3 on pinout = B1
|
||||||
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
|
@ -71,10 +71,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
/* i2c config for oleds */
|
/* i2c config for oleds */
|
||||||
#define I2C_DRIVER I2CD1
|
#define I2C_DRIVER I2CD1
|
||||||
#define I2C1_SCL_BANK GPIOB
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA_BANK GPIOB
|
#define I2C1_SDA_PIN B9
|
||||||
#define I2C1_SCL 8
|
|
||||||
#define I2C1_SDA 9
|
|
||||||
#define I2C1_SCL_PAL_MODE 4
|
#define I2C1_SCL_PAL_MODE 4
|
||||||
#define I2C1_SDA_PAL_MODE 4
|
#define I2C1_SDA_PAL_MODE 4
|
||||||
#define I2C1_CLOCK_SPEED 400000
|
#define I2C1_CLOCK_SPEED 400000
|
||||||
|
@ -82,8 +82,8 @@
|
|||||||
#define DEBOUNCE 5
|
#define DEBOUNCE 5
|
||||||
|
|
||||||
// i2c setting
|
// i2c setting
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
#define I2C1_CLOCK_SPEED 400000
|
#define I2C1_CLOCK_SPEED 400000
|
||||||
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
|
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
|
||||||
|
|
||||||
|
@ -64,12 +64,12 @@ void i2c_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try releasing special pins for a short time
|
// Try releasing special pins for a short time
|
||||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT);
|
palSetLineMode(I2C1_SCL_PIN, PAL_MODE_INPUT);
|
||||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT);
|
palSetLineMode(I2C1_SDA_PIN, PAL_MODE_INPUT);
|
||||||
|
|
||||||
chThdSleepMilliseconds(10);
|
chThdSleepMilliseconds(10);
|
||||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
palSetLineMode(I2C1_SCL_PIN, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
palSetLineMode(I2C1_SDA_PIN, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define REBOOT_MAGIC 0x41544B42
|
#define REBOOT_MAGIC 0x41544B42
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
#define DEBOUNCE 5
|
#define DEBOUNCE 5
|
||||||
|
|
||||||
// i2c setting
|
// i2c setting
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
#define I2C1_CLOCK_SPEED 400000
|
#define I2C1_CLOCK_SPEED 400000
|
||||||
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
|
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
|
||||||
#define PAL_MODE_STM32_ALTERNATE_OPENDRAIN (PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN)
|
#define PAL_MODE_STM32_ALTERNATE_OPENDRAIN (PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN)
|
||||||
|
@ -72,9 +72,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define I2C1_CLOCK_SPEED 400000
|
#define I2C1_CLOCK_SPEED 400000
|
||||||
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
|
||||||
#define I2C1_BANK GPIOB
|
#define I2C1_SCL_PIN B0
|
||||||
#define I2C1_SCL 0
|
#define I2C1_SDA_PIN B1
|
||||||
#define I2C1_SDA 1
|
|
||||||
|
|
||||||
/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
|
/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
|
||||||
* This is useful for the Windows task manager shortcut (ctrl+shift+esc).
|
* This is useful for the Windows task manager shortcut (ctrl+shift+esc).
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
#define LOCKING_RESYNC_ENABLE
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
// I2C OLED defines
|
// I2C OLED defines
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
|
|
||||||
#define I2C1_SCL_PAL_MODE 1
|
#define I2C1_SCL_PAL_MODE 1
|
||||||
#define I2C1_SDA_PAL_MODE 1
|
#define I2C1_SDA_PAL_MODE 1
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
#define LOCKING_RESYNC_ENABLE
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
// I2C setup
|
// I2C setup
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
#define I2C1_SCL_PAL_MODE 4
|
#define I2C1_SCL_PAL_MODE 4
|
||||||
#define I2C1_SDA_PAL_MODE 4
|
#define I2C1_SDA_PAL_MODE 4
|
||||||
#define I2C1_TIMINGR_PRESC 0U
|
#define I2C1_TIMINGR_PRESC 0U
|
||||||
|
@ -47,8 +47,8 @@
|
|||||||
#define LOCKING_RESYNC_ENABLE
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
// I2C setup
|
// I2C setup
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
#define I2C1_SCL_PAL_MODE 4
|
#define I2C1_SCL_PAL_MODE 4
|
||||||
#define I2C1_SDA_PAL_MODE 4
|
#define I2C1_SDA_PAL_MODE 4
|
||||||
#define I2C1_TIMINGR_PRESC 0U
|
#define I2C1_TIMINGR_PRESC 0U
|
||||||
|
@ -47,8 +47,8 @@
|
|||||||
#define LOCKING_RESYNC_ENABLE
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
// I2C OLED defines
|
// I2C OLED defines
|
||||||
#define I2C1_SCL 8
|
#define I2C1_SCL_PIN B8
|
||||||
#define I2C1_SDA 9
|
#define I2C1_SDA_PIN B9
|
||||||
|
|
||||||
#define I2C1_SCL_PAL_MODE 1
|
#define I2C1_SCL_PAL_MODE 1
|
||||||
#define I2C1_SDA_PAL_MODE 1
|
#define I2C1_SDA_PAL_MODE 1
|
||||||
|
@ -63,16 +63,16 @@ __attribute__((weak)) void i2c_init(void) {
|
|||||||
is_initialised = true;
|
is_initialised = true;
|
||||||
|
|
||||||
// Try releasing special pins for a short time
|
// Try releasing special pins for a short time
|
||||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT);
|
palSetLineMode(I2C1_SCL_PIN, PAL_MODE_INPUT);
|
||||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT);
|
palSetLineMode(I2C1_SDA_PIN, PAL_MODE_INPUT);
|
||||||
|
|
||||||
chThdSleepMilliseconds(10);
|
chThdSleepMilliseconds(10);
|
||||||
#if defined(USE_GPIOV1)
|
#if defined(USE_GPIOV1)
|
||||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, I2C1_SCL_PAL_MODE);
|
palSetLineMode(I2C1_SCL_PIN, I2C1_SCL_PAL_MODE);
|
||||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, I2C1_SDA_PAL_MODE);
|
palSetLineMode(I2C1_SDA_PIN, I2C1_SDA_PAL_MODE);
|
||||||
#else
|
#else
|
||||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
palSetLineMode(I2C1_SCL_PIN, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
palSetLineMode(I2C1_SDA_PIN, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,24 +27,11 @@
|
|||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
|
|
||||||
#ifdef I2C1_BANK
|
#ifndef I2C1_SCL_PIN
|
||||||
# define I2C1_SCL_BANK I2C1_BANK
|
# define I2C1_SCL_PIN B6
|
||||||
# define I2C1_SDA_BANK I2C1_BANK
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef I2C1_SDA_PIN
|
||||||
#ifndef I2C1_SCL_BANK
|
# define I2C1_SDA_PIN B7
|
||||||
# define I2C1_SCL_BANK GPIOB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef I2C1_SDA_BANK
|
|
||||||
# define I2C1_SDA_BANK GPIOB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef I2C1_SCL
|
|
||||||
# define I2C1_SCL 6
|
|
||||||
#endif
|
|
||||||
#ifndef I2C1_SDA
|
|
||||||
# define I2C1_SDA 7
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_I2CV1
|
#ifdef USE_I2CV1
|
||||||
|
Loading…
Reference in New Issue
Block a user