MiniCAN | MiniCAN: minican.c File Reference | Documentation |
#include "max_lib.h"
#include "x_error.h"
#include "x_mdd.h"
#include "dos.h"
#include "stdlib.h"
#include "string.h"
#include "minican.h"
Include dependency graph for minican.c:
Go to the source code of this file.
Data Structures | |
struct | PDT_t |
PDT (Program Descriptor Table). More... | |
struct | parameter_t |
task parameter range structure More... | |
Defines | |
#define | _RTLIB_ |
must be defined in every real time program before including max_lib.h | |
Functions | |
MAX_ERROR | GetBitTiming (USHORT usInterface, XCAN_BIT_PARAMS *prcBitParam) |
fill in XCAN_BIT_PARAMS for a given bit rate | |
MAX_CALLBACK | CbFilter (MAXCHLHND hChannel, ULONG ulParam, ULONG ulSize, void *prcCanMessage) |
callback from acceptance filter | |
MAX_CALLBACK | CbControl (MAXCHLHND hChannel, ULONG ulParam, ULONG ulSize, void *pData) |
callback from control channel | |
MAX_CALLBACK | CbAcknowledge (MAXCHLHND hChannel, ULONG ulParam, ULONG ulSize, void *pVoid) |
callback from universal sender | |
void MAXEXPORT | MainProc (void) |
(0): main procedure | |
void MAXEXPORT | AutoInit (void) |
(1): init task parameter | |
void MAXEXPORT | Start (void) |
(2): start CAN communication | |
void MAXEXPORT | Stop (void) |
(3): stop CAN communication | |
void MAXEXPORT | Write0 (USHORT *pusLength, CAN_INTERFACE_WRITE *prcCanMsg, USHORT *pusRetsize, void *pRetData) |
(5): send data via interface 0 | |
void MAXEXPORT | Write1 (USHORT *pusLength, CAN_INTERFACE_WRITE *prcCanMsg, USHORT *pusRetsize, void *pRetData) |
(7): send data via interface 1 | |
void MAXEXPORT | Read0 (USHORT *pusLength, void *pIn, USHORT *pusRetsize, CAN_INTERFACE_READ *prcCanMsg) |
(4): read data from interface 0 | |
void MAXEXPORT | Read1 (USHORT *pusLength, void *pIn, USHORT *pusRetsize, CAN_INTERFACE_READ *prcCanMsg) |
(6): read data from interface 1 | |
void | main () |
initialize the Program Descriptor Table (PDT); called once on installing the program | |
Variables | |
PDT_t | rcPDT |
instance of PDT | |
parameter_t | parameter |
instance of task parameters |
Definition in file minican.c.
#define _RTLIB_ |
void MAXEXPORT AutoInit | ( | void | ) |
(1): init task parameter
Init task parameters, create ring buffers, activate task
- |
Definition at line 336 of file minican.c.
References parameter_t::arcCanParameters, CAN_RCV_BUFFER_SIZE, parameter_t::Error, parameter_t::hBuf, parameter_t::hCtrl, parameter_t::hIn11, parameter_t::hIn29, parameter_t::hMdd, parameter_t::hMyself, parameter_t::hOut, parameter, PDT_t::rcHead, parameter_t::rcOsX, rcPDT, CAN_INTERFACE_PARAMETERS::ulBitRate, CAN_INTERFACE_PARAMETERS::ulCanId, CAN_INTERFACE_PARAMETERS::ulCanMask, parameter_t::ulCbCtrlCount, parameter_t::ulCbFilterCount, CAN_INTERFACE_PARAMETERS::ulFormat, CAN_INTERFACE_PARAMETERS::ulRbus, parameter_t::ulTimeStampHi, parameter_t::ulTimeStampLo, parameter_t::ulTmtPending, and parameter_t::usSlot.
Referenced by main().
MAX_CALLBACK CbAcknowledge | ( | MAXCHLHND | hChannel, | |
ULONG | ulParam, | |||
ULONG | ulSize, | |||
void * | pVoid | |||
) |
callback from universal sender
hChannel | handle of the calling send channel | |
ulParam | interface index | |
ulSize | not used | |
pVoid | not used |
Definition at line 295 of file minican.c.
References parameter, and parameter_t::ulTmtPending.
Referenced by Start().
MAX_CALLBACK CbControl | ( | MAXCHLHND | hChannel, | |
ULONG | ulParam, | |||
ULONG | ulSize, | |||
void * | pData | |||
) |
callback from control channel
hChannel | handle of the calling control channel | |
ulParam | interface index | |
ulSize | size of data pointed to by pData | |
pData | pointer to ULONG; low word: bus state; high word: error info |
Definition at line 267 of file minican.c.
References parameter_t::arcIfcState, parameter, parameter_t::ulCbCtrlCount, parameter_t::ulTimeStampHi, CAN_INTERFACE_STATE::ulTimeStampHi, parameter_t::ulTimeStampLo, CAN_INTERFACE_STATE::ulTimeStampLo, and CAN_INTERFACE_STATE::usBusState.
Referenced by Start().
MAX_CALLBACK CbFilter | ( | MAXCHLHND | hChannel, | |
ULONG | ulParam, | |||
ULONG | ulSize, | |||
void * | prcCanMessage | |||
) |
callback from acceptance filter
hChannel | handle of the calling acceptance filter channel | |
ulParam | high word: interface index; low word: message format | |
ulSize | size of data pointed to by prcCanMessage | |
prcCanMessage | CAN message received by the acceptance filter |
Definition at line 202 of file minican.c.
References CAN_INTERFACE_READ::aucData, parameter_t::Error, parameter_t::hBuf, parameter, parameter_t::ulCbFilterCount, CAN_INTERFACE_READ::ulDataSize, CAN_INTERFACE_READ::ulFormat, CAN_INTERFACE_READ::ulId, parameter_t::ulTimeStampHi, CAN_INTERFACE_READ::ulTimeStampHi, parameter_t::ulTimeStampLo, and CAN_INTERFACE_READ::ulTimeStampLo.
Referenced by Start().
MAX_ERROR GetBitTiming | ( | USHORT | usInterface, | |
XCAN_BIT_PARAMS * | prcBitParam | |||
) |
fill in XCAN_BIT_PARAMS for a given bit rate
usInterface | interface index: 0 | 1 | |
prcBitParam | pointer to a structure of type XCAN_BIT_PARAMS |
Definition at line 90 of file minican.c.
References parameter_t::arcBitTiming, parameter_t::arcCanParameters, parameter, CAN_INTERFACE_PARAMETERS::ulBitRate, CAN_INTERFACE_PARAMETERS::ulFormat, and CAN_INTERFACE_PARAMETERS::ulRbus.
Referenced by Start().
void main | ( | ) |
initialize the Program Descriptor Table (PDT); called once on installing the program
- |
Definition at line 834 of file minican.c.
References PDT_t::auto_init, AutoInit(), PDT_t::main_proc, MainProc(), parameter, PROGRAMM_NUMBER, PDT_t::rcHead, rcPDT, Read0(), PDT_t::Read0, Read1(), PDT_t::Read1, REVISION, Start(), PDT_t::Start, Stop(), PDT_t::Stop, VERSION, Write0(), PDT_t::Write0, Write1(), and PDT_t::Write1.
void MAXEXPORT MainProc | ( | void | ) |
(0): main procedure
called cyclic after activation, increment timestamp
- |
Definition at line 315 of file minican.c.
References parameter, parameter_t::ulTimeStampHi, and parameter_t::ulTimeStampLo.
Referenced by main().
void MAXEXPORT Read0 | ( | USHORT * | pusLength, | |
void * | pIn, | |||
USHORT * | pusRetsize, | |||
CAN_INTERFACE_READ * | prcCanMsg | |||
) |
(4): read data from interface 0
In case of error max_clear_func() is called as the error code is passed to the caller with max_exit_func.
pusLength | not used | |
pIn | not used | |
pusRetsize | size of the data buffer | |
prcCanMsg | pointer of type CAN_INTERFACE_READ |
Definition at line 741 of file minican.c.
References parameter_t::Error, parameter_t::hBuf, and parameter.
Referenced by main().
void MAXEXPORT Read1 | ( | USHORT * | pusLength, | |
void * | pIn, | |||
USHORT * | pusRetsize, | |||
CAN_INTERFACE_READ * | prcCanMsg | |||
) |
(6): read data from interface 1
In case of error max_clear_func() is called as the error code is passed to the caller with max_exit_func.
pusLength | not used | |
pIn | not used | |
pusRetsize | size of the data buffer | |
prcCanMsg | pointer of type CAN_INTERFACE_READ |
Definition at line 791 of file minican.c.
References parameter_t::Error, parameter_t::hBuf, and parameter.
Referenced by main().
void MAXEXPORT Start | ( | void | ) |
(2): start CAN communication
Start bus and open required channels. In case of error max_clear_error() is called and the procedure is left immediately.
- |
Definition at line 440 of file minican.c.
References parameter_t::arcCanParameters, CbAcknowledge(), CbControl(), CbFilter(), parameter_t::Error, GetBitTiming(), parameter_t::hCtrl, parameter_t::hIn11, parameter_t::hIn29, parameter_t::hMdd, parameter_t::hMyself, parameter_t::hOut, parameter, CAN_INTERFACE_PARAMETERS::ulBitRate, CAN_INTERFACE_PARAMETERS::ulCanId, CAN_INTERFACE_PARAMETERS::ulCanMask, CAN_INTERFACE_PARAMETERS::ulFormat, and parameter_t::usSlot.
Referenced by main().
void MAXEXPORT Stop | ( | void | ) |
(3): stop CAN communication
Stop bus and close all channels. In case of error max_clear_error() is called and the procedure is continued to get into a defined state again.
- |
Definition at line 576 of file minican.c.
References parameter_t::Error, parameter_t::hBuf, parameter_t::hCtrl, parameter_t::hIn11, parameter_t::hIn29, parameter_t::hOut, and parameter.
Referenced by main().
void MAXEXPORT Write0 | ( | USHORT * | pusLength, | |
CAN_INTERFACE_WRITE * | prcCanMsg, | |||
USHORT * | pusRetsize, | |||
void * | pRetData | |||
) |
(5): send data via interface 0
In case of error max_clear_func() is called as the error code is passed to the caller with max_exit_func.
pusLength | size of input data | |
prcCanMsg | pointer of type CAN_INTERFACE_WRITE | |
pusRetsize | not used | |
pRetData | not used |
Definition at line 646 of file minican.c.
References CAN_INTERFACE_WRITE::aucData, parameter_t::Error, parameter_t::hOut, parameter, CAN_INTERFACE_WRITE::ulDataSize, CAN_INTERFACE_WRITE::ulFormat, CAN_INTERFACE_WRITE::ulId, and parameter_t::ulTmtPending.
Referenced by main().
void MAXEXPORT Write1 | ( | USHORT * | pusLength, | |
CAN_INTERFACE_WRITE * | prcCanMsg, | |||
USHORT * | pusRetsize, | |||
void * | pRetData | |||
) |
(7): send data via interface 1
In case of error max_clear_func() is called as the error code is passed to the caller with max_exit_func.
pusLength | size of input data | |
prcCanMsg | pointer of type CAN_INTERFACE_WRITE | |
pusRetsize | not used | |
pRetData | not used |
Definition at line 694 of file minican.c.
References CAN_INTERFACE_WRITE::aucData, parameter_t::Error, parameter_t::hOut, parameter, CAN_INTERFACE_WRITE::ulDataSize, CAN_INTERFACE_WRITE::ulFormat, CAN_INTERFACE_WRITE::ulId, and parameter_t::ulTmtPending.
Referenced by main().
instance of task parameters
Definition at line 79 of file minican.c.
Referenced by AutoInit(), CbAcknowledge(), CbControl(), CbFilter(), GetBitTiming(), main(), MainProc(), Read0(), Read1(), Start(), Stop(), Write0(), and Write1().
24 Sep 2008 | SORCUS Computer GmbH |