set_interrupt_handler

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
maqu67
Member++
Posts: 22
Joined: Tue Jan 23, 2018 3:26 pm

set_interrupt_handler

Post by maqu67 »

Hello,

I've problems to understand the following definition I found in interrupt.h (USB Audio 2.0 software) :

#define set_interrupt_handler(f, args, c, ...)

In the decouple.xc file is called in the form:

set_interrupt_handler(handle_audio_request, 1, c_mix_out, 0);

Can someone explain me how it works ? I can't undestand the arguments. "handle_audio_request" is the function that is called when I have a request
on c_mix_out but '1' and '0' in the arguments list what do they represent?

Thanks a lot

Massimiliano


User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Can be of partial help:

Code: Select all


#define set_interrupt_handler(f, nstackwords, args, c, ...) \
  asm (" .section .dp.data,       \"adw\", @progbits\n" \
       " .align 4\n" \
       "__" #f "_kernel_stack:\n" \
       " .space  " #nstackwords ", 0\n" \
       " .text\n"); \
  asm("mov r10, %0; ldaw r11, dp[__" #f "_kernel_stack];add r11, r11, r10;ldaw r10, sp[0]; "\
      "set sp,r11;stw r10, sp[0]; krestsp 0"::"r"(nstackwords-8):"r10","r11"); \
  store_args ## args(c, __VA_ARGS__) \
  do_interrupt_handler(f, args) \
  asm("ldap r11, __" #f "_handler; setv res[%0],r11"::"r"(c):"r11");    \
  asm("setc res[%0], 0xa; eeu res[%0]"::"r"(c));                        \
  asm("setsr (((0) & ~(((1 << 0x1) - 1) << 0x1)) | (((1) << 0x1) & (((1 << 0x1) - 1) << 0x1)))");

where:

#define set_interrupt_handler(f, nstackwords, args, c, ...)
maqu67
Member++
Posts: 22
Joined: Tue Jan 23, 2018 3:26 pm

Post by maqu67 »

Hello mon2, thanks in any case.
I'm not able to understand this piece of assembly code.

Massimiliano
Post Reply