00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CANPIECONTROLLER_HPP
00029 #define CANPIECONTROLLER_HPP
00030
00031 #include "CAN.hpp"
00032 #include "CANControllerInterface.hpp"
00033 #include "CANBusInterface.hpp"
00034 #include "CANMessage.hpp"
00035
00036 #include <rtt/PeriodicActivity.hpp>
00037 #include <rtt/os/threads.hpp>
00038 #include "../drivers/canpie/cpuser.h"
00039
00040 namespace RTT
00041 {namespace CAN
00042 {
00043
00048 class CANPieController
00049 : public CANControllerInterface,
00050 public PeriodicActivity
00051 {
00052 public:
00058 CANPieController( double period, bool interrupt = false);
00059 virtual ~CANPieController();
00060
00061 bool initialize();
00062
00063 void step();
00064
00065 void finalize();
00066
00067 virtual void addBus( unsigned int chan, CANBusInterface* _bus);
00068
00069 virtual void process(const CANMessage* msg);
00070
00071 virtual unsigned int nodeId() const;
00072
00073 static unsigned int ReceiveIntHandler(unsigned int channel, CpStruct_CAN* msg);
00074
00075 bool readFromBuffer( CANMessage& msg);
00076
00077 bool writeToBuffer(const CANMessage& msg);
00078 protected:
00083 int receive(CpStruct_CAN* msg);
00084
00085 static CANPieController* controller[CP_CHANNEL_MAX];
00086
00087 int CANPieStatus;
00088
00089 int CANPieChannel;
00090
00091 CANBusInterface *bus;
00092
00093 bool process_in_int;
00094
00095 CANMessage CANmsg;
00096
00097 unsigned int total_recv;
00098 unsigned int total_trns;
00099 unsigned int failed_recv;
00100 unsigned int failed_trns;
00101 unsigned int generic_trns;
00102 };
00103
00104 }}
00105
00106
00107 #endif
00108