Subversion Repositories HomeAutomation

Rev

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

Rev 356 Rev 380
Line 1... Line 1...
1
/**
1
/**
2
 * CAN test program.
2
 * CAN test program.
3
 *
3
 *
4
 * @target  AVR
4
 * @target  AVR
5
 * @date    2006-10-29
5
 * @date    2006-10-29
6
 * @author  Jimmy Myhrman
6
 * @author  Jimmy Myhrman, Andreas Fritiofsson
7
 *  
7
 *  
8
 */
8
 */
9
 
9
 
10
/*-----------------------------------------------------------------------------
10
/*-----------------------------------------------------------------------------
11
 * Includes
11
 * Includes
Line 50... Line 50...
50
        ss=0;
50
        ss=0;
51
        if (mm++ > 59) {
51
        if (mm++ > 59) {
52
            mm=0;
52
            mm=0;
53
            if (hh++ > 23) {
53
            if (hh++ > 23) {
54
                hh=0;
54
                hh=0;
55
                if (DD++ > days[MM-1] + ((YY%4) & (MM==2)) ? 1 : 0))) {
55
                if (DD++ > days[MM-1] + ((YY%4) & (MM==2)) ? 1 : 0) {
56
                    DD=1;
56
                    DD=1;
57
                    if (MM++ > 12) {
57
                    if (MM++ > 12) {
58
                        MM=1; YY++;
58
                        MM=1; YY++;
59
                    }
59
                    }
60
                }
60
                }
Line 147... Line 147...
147
 
147
 
148
/*-----------------------------------------------------------------------------
148
/*-----------------------------------------------------------------------------
149
 * Main Program
149
 * Main Program
150
 *---------------------------------------------------------------------------*/
150
 *---------------------------------------------------------------------------*/
151
int main(void) {
151
int main(void) {
-
 
152
//  For calibrating internal oscillator
152
    OSCCAL = eeprom_read_byte(0);
153
//  OSCCAL = eeprom_read_byte(0);
153
    Timebase_Init();
154
    Timebase_Init();
154
    Serial_Init();
155
    Serial_Init();
155
    Can_Init();
156
    Can_Init();
156
   
157
   
157
    DDRC = 1<<PC1 | 1<<PC0;
158
    DDRC = 1<<PC1 | 1<<PC0;
Line 178... Line 179...
178
        /* service the CAN routines */
179
        /* service the CAN routines */
179
        Can_Service();
180
        Can_Service();
180
       
181
       
181
        /* any new CAN messages received? */
182
        /* any new CAN messages received? */
182
        if (Can_Receive(&rxMsg) == CAN_OK) {
183
        if (Can_Receive(&rxMsg) == CAN_OK) {
-
 
184
            // Toggle activity LED
183
            PORTC ^= (1<<PC1);
185
            PORTC ^= (1<<PC1);
184
            /* send message to CanWatcher */
186
            /* send message to CanWatcher */
185
            uart_putc(UART_START_BYTE);
187
            uart_putc(UART_START_BYTE);
186
            uart_putc((uint8_t)rxMsg.Id);
188
            uart_putc((uint8_t)rxMsg.Id);
187
            uart_putc((uint8_t)(rxMsg.Id>>8));
189
            uart_putc((uint8_t)(rxMsg.Id>>8));