Subversion Repositories HomeAutomation

Rev

Rev 851 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. #include "template.h"
  3.  
  4. void template_Init(void)
  5. {
  6.     ///TODO: Initialize hardware etc here
  7. }
  8.  
  9. void template_Process(void)
  10. {
  11.     ///TODO: Stuff that needs doing is done here
  12. }
  13.  
  14. void template_HandleMessage(StdCan_Msg_t *rxMsg)
  15. {
  16.     StdCan_Msg_t txMsg;
  17.     uint8_t n = 0;
  18.  
  19.     if (    StdCan_Ret_class(rxMsg->Header) == CAN_CLASS_MODULE_TEMPLATE && ///TODO: Change this to the actual class type
  20.         StdCan_Ret_direction(rxMsg->Header) == DIR_TO_OWNER &&
  21.         rxMsg->Header.ModuleType == CAN_TYPE_MODULE_TEMPLATE && ///TODO: Change this to the actual module type
  22.         rxMsg->Header.ModuleId == template_ID)
  23.     {
  24.         switch (rxMsg->Header.Command)
  25.         {
  26.         case CAN_CMD_MODULE_DUMMY:
  27.         ///TODO: Do something dummy
  28.         break;
  29.         }
  30.     }
  31. }
  32.  
  33. void template_List(uint8_t ModuleSequenceNumber)
  34. {
  35.     StdCan_Msg_t txMsg;
  36.    
  37.     StdCan_Set_class(txMsg.Header, CAN_CLASS_MODULE_TEMPLATE); ///TODO: Change this to the actual class type
  38.     StdCan_Set_direction(txMsg.Header, DIR_FROM_OWNER);
  39.     txMsg.Header.ModuleType = CAN_TYPE_MODULE_TEMPLATE; ///TODO: Change this to the actual module type
  40.     txMsg.Header.ModuleId = template_ID;
  41.     txMsg.Header.Command = CAN_CMD_MODULE_NMT_LIST;
  42.     txMsg.Length = 6;
  43.  
  44.     txMsg.Data[0] = NODE_HW_ID_BYTE0;
  45.     txMsg.Data[1] = NODE_HW_ID_BYTE1;
  46.     txMsg.Data[2] = NODE_HW_ID_BYTE2;
  47.     txMsg.Data[3] = NODE_HW_ID_BYTE3;
  48.    
  49.     txMsg.Data[4] = NUMBER_OF_MODULES;
  50.     txMsg.Data[5] = ModuleSequenceNumber;
  51.    
  52.     StdCan_Put(&txMsg);
  53. }
  54.