Skip to content

Commit 11f5faf

Browse files
ABOSTMfpistm
authored andcommitted
libraries(C0): I2C support
Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent dbd4888 commit 11f5faf

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

libraries/Wire/src/utility/twi.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,9 @@ void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode, uint3
674674
__HAL_RCC_I2C1_RELEASE_RESET();
675675

676676
obj->irq = I2C1_EV_IRQn;
677-
#if !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
677+
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
678678
obj->irqER = I2C1_ER_IRQn;
679-
#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
679+
#endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
680680
i2c_handles[I2C1_INDEX] = handle;
681681
}
682682
#endif // I2C1_BASE
@@ -702,7 +702,7 @@ void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode, uint3
702702
obj->irq = I2C3_EV_IRQn;
703703
#if !defined(STM32G0xx) && !defined(STM32L0xx)
704704
obj->irqER = I2C3_ER_IRQn;
705-
#endif /* !STM32L0xx */
705+
#endif /* !STM32G0xx && !STM32L0xx */
706706
i2c_handles[I2C3_INDEX] = handle;
707707
}
708708
#endif // I2C3_BASE
@@ -768,10 +768,10 @@ void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode, uint3
768768

769769
HAL_NVIC_SetPriority(obj->irq, I2C_IRQ_PRIO, I2C_IRQ_SUBPRIO);
770770
HAL_NVIC_EnableIRQ(obj->irq);
771-
#if !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
771+
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
772772
HAL_NVIC_SetPriority(obj->irqER, I2C_IRQ_PRIO, I2C_IRQ_SUBPRIO);
773773
HAL_NVIC_EnableIRQ(obj->irqER);
774-
#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
774+
#endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
775775

776776
/* Init the I2C */
777777
if (HAL_I2C_Init(handle) != HAL_OK) {
@@ -795,9 +795,9 @@ void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode, uint3
795795
void i2c_deinit(i2c_t *obj)
796796
{
797797
HAL_NVIC_DisableIRQ(obj->irq);
798-
#if !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
798+
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
799799
HAL_NVIC_DisableIRQ(obj->irqER);
800-
#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
800+
#endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
801801
HAL_I2C_DeInit(&(obj->handle));
802802
}
803803

@@ -1174,12 +1174,12 @@ void I2C1_EV_IRQHandler(void)
11741174
{
11751175
I2C_HandleTypeDef *handle = i2c_handles[I2C1_INDEX];
11761176
HAL_I2C_EV_IRQHandler(handle);
1177-
#if defined(STM32F0xx) || defined(STM32G0xx) || defined(STM32L0xx)
1177+
#if defined(STM32C0xx) || defined(STM32F0xx) || defined(STM32G0xx) || defined(STM32L0xx)
11781178
HAL_I2C_ER_IRQHandler(handle);
1179-
#endif /* STM32F0xx || STM32G0xx || STM32L0xx */
1179+
#endif /* STM32C0xx || STM32F0xx || STM32G0xx || STM32L0xx */
11801180
}
11811181

1182-
#if !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
1182+
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
11831183
/**
11841184
* @brief This function handles I2C1 interrupt.
11851185
* @param None
@@ -1190,7 +1190,7 @@ void I2C1_ER_IRQHandler(void)
11901190
I2C_HandleTypeDef *handle = i2c_handles[I2C1_INDEX];
11911191
HAL_I2C_ER_IRQHandler(handle);
11921192
}
1193-
#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
1193+
#endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
11941194
#endif // I2C1_BASE
11951195

11961196
#if defined(I2C2_BASE)

libraries/Wire/src/utility/twi.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ extern "C" {
6767
#error I2C buffer size cannot exceed 255
6868
#endif
6969

70-
/* Redefinition of IRQ for F0/G0/L0 families */
71-
#if defined(STM32F0xx) || defined(STM32G0xx) || defined(STM32L0xx)
70+
/* Redefinition of IRQ for C0/F0/G0/L0 families */
71+
#if defined(STM32C0xx) || defined(STM32F0xx) || defined(STM32G0xx) || defined(STM32L0xx)
7272
#if defined(I2C1_BASE)
7373
#define I2C1_EV_IRQn I2C1_IRQn
7474
#define I2C1_EV_IRQHandler I2C1_IRQHandler
@@ -95,7 +95,7 @@ extern "C" {
9595
#define I2C4_EV_IRQn I2C4_IRQn
9696
#define I2C4_EV_IRQHandler I2C4_IRQHandler
9797
#endif // defined(I2C4_BASE)
98-
#endif /* STM32F0xx || STM32G0xx || STM32L0xx */
98+
#endif /* STM32C0xx || STM32F0xx || STM32G0xx || STM32L0xx */
9999

100100
typedef struct i2c_s i2c_t;
101101

@@ -111,9 +111,9 @@ struct i2c_s {
111111
PinName sda;
112112
PinName scl;
113113
IRQn_Type irq;
114-
#if !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
114+
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx)
115115
IRQn_Type irqER;
116-
#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
116+
#endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
117117
volatile int slaveRxNbData; // Number of accumulated bytes received in Slave mode
118118
void (*i2c_onSlaveReceive)(i2c_t *);
119119
void (*i2c_onSlaveTransmit)(i2c_t *);

0 commit comments

Comments
 (0)