Subversion Repositories HomeAutomation

Rev

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

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