Subversion Repositories HomeAutomation

Rev

Rev 326 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 326 Rev 350
Line 16... Line 16...
16
 * --------------------------------------------------------------------------*/
16
 * --------------------------------------------------------------------------*/
17
#define USE_DS18S20
17
#define USE_DS18S20
18
//#define USE_TC1047
18
//#define USE_TC1047
19
 
19
 
20
#define DS_SEND_PERIOD 10000
20
#define DS_SEND_PERIOD  10000
-
 
21
#define DS_SEND_DELAY   2000
21
#define TC_SEND_PERIOD 10000
22
#define TC_SEND_PERIOD  10000
22
 
23
 
23
#include <eqlazer_funcdefs.h>
24
#include <funcdefs.h>
24
 
25
 
25
/*-----------------------------------------------------------------------------
26
/*-----------------------------------------------------------------------------
26
 * Includes
27
 * Includes
27
 *---------------------------------------------------------------------------*/
28
 *---------------------------------------------------------------------------*/
28
/* system files */
29
/* system files */
Line 48... Line 49...
48
 *---------------------------------------------------------------------------*/
49
 *---------------------------------------------------------------------------*/
49
int main(void) {
50
int main(void) {
50
#if defined(USE_DS18S20)
51
#if defined(USE_DS18S20)
51
    uint8_t nSensors, i;
52
    uint8_t nSensors, i;
52
    uint8_t subzero, cel, cel_frac_bits;
53
    uint8_t subzero, cel, cel_frac_bits;
53
    uint32_t timeStamp_DS = 0;
54
    uint32_t timeStamp_DS = 0, timeStamp_DS_del = 0;
54
    /* This is to identify and give the sensors correct ID (For eqlazers net)
55
    /* This is to identify and give the sensors correct ID (For eqlazers net)
55
     * TODO read ds18s20 serial id and that way give the "can id" */
56
     * TODO read ds18s20 serial id and that way give the "can id" */
56
    uint16_t sensor_ds_id[] = {SNS_DS18S20_FREEZER, SNS_DS18S20_INSIDE1, SNS_DS18S20_OUTSIDE, SNS_DS18S20_INSIDE2};
57
    uint16_t sensor_ds_id[] = {SNS_DS18S20_FREEZER, SNS_DS18S20_INSIDE1, SNS_DS18S20_OUTSIDE, SNS_DS18S20_INSIDE2};
57
#endif
58
#endif
58
#if defined(USE_TC1047)
59
#if defined(USE_TC1047)
Line 96... Line 97...
96
                        }else{
97
                        }else{
97
                            txMsg.Data.bytes[0] = cel;
98
                            txMsg.Data.bytes[0] = cel;
98
                            txMsg.Data.bytes[1] = (cel_frac_bits<<4);
99
                            txMsg.Data.bytes[1] = (cel_frac_bits<<4);
99
                        }
100
                        }
100
                    }
101
                    }
-
 
102
                    /* Delay */
-
 
103
                    timeStamp_DS_del = bios->timebase_get();
-
 
104
                    while(bios->timebase_get() - timeStamp_DS_del < DS_SEND_DELAY){}
-
 
105
 
101
                    /* send txMsg */
106
                    /* send txMsg */
102
                    txMsg.Id &= ~SNS_ID_MASK; /* Clear sensor id */
107
                    txMsg.Id &= ~SNS_ID_MASK; /* Clear sensor id */
103
                    txMsg.Id |= ( sensor_ds_id[i] << SNS_ID_BITS); /* Set sesor id */
108
                    txMsg.Id |= ( sensor_ds_id[i] << SNS_ID_BITS); /* Set sesor id */
104
                    bios->can_send(&txMsg);
109
                    bios->can_send(&txMsg);
105
                }
110
                }