Subversion Repositories HomeAutomation

Rev

Rev 807 | Blame | Last modification | View Log | SVN | RSS feed

  1. #include <inttypes.h>
  2. #include <avr/interrupt.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <drivers/can/stdcan.h>
  6. #include <config.h> // All configuration parameters
  7. #include <bios.h>   // BIOS interface declarations, including CAN structure and ID defines.
  8. #include <drivers/timer/timer.h>
  9.  
  10. #include "../modules/sns_ds18x20/sns_ds18x20.h"
  11.  
  12. int main(void)
  13. {
  14.     StdCan_Msg_t rxMsg; // Message storage
  15.  
  16.     // Enable interrupts as early as possible
  17.     sei();
  18.    
  19.     Timer_Init();
  20.  
  21.     StdCan_Init();
  22.    
  23.     Timer_SetTimeout(APP_HEARTBEAT_TIMER, STDCAN_HEARTBEAT_PERIOD, TimerTypeFreeRunning, StdCan_SendHeartbeat);
  24.    
  25.     sns_ds18x20_Init();
  26.  
  27.     while (1)
  28.     {
  29.         sns_ds18x20_Process();
  30.    
  31.         if (StdCan_Get(&rxMsg) == StdCan_Ret_OK)
  32.         {
  33.             if (    StdCan_Ret_class(rxMsg) == CAN_CLASS_MODULE_NMT &&
  34.                 StdCan_Ret_direction(rxMsg) == DIR_TO_OWNER &&
  35.                 rxMsg.Header.Command == CAN_CMD_MODULE_NMT_LIST &&
  36.                 rxMsg.Data[0] == NODE_HW_ID_BYTE0 &&
  37.                 rxMsg.Data[1] == NODE_HW_ID_BYTE1 &&
  38.                 rxMsg.Data[2] == NODE_HW_ID_BYTE2 &&
  39.                 rxMsg.Data[3] == NODE_HW_ID_BYTE3)
  40.             {
  41.                 sns_ds18x20_List(1);
  42.             }
  43.             else
  44.             {
  45.                 sns_ds18x20_HandleMessage(&rxMsg);
  46.             }
  47.         }
  48.     }
  49.    
  50.     return 0;
  51. }
  52.