Rev 1446 | 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" |
| 1446 | linlun | 6 | struct eeprom_<template> EEMEM eeprom_<template> = |
| 1062 | linlun | 7 | { |
| 8 | { |
||
| 1446 | linlun | 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. |
| 1557 | arune | 10 | 0xAB, // x |
| 11 | 0x1234 // y |
||
| 12 | 0x12345678 // z |
||
| 1062 | linlun | 13 | }, |
| 14 | |||
| 1446 | linlun | 15 | }; |
| 1062 | linlun | 16 | #endif |
| 17 | |||
| 851 | migan | 18 | void <template>_Init(void) |
| 847 | migan | 19 | { |
| 1062 | linlun | 20 | #ifdef <template>_USEEEPROM |
| 21 | if (EEDATA_OK) |
||
| 22 | { |
||
| 23 | ///TODO: Use stored data to set initial values for the module |
||
| 24 | blablaX = eeprom_read_byte(EEDATA.x); |
||
| 1446 | linlun | 25 | blablaY = eeprom_read_word(EEDATA16.y); |
| 1557 | arune | 26 | blablaZ = eeprom_read_dword(EEDATA32.y); |
| 1062 | linlun | 27 | } else |
| 28 | { //The CRC of the EEPROM is not correct, store default values and update CRC |
||
| 29 | eeprom_write_byte_crc(EEDATA.x, 0xAB, WITHOUT_CRC); |
||
| 1446 | linlun | 30 | eeprom_write_word_crc(EEDATA16.y, 0x1234, WITHOUT_CRC); |
| 1557 | arune | 31 | eeprom_write_dword_crc(EEDATA32.y, 0x12345678, WITHOUT_CRC); |
| 1062 | linlun | 32 | EEDATA_UPDATE_CRC; |
| 33 | } |
||
| 1446 | linlun | 34 | #endif |
| 847 | migan | 35 | ///TODO: Initialize hardware etc here |
| 1062 | linlun | 36 | |
| 1125 | linlun | 37 | // to use PCINt lib, call this function: (the callback function look as a timer callback function) |
| 38 | // Pcint_SetCallbackPin(<template>_PCINT, EXP_C , &<template>_pcint_callback); |
||
| 39 | |||
| 847 | migan | 40 | } |
| 41 | |||
| 851 | migan | 42 | void <template>_Process(void) |
| 847 | migan | 43 | { |
| 44 | ///TODO: Stuff that needs doing is done here |
||
| 45 | } |
||
| 46 | |||
| 851 | migan | 47 | void <template>_HandleMessage(StdCan_Msg_t *rxMsg) |
| 847 | migan | 48 | { |
| 989 | arune | 49 | if ( StdCan_Ret_class(rxMsg->Header) == CAN_MODULE_CLASS_xyz && ///TODO: Change this to the actual class type |
| 50 | StdCan_Ret_direction(rxMsg->Header) == DIRECTIONFLAG_FROM_OWNER && |
||
| 51 | rxMsg->Header.ModuleType == CAN_MODULE_TYPE_xyz && ///TODO: Change this to the actual module type |
||
| 851 | migan | 52 | rxMsg->Header.ModuleId == <template>_ID) |
| 847 | migan | 53 | { |
| 54 | switch (rxMsg->Header.Command) |
||
| 55 | { |
||
| 56 | case CAN_CMD_MODULE_DUMMY: |
||
| 57 | ///TODO: Do something dummy |
||
| 58 | break; |
||
| 59 | } |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 851 | migan | 63 | void <template>_List(uint8_t ModuleSequenceNumber) |
| 847 | migan | 64 | { |
| 65 | StdCan_Msg_t txMsg; |
||
| 1446 | linlun | 66 | |
| 989 | arune | 67 | StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_xyz); ///TODO: Change this to the actual class type |
| 68 | StdCan_Set_direction(txMsg.Header, DIRECTIONFLAG_FROM_OWNER); |
||
| 69 | txMsg.Header.ModuleType = CAN_MODULE_TYPE_xyz; ///TODO: Change this to the actual module type |
||
| 851 | migan | 70 | txMsg.Header.ModuleId = <template>_ID; |
| 988 | arune | 71 | txMsg.Header.Command = CAN_MODULE_CMD_GLOBAL_LIST; |
| 847 | migan | 72 | txMsg.Length = 6; |
| 73 | |||
| 74 | txMsg.Data[0] = NODE_HW_ID_BYTE0; |
||
| 75 | txMsg.Data[1] = NODE_HW_ID_BYTE1; |
||
| 76 | txMsg.Data[2] = NODE_HW_ID_BYTE2; |
||
| 77 | txMsg.Data[3] = NODE_HW_ID_BYTE3; |
||
| 1446 | linlun | 78 | |
| 847 | migan | 79 | txMsg.Data[4] = NUMBER_OF_MODULES; |
| 80 | txMsg.Data[5] = ModuleSequenceNumber; |
||
| 1446 | linlun | 81 | |
| 967 | runge | 82 | while (StdCan_Put(&txMsg) != StdCan_Ret_OK); |
| 847 | migan | 83 | } |