<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 2016-May-16, at 11:10, Ярослав Лещинский <<a href="mailto:midniwalker@gmail.com" class="">midniwalker@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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 class=""><div class=""><br class=""></div><div class="">Yaroslavl.</div></div></div></blockquote><br class=""></div><div>In my code I use interrupts for DMA with ADCs, and CAN using the HAL interrupt handler callback structure. </div><div><br class=""></div><div>In this case, <span style="font-family: 'Courier New';" class="">DMA2_Stream2_IRQHandler </span>calls<span style="font-family: 'Courier New';" class=""> </span><span style="font-family: 'Courier New';" class="">HAL_DMA_IRQHandler </span>in<span style="font-family: 'Courier New';" class=""> stm32f4xx_hal_dma.c </span>which figures what caused the interrupt and calls the appropriate callback.</div><div><br class=""></div><div>In my ADC code I use this:</div><div><br class=""></div><div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; color: rgb(0, 97, 65);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">   </span></span>rtems_status_code<span style="color: #000000" class=""> status;</span></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">       </span><span style="color: #931a68" class=""><b class="">const</b></span> <span style="color: #931a68" class=""><b class="">char</b></span> ADC1handlerName[] = <span style="color: #3933ff" class="">"AD1r"</span>;</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>status = <span style="color: #793d93" class=""><b class="">rtems_interrupt_handler_install</b></span>((<span style="color: #006141" class="">rtems_vector_number</span>) <span style="text-decoration: underline" class="">DMA2_Stream2_IRQn</span>,</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>ADC2handlerName, RTEMS_INTERRUPT_UNIQUE,</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">                  </span>(<span style="color: #006141" class="">rtems_interrupt_handler</span>) DMA2_Stream2_IRQHandler, <span style="text-decoration: underline" class="">NULL</span>);</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">   </span><span style="color: #931a68" class=""><b class="">if</b></span> (status != <span style="color: #0326cc" class=""><i class="">RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; color: rgb(57, 51, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">          </span></span><span style="color: #793d93" class=""><b class="">printk</b></span><span style="color: #000000" class="">(</span>"interrupt handler install 2 failed with %d\n"<span style="color: #000000" class="">, status);</span></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>}</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Later, I have the interrupt callbacks:</div><div class=""><br class=""></div></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span style="color: #931a68" class=""><b class="">void</b></span> <b class="">HAL_ADC_ConvCpltCallback</b>(<span style="color: #006141" class="">ADC_HandleTypeDef</span>* hadc) {</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; color: rgb(0, 97, 65);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span>rtems_status_code<span style="color: #000000" class=""> status;</span></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>status = <span style="color: #793d93" class=""><b class="">rtems_event_send</b></span>(ADCTaskId, RTEMS_EVENT_0);</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">   </span><span style="color: #931a68" class=""><b class="">if</b></span> (status != <span style="color: #0326cc" class=""><i class="">RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; color: rgb(57, 51, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">          </span></span><span style="color: #793d93" class=""><b class="">printk</b></span><span style="color: #000000" class="">(</span>"complete callback failed with %d"<span style="color: #000000" class="">, status);</span></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>}</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class="">}</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span style="color: #931a68" class=""><b class="">void</b></span> <b class="">HAL_ADC_ConvHalfCpltCallback</b>(<span style="color: #006141" class="">ADC_HandleTypeDef</span>* hadc) {</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; color: rgb(0, 97, 65);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span>rtems_status_code<span style="color: #000000" class=""> status;</span></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>status = <span style="color: #793d93" class=""><b class="">rtems_event_send</b></span>(ADCTaskId, RTEMS_EVENT_1);</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">   </span><span style="color: #931a68" class=""><b class="">if</b></span> (status != <span style="color: #0326cc" class=""><i class="">RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; color: rgb(57, 51, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">          </span></span><span style="color: #793d93" class=""><b class="">printk</b></span><span style="color: #000000" class="">(</span>"half complete callback failed with %d"<span style="color: #000000" class="">, status);</span></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>}</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class="">}</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">In my CAN code I use:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; color: rgb(0, 97, 65);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">     </span></span>rtems_status_code<span style="color: #000000" class=""> status;</span></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>status = <span style="color: #793d93" class=""><b class="">rtems_interrupt_handler_install</b></span>(<span style="text-decoration: underline" class="">CAN1_RX0_IRQn</span>, <span style="color: #3933ff" class="">"CANR"</span>, RTEMS_INTERRUPT_UNIQUE,</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>(<span style="color: #006141" class="">rtems_interrupt_handler</span>) CAN1_RX0_IRQHandler, <span style="text-decoration: underline" class="">NULL</span>);</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">       </span><span style="color: #931a68" class=""><b class="">if</b></span> (status != <span style="color: #0326cc" class=""><i class="">RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin: 0px; line-height: normal; font-family: 'Courier New'; color: rgb(57, 51, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">          </span></span><span style="color: #793d93" class=""><b class="">printk</b></span><span style="color: #000000" class="">(</span>"Pressure task interrupt install bombed with %d\n"<span style="color: #000000" class="">, status);</span></div><div style="margin: 0px; line-height: normal; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>}</div></div><div class=""><br class=""></div><div class="">and use the two call back functions <b style="font-family: 'Courier New';" class="">HAL_CAN_RxCpltCallback</b> and <b style="font-family: 'Courier New';" class="">HAL_CAN_ErrorCallback i</b>n the same way as the ADC callbacks.</div><div class=""><br class=""></div><div class="">The symbol for external interrupt looks like <span style="text-decoration: underline; font-family: 'Courier New';" class="">EXTI0_IRQn </span>and the UART would be like <span style="text-decoration: underline; font-family: 'Courier New';" class="">USART2_IRQn.</span></div><div class=""><b style="font-family: 'Courier New';" class=""><br class=""></b></div><div class=""><b style="font-family: 'Courier New';" class=""><br class=""></b></div><div class="">Andrei from The Great White North.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><b style="font-family: 'Courier New';" class=""><br class=""></b></div><div class=""><b style="font-family: 'Courier New';" class=""><br class=""></b></div></body></html>