Advertisement

Quick Links

Revision: 1.0
PROGRAMMER'S GUIDE
Date: Jul 1, 10
CrossCore XA
Programmer's guide
www.crosscontrol.com

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the CrossCore XA and is the answer not in the manual?

Questions and answers

Summary of Contents for crosscontrol CrossCore XA

  • Page 1 Revision: 1.0 PROGRAMMER’S GUIDE Date: Jul 1, 10 CrossCore XA Programmer's guide www.crosscontrol.com...
  • Page 2: Table Of Contents

    Debug card ..........................5       2.1. J14 - Configuration header ....................5     2.2. J15 – Connection to CrossCore XA ..................5 2.3. J18 – USB Serialport ......................... 6         2.4. J19 – FPGA ..........................6  ...
  • Page 3: Revision History

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 8.2. Summary of data types ......................42         8.3. Interface functions ........................ 43   Watchdog Device Interface ....................46   9.1. Configuration of device interface ..................46  ...
  • Page 4: Introduction

    Common defines used in this document True Non-zero value False Zero value The term CrossCore XA is used to refer both of the device types simultaneously. 1.3. References CrossCore XA – Software User Guide Codesourcery Sourcery G++ user manual CrossCore XA – HALIO http://openfacts.berlios.de/index-en.phtml?title=Socket-CAN...
  • Page 5: Debug Card

    Enable Bootflash Disable Bootflash 9 – 10 No factory reset Factory reset 2.2. J15 – Connection to CrossCore XA J15 is used to connect debug card to actual CrossCore XA hardware with a ribbon cable provided with the debug card. www.crosscontrol.com...
  • Page 6: J18 - Usb Serialport

    It requires external FT232 (or similar.) USB to RS232 – converter. USB and DSUB9 serial port cannot be used at the same time. DESC VDD +5V 2.4. J19 – FPGA J19 provides interface to reprogram FPGA in CrossCore XA. DESC. DESC. 2.5V FPGA TMS...
  • Page 7: J26 - Rs232

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 2.7. J26 – RS232 J26 is standard DBUS RS232 – serial port for debug console. It’s alternative for J18 and they cannot be used at the same time. DESC. REST 2.8.
  • Page 8: Can Communication Interface

    The CAN Communication interface enables the caller to receive messages from and send messages to the CAN interfaces on the CrossCore XA device. The CAN communication is handled over the SocketCAN interface, which is a method to use standard socket API functions for CAN communication [4].
  • Page 9 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 3.1.1. Selecting CAN driver operation modes Starting from SW release 0.4.0.0, there are two different operation modes available for the CAN driver xilinx.ko: accurate mode and rapid mode. In accurate mode, received messages are handled one by one, which consumes more CPU time, but ensures accurate timestamps of received CAN frames.
  • Page 10 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 3.1.3. Error interrupt options Error interrupts are disabled by default. Enabled them by giving module parameter errorirq=1 during module loading. By enabling error interrupts user can receive error frames. Bus off errors will come through even if the error interrupts are not enabled.
  • Page 11: Summary Of Data Types

    Communication is done analogue to the use of Internet Protocol via Sockets. The protocol family provide the structures to enable different protocols on the bus. CrossCore XA module support by default raw sockets for direct communication and broadcast manager (bcm) for sending messages periodically or realizing complex message filters.
  • Page 12: Interface Functions

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 The interface uses following struct to define sockaddr structure for CAN sockets: struc t s o c k ad d r _ c a n { sa_ fami l y_ t ca n_ fa mi l y;...
  • Page 13 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Syntax i nt socket ( i nt d om ai n, i nt type , i nt proto c ol Parameters domain Specifies communication domain type Specifies socket type protocol...
  • Page 14 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 / * S el ect tha t CA N int erfac e , a nd bi nd the socke t to i t . */ s tr u c t s o c k a d d r _ c a n a d d r ;...
  • Page 15 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Syntax i nt setsoc k opt ( i nt socket, i nt l ev el , i nt opti on_nam e, c o nst v oi d *opti on_v al u e ,...
  • Page 16 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Parameters nfds Specifies sizes of fd_set type parameters readfds Read file descriptor list writefds Write file descriptor list errorfds Error file descriptor list timeout Specifies maximum wait time for select to block Return value Returns zero on success.
  • Page 17 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 (n by tes < si z eof (s truc t c a n _ f r a m e )) { fpri ntf (s td e r r , " read : i ncom pl ete CA N fram e\n" );...
  • Page 18 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Syntax ssi z e_t recv from ( i nt socket, v oi d *bu f f er , si z e_ t l eng th , i nt fl ag s ,...
  • Page 19 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Return value Returns non-negative integer indicating the number of bytes actually written. In case of errors, -1 is returned and errno is set appropriately. Example See example of socket. 3.3.8. sendto Description Send a message to a socket.
  • Page 20 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 ((s l = s o c k e t (P F _I NE T , S O C K _ S T R EA M , 0 )) < 0 ) { per r o r ("i netsock e t"...
  • Page 21 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 r et = s el ec t ((s c > s a )? s c + 1 :sa + 1 , & r ead f d s , N UL L , N UL L , N UL L );...
  • Page 22 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 3.3.10. listen Description Listen for socket connections and limit the queue of incoming connections. Include files #include <sys/socket.h> Syntax i nt l i sten ( i nt socket, i nt bac kl o g...
  • Page 23 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Return value Returns the non-negative file descriptor of the accepted socket on success. In case of errors, -1 is returned and errno is set appropriately. Example See example of send.
  • Page 24: Digital I/O Device Interface

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 4. Digital I/O Device Interface There are eight digital input signals that can be monitored through ioctl() calls or the read function, and two digital output signals that can be controlled through ioctl() call or write function.
  • Page 25 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Parameters pathname Path to the device file flags Parameter flag must include one of the following access modes: O_RDONLY, O_WRONLY or O_RDWR Return value The new file descriptor if successful. In case of errors, -1 is returned and errno is set appropriately.
  • Page 26 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Parameters File descriptor Pointer to the buffer where received data is stored count Number of bytes to read from the I/O-device Return value On success, the number of read bytes is returned. In case of errors, -1 is returned and errno is set appropriately.
  • Page 27 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 4.3.4. write Description Writes a value to a digital I/O-device. Include files #include <unistd.h> Syntax ssi z e_ t wri te( i nt f d , v oi d *bu f ,...
  • Page 28 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 4.3.5. ioctl Description The ioctl function calls are used for accessing the Digital I/O - device. The available ioctl operations Define Description CROSS_DIG_IOC_SET Set Digital output-pin state CROSS_DIG_IOC_GET Get Digital input-pin state...
  • Page 29: Power Device Interface

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 5. Power Device Interface There is a set of built-in modules, which have their supply power controlled by ioctl() calls or the write function. Also the device power supply state has a couple of state signals, which can be accessed through this interface.
  • Page 30 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 5.3.1. open Description Opens the PWR device. The call will return a file descriptor used in subsequent calls such as read() and ioctl(). Include files #include <fctnl.h> Syntax i nt open (...
  • Page 31 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 5.3.3. read Description Reads data from the PWR-device. Note that the returned data is in a kind of textual format that shows the status of all the PWR-states. Include files #include <unistd.h>...
  • Page 32 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 5.3.4. write Description Writes a value to a PWR-device. Values can be set on or off independently. Include files #include <unistd.h> Syntax ssi z e_ t wri te( i nt f d ,...
  • Page 33 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 5.3.5. ioctl Description The ioctl function calls are used for accessing the I/O device at different offsets. The available ioctl operations are summarized in the table below. Define Description CROSS_PWR_IOC_GET_PWRFAIL_STATUS Get low power –...
  • Page 34: Power Signal Handling

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 5.4. Power signal handling There are two signals that user applications can use for monitoring status of the power supply voltage. When either one of them activates, the application should call the power interface to turn off all unnecessary built-in peripherals, in order to preserve power.
  • Page 35: Usb Device Interface

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 6. USB Device Interface Whether or not a USB device is connected to the USB host can be detected using ioctl() calls. 6.1. Configuration of device interface The device node file for the USB interface is /dev/cross_usb_io, which is the entry point to the USB driver.
  • Page 36 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Return value The new file descriptor if successful. In case of errors, -1 is returned and errno is set appropriately. Example See example of ioctl. 6.3.2. close Description Closes the file descriptor Include files #include <unistd.h>...
  • Page 37 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 6.3.3. ioctl Description The ioctl function calls are used for accessing the I/O device at different offsets. The available ioctl operations are summarized in the table below. Define Description CROSS_USB_IOC_GET_USB_STATUS Get USB connected –...
  • Page 38: Front Led Device Interface

    7. Front LED Device Interface The CrossCore XA device has user controllable LED in the front. It can be set to flash at 1-50 Hz, or to be constantly on or off. Device also has two CAN leds that can be controlled through ioctl() calls.
  • Page 39 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 7.3.1. open Description Opens the front LED device. The call will return a file descriptor used in subsequent calls such as write() or close(). Include files #include <fctnl.h> Syntax i nt open (...
  • Page 40 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 7.3.3. write Description Writes a value to the front LED device. It can be set to off, on or flashing in the range (1-50 Hz). Writing the value “0” will turn the front LED off. A value of “51” or higher will turn on the front LED constantly on.
  • Page 41 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 7.3.4. ioctl Description An ioctl function call can be used for setting the state of the front LED. It has only one data type which was covered in section 7.2. The available ioctl operations are listed in the table below.
  • Page 42: Accelerometer Device Interface

    Date: Jul 1, 10 8. Accelerometer Device Interface The CrossCore XA device can have built-in accelerometer. It can used to detect sudden changes in acceleration. It can be controlled through ioctl() calls. Note: The accelerometer is available as an optional module and may not be available on your unit.
  • Page 43: Interface Functions

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 ui nt8 surv ei ll ance_str ategy ; / / bi t-or' ed surv ei ll ance str ategi e (s ) to arm // hi gh gai n thres hol d mode stuff (s ee SM B380 datas heet for more detai l s) ui nt16 HG_thr es ;...
  • Page 44 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Include files #include <unistd.h> Syntax i nt cl ose ( i nt f d Parameters File descriptor Return value Returns zero on success. In case of errors, -1 is returned and errno is set appropriately.
  • Page 45 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Example Note that this example is intended to show how to make the different function calls. All possible errors are not handled. i nt fd, retv al ; i nt mmapsi ze = si zeof (s mb380face);...
  • Page 46: Watchdog Device Interface

    CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 9. Watchdog Device Interface The device has a watchdog device, which can be used to reset the device in case if the software does not respond in predefined time. The watchdog device can be controlled through ioctl() calls.
  • Page 47 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Return value The new file descriptor if successful or -1 if an error occurred. In case of error, errno is set appropriately. Example See example of ioctl. 9.3.2. close Description...
  • Page 48 CrossCore XA Revision: 1.0 Programmers Guide Date: Jul 1, 10 Parameters File descriptor request Code of the request argp Used for transferring data in the ioctl call. Return value Returns a positive value on success. On error, -1 is returned and errno is set appropriately.
  • Page 49: Erial Number Broadcast Interface

    IP address is available in datagram headers. Example data contents (without quotes): “P R01< t ab> 0 .3 .0< t ab> 0 ” An example implementation of the data listener is available in CrossCore XA development package in example_src/snb/snb_reader.c www.crosscontrol.com...
  • Page 50: Technical Support

    Contact your reseller or supplier for help with possible problems with your CrossCore XA device. In order to get the best help, you should have access to your CrossCore XA device and be prepared with the following information before you contact support.

Table of Contents