I'm trying to bring up I2C on an Olimexino-STM32 (STM32F103-based).
When I step through with gdb, I see that i2cStart is failing with "stream already allocated".
I don't know what it could be that is using the DMA. I do have UARTs and Serial-over-USB enabled. Could that be it?
Code: Select all
45 static I2CConfig i2c_cfg = {
46 OPMODE_I2C,
47 100000,
48 STD_DUTY_CYCLE,
49 };
50
51 static THD_WORKING_AREA(waTestThd, 128);
52 static msg_t TestThd(void *arg) {
53 (void)arg;
54
55 i2cStart(&I2CD1, &i2c_cfg);
56
57 uint8_t rxbuf[128];
58 uint8_t txbuf[2];
59 txbuf[0]=0;
60 txbuf[1]=0;
61
62 // I2C
63 while(1)
64 {
65 i2cAcquireBus(&I2CD1);
66 i2cMasterTransmitTimeout(&I2CD1,
67 /*addr*/ 0b1010000,
68 /*txbuf*/ txbuf,
69 /*txbytes*/ 2,
70 /*rxbuf*/ rxbuf,
71 /*rxbytes*/ 0,
72 /*timeout(ticks)*/ MS2ST(4));
73 i2cReleaseBus(&I2CD1);
74 };
75
76 return 0;
77 }
And in mcuconf.h:
Code: Select all
104 /*
105 * I2C driver system settings.
106 */
107 #define STM32_I2C_USE_I2C1 TRUE
108 #define STM32_I2C_USE_I2C2 FALSE
109 #define STM32_I2C_BUSY_TIMEOUT 50
110 #define STM32_I2C_I2C1_IRQ_PRIORITY 5
111 #define STM32_I2C_I2C2_IRQ_PRIORITY 5
112 #define STM32_I2C_I2C1_DMA_PRIORITY 3
113 #define STM32_I2C_I2C2_DMA_PRIORITY 3
114 #define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
182 /*
183 * UART driver system settings.
184 */
185 #define STM32_UART_USE_USART1 TRUE
186 #define STM32_UART_USE_USART2 TRUE
187 #define STM32_UART_USE_USART3 FALSE
188 #define STM32_UART_USART1_IRQ_PRIORITY 12
189 #define STM32_UART_USART2_IRQ_PRIORITY 12
190 #define STM32_UART_USART3_IRQ_PRIORITY 12
191 #define STM32_UART_USART1_DMA_PRIORITY 0
192 #define STM32_UART_USART2_DMA_PRIORITY 0
193 #define STM32_UART_USART3_DMA_PRIORITY 0
194 #define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")