aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/I2Cv2
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2019-01-02 11:43:13 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2019-01-02 11:43:13 +0000
commitd5635adecc959228fefce27610f211087fefd87f (patch)
treeda768fca6a17255b1d9b82fab19cc87e992340e3 /os/hal/ports/STM32/LLD/I2Cv2
parent60c04d66ec3c383febd9c9324e166aec2adb6e38 (diff)
downloadChibiOS-d5635adecc959228fefce27610f211087fefd87f.tar.gz
ChibiOS-d5635adecc959228fefce27610f211087fefd87f.tar.bz2
ChibiOS-d5635adecc959228fefce27610f211087fefd87f.zip
Mass update of all drivers to use the new DMA API. What could possibly go wrong?
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12521 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal/ports/STM32/LLD/I2Cv2')
-rw-r--r--os/hal/ports/STM32/LLD/I2Cv2/hal_i2c_lld.c110
1 files changed, 52 insertions, 58 deletions
diff --git a/os/hal/ports/STM32/LLD/I2Cv2/hal_i2c_lld.c b/os/hal/ports/STM32/LLD/I2Cv2/hal_i2c_lld.c
index f8aab4a5a..7fa0b8672 100644
--- a/os/hal/ports/STM32/LLD/I2Cv2/hal_i2c_lld.c
+++ b/os/hal/ports/STM32/LLD/I2Cv2/hal_i2c_lld.c
@@ -626,8 +626,8 @@ void i2c_lld_init(void) {
I2CD1.thread = NULL;
I2CD1.i2c = I2C1;
#if STM32_I2C_USE_DMA == TRUE
- I2CD1.dmarx = STM32_DMA_STREAM(STM32_I2C_I2C1_RX_DMA_STREAM);
- I2CD1.dmatx = STM32_DMA_STREAM(STM32_I2C_I2C1_TX_DMA_STREAM);
+ I2CD1.dmarx = NULL;
+ I2CD1.dmatx = NULL;
#endif
#endif /* STM32_I2C_USE_I2C1 */
@@ -636,8 +636,8 @@ void i2c_lld_init(void) {
I2CD2.thread = NULL;
I2CD2.i2c = I2C2;
#if STM32_I2C_USE_DMA == TRUE
- I2CD2.dmarx = STM32_DMA_STREAM(STM32_I2C_I2C2_RX_DMA_STREAM);
- I2CD2.dmatx = STM32_DMA_STREAM(STM32_I2C_I2C2_TX_DMA_STREAM);
+ I2CD2.dmarx = NULL;
+ I2CD2.dmatx = NULL;
#endif
#endif /* STM32_I2C_USE_I2C2 */
@@ -646,8 +646,8 @@ void i2c_lld_init(void) {
I2CD3.thread = NULL;
I2CD3.i2c = I2C3;
#if STM32_I2C_USE_DMA == TRUE
- I2CD3.dmarx = STM32_DMA_STREAM(STM32_I2C_I2C3_RX_DMA_STREAM);
- I2CD3.dmatx = STM32_DMA_STREAM(STM32_I2C_I2C3_TX_DMA_STREAM);
+ I2CD3.dmarx = NULL;
+ I2CD3.dmatx = NULL;
#endif
#endif /* STM32_I2C_USE_I2C3 */
@@ -656,8 +656,8 @@ void i2c_lld_init(void) {
I2CD4.thread = NULL;
I2CD4.i2c = I2C4;
#if STM32_I2C_USE_DMA == TRUE
- I2CD4.dmarx = STM32_DMA_STREAM(STM32_I2C_I2C4_RX_DMA_STREAM);
- I2CD4.dmatx = STM32_DMA_STREAM(STM32_I2C_I2C4_TX_DMA_STREAM);
+ I2CD4.dmarx = NULL;
+ I2CD4.dmatx = NULL;
#endif
#endif /* STM32_I2C_USE_I2C4 */
}
@@ -691,18 +691,16 @@ void i2c_lld_start(I2CDriver *i2cp) {
rccEnableI2C1(true);
#if STM32_I2C_USE_DMA == TRUE
{
- bool b;
-
- b = dmaStreamAllocate(i2cp->dmarx,
- STM32_I2C_I2C1_IRQ_PRIORITY,
- NULL,
- (void *)i2cp);
- osalDbgAssert(!b, "stream already allocated");
- b = dmaStreamAllocate(i2cp->dmatx,
- STM32_I2C_I2C1_IRQ_PRIORITY,
- NULL,
- (void *)i2cp);
- osalDbgAssert(!b, "stream already allocated");
+ i2cp->dmarx = dmaStreamAllocI(STM32_I2C_I2C1_RX_DMA_STREAM,
+ STM32_I2C_I2C1_IRQ_PRIORITY,
+ NULL,
+ (void *)i2cp);
+ osalDbgAssert(i2cp->dmarx != NULL, "unable to allocate stream");
+ i2cp->dmatx = dmaStreamAllocI(STM32_I2C_I2C1_TX_DMA_STREAM,
+ STM32_I2C_I2C1_IRQ_PRIORITY,
+ NULL,
+ (void *)i2cp);
+ osalDbgAssert(i2cp->dmatx != NULL, "unable to allocate stream");
i2cp->rxdmamode |= STM32_DMA_CR_CHSEL(I2C1_RX_DMA_CHANNEL) |
STM32_DMA_CR_PL(STM32_I2C_I2C1_DMA_PRIORITY);
@@ -729,18 +727,16 @@ void i2c_lld_start(I2CDriver *i2cp) {
rccEnableI2C2(true);
#if STM32_I2C_USE_DMA == TRUE
{
- bool b;
-
- b = dmaStreamAllocate(i2cp->dmarx,
- STM32_I2C_I2C2_IRQ_PRIORITY,
- NULL,
- (void *)i2cp);
- osalDbgAssert(!b, "stream already allocated");
- b = dmaStreamAllocate(i2cp->dmatx,
- STM32_I2C_I2C2_IRQ_PRIORITY,
- NULL,
- (void *)i2cp);
- osalDbgAssert(!b, "stream already allocated");
+ i2cp->dmarx = dmaStreamAllocI(STM32_I2C_I2C2_RX_DMA_STREAM,
+ STM32_I2C_I2C2_IRQ_PRIORITY,
+ NULL,
+ (void *)i2cp);
+ osalDbgAssert(i2cp->dmarx != NULL, "unable to allocate stream");
+ i2cp->dmatx = dmaStreamAllocI(STM32_I2C_I2C2_TX_DMA_STREAM,
+ STM32_I2C_I2C2_IRQ_PRIORITY,
+ NULL,
+ (void *)i2cp);
+ osalDbgAssert(i2cp->dmatx != NULL, "unable to allocate stream");
i2cp->rxdmamode |= STM32_DMA_CR_CHSEL(I2C2_RX_DMA_CHANNEL) |
STM32_DMA_CR_PL(STM32_I2C_I2C2_DMA_PRIORITY);
@@ -767,18 +763,16 @@ void i2c_lld_start(I2CDriver *i2cp) {
rccEnableI2C3(true);
#if STM32_I2C_USE_DMA == TRUE
{
- bool b;
-
- b = dmaStreamAllocate(i2cp->dmarx,
- STM32_I2C_I2C3_IRQ_PRIORITY,
- NULL,
- (void *)i2cp);
- osalDbgAssert(!b, "stream already allocated");
- b = dmaStreamAllocate(i2cp->dmatx,
- STM32_I2C_I2C3_IRQ_PRIORITY,
- NULL,
- (void *)i2cp);
- osalDbgAssert(!b, "stream already allocated");
+ i2cp->dmarx = dmaStreamAllocI(STM32_I2C_I2C3_RX_DMA_STREAM,
+ STM32_I2C_I2C3_IRQ_PRIORITY,
+ NULL,
+ (void *)i2cp);
+ osalDbgAssert(i2cp->dmarx != NULL, "unable to allocate stream");
+ i2cp->dmatx = dmaStreamAllocI(STM32_I2C_I2C3_TX_DMA_STREAM,
+ STM32_I2C_I2C3_IRQ_PRIORITY,
+ NULL,
+ (void *)i2cp);
+ osalDbgAssert(i2cp->dmatx != NULL, "unable to allocate stream");
i2cp->rxdmamode |= STM32_DMA_CR_CHSEL(I2C3_RX_DMA_CHANNEL) |
STM32_DMA_CR_PL(STM32_I2C_I2C3_DMA_PRIORITY);
@@ -805,18 +799,16 @@ void i2c_lld_start(I2CDriver *i2cp) {
rccEnableI2C4(true);
#if STM32_I2C_USE_DMA == TRUE
{
- bool b;
-
- b = dmaStreamAllocate(i2cp->dmarx,
- STM32_I2C_I2C4_IRQ_PRIORITY,
- NULL,
- (void *)i2cp);
- osalDbgAssert(!b, "stream already allocated");
- b = dmaStreamAllocate(i2cp->dmatx,
- STM32_I2C_I2C4_IRQ_PRIORITY,
- NULL,
- (void *)i2cp);
- osalDbgAssert(!b, "stream already allocated");
+ i2cp->dmarx = dmaStreamAllocI(STM32_I2C_I2C4_RX_DMA_STREAM,
+ STM32_I2C_I2C4_IRQ_PRIORITY,
+ NULL,
+ (void *)i2cp);
+ osalDbgAssert(i2cp->dmarx != NULL, "unable to allocate stream");
+ i2cp->dmatx = dmaStreamAllocI(STM32_I2C_I2C4_TX_DMA_STREAM,
+ STM32_I2C_I2C4_IRQ_PRIORITY,
+ NULL,
+ (void *)i2cp);
+ osalDbgAssert(i2cp->dmatx != NULL, "unable to allocate stream");
i2cp->rxdmamode |= STM32_DMA_CR_CHSEL(I2C4_RX_DMA_CHANNEL) |
STM32_DMA_CR_PL(STM32_I2C_I2C4_DMA_PRIORITY);
@@ -872,8 +864,10 @@ void i2c_lld_stop(I2CDriver *i2cp) {
/* I2C disable.*/
i2c_lld_abort_operation(i2cp);
#if STM32_I2C_USE_DMA == TRUE
- dmaStreamRelease(i2cp->dmatx);
- dmaStreamRelease(i2cp->dmarx);
+ dmaStreamFreeI(i2cp->dmatx);
+ dmaStreamFreeI(i2cp->dmarx);
+ i2cp->dmatx = NULL;
+ i2cp->dmarx = NULL;
#endif
#if STM32_I2C_USE_I2C1