Subversion Repositories HomeAutomation

Rev

Rev 989 | Rev 1106 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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