Subversion Repositories HomeAutomation

Rev

Rev 1062 | Rev 1125 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
847 migan 1
 
851 migan 2
#include "<template>.h"
847 migan 3
 
1062 linlun 4
#ifdef <template>_USEEEPROM
1106 linlun 5
#include "<template>_eeprom.h"
1062 linlun 6
struct eeprom_<template> EEMEM eeprom_<template> =
7
{
8
    {
9
        ///TODO: Define initialization values on the EEPROM variables here, this will generate a *.eep file that can be used to store this values to the node, can in future be done with a EEPROM module and the make-scrips. Write the values in the exact same order as the struct is defined in the *.h file. 
10
        0xAB,   // x
11
        0x1234  // y
12
    },
13
 
14
};
15
#endif
16
 
851 migan 17
void <template>_Init(void)
847 migan 18
{
1062 linlun 19
#ifdef <template>_USEEEPROM
20
    if (EEDATA_OK)
21
    {
22
      ///TODO: Use stored data to set initial values for the module
23
      blablaX = eeprom_read_byte(EEDATA.x);
24
      blablaY = eeprom_read_word(EEDATA.y);
25
    } else
26
    {   //The CRC of the EEPROM is not correct, store default values and update CRC
27
      eeprom_write_byte_crc(EEDATA.x, 0xAB, WITHOUT_CRC);
28
      eeprom_write_word_crc(EEDATA.y, 0x1234, WITHOUT_CRC);
29
      EEDATA_UPDATE_CRC;
30
    }
31
#endif  
847 migan 32
    ///TODO: Initialize hardware etc here
1062 linlun 33
 
847 migan 34
}
35
 
851 migan 36
void <template>_Process(void)
847 migan 37
{
38
    ///TODO: Stuff that needs doing is done here
39
}
40
 
851 migan 41
void <template>_HandleMessage(StdCan_Msg_t *rxMsg)
847 migan 42
{
989 arune 43
    if (    StdCan_Ret_class(rxMsg->Header) == CAN_MODULE_CLASS_xyz && ///TODO: Change this to the actual class type
44
        StdCan_Ret_direction(rxMsg->Header) == DIRECTIONFLAG_FROM_OWNER &&
45
        rxMsg->Header.ModuleType == CAN_MODULE_TYPE_xyz && ///TODO: Change this to the actual module type
851 migan 46
        rxMsg->Header.ModuleId == <template>_ID)
847 migan 47
    {
48
        switch (rxMsg->Header.Command)
49
        {
50
        case CAN_CMD_MODULE_DUMMY:
51
        ///TODO: Do something dummy
52
        break;
53
        }
54
    }
55
}
56
 
851 migan 57
void <template>_List(uint8_t ModuleSequenceNumber)
847 migan 58
{
59
    StdCan_Msg_t txMsg;
60
 
989 arune 61
    StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_xyz); ///TODO: Change this to the actual class type
62
    StdCan_Set_direction(txMsg.Header, DIRECTIONFLAG_FROM_OWNER);
63
    txMsg.Header.ModuleType = CAN_MODULE_TYPE_xyz; ///TODO: Change this to the actual module type
851 migan 64
    txMsg.Header.ModuleId = <template>_ID;
988 arune 65
    txMsg.Header.Command = CAN_MODULE_CMD_GLOBAL_LIST;
847 migan 66
    txMsg.Length = 6;
67
 
68
    txMsg.Data[0] = NODE_HW_ID_BYTE0;
69
    txMsg.Data[1] = NODE_HW_ID_BYTE1;
70
    txMsg.Data[2] = NODE_HW_ID_BYTE2;
71
    txMsg.Data[3] = NODE_HW_ID_BYTE3;
72
 
73
    txMsg.Data[4] = NUMBER_OF_MODULES;
74
    txMsg.Data[5] = ModuleSequenceNumber;
75
 
967 runge 76
    while (StdCan_Put(&txMsg) != StdCan_Ret_OK);
847 migan 77
}