Rev 163 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 163 | Rev 164 | ||
|---|---|---|---|
| Line 19... | Line 19... | ||
| 19 | /* lib files */ |
19 | /* lib files */ |
| 20 | #include <can.h> |
20 | #include <can.h> |
| 21 | #include <serial.h> |
21 | #include <serial.h> |
| 22 | #include <timebase.h> |
22 | #include <timebase.h> |
| 23 | #include <lcd_HD44780.h> |
23 | #include <lcd_HD44780.h> |
| - | 24 | ||
| - | 25 | #define BUFFER_SIZE 20 |
|
| 24 | 26 | ||
| 25 | /*----------------------------------------------------------------------------- |
27 | /*----------------------------------------------------------------------------- |
| 26 | * Main Program |
28 | * Main Program |
| 27 | *---------------------------------------------------------------------------*/ |
29 | *---------------------------------------------------------------------------*/ |
| 28 | int main(void) { |
30 | int main(void) { |
| - | 31 | ||
| - | 32 | char buffer[ BUFFER_SIZE ]; |
|
| - | 33 | int num=1234; |
|
| - | 34 | ||
| 29 | Timebase_Init(); |
35 | Timebase_Init(); |
| 30 | Serial_Init(); |
36 | Serial_Init(); |
| 31 | sei(); |
37 | sei(); |
| 32 | lcd_init( LCD_DISP_ON ); |
38 | lcd_init( LCD_DISP_ON ); |
| 33 | 39 | ||
| Line 47... | Line 53... | ||
| 47 | else { |
53 | else { |
| 48 | printf("OK!\n"); |
54 | printf("OK!\n"); |
| 49 | lcd_puts("OK!\n"); |
55 | lcd_puts("OK!\n"); |
| 50 | } |
56 | } |
| 51 | 57 | ||
| - | 58 | // snprintf(buffer, BUFFER_SIZE, "yo %d 98765432109\n", num); |
|
| - | 59 | // lcd_puts(buffer); |
|
| - | 60 | // lcd_puts("test\n"); |
|
| - | 61 | // lcd_puts(buffer); |
|
| - | 62 | ||
| 52 | uint32_t timeStamp = 0; |
63 | uint32_t timeStamp = 0; |
| 53 | 64 | ||
| 54 | Can_Message_t txMsg; |
65 | Can_Message_t txMsg; |
| 55 | Can_Message_t rxMsg; |
66 | Can_Message_t rxMsg; |
| 56 | txMsg.Id = 0; |
67 | txMsg.Id = 0; |
| Line 72... | Line 83... | ||
| 72 | 83 | ||
| 73 | /* check if any messages have been received */ |
84 | /* check if any messages have been received */ |
| 74 | while (Can_Receive(&rxMsg) == CAN_OK) { |
85 | while (Can_Receive(&rxMsg) == CAN_OK) { |
| 75 | printf("MSG Received: ID=%lx, DLC=%u, EXT=%u, RTR=%u, ", rxMsg.Id, (uint16_t)(rxMsg.DataLength), (uint16_t)(rxMsg.ExtendedFlag), (uint16_t)(rxMsg.RemoteFlag)); |
86 | printf("MSG Received: ID=%lx, DLC=%u, EXT=%u, RTR=%u, ", rxMsg.Id, (uint16_t)(rxMsg.DataLength), (uint16_t)(rxMsg.ExtendedFlag), (uint16_t)(rxMsg.RemoteFlag)); |
| 76 | printf("data={ "); |
87 | printf("data={ "); |
| - | 88 | ||
| 77 | for (uint8_t i=0; i<rxMsg.DataLength; i++) { |
89 | for (uint8_t i=0; i<rxMsg.DataLength; i++) { |
| 78 | printf("%x ", rxMsg.Data.bytes[i]); |
90 | printf("%x ", rxMsg.Data.bytes[i]); |
| 79 | } |
91 | } |
| 80 | printf("}\n"); |
92 | printf("}\n"); |
| - | 93 | ||
| - | 94 | if( rxMsg.Id == 0x3 ){ |
|
| - | 95 | // lcd_gotoxy(0,1); |
|
| - | 96 | lcd_clrscr(); |
|
| - | 97 | // lcd_putc(0xdf); |
|
| - | 98 | lcd_puts("Temperature data:\n"); |
|
| - | 99 | ||
| - | 100 | for( uint8_t i=0; i<(rxMsg.DataLength/2); i++ ){ |
|
| - | 101 | snprintf( buffer, BUFFER_SIZE, "Sensor %i: %d,%d%cC", i, rxMsg.Data.bytes[i*2], rxMsg.Data.bytes[i*2+1], 0xdf ); |
|
| - | 102 | lcd_gotoxy(0,1+i); |
|
| - | 103 | lcd_puts( buffer ); |
|
| - | 104 | } |
|
| - | 105 | } |
|
| 81 | } |
106 | } |
| 82 | } |
107 | } |
| 83 | 108 | ||
| 84 | return 0; |
109 | return 0; |
| 85 | } |
110 | } |