User guide
206 運動控制功能原理介紹
• 例 :
另外,若使用者想要使用 win32 的 Event handle,可在步驟 1 後使
用 APS_int_no_to_handle() 將 Event number 轉換成 win32 下的
Event handle 格式
• 例 :
void interrupt_example()
{
// This example shows how interrupt functions work.
I32 board_id = 0;
I32 int_no; // Interrupt number
I32 return_code; // function return code
I32 item = 0; // Axis #0 interrupt
I32 factor = ( 1 << 12 ); // bit 12 IMDN interrupt
//Step 1: 姕⭂天䫱⼭䘬ᷕ㕟ḳẞ, factor = IMDN
int_no = APS_set_int_factor( board_id, item, factor, 1 );
//Step 2: 姕⭂ᷕ㕟䷥攳斄
APS_int_enable( board_id, 1 ); // Enable the interrupt main switch
//Step 3: 䫱⼭ᷕ㕟妠䘤
return_code = APS_wait_single_int( int_no, -1 ); //Wait interrupt
if( return_code == ERR_NoError )
{ //Interrupt occurred
//Step 4: 慵伖ᷕ㕟䁢妠䘤䉨ン
APS_reset_int( int_no );
}
// Step 5: 斄攱ᷕ㕟ḳẞᷕ㕟䷥攳斄
APS_set_int_factor( board_id, item, factor, 0 );
APS_int_enable( board_id, 0 );
}
preliminary