AR-B104D Software Guide V1.
AR-B104D Software Programming Guide Revision Version Date Author Description 0.1 2010/5/17 Bankle Chen Draft 0.2 2010/7/21 Bankle Chen Add Canbus related function 1.
AR-B104D Software Programming Guide Table of Contents Chapter 1 Chapter 2 2.1 Introduction .............................................................................. 1 Application Interface ................................................................ 2 General Usage ..............................................................................2 2.1.1 RegisterCard......................................................................2 2.1.2 ReleaseCard..............................................
AR-B104D Software Programming Guide 2.3.15 2.3.16 GetCounterTimeoutBase ................................................13 GetCounterValue .............................................................14 2.3.17 2.3.18 2.3.19 SetCounterTarget ............................................................14 GetCounterTarget ............................................................14 WriteOutputChannel........................................................15 2.3.20 2.3.21 ReadOutputChannel...............
AR-B104D Software Programming Guide Chapter 1 Introduction AR-B104D is a PCI-104 board which contains 12 general purposed input channels with pulse counter alternative function, 12 general purposed output channels with pulse generator alternative function, SRAM with battery supplied, hardware timer, and CAN-bus interface. In order to ease the customer’s operation on AR-B104D, Acrosser provides device driver, application interface (API), and source code of demo application.
AR-B104D Software Programming Guide Chapter 2 Application Interface This chapter describes the details of the provided API function. To prevent using the function under wrong operation system, we add the operation system prefix in front of function name and separate by underline, e.g. WXP_RegisterCard or LNX_RegisterCard. 2.1 General Usage 2.1.1 ♦ RegisterCard Description This function is used to register the selected AR-B104D card.
AR-B104D Software Programming Guide 2.1.4 ♦ GetMemBaseAddr Description This function is used to get the SRAM base address of the selected AR-B104D card. ♦ Syntax XXX_GetMemBaseAddr (i16 CardNum, u32* MemBaseAddr) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. MemBaseAddr: The SRAM base address of the selected AR-B104D card. 2.1.5 ♦ GetEventBuffer Description Get an event from device event queue.
AR-B104D Software Programming Guide XXX_SetCallbackFunc (i16 CardNum, agc_callback_t func) ♦ ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. func: The callback function pointer. Example void IOIST(event Event) { switch( Event.Type ) { case INPUT: printf("Get input event: Channel %d is %s.\n", Event.Channel, (Event.Value)? "high":"low"); break; case COUNTER_TO: printf("Get counter timeout event: Counter %d, value = %d.\n", Event.Channel, Event.
AR-B104D Software Programming Guide } ---------------------------------------------------------------------------------------------------Errbox = LNX_RegisterCard( &CardNum ); if(Errbox != 0) printf(" Register Card Error\n"); if( CardNum == 0xff ) { printf("[Not Found]\n"); return -1; } LNX_SetCallbackFunc(CardNum, &IOIST); 5
AR-B104D Software Programming Guide 2.2 SRAM 2.2.1 ReadMemByte ♦ Description This function is used to read SRAM data in byte alignment. ♦ Syntax XXX_ReadMemByte (i16 CardNum, u32 Offset, u8* Buffer) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. Offset: SRAM offset to read. Buffer: The memory address of buffer to put read SRAM data. 2.2.2 ♦ ReadMemWord Description This function is used to read SRAM data in word alignment.
AR-B104D Software Programming Guide ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. Offset: SRAM offset to read Value: Value to write to SRAM. 2.2.5 ♦ WriteMemWord Description This function is used to write SRAM data in word alignment. ♦ Syntax XXX_WriteMemWord (i16 CardNum, u32 Offset, u16 Value) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. Offset: SRAM offset to read (must in word alignment) Value: Value to write to SRAM. 2.2.
AR-B104D Software Programming Guide This function is used to read memory with a specified length. ♦ Syntax XXX_ReadMem_Block (i16 CardNum, u32 Offset, u8* Buffer, u32 Size) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. Offset: SRAM offset to read Buffer: The start address of memory buffer to put SRAM data. Size: The memory block size (in byte) to read. 2.2.9 ♦ WriteMemBlock Description This function is used to write data to memory with a specified length.
AR-B104D Software Programming Guide 2.3 General Purpose Input/Output 2.3.1 ReadInputChannel ♦ Description This function is used to read the status of the selected input channel on the selected AR-104D card. ♦ Syntax XXX_ReadInputChannel (i16 CardNum, i16 ChannelNum, u8* Value) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Input channel number. Range from 0~11. Value: The channel status. 0 indicates input low; 1 indicates input high. 2.3.
AR-B104D Software Programming Guide 2.3.4 ♦ SetDebounce Description Set the debounce time for the selected channel (in ms). ♦ Syntax XXX_SetDebounce (i16 CardNum, i16 ChannelNum, u8 Dtime) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Input channel number. Range from 0~11. Dtime: The de-bounce time. 0 indicates the debounce function is disabled; others indicate the debounce time in ms, e.g., 1 means debounce time is 1 ms. 2.3.
AR-B104D Software Programming Guide ♦ Description Get the interrupt enable status of the selected input channel. ♦ Syntax XXX_GetInputInterruptEnable (i16 CardNum, i16 ChannelNum, u8* Enable) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Input channel number. Range from 0~11. Enable: The memory address of buffer to put the interrupt enable status of the selected input channel.
AR-B104D Software Programming Guide 2.3.10 SetCounterMode ♦ Description Set the counter value access mode of the selected input channel. ♦ Syntax XXX_SetCounterMode (i16 CardNum, i16 ChannelNum, u8 Mode) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Input channel number. Range from 0~11. Mode: The counter value access mode of the selected input channel.
AR-B104D Software Programming Guide interrupt triggered if the selected input channel remains unchanged; others indicate the timeout value in timeout timebase. 2.3.13 GetCounterTimeout ♦ Description Get the counter timeout value of the selected input channel. ♦ Syntax XXX_GetCounterTimeout (i16 CardNum, i16 ChannelNum, u16* Value) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Input channel number. Range from 0~11.
AR-B104D Software Programming Guide timebase of the selected input channel. 0 indicates the base is 1 ms; 1 indicates the base is 100 ms. 2.3.16 GetCounterValue ♦ Description Get the counter value of the selected input channel. ♦ Syntax XXX_GetCounterValue (i16 CardNum, i16 ChannelNum, u16* Value) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Input channel number. Range from 0~11.
AR-B104D Software Programming Guide 2.3.19 WriteOutputChannel ♦ Description Write the status of the selected output channel on the selected AR-104D card. ♦ Syntax XXX_WriteOutputChannel (i16 CardNum, i16 ChannelNum, u8 Value) ♦ Argument CardNum: The number of AR-B104D. Range from 1~4. ChannelNum: Output channel number. Range from 0~11. Value: The channel status. 0 indicates output low; 1 indicates output high. 2.3.
AR-B104D Software Programming Guide 2.3.22 GetOutputMode ♦ Description Get the output operation mode of the selected output channel. ♦ Syntax XXX_GetOutputMode (i16 CardNum, i16 ChannelNum, u8* Mode) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: output channel number. Range from 0~11. Mode: The memory address of buffer to put the output operation mode of the selected output channel.
AR-B104D Software Programming Guide 2.3.25 SetPGInterruptEnable ♦ Description Enable the interrupt of the selected output channel (pulse generator). ♦ Syntax XXX_SetPGInterruptEnable (i16 CardNum, i16 ChannelNum, u8 Enable) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Output channel number. Range from 0~11.
AR-B104D Software Programming Guide ♦ Description Get the pulse generator timebase of the selected output channel. ♦ Syntax XXX_GetPGBase (i16 CardNum, i16 ChannelNum, u8* Base) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Output channel number. Range from 0~11. Base: The memory address of buffer to put the pulse generator timebase of the selected output channel. 0 indicates the base is 1 ms; 1 indicates the base is 100 ms. 2.3.
AR-B104D Software Programming Guide 2.3.31 SetPGCycle ♦ Description Set the pulse generator cycles of the selected output channel. ♦ Syntax XXX_SetPGCycle (i16 CardNum, i16 ChannelNum, u16 Cycle) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. ChannelNum: Output channel number. Range from 0~11. Cycle: The number of the related pulse generator running cycle. 2.3.32 GetPGCycle ♦ Description Get the pulse generator cycles of the selected output channel.
AR-B104D Software Programming Guide Low: The time of the related pulse generator remains low in one cycle. Cycle: The number of the related pulse generator running cycle.
AR-B104D Software Programming Guide 2.4 Timer 2.4.1 SetTimerInterruptEnable ♦ Description Enable the selected timer interrupt. Timer will start automatically once interrupt is set to enable. ♦ Syntax XXX_SetTimerInterruptEnable (i16 CardNum, i16 TimerNum, u8 Enable) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. TimerNum: Timer number. Range from 0~12. Enable: 0 indicates the timer interrupt is disabled; 1 indicates the timer interrupt is enabled. 2.4.
AR-B104D Software Programming Guide ♦ Description Get the time base of the selected timer. ♦ Syntax XXX_GetTimerBase (i16 CardNum, i16 TimerNum, u8* Base) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. TimerNum: Timer number. Range from 0~12. Base: The memory address of buffer to put the time base of the selected output channel. 0 indicates the base is 1 ms; 1 indicates the base is 100 ms. 2.4.5 ♦ SetTimerValue Description Set the timer value of the selected timer.
AR-B104D Software Programming Guide 2.5 CAN-bus 2.5.1 CanSendMessages ♦ Description Send messages via CAN-bus interface. ♦ Syntax XXX_CanSendMessages (i16 CardNum, canmsg_t* Buffer, u8 Count) ♦ Argument CardNum: The card number of AR-B104D. Range from 1~4. Buffer: The memory buffer which stores the messages to send. Count: The number of messages to send in the buffer. 2.5.2 ♦ CanGetMessages Description Get messages via CAN-bus interface.