1 /** 2 * Application interface for CANopenNode stack. 3 * 4 * @file application.h 5 * @ingroup CO_application 6 * @author Janez Paternoster 7 * @copyright 2012 - 2020 Janez Paternoster 8 * 9 * This file is part of CANopenNode, an opensource CANopen Stack. 10 * Project home page is <https://github.com/CANopenNode/CANopenNode>. 11 * For more information on CANopen see <http://www.can-cia.org/>. 12 * 13 * Licensed under the Apache License, Version 2.0 (the "License"); 14 * you may not use this file except in compliance with the License. 15 * You may obtain a copy of the License at 16 * 17 * http://www.apache.org/licenses/LICENSE-2.0 18 * 19 * Unless required by applicable law or agreed to in writing, software 20 * distributed under the License is distributed on an "AS IS" BASIS, 21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 * See the License for the specific language governing permissions and 23 * limitations under the License. 24 */ 25 26 27 #ifndef CO_APPLICATION_H 28 #define CO_APPLICATION_H 29 30 31 /** 32 * @defgroup CO_application Application interface 33 * @ingroup CO_CANopen 34 * @{ 35 * 36 * Application interface for CANopenNode stack. Function is called 37 * from file main_xxx.c (if implemented). 38 * 39 * ###Main program flow chart 40 * 41 * @code 42 (Program Start) 43 | 44 V 45 +------------------------------------+ 46 | programStart() | 47 +------------------------------------+ 48 | 49 |<-------------------------+ 50 | | 51 V | 52 (Initialze CANopen) | 53 | | 54 V | 55 +------------------------------------+ | 56 | communicationReset() | | 57 +------------------------------------+ | 58 | | 59 V | 60 (Enable CAN and interrupts) | 61 | | 62 |<----------------------+ | 63 | | | 64 V | | 65 +------------------------------------+ | | 66 | programAsync() | | | 67 +------------------------------------+ | | 68 | | | 69 V | | 70 (Process CANopen asynchronous) | | 71 | | | 72 +- infinite loop -------+ | 73 | | 74 +- reset communication ----+ 75 | 76 V 77 +------------------------------------+ 78 | programEnd() | 79 +------------------------------------+ 80 | 81 V 82 (delete CANopen) 83 | 84 V 85 (Program end) 86 @endcode 87 * 88 * 89 * ###Timer program flow chart 90 * 91 * @code 92 (Timer interrupt 1 millisecond) 93 | 94 V 95 (CANopen read RPDOs) 96 | 97 V 98 +------------------------------------+ 99 | program1ms() | 100 +------------------------------------+ 101 | 102 V 103 (CANopen write TPDOs) 104 @endcode 105 * 106 * 107 * ###Receive and transmit high priority interrupt flow chart 108 * 109 * @code 110 (CAN receive event or) 111 (CAN transmit buffer empty event) 112 | 113 V 114 (Process received CAN message or) 115 (copy next message to CAN transmit buffer) 116 @endcode 117 */ 118 119 120 /** 121 * Called after microcontroller reset. 122 */ 123 void programStart(void); 124 125 126 /** 127 * Called after communication reset. 128 */ 129 void communicationReset(void); 130 131 132 /** 133 * Called before program end. 134 */ 135 void programEnd(void); 136 137 138 /** 139 * Called cyclically from main. 140 * 141 * @param timer1msDiff Time difference since last call 142 */ 143 void programAsync(uint16_t timer1msDiff); 144 145 146 /** 147 * Called cyclically from 1ms timer task. 148 */ 149 void program1ms(void); 150 151 152 /** @} */ 153 #endif 154