Subversion Repositories HomeAutomation

Rev

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

Rev Author Line No. Line
851 migan 1
#ifndef <TEMPLATE>
2
#define <TEMPLATE>
847 migan 3
 
4
/*-----------------------------------------------------------------------------
5
 * Includes
6
 *---------------------------------------------------------------------------*/
7
/* system files */
8
#include <avr/io.h>
9
#include <avr/interrupt.h>
10
#include <stdio.h>
11
/* lib files */
12
#include <config.h>
13
#include <bios.h>
14
#include <drivers/can/stdcan.h>
15
#include <drivers/timer/timer.h>
16
 
851 migan 17
void <template>_Init(void);
18
void <template>_Process(void);
19
void <template>_HandleMessage(StdCan_Msg_t *rxMsg);
20
void <template>_List(uint8_t ModuleSequenceNumber);
847 migan 21
 
1062 linlun 22
 
23
#ifdef <template>_USEEEPROM
24
    struct <template>_Data{
25
        ///TODO: Define EEPROM variables needed by the module
26
        uint8_t x;
27
        uint16_t y;
28
    }; 
29
 
30
// Do not change anything below this line.
31
// ----------------------------------------------------------------
32
 
33
    #include <drivers/misc/eeprom_crc8.h>
34
    #include <avr/eeprom.h>
35
    #define EEDATA          (uint8_t*)&eeprom_<template>.Data
36
    #define EEDATA16        (uint16_t*)&eeprom_<template>.Data
37
    #define EEDATA_CALC_CRC     eeprom_crc8((uint8_t*)&eeprom_<template>.Data,sizeof(struct <template>_Data))
38
    #define EEDATA_UPDATE_CRC   eeprom_write_byte((uint8_t*)&eeprom_<template>.crc,eeprom_crc8((uint8_t*)&eeprom_<template>.Data,sizeof(struct <template>_Data)))
39
    #define EEDATA_OK       EEDATA_CALC_CRC == EEDATA_STORED_CRC
40
    #define EEDATA_STORED_CRC   eeprom_read_byte((uint8_t*)&eeprom_<template>.crc)
41
 
42
    struct eeprom_<template>{
43
        struct <template>_Data Data;
44
        uint8_t crc;
45
    };
46
    extern struct eeprom_<template> EEMEM eeprom_<template>;
47
 
48
    #define WITH_CRC    1
49
    #define WITHOUT_CRC 0
50
    static __inline__ void eeprom_write_byte_crc(uint8_t *__p, uint8_t __value, uint8_t crc) {
51
      if (__value != eeprom_read_byte(__p))
52
      {
53
        eeprom_write_byte(__p, __value);
54
        if (crc == WITH_CRC)
55
        {
56
          EEDATA_UPDATE_CRC;
57
        }
58
      }
59
    }
60
    static __inline__ void eeprom_write_word_crc(uint16_t *__p, uint16_t __value, uint8_t crc) {
61
      if (__value != eeprom_read_word(__p))
62
      {
63
        eeprom_write_word(__p, __value);
64
        if (crc == WITH_CRC)
65
        {
66
          EEDATA_UPDATE_CRC;
67
        }
68
      }
69
    }
70
#endif
851 migan 71
#endif // <TEMPLATE>