Subversion Repositories HomeAutomation

Rev

Rev 686 | Rev 811 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 686 Rev 797
Line 56... Line 56...
56
    /* This is to identify and give the sensors correct ID
56
    /* This is to identify and give the sensors correct ID
57
     * TODO read ds18s20 serial id and that way give the "can id" */
57
     * TODO read ds18s20 serial id and that way give the "can id" */
58
    uint16_t sensor_ds_id[] = {TEMPSENSORID_1, TEMPSENSORID_2, TEMPSENSORID_3, TEMPSENSORID_4};
58
    uint16_t sensor_ds_id[] = {TEMPSENSORID_1, TEMPSENSORID_2, TEMPSENSORID_3, TEMPSENSORID_4};
59
#endif
59
#endif
60
#if defined(USE_TC1047)
60
#if defined(USE_TC1047)
61
    uint32_t tcTemperature = 0, timeStamp_TC = 0;
61
    uint16_t tcTemperature = 0, timeStamp_TC = 0;
62
    adcTemperatureInit();
62
    adcTemperatureInit();
63
#endif
63
#endif
64
#if defined(USE_LDR)
64
#if defined(USE_LDR)
65
    uint32_t timeStamp_LDR = 0;
65
    uint32_t timeStamp_LDR = 0;
66
    uint32_t ldr;
66
    uint8_t ldr;
67
    LDR_SensorInit();
67
    LDR_SensorInit();
68
#endif
68
#endif
69
    sei();
69
    sei();
70
 
70
 
71
    Timebase_Init();
71
    Timebase_Init();
Line 126... Line 126...
126
#error tc1047 id is still not correct // FIXME
126
#error tc1047 id is still not correct // FIXME
127
            /* check temperature and send on CAN */
127
            /* check temperature and send on CAN */
128
        if( bios->timebase_get() - timeStamp_TC >= TC_SEND_PERIOD ){
128
        if( bios->timebase_get() - timeStamp_TC >= TC_SEND_PERIOD ){
129
            timeStamp_TC = bios->timebase_get();
129
            timeStamp_TC = bios->timebase_get();
130
 
130
 
131
            tcTemperature = getTC1047temperature();
131
            tcTemperature = getTC1047temperature(TC1047_AD);
132
            txMsg.Data.bytes[0] = tcTemperature & 0x00FF;
132
            txMsg.Data.bytes[0] = tcTemperature&0xff;
133
            txMsg.Data.bytes[1] = (tcTemperature & 0xFF00)>>8;
133
            txMsg.Data.bytes[1] = (tcTemperature>>8)&0xff;
134
            txMsg.DataLength = 2;
134
            txMsg.DataLength = 2;
135
 
135
 
136
            txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_TEMPERATURE << CAN_SHIFT_SNS_TYPE) | (NODE_ID << CAN_SHIFT_SNS_SID));
136
            txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_TEMPERATURE << CAN_SHIFT_SNS_TYPE) | (NODE_ID << CAN_SHIFT_SNS_SID));
137
            txMsg.Id |= (TEMPSENSORID_5 << CAN_SHIFT_SNS_ID); // sätt korrekt sensorid
137
            txMsg.Id |= (TEMPSENSORID_5 << CAN_SHIFT_SNS_ID); // sätt korrekt sensorid
138
 
138
 
Line 142... Line 142...
142
#if defined(USE_LDR)
142
#if defined(USE_LDR)
143
            /* check light and send on CAN */
143
            /* check light and send on CAN */
144
        if( Timebase_PassedTimeMillis(timeStamp_LDR) >= LDR_SEND_PERIOD ){
144
        if( Timebase_PassedTimeMillis(timeStamp_LDR) >= LDR_SEND_PERIOD ){
145
            timeStamp_LDR = Timebase_CurrentTime();
145
            timeStamp_LDR = Timebase_CurrentTime();
146
 
146
 
147
            ldr = (uint8_t)LDR_GetData(0);
147
            ldr = (LDR_GetData(LDR_AD)>>2);
148
            txMsg.Data.bytes[0] = (ldr>>2)&0xff;
148
            txMsg.Data.bytes[0] = ldr&0xff;
149
            txMsg.DataLength = 1;
149
            txMsg.DataLength = 1;
150
 
150
 
151
            txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_LIGHT << CAN_SHIFT_SNS_TYPE) | (LIGHTSENSORID_1 << CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
151
            txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_LIGHT << CAN_SHIFT_SNS_TYPE) | (LIGHTSENSORID_1 << CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
152
 
152
 
153
            BIOS_CanSend(&txMsg);
153
            BIOS_CanSend(&txMsg);