Subversion Repositories Code-Repo

Rev

Rev 329 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
329 Kevin 1
#include "defines.h"
2
#include "SMT6500.h"
3
#include "TIMER.h"
4
#include "IOC.h"
5
 
6
static uint16_t tmr_value;
7
 
8
void SMT6500_Init(void) {
9
    BLNK_LAT = 0;
10
    INIT_LAT = 0;
11
    BINH_LAT = 0;
12
}
13
 
14
uint16_t SMT6500_Read(void) {
15
    // Start transmission and timer
16
    INIT_LAT = 1;
17
    TIMER1_Start();
18
    tmr_value = 0;
19
 
20
    // Enable interrupt after 1ms (blanking period)
21
    __delay_ms(1);
22
    IOC_Enable();
23
 
24
    __delay_ms(120);
25
    INIT_LAT = 0;
26
    IOC_Disable();
27
    TIMER1_Stop();
28
 
29
 
30
    if (tmr_value == 0) {
31
        return 0xFFFF;
32
    } else {
33
        return tmr_value;
34
    }
35
}
36
 
37
void SMT6500_Callback(void) {
38
    tmr_value = TIMER1_Read();
39
    IOC_Disable();
40
    TIMER1_Stop();
41
}