Official support library for using mbed as a programmable coprocessor in the Innomatix DAP-III+ telematics platform
InnomatixCanAPI/inc/InnomatixCanAPI.h@0:b9e1003fbee7, 2016-04-15 (annotated)
- Committer:
- Innomatix
- Date:
- Fri Apr 15 18:35:31 2016 +0000
- Revision:
- 0:b9e1003fbee7
v1.0.2 Rework to use USB for comms, rework example, add user guides
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Innomatix | 0:b9e1003fbee7 | 1 | /******************************************************************* |
Innomatix | 0:b9e1003fbee7 | 2 | * |
Innomatix | 0:b9e1003fbee7 | 3 | * File: InnomatixCanAPI.h |
Innomatix | 0:b9e1003fbee7 | 4 | * |
Innomatix | 0:b9e1003fbee7 | 5 | * Description: Simple CAN API for Innomatix Coprocessor applications |
Innomatix | 0:b9e1003fbee7 | 6 | * |
Innomatix | 0:b9e1003fbee7 | 7 | * Copyright 2015 Innomatix, LLC., All Rights Reserved |
Innomatix | 0:b9e1003fbee7 | 8 | * |
Innomatix | 0:b9e1003fbee7 | 9 | * THIS DOCUMENT AND ITS CONTENTS ARE INTELLECTUAL PROPERTY |
Innomatix | 0:b9e1003fbee7 | 10 | * OF INNOMATIX, LLC. ANY DUPLICATION IN PART OR WHOLE |
Innomatix | 0:b9e1003fbee7 | 11 | * WITHOUT PRIOR WRITTEN CONSENT IS STRICTLY PROHIBITED. |
Innomatix | 0:b9e1003fbee7 | 12 | * |
Innomatix | 0:b9e1003fbee7 | 13 | *******************************************************************/ |
Innomatix | 0:b9e1003fbee7 | 14 | |
Innomatix | 0:b9e1003fbee7 | 15 | #ifndef _INNOMATIX_CAN_API_H |
Innomatix | 0:b9e1003fbee7 | 16 | #define _INNOMATIX_CAN_API_H |
Innomatix | 0:b9e1003fbee7 | 17 | |
Innomatix | 0:b9e1003fbee7 | 18 | #ifdef __cplusplus |
Innomatix | 0:b9e1003fbee7 | 19 | extern "C" |
Innomatix | 0:b9e1003fbee7 | 20 | { |
Innomatix | 0:b9e1003fbee7 | 21 | #endif |
Innomatix | 0:b9e1003fbee7 | 22 | /*************************************************/ |
Innomatix | 0:b9e1003fbee7 | 23 | |
Innomatix | 0:b9e1003fbee7 | 24 | typedef enum |
Innomatix | 0:b9e1003fbee7 | 25 | { |
Innomatix | 0:b9e1003fbee7 | 26 | canSuccess, // 0 |
Innomatix | 0:b9e1003fbee7 | 27 | canInvalidChannel, // 1 |
Innomatix | 0:b9e1003fbee7 | 28 | canInvalidSpeed, // 2 |
Innomatix | 0:b9e1003fbee7 | 29 | canInvalidIdentifier, // 3 |
Innomatix | 0:b9e1003fbee7 | 30 | canInvalidLength, // 4 |
Innomatix | 0:b9e1003fbee7 | 31 | canNoData, // 5 |
Innomatix | 0:b9e1003fbee7 | 32 | canNotInitialized, // 6 |
Innomatix | 0:b9e1003fbee7 | 33 | canGeneralError // N |
Innomatix | 0:b9e1003fbee7 | 34 | }CanResults_e; |
Innomatix | 0:b9e1003fbee7 | 35 | |
Innomatix | 0:b9e1003fbee7 | 36 | typedef enum |
Innomatix | 0:b9e1003fbee7 | 37 | { |
Innomatix | 0:b9e1003fbee7 | 38 | canChDAP3, // CAN 3 interface on the DAP connector or wiring harness |
Innomatix | 0:b9e1003fbee7 | 39 | canChDAP4 // CAN 4 interface on the DAP connector or wiring harness |
Innomatix | 0:b9e1003fbee7 | 40 | }CanChannel_e; |
Innomatix | 0:b9e1003fbee7 | 41 | static const char *CanChannelName[] = {"CanChDAP3", "CanChDAP4"}; |
Innomatix | 0:b9e1003fbee7 | 42 | |
Innomatix | 0:b9e1003fbee7 | 43 | |
Innomatix | 0:b9e1003fbee7 | 44 | typedef enum |
Innomatix | 0:b9e1003fbee7 | 45 | { |
Innomatix | 0:b9e1003fbee7 | 46 | canFormatStandard, // A standard, 11-bit identifier |
Innomatix | 0:b9e1003fbee7 | 47 | canFormatExtended, // An extended, 29-bit identifier |
Innomatix | 0:b9e1003fbee7 | 48 | }CanFormat_e; |
Innomatix | 0:b9e1003fbee7 | 49 | |
Innomatix | 0:b9e1003fbee7 | 50 | typedef struct |
Innomatix | 0:b9e1003fbee7 | 51 | { |
Innomatix | 0:b9e1003fbee7 | 52 | int TxMessageCount; |
Innomatix | 0:b9e1003fbee7 | 53 | int RxMessageCount; |
Innomatix | 0:b9e1003fbee7 | 54 | |
Innomatix | 0:b9e1003fbee7 | 55 | // Increments when the internal message receive buffer is full and another message is received |
Innomatix | 0:b9e1003fbee7 | 56 | int OverflowCount; |
Innomatix | 0:b9e1003fbee7 | 57 | }StatisticsStruct_t, *StatisticsStruct_p; |
Innomatix | 0:b9e1003fbee7 | 58 | |
Innomatix | 0:b9e1003fbee7 | 59 | |
Innomatix | 0:b9e1003fbee7 | 60 | typedef struct |
Innomatix | 0:b9e1003fbee7 | 61 | { |
Innomatix | 0:b9e1003fbee7 | 62 | int Id; |
Innomatix | 0:b9e1003fbee7 | 63 | int DataLen; |
Innomatix | 0:b9e1003fbee7 | 64 | int Timestamp; |
Innomatix | 0:b9e1003fbee7 | 65 | CanFormat_e Format; |
Innomatix | 0:b9e1003fbee7 | 66 | unsigned char Data[ 8 ]; |
Innomatix | 0:b9e1003fbee7 | 67 | }CanMessage_t, *CanMessage_p; |
Innomatix | 0:b9e1003fbee7 | 68 | |
Innomatix | 0:b9e1003fbee7 | 69 | /** |
Innomatix | 0:b9e1003fbee7 | 70 | * This function initializes the API and the designated CAN interface. |
Innomatix | 0:b9e1003fbee7 | 71 | * Return Values: |
Innomatix | 0:b9e1003fbee7 | 72 | * Success � the API was initialized and the channel is ready to use. |
Innomatix | 0:b9e1003fbee7 | 73 | * InvalidChannel � the specified channel is not supported |
Innomatix | 0:b9e1003fbee7 | 74 | * InvalidSpeed � the specified network speed is not supported |
Innomatix | 0:b9e1003fbee7 | 75 | * GeneralError � an unknown or unspecified error has occurred |
Innomatix | 0:b9e1003fbee7 | 76 | *************************************************************************/ |
Innomatix | 0:b9e1003fbee7 | 77 | CanResults_e CanInit( CanChannel_e Channel, int Speed ); |
Innomatix | 0:b9e1003fbee7 | 78 | |
Innomatix | 0:b9e1003fbee7 | 79 | |
Innomatix | 0:b9e1003fbee7 | 80 | /** |
Innomatix | 0:b9e1003fbee7 | 81 | * This function disables the designated CAN interface. |
Innomatix | 0:b9e1003fbee7 | 82 | *************************************************************************/ |
Innomatix | 0:b9e1003fbee7 | 83 | void CanClose( CanChannel_e Channel ); |
Innomatix | 0:b9e1003fbee7 | 84 | |
Innomatix | 0:b9e1003fbee7 | 85 | |
Innomatix | 0:b9e1003fbee7 | 86 | /** |
Innomatix | 0:b9e1003fbee7 | 87 | * Allow the client to send a message on the CAN bus. |
Innomatix | 0:b9e1003fbee7 | 88 | * Return Values: |
Innomatix | 0:b9e1003fbee7 | 89 | * Success � the message was sent |
Innomatix | 0:b9e1003fbee7 | 90 | * InvalidChannel � the specified channel is not supported |
Innomatix | 0:b9e1003fbee7 | 91 | * InvalidIdentifier � the provided message id is not a valid for the specified format |
Innomatix | 0:b9e1003fbee7 | 92 | * InvalidLength � more than 8 bytes of data were indicated |
Innomatix | 0:b9e1003fbee7 | 93 | * GeneralError � an unknown or unspecified error has occurred |
Innomatix | 0:b9e1003fbee7 | 94 | *************************************************************************/ |
Innomatix | 0:b9e1003fbee7 | 95 | CanResults_e CanSend( CanChannel_e Channel, unsigned long Id, CanFormat_e Format, const unsigned char *Data, char DLen ); |
Innomatix | 0:b9e1003fbee7 | 96 | |
Innomatix | 0:b9e1003fbee7 | 97 | |
Innomatix | 0:b9e1003fbee7 | 98 | /** |
Innomatix | 0:b9e1003fbee7 | 99 | * Allow the client to get a message from the CAN bus. |
Innomatix | 0:b9e1003fbee7 | 100 | * Return Values: |
Innomatix | 0:b9e1003fbee7 | 101 | * Success � a message was retrieved, the parameters hold the message values. |
Innomatix | 0:b9e1003fbee7 | 102 | * InvalidChannel � the specified channel is not supported |
Innomatix | 0:b9e1003fbee7 | 103 | * NoData � no message is available on the requested channel |
Innomatix | 0:b9e1003fbee7 | 104 | * GeneralError � an unknown or unspecified error has occurred |
Innomatix | 0:b9e1003fbee7 | 105 | *************************************************************************/ |
Innomatix | 0:b9e1003fbee7 | 106 | CanResults_e CanReceive( CanChannel_e Channel, unsigned long *Timestamp, unsigned long *Id, CanFormat_e *Format, unsigned char *Data, char *DLen ); |
Innomatix | 0:b9e1003fbee7 | 107 | |
Innomatix | 0:b9e1003fbee7 | 108 | |
Innomatix | 0:b9e1003fbee7 | 109 | /** |
Innomatix | 0:b9e1003fbee7 | 110 | * Allow the client to retrieve statistics about the CAN interface. |
Innomatix | 0:b9e1003fbee7 | 111 | * |
Innomatix | 0:b9e1003fbee7 | 112 | * Return Values: |
Innomatix | 0:b9e1003fbee7 | 113 | * Success � statistics were retrieved |
Innomatix | 0:b9e1003fbee7 | 114 | * InvalidChannel � the specified channel is not supported |
Innomatix | 0:b9e1003fbee7 | 115 | * GeneralError � an unknown or unspecified error has occurred |
Innomatix | 0:b9e1003fbee7 | 116 | *************************************************************************/ |
Innomatix | 0:b9e1003fbee7 | 117 | CanResults_e CanStatistics( CanChannel_e Channel, StatisticsStruct_t *Stats ); |
Innomatix | 0:b9e1003fbee7 | 118 | |
Innomatix | 0:b9e1003fbee7 | 119 | |
Innomatix | 0:b9e1003fbee7 | 120 | /** |
Innomatix | 0:b9e1003fbee7 | 121 | * Flush the Rx buffer - all messages are discarded, Rx and Overflow stats are cleared |
Innomatix | 0:b9e1003fbee7 | 122 | * |
Innomatix | 0:b9e1003fbee7 | 123 | * Return Values: |
Innomatix | 0:b9e1003fbee7 | 124 | * Success � statistics were retrieved |
Innomatix | 0:b9e1003fbee7 | 125 | * InvalidChannel � the specified channel is not supported |
Innomatix | 0:b9e1003fbee7 | 126 | * GeneralError � an unknown or unspecified error has occurred |
Innomatix | 0:b9e1003fbee7 | 127 | *************************************************************************/ |
Innomatix | 0:b9e1003fbee7 | 128 | CanResults_e CanFlush( CanChannel_e Channel ); |
Innomatix | 0:b9e1003fbee7 | 129 | |
Innomatix | 0:b9e1003fbee7 | 130 | |
Innomatix | 0:b9e1003fbee7 | 131 | /*************************************************/ |
Innomatix | 0:b9e1003fbee7 | 132 | #ifdef __cplusplus |
Innomatix | 0:b9e1003fbee7 | 133 | } |
Innomatix | 0:b9e1003fbee7 | 134 | #endif |
Innomatix | 0:b9e1003fbee7 | 135 | |
Innomatix | 0:b9e1003fbee7 | 136 | #endif /* _INNOMATIX_CAN_API_H */ |