source: trunk/Cosy/incl/cal.h@ 18054

Last change on this file since 18054 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 3.7 KB
Line 
1/*-----------------------------------------------------------------------------
2cal.h -- CAN Application Layer CAL
3
4Copyright (c) 1994 JANZ Computer AG
5All Rights Reserved
6
7Created 94/10/11 by Soenke Hansen
8Version 1.9 of 98/07/31
9
10CALO: CAN Application Layer Object
11
12CALO's receive CAN messages. Using only the identifier and the RTR bit
13of a CAN message CAL forwards a message to the appropriate CALO.
14CALO's are either waiting on an event (e.g., CAN message, timer, user
15request) or are ready to do work. The latter objects are maintained on a
16queue until they have finished their work.
17
18Prototypes of functions defined in cal.c.
19
20-----------------------------------------------------------------------------*/
21
22
23#ifndef cal_DEFINED
24#define cal_DEFINED
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include "defs.h"
31#include "msg.h"
32
33
34#ifdef FIRMWARE
35/* CAN Application Layer Object */
36struct calo {
37 WORD_t id; /* identifier (handle) of object */
38 WORD_t head; /* head of CAN messages received */
39 OBJECT obj; /* object specific data */
40 void (*mhdl)(); /* CAL handler for received message */
41 struct calo *nxtrx; /* next on rx id hash queue */
42 struct calo *nxtcal; /* next on CAL id hash queue */
43};
44
45#define NIL_CALO (struct calo *)0
46
47/* Identifiers (handles) of CAL objects -- not to be confused with
48 CAN message Ids -- are 11 bit numbers. Ids of requests issued to
49 ICANOS are 16 bit words with the lower bits equal to the
50 Id of the requesting CAL Object. CALID_MASK is used in retrieving
51 the CAL Object Id from the request Id. */
52#define CALID_MASK 0x07ff
53
54/* Nil CAN message head (descriptor) */
55#define NIL_CAN_HEAD 0xffff /* invalid descriptor */
56
57#endif /* FIRMWARE */
58
59/* CAN Identifiers used by CAL (cf. CiA/DS204-1, Annex I) */
60#define ID_START_STOP 0 /* Node Start, Stop, Disconnect */
61#define ID_CMS_NIL 0 /* invalid CMS Id */
62#define ID_CMS_MIN 1 /* range of CMS */
63#define ID_CMS_MAX 1760 /* identifiers */
64#define ID_GUARD_NIL 0 /* invalid guard Id */
65#define ID_GUARD_MIN 1761 /* range of guarding */
66#define ID_GUARD_MAX 2015 /* identifiers */
67#define ID_LMT_S 2020 /* from LMT Slave */
68#define ID_LMT_M 2021 /* from LMT Master */
69#define ID_NMT_IDENTIFY 2022 /* Identify Node Protocol */
70#define ID_DBT_S 2023 /* from DBT Slave */
71#define ID_DBT_M 2024 /* from DBT Master */
72#define ID_NMT_S 2025 /* from NMT Slave */
73#define ID_NMT_M 2026 /* from NMT Master */
74#define ID_SELFTEST 2027 /* for module selftest */
75#define ID_MIN 0 /* range of identifiers */
76#define ID_MAX 2031 /* controlled by CiA */
77
78
79/*--------- Prototypes of CAL User Functions -------------------------------*/
80
81#ifdef FIRMWARE
82
83/* Initialize CAL */
84extern void InitCal(
85 WORD_t, /* req. clock period */
86 WORD_t, /* bus timing */
87 WORD_t, /* timeout interval */
88 void (*)(), /* user handler for NMT Slave ind/con */
89 void (*)(), /* user handler for DBT Slave ind/con */
90 void (*)() /* user handler for LMT Slave ind/con */
91);
92
93/* Free the resources held by CAL */
94extern void DeleteCal(void);
95
96/* Execute CAL */
97extern void RunCal(void);
98
99/*--------- Enable/Disable Remote Services ---------------------------------*/
100
101#define EnableCAN() buson_bcan()
102#define DisableCAN() busoff_bcan()
103
104/*--------- Prototypes of CAL internal functions ---------------------------*/
105
106/* Create a CAL object. */
107extern struct calo *NewCalO(void);
108
109/* Delete a CAL object. */
110extern void DeleteCalO(struct calo *);
111
112/* Get a CAL object by its Id (handle). */
113extern struct calo *GetCalO(WORD_t);
114
115/* Assign CAN message head to a CAL Object */
116extern int AssignCalO(struct calo *, WORD_t);
117
118/* Unassign CAN message head from a CAL Object */
119extern void UnassignCalO(struct calo *);
120
121#endif /* FIRMWARE */
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif /* !cal_DEFINED */
Note: See TracBrowser for help on using the repository browser.