Subversion Repositories HomeAutomation

Rev

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.             if ((uint8_t)StdCan_Ret_class(rxMsg) == CAN_MODULE_NMT) {
  33.                
  34.                 if (rxMsg.Header.ModuleType == CAN_MODULE_NMT_LIST) {
  35.                     sns_ds18x20_List(1);
  36.                 }
  37.             }
  38.             else {
  39.            
  40.                 sns_ds18x20_HandleMessage(&rxMsg);
  41.             }
  42.         }
  43.     }
  44.    
  45.     return 0;
  46. }
  47.