<div dir="ltr">Hi, everyone!<div><br></div><div>My battle with stm32 interrupts continues. Three month ago <span style="font-size:12.8px">Andrei from The Great White North gave me some code advise:</span></div><div><span style="font-size:12.8px"><br></span></div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex" class="gmail_quote">In my code I use interrupts for DMA with ADCs, and CAN using the HAL interrupt handler callback structure. <br>In this case, <span style="font-family:'Courier New'">DMA2_Stream2_IRQHandler </span><wbr>calls<span style="font-family:'Courier New'"> </span><span style="font-family:'Courier New'">HAL_DMA_IRQHandler </span>in<span style="font-family:'Courier New'"> <wbr>stm32f4xx_hal_dma.c </span>which figures what caused the interrupt and calls the appropriate callback.<br>In my ADC code I use this:<br><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">    </span></span>rtems_status_code<span style="color:rgb(0,0,0)"> status;<br></span><span style="white-space:pre-wrap">   </span><span style="color:rgb(147,26,104)"><b>const</b></span> <span style="color:rgb(147,26,104)"><b>char</b></span> ADC1handlerName[] = <span style="color:rgb(57,51,255)">"AD1r"</span>;<br><span style="white-space:pre-wrap">   </span>status = <span style="color:rgb(121,61,147)"><b>rtems_interrupt_handler_<wbr>install</b></span>((<span style="color:rgb(0,97,65)">rtems_vector_number</span>) <span style="text-decoration:underline">DMA2_Stream2_IRQn</span>,<br><span style="white-space:pre-wrap">                 </span>ADC2handlerName, RTEMS_INTERRUPT_UNIQUE,<br><span style="white-space:pre-wrap">                      </span>(<span style="color:rgb(0,97,65)">rtems_interrupt_handler</span>) DMA2_Stream2_IRQHandler, <span style="text-decoration:underline">NULL</span>);<br><span style="white-space:pre-wrap"> </span><span style="color:rgb(147,26,104)"><b>if</b></span> (status != <span style="color:rgb(3,38,204)"><i>RTEMS_SUCCESSFUL</i></span>) {<br><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">              </span></span><span style="color:rgb(121,61,147)"><b>printk</b></span><span style="color:rgb(0,0,0)">(</span>"interrupt handler install 2 failed with %d\n"<span style="color:rgb(0,0,0)">, status);<br></span><span style="white-space:pre-wrap">    </span>}<br><br>Later, I have the interrupt callbacks:<br><span style="color:rgb(147,26,104)"><b>void</b></span> <b>HAL_ADC_ConvCpltCallback</b>(<span style="color:rgb(0,97,65)">ADC_<wbr>HandleTypeDef</span>* hadc) {<br><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap"> </span></span>rtems_status_code<span style="color:rgb(0,0,0)"> status;<br></span><span style="white-space:pre-wrap">   </span>status = <span style="color:rgb(121,61,147)"><b>rtems_event_send</b></span>(ADCTaskId, RTEMS_EVENT_0);<br><span style="white-space:pre-wrap">     </span><span style="color:rgb(147,26,104)"><b>if</b></span> (status != <span style="color:rgb(3,38,204)"><i>RTEMS_SUCCESSFUL</i></span>) {<br><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">              </span></span><span style="color:rgb(121,61,147)"><b>printk</b></span><span style="color:rgb(0,0,0)">(</span>"complete callback failed with %d"<span style="color:rgb(0,0,0)">, status);<br></span><span style="white-space:pre-wrap">        </span>}<br>}<br><span style="color:rgb(147,26,104)"><b>void</b></span> <b>HAL_ADC_ConvHalfCpltCallback</b>(<span style="color:rgb(0,97,65)">A<wbr>DC_HandleTypeDef</span>* hadc) {<br><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">    </span></span>rtems_status_code<span style="color:rgb(0,0,0)"> status;<br></span><span style="white-space:pre-wrap">   </span>status = <span style="color:rgb(121,61,147)"><b>rtems_event_send</b></span>(ADCTaskId, RTEMS_EVENT_1);<br><span style="white-space:pre-wrap">     </span><span style="color:rgb(147,26,104)"><b>if</b></span> (status != <span style="color:rgb(3,38,204)"><i>RTEMS_SUCCESSFUL</i></span>) {<br><span style="color:rgb(0,0,0)"><span style="white-space:pre-wrap">              </span></span><span style="color:rgb(121,61,147)"><b>printk</b></span><span style="color:rgb(0,0,0)">(</span>"half complete callback failed with %d"<span style="color:rgb(0,0,0)">, status);<br></span><span style="white-space:pre-wrap">   </span>}<br>}</blockquote></div><div style="font-size:12.8px;margin:0px;font-family:'Courier New'"><br></div><div style="font-size:12.8px;margin:0px;font-family:'Courier New'"><br></div>i was trying the same but only for EXTI driver and no result. I have such code:<br><a href="http://pastebin.com/BZBNPRbg">http://pastebin.com/BZBNPRbg</a><br><br>After flashing, i received in console string "53", when i pushed the button - all stopped, only reset can brought him back to life.<div><br>In C user guide i didn't find any references to  rtems_interrupt_handler_install, some info was about rtems_interrupt_catch, but when i try to use this, i received "undefined reference". </div><div><br></div><div>Maybe, someone can help me with that problem?</div><div><br></div><div>Thanks.</div><div><br></div><div>P.S. Sorry for my english.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-05-17 8:40 GMT+03:00 Ярослав Лещинский <span dir="ltr"><<a href="mailto:midniwalker@gmail.com" target="_blank">midniwalker@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Andrei, thanks! </p>
<div class="gmail_quote">17 мая 2016 г. 8:31 пользователь  <<a href="mailto:groups@chichak.ca" target="_blank">groups@chichak.ca</a>> написал:<div><div class="h5"><br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On 2016-May-16, at 11:10, Ярослав Лещинский <<a href="mailto:midniwalker@gmail.com" target="_blank">midniwalker@gmail.com</a>> wrote:</div><br><div><div dir="ltr">Hello. I'm try to use rtems with my stm board(stm32f4xx). And for now i have one problem: it's about ISR. The thing is, i have my own drivers, which uses isr(exti driver, uart and etc). I read rtems c-user manual properly,  but still can't understand clearly, how i can bring control to rtems signal manager via ASR. I'll be appreciated, if someone can give some advise.<br><div><br></div><div>Yaroslavl.</div></div></div></blockquote><br></div><div>In my code I use interrupts for DMA with ADCs, and CAN using the HAL interrupt handler callback structure. </div><div><br></div><div>In this case, <span style="font-family:'Courier New'">DMA2_Stream2_IRQHandler </span><wbr>calls<span style="font-family:'Courier New'"> </span><span style="font-family:'Courier New'">HAL_DMA_IRQHandler </span>in<span style="font-family:'Courier New'"> <wbr>stm32f4xx_hal_dma.c </span>which figures what caused the interrupt and calls the appropriate callback.</div><div><br></div><div>In my ADC code I use this:</div><div><br></div><div><div style="margin:0px;line-height:normal;font-family:'Courier New';color:rgb(0,97,65)"><span style="color:#000000"><span style="white-space:pre-wrap">     </span></span>rtems_status_code<span style="color:#000000"> status;</span></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">        </span><span style="color:#931a68"><b>const</b></span> <span style="color:#931a68"><b>char</b></span> ADC1handlerName[] = <span style="color:#3933ff">"AD1r"</span>;</div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">      </span>status = <span style="color:#793d93"><b>rtems_interrupt_handler_<wbr>install</b></span>((<span style="color:#006141">rtems_vector_number</span>) <span style="text-decoration:underline">DMA2_Stream2_IRQn</span>,</div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">                 </span>ADC2handlerName, RTEMS_INTERRUPT_UNIQUE,</div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">                       </span>(<span style="color:#006141">rtems_interrupt_handler</span>) DMA2_Stream2_IRQHandler, <span style="text-decoration:underline">NULL</span>);</div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">        </span><span style="color:#931a68"><b>if</b></span> (status != <span style="color:#0326cc"><i>RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin:0px;line-height:normal;font-family:'Courier New';color:rgb(57,51,255)"><span style="color:#000000"><span style="white-space:pre-wrap">             </span></span><span style="color:#793d93"><b>printk</b></span><span style="color:#000000">(</span>"interrupt handler install 2 failed with %d\n"<span style="color:#000000">, status);</span></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">   </span>}</div><div><br></div><div><br></div><div>Later, I have the interrupt callbacks:</div><div><br></div></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="color:#931a68"><b>void</b></span> <b>HAL_ADC_ConvCpltCallback</b>(<span style="color:#006141">ADC_<wbr>HandleTypeDef</span>* hadc) {</div><div style="margin:0px;line-height:normal;font-family:'Courier New';min-height:14px"><br></div><div style="margin:0px;line-height:normal;font-family:'Courier New';color:rgb(0,97,65)"><span style="color:#000000"><span style="white-space:pre-wrap">    </span></span>rtems_status_code<span style="color:#000000"> status;</span></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">        </span>status = <span style="color:#793d93"><b>rtems_event_send</b></span>(ADCTaskId, RTEMS_EVENT_0);</div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">       </span><span style="color:#931a68"><b>if</b></span> (status != <span style="color:#0326cc"><i>RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin:0px;line-height:normal;font-family:'Courier New';color:rgb(57,51,255)"><span style="color:#000000"><span style="white-space:pre-wrap">             </span></span><span style="color:#793d93"><b>printk</b></span><span style="color:#000000">(</span>"complete callback failed with %d"<span style="color:#000000">, status);</span></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">       </span>}</div><div style="margin:0px;line-height:normal;font-family:'Courier New'">}</div><div style="margin:0px;line-height:normal;font-family:'Courier New';min-height:14px"><br></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="color:#931a68"><b>void</b></span> <b>HAL_ADC_ConvHalfCpltCallback</b>(<span style="color:#006141">A<wbr>DC_HandleTypeDef</span>* hadc) {</div><div style="margin:0px;line-height:normal;font-family:'Courier New';min-height:14px"><br></div><div style="margin:0px;line-height:normal;font-family:'Courier New';color:rgb(0,97,65)"><span style="color:#000000"><span style="white-space:pre-wrap">       </span></span>rtems_status_code<span style="color:#000000"> status;</span></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">        </span>status = <span style="color:#793d93"><b>rtems_event_send</b></span>(ADCTaskId, RTEMS_EVENT_1);</div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">       </span><span style="color:#931a68"><b>if</b></span> (status != <span style="color:#0326cc"><i>RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin:0px;line-height:normal;font-family:'Courier New';color:rgb(57,51,255)"><span style="color:#000000"><span style="white-space:pre-wrap">             </span></span><span style="color:#793d93"><b>printk</b></span><span style="color:#000000">(</span>"half complete callback failed with %d"<span style="color:#000000">, status);</span></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">  </span>}</div><div style="margin:0px;line-height:normal;font-family:'Courier New'">}</div><div><br></div><div><br></div><div>In my CAN code I use:</div><div><br></div><div><div style="margin:0px;line-height:normal;font-family:'Courier New';color:rgb(0,97,65)"><span style="color:#000000"><span style="white-space:pre-wrap">   </span></span>rtems_status_code<span style="color:#000000"> status;</span></div><div style="margin:0px;line-height:normal;font-family:'Courier New';min-height:14px"><br></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">     </span>status = <span style="color:#793d93"><b>rtems_interrupt_handler_<wbr>install</b></span>(<span style="text-decoration:underline">CAN1_RX0_IRQn</span>, <span style="color:#3933ff">"CANR"</span>, RTEMS_INTERRUPT_UNIQUE,</div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">                 </span>(<span style="color:#006141">rtems_interrupt_handler</span>) CAN1_RX0_IRQHandler, <span style="text-decoration:underline">NULL</span>);</div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">    </span><span style="color:#931a68"><b>if</b></span> (status != <span style="color:#0326cc"><i>RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin:0px;line-height:normal;font-family:'Courier New';color:rgb(57,51,255)"><span style="color:#000000"><span style="white-space:pre-wrap">             </span></span><span style="color:#793d93"><b>printk</b></span><span style="color:#000000">(</span>"Pressure task interrupt install bombed with %d\n"<span style="color:#000000">, status);</span></div><div style="margin:0px;line-height:normal;font-family:'Courier New'"><span style="white-space:pre-wrap">       </span>}</div></div><div><br></div><div>and use the two call back functions <b style="font-family:'Courier New'">HAL_CAN_<wbr>RxCpltCallback</b> and <b style="font-family:'Courier New'">HAL_CAN_<wbr>ErrorCallback i</b>n the same way as the ADC callbacks.</div><div><br></div><div>The symbol for external interrupt looks like <span style="text-decoration:underline;font-family:'Courier New'">EXTI0_IRQn </span>and the UART would be like <span style="text-decoration:underline;font-family:'Courier New'">USART2_IRQn.</span></div><div><b style="font-family:'Courier New'"><br></b></div><div><b style="font-family:'Courier New'"><br></b></div><div>Andrei from The Great White North.</div><div><br></div><div><br></div><div><b style="font-family:'Courier New'"><br></b></div><div><b style="font-family:'Courier New'"><br></b></div></div></blockquote></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><div><p>С уважением, Лещинский Ярослав.</p></div>+79814031224</span></div></div>
</div>