$search
00001 /* 00002 Aseba - an event-based framework for distributed robot control 00003 Copyright (C) 2007--2012: 00004 Stephane Magnenat <stephane at magnenat dot net> 00005 (http://stephane.magnenat.net) 00006 and other contributors, see authors.txt for details 00007 00008 This program is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU Lesser General Public License as published 00010 by the Free Software Foundation, version 3 of the License. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef ASEBA_CAN 00022 #define ASEBA_CAN 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 #include "../../common/types.h" 00029 00046 00047 // Network 00048 00050 typedef struct 00051 { 00052 uint8 data[8] __attribute__((aligned(sizeof(int)))); 00053 unsigned id:11; 00054 unsigned len:4; 00055 unsigned used:1; 00056 } CanFrame; 00057 00059 typedef void (*AsebaCanVoidVoidFP)(); 00060 00062 typedef int (*AsebaCanIntVoidFP)(); 00063 00065 typedef void (*AsebaCanSendFrameFP)(const CanFrame *frame); 00066 00078 void AsebaCanInit(uint16 id, AsebaCanSendFrameFP sendFrameFP, AsebaCanIntVoidFP isFrameRoomFP, AsebaCanVoidVoidFP receivedPacketDroppedFP, AsebaCanVoidVoidFP sentPacketDroppedFP, CanFrame* sendQueue, size_t sendQueueSize, CanFrame* recvQueue, size_t recvQueueSize); 00079 00085 uint16 AsebaCanSend(const uint8 *data, size_t size); 00086 00093 uint16 AsebaCanSendSpecificSource(const uint8 *data, size_t size, uint16 source); 00094 00102 uint16 AsebaCanRecv(uint8 *data, size_t size, uint16 *source); 00103 00106 void AsebaCanFlushQueue(void); 00107 00110 void AsebaCanRecvFreeQueue(void); 00111 00112 // to be implemented by the glue 00113 00115 void AsebaIdle(void); 00116 00118 uint16 AsebaShouldDropPacket(uint16 source, const uint8* data); 00119 00120 // to be called by data layer on interrupts 00121 00123 void AsebaCanFrameReceived(const CanFrame *frame); 00124 00126 void AsebaCanFrameSent(); 00127 00129 uint16 AsebaCanRecvBufferEmpty(void); 00130 00133 #ifdef __cplusplus 00134 } 00135 #endif 00136 00137 #endif