Electronic Components Datasheet Search
  New Zealand  ▼
ALLDATASHEET.CO.NZ

X  

UM0851 Datasheet(PDF) 109 Page - STMicroelectronics

Part # UM0851
Description  SPEAr is a family of highly customizable ARM-based embedded
PDF  245 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Manufacturer  STMICROELECTRONICS [STMicroelectronics]
Direct Link  http://www.st.com
Logo STMICROELECTRONICS - STMicroelectronics

UM0851 Datasheet(HTML) 109 Page - STMicroelectronics

Back Button UM0851 Datasheet HTML 105Page - STMicroelectronics UM0851 Datasheet HTML 106Page - STMicroelectronics UM0851 Datasheet HTML 107Page - STMicroelectronics UM0851 Datasheet HTML 108Page - STMicroelectronics UM0851 Datasheet HTML 109Page - STMicroelectronics UM0851 Datasheet HTML 110Page - STMicroelectronics UM0851 Datasheet HTML 111Page - STMicroelectronics UM0851 Datasheet HTML 112Page - STMicroelectronics UM0851 Datasheet HTML 113Page - STMicroelectronics Next Button
Zoom Inzoom in Zoom Outzoom out
 109 / 245 page
background image
UM0851
Communication device drivers
Doc ID 16604 Rev 2
109/245
void (*write_reg)(struct net_device *dev,
enum c_regs reg, u16 val);
#ifdef CCAN_DEBUG
unsigned int bufstat[MAX_OBJECT + 1];
#endif
};
To write and read the CAN IP registers the APIs spr_can_write_reg() and
spr_can_read_reg() are used respectively:
static u16 spr_can_read_reg(struct net_device *dev, enum c_regs reg);
static void spr_can_write_reg(struct net_device *dev, enum c_regs reg,
u16 val);
4.9.5
User-land applications over the CAN driver
This section describes how to design a simple application that accesses the services
provided by the CAN driver. For designing a typical user-land application that uses the CAN
driver, the following steps should be followed:
To open a socket for communicating over a CAN network:
1.
Pass PF_CAN as the first argument to the socket() system call. Currently, there are two
CAN protocols to choose from, the raw socket protocol (RAW) and the broadcast
manager (BCM):
/* Open a RAW socket */
s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
/* Open a BCM socket */
s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM);
2.
Now, bind the socket to a CAN interface using the bind() system call. An example of
binding a raw socket to the CAN interface can0 is given below:
int s;
struct sockaddr_can addr;
struct ifreq ifr;
s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
strcpy(ifr.ifr_name, "can0" );
ioctl(s, SIOCGIFINDEX, &ifr);
addr.can_family = AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex;
bind(s, (struct sockaddr *)&addr, sizeof(addr));
3.
After binding (CAN_RAW) or connecting (CAN_BCM) the socket, you can read and
write from/to the socket using read() and write() APIs respectively:
/* Read nbytes from a CAN socket */
nbytes = read(s, &frame, sizeof(struct can_frame));
/* Write nbytes to a CAN socket */
nbytes = write(s, &frame, sizeof(struct can_frame));
You can also use other standard APIs like send(), sendto(), sendmsg() and recv() to perform
the desired operations on the socket.



Html Pages

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100  ...More


Datasheet Download

Go To PDF Page


Link URL



Does ALLDATASHEET help your business so far?  [ DONATE ] 

About Alldatasheet   |   Advertisement   |   Contact us   |   Privacy Policy   |   Link to Datasheet    |   Link Exchange   |   Manufacturer List
All Rights Reserved©Alldatasheet.com


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
Russian : Alldatasheetru.com  |   Korean : Alldatasheet.co.kr  |   Spanish : Alldatasheet.es  |   French : Alldatasheet.fr  |   Italian : Alldatasheetit.com
Portuguese : Alldatasheetpt.com  |   Polish : Alldatasheet.pl  |   Vietnamese : Alldatasheet.vn
Indian : Alldatasheet.in  |   Mexican : Alldatasheet.com.mx  |   British : Alldatasheet.co.uk  |   New Zealand : Alldatasheet.co.nz
Family Site : ic2ic.com  |   icmetro.com