<p dir="ltr">Andrei, thanks! </p>
<div class="gmail_quote">17 мая 2016 г. 8:31 пользователь <<a href="mailto:groups@chichak.ca">groups@chichak.ca</a>> написал:<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>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'"> 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_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_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">ADC_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_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_RxCpltCallback</b> and <b style="font-family:'Courier New'">HAL_CAN_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>