void Speedo_CAN::process_incoming_messages(){ while(can_get_message(&message)!=0xff){ //0xff=no more frames available #ifdef CAN_DEBUG /////////////// DEBUG ////////// Serial.print("*"); #endif if(can_missed_count==999){ can_missed_count=0; } else if(can_missed_count>1){ can_missed_count-=2; } else if(can_missed_count>0){ can_missed_count-=1; }; last_received=millis(); // Serial.println("New CAN Message found"); //////////////////////////////////////////////////////////////////////////////// /////////////////// Triumph Daytone 675 Tacho request ////////////////////////// //////////////////////////////////////////////////////////////////////////////// if(message.id==0x568){ message.length=2; message.id=0x569; message.data[0]=0x00; message.data[1]=0x01; can_send_message(&message); } //////////////////////////////////////////////////////////////////////////////// //////////////////// Triumph Daytone 675 RPM/Speed //////////////////////////// //////////////////////////////////////////////////////////////////////////////// else if(message.id==0x530){ // Triumph Daytone 675 Tacho request can_rpm=(message.data[1]<<6)|(message.data[0]>>2); can_speed=round(pSensors->flatIt((int)(((message.data[3]<<8)|(message.data[2]))/10),&can_speed_counter,4,can_speed)); // IIR 4 Tabs //can_speed=(((message.data[3]<<8)|(message.data[2]))/10); // raw #ifdef CAN_DEBUG /////////////// DEBUG ////////// Serial.print("RPM:"); Serial.print(can_rpm); Serial.print(" Speed:"); Serial.print(can_speed); #endif if(can_rpm>0){ high_prio_processing=false; }; } //////////////////////////////////////////////////////////////////////////////// ///////////////////// Triumph Daytone 675 Temperatur /////////////////////////// //////////////////////////////////////////////////////////////////////////////// else if(message.id==0x570){ // Triumph Daytone 675 Tacho request
int main(void) { // Initialize MCP2515 can_init(BITRATE_125_KBPS); // Load filters and masks can_static_filter(can_filter); // Create a test messsage can_t msg; msg.id = 0x123456; msg.flags.rtr = 0; msg.flags.extended = 1; msg.length = 4; msg.data[0] = 0xde; msg.data[1] = 0xad; msg.data[2] = 0xbe; msg.data[3] = 0xef; // Send the message can_send_message(&msg); while (1) { // Check if a new messag was received if (can_check_message()) { can_t msg; // Try to read the message if (can_get_message(&msg)) { // If we received a message resend it with a different id msg.id += 10; // Send the new message can_send_message(&msg); } } } return 0; }
/* * Read CAN Bus */ void Can::read() { if(digitalRead(CAN_INT) == 0) { CanMessage message = can_get_message(); if(message.id != 0) { Serial.println("MESSAGE RECIEVED"); Serial.println(message.id); // read headlights if( message.id == headlights_msg.id()) { _headlights = message.data[0]; _headlights_flag = true; } // read wipers if( message.id == wipers_msg.id() ) { _wipers = message.data[0]; _wipers_flag = true; } // read horn if( message.id == horn_msg.id() ) { _horn = message.data[0]; _horn_flag = true; } // read brake // if( message.id == brake_msg.id() ) { // _brake = message.data[0] > 0; // _horn_flag = true; // } // if(analogRead(A0) < 800) // { // _brake = message.data[0] > 0; // _horn_flag = true; // } // read signals if( message.id == signals_msg.id() ) { if(message.data[0] & 1 << can_msg::LEFT_SIGNAL) _signal = LEFT_SIG; else if (message.data[0] & 1 << can_msg::RIGHT_SIGNAL) _signal = RIGHT_SIG; else if (message.data[0] & 1 << can_msg::HAZARD_LIGHTS) _signal = HAZARDS_SIG; else _signal = 0; _signal_flag = true; } } } }
/** * @brief Programa principal */ int main(void) { // Configure system configSystem(); // Initialize system status estados_t estados; estados = ESTADO_INICIAL; can_t received_msg; //! Armazena a mensagem recebida via CAN // main loop: reads a message and sends it via USART for(;;){ // Checks if a new message was received if (can_check_message()){ // Try to read the message if(can_get_message(&received_msg)){ // Sends via USART sendSystemStatusUSART(received_msg.data[0]); } }else{ usartTransmit(0); } // Updates system status updateSystemStatus(&estados); // Sends system status via CAN sendSystemStatusCAN(estados); _delay_ms(500); } }
void shackbus_main(void) { if ( fifo_get_count(&can_outfifo) > 0 ) { uint8_t cur_nr = fifo_read (&can_outfifo); if ( can_send_message(&framestorage_data[cur_nr]) ) { fifo_get (&can_outfifo); framestorage_get(cur_nr); } } // Check if a new messag was received if (can_check_message()) { can_t msg; // Try to read the message if (can_get_message(&msg)) { shackbus_id_t shackbus_id; shackbus_id2sb(&shackbus_id,&msg); //prot=10 = Basis IO data[0]=10 = Ping if (shackbus_id.prot == 10 && shackbus_id.dst == 8 && msg.data[0]==10) { shackbus_id.prio = 3; shackbus_id.vlan = 4; shackbus_id.dst = shackbus_id.src; shackbus_id.src = 8; shackbus_id.prot = 10; msg.id = shackbus_sb2id(&shackbus_id); msg.length = 2; msg.data[0] = 11; msg.data[1] = msg.data[1]; //Send the new message can_send_message_fifo(&msg); } //prot=10 = Basis IO data[0]=04 = Jump2Bootloader if (shackbus_id.prot == 10 && shackbus_id.dst == 8 && msg.data[0]==04) { cli(); wdt_enable(WDTO_15MS ); while (1); } /* prot=11 = PowerManagement data[0]=1 =on/off data[1]=channel data[2]=state */ /* channel 140 0x8c = DLE Dusche */ /* channel 141 0x8d = DLE E-Lab */ /* channel 142 0x8e = Optionsraeume */ /* channel 143 0x8f = Kueche */ if (shackbus_id.prot == 11 && shackbus_id.dst == 6 && msg.data[0]==1 \ && msg.data[1] >= 140 && msg.data[1] <= 143) { shackbus_id.prio = 3; shackbus_id.vlan = 4; shackbus_id.dst = shackbus_id.src; shackbus_id.src = 8; shackbus_id.prot = 11; msg.id = shackbus_sb2id(&shackbus_id); msg.length = 3; msg.data[0] = 1; msg.data[1] = msg.data[1]; msg.data[2] = msg.data[2]; /* Send the message */ can_send_message_fifo(&msg); if (msg.data[2]==1) enocean_state_set(msg.data[1],ENOCEAN_CHANNEL_SE_SA_SS); if (msg.data[2]==0) enocean_state_set(msg.data[1],ENOCEAN_CHANNEL_SE_SA_CS); } /* prot=11 = PowerManagement data[0]=0 =on/off data[1]=channel data[2]=state */ /* channel 140 0x8c = DLE Dusche */ /* channel 141 0x8d = DLE E-Lab */ /* channel 142 0x8e = Optionsraeume */ /* channel 143 0x8f = Kueche */ if (shackbus_id.prot == 11 && shackbus_id.dst == 6 && msg.data[0]==0 \ && msg.data[1] >= 140 && msg.data[1] <= 143) { shackbus_id.prio = 3; shackbus_id.vlan = 4; shackbus_id.dst = shackbus_id.src; shackbus_id.src = 8; shackbus_id.prot = 11; msg.id = shackbus_sb2id(&shackbus_id); msg.length = 3; msg.data[0] = 0; msg.data[1] = msg.data[1]; msg.data[2] = msg.data[2]; /* Send the message */ can_send_message_fifo(&msg); void power_mgt_set_input_1(uint8_t _channel, uint8_t _state); void power_mgt_set_wait_off(uint8_t _channel, uint16_t _value); power_mgt_set_input_1(msg.data[1]-140, msg.data[2]); power_mgt_set_wait_off(msg.data[1]-140, 20); } /* prot=13 = Hauptschalterstate length=1 data[0]=state */ /* 0 => OFF */ /* 1 => ON */ if (shackbus_id.prot == 13 && shackbus_id.dst == 255 && msg.length == 1) { shackbus_id.prio = 3; shackbus_id.vlan = 4; shackbus_id.dst = shackbus_id.src; shackbus_id.src = 8; shackbus_id.prot = 13; msg.id = shackbus_sb2id(&shackbus_id); msg.length = 3; msg.data[1] = 2; msg.data[2] = 3; /* Send the message */ // can_send_message(&msg); if (msg.data[0] > 1) msg.data[0] = 0; //power_mgt_set_input_1 (1, msg.data[0]); power_mgt_set_wait_on (1, 4); //DLE Kueche power_mgt_set_wait_off(1, 5); power_mgt_set_input_1 (2, msg.data[0]); power_mgt_set_wait_on (2, 2); //OR power_mgt_set_wait_off(2, 4); power_mgt_set_input_1 (3, msg.data[0]); power_mgt_set_wait_on (3, 3); //Kueche power_mgt_set_wait_off(3, 90 * 60); //Sekunden } } } if (shackbus_system_time_send_flag >= 60) { shackbus_system_time_send_flag = 0; shackbus_id_t ka_id; ka_id.prio = 1; ka_id.vlan = 3; ka_id.dst = 255; ka_id.src = 8; ka_id.prot = 2; can_t ka; memset(&ka,0,sizeof(can_t)); ka.id = shackbus_sb2id(&ka_id); ka.length = 8; ka.flags.extended = 1; ka.flags.rtr = 0; uint8_t sreg = SREG; cli(); for (uint8_t i = 0;i<8;i++) ka.data[i] = system_time.type8[i]; SREG = sreg; can_send_message_fifo(&ka); } }
// ---------------------------------------------------------------------------- void usbcan_decode_command(char *str, uint8_t length) { uint8_t temp; if (length == 0) return; switch (str[0]) { case 'S': // set bitrate // Lawicel has the folowing settings: // S0 10 kbps // S1 20 kbps // S2 50 kbps // S3 100 kbps // S4 125 kbps // S5 250 kbps // S6 500 kbps // S7 800 kbps // S8 1 mbps; is index 7 on USB2CAN // Note that the USB2CAN adapter does not support 800 kbps. // With index 7 USB2CAN runs on 1 mbps. // Report error if the range is wrong, communication channel // already open, Parameter wrong or the user tries to set // 800 kbps, which is not supported. if ( ((temp = str[1] - '0') > 8) || channel_open || length != 2 || temp == 7 ) { goto error; } else { // Take care of different index usage for 1 mbps. if ( temp == 8 ) { temp--; } // Set new bitrate, remember all MOB are cleared! can_init(temp); bitrate_set = true; } break; case 'r': // send frames case 't': case 'R': case 'T': if ( !channel_open ) { goto error; } else { if ( !usbcan_decode_message(str, length) ) { goto error; } } break; case 'M': // Set acceptance code for SJA1000 case 'm': // Set acceptance mask for SJA1000 case 's': // Set BTR0/BTR1 for SJA1000 goto error; // TODO break; case 'O': // Open channel, i.e. connect CAN to output. if ( channel_open || !bitrate_set ) { goto error; } else { can_set_mode(NORMAL_MODE); // In case the baudrate changed, re-enable some filters. can_filter_t filter = { .mask = 0, .id = 0, .flags.extended = 0, .flags.rtr = 0 }; for (uint8_t i=11; i<15; i++) { can_set_filter(i, &filter); } // Mark the channel as open. channel_open = true; } break; case 'L': // Open channel, i.e. connect CAN to output in listen only mode. if ( channel_open || !bitrate_set ) { goto error; } else { can_set_mode(LISTEN_ONLY_MODE); channel_open = true; } break; case 'C': // Close channel, i.e. disconnect CAN from output. if ( !channel_open ) { goto error; } else { channel_open = false; } break; case 'F': // read Status Flags term_put_hex(0); // TODO break; case 'N': // read serial number term_putc( 'N' ); term_put_hex( 0 ); term_put_hex( 0 ); break; case 'V': // read hardware and firmeware version term_putc( 'V' ); term_put_hex( (HARDWARE_VERSION_MAJOR << 4) | HARDWARE_VERSION_MINOR ); term_put_hex( (SOFTWARE_VERSION_MAJOR << 4) | SOFTWARE_VERSION_MINOR ); break; case 'Z': // Switch on or off timestamps. // On Lawicel this value is stored in EEPROM. if ( channel_open || length != 2) { goto error; } else { use_timestamps = (str[1] - '0' == 0) ? false : true; CANTIM = 0; } break; } term_putc('\r'); // command could be executed return; error: term_putc(7); // Error in command } // ---------------------------------------------------------------------------- // processes commands in usbcan-protocol mode void usbcan_handle_protocol(void) { static char buffer[40]; static uint8_t pos; static can_error_register_t last_error = { 0, 0 }; can_error_register_t error; // check for new messages if (can_check_message()) { can_t message; // Only communicate data if channel is open. // Due to left -> right evaluation messages are extracted from the // MOB to avoid overflow, even if no communication is desired. if ( can_get_message(&message) && channel_open ) { uint8_t length = message.length; if (message.flags.rtr) { // print identifier if (message.flags.extended) { printf_P(PSTR("R%08lx"), message.id); } else { uint16_t id = message.id; printf_P(PSTR("r%03x"), id); } term_putc(length + '0'); } else { // print identifier if (message.flags.extended) { printf_P(PSTR("T%08lx"), message.id); } else { uint16_t id = message.id; printf_P(PSTR("t%03x"), id); } term_putc(length + '0'); // print data for (uint8_t i = 0; i < length; i++) term_put_hex(message.data[i]); } if (use_timestamps) printf_P(PSTR("%04x"), message.timestamp); term_putc('\r'); } } // get commands while (term_data_available()) { char chr = term_getc(); if (chr != '\r') { buffer[pos] = chr; pos++; if (pos >= sizeof(buffer)) { // format-error: command to long! pos = 0; } } else { buffer[pos] = '\0'; usbcan_decode_command(buffer, pos); pos = 0; } } // get error-register error = can_read_error_register(); if (last_error.tx != error.tx || last_error.rx != error.rx) { printf_P(PSTR("E%02x%02x\r"), error.rx, error.tx); last_error = error; } }
int main () { DDRA = 0xFF; pwm_init(); /** testing ++++++++++++++++++ **/ pwm_set(500, 0); _delay_ms(2000); pwm_set(1000, 0); while(true); /** ---------------------------- **/ can_init(BITRATE_1_MBPS); sei(); // motor 1 can_filter_t filter0; filter0.id = BOARD_ID; filter0.mask = 0x7FF; filter0.flags.rtr = 0; can_set_filter(0, &filter0); while(42) { if (can_check_message()) { //PORTA ^= 0xF0; can_t message; can_get_message(&message); signed short value0; signed short value1; if (BOARD_0) { value0 = message.data[1]; value1 = -message.data[3]; if (message.data[0] == 1) value0 *= -1; if (message.data[2] == 1) value1 *= -1; } else { //value0 = message.data[5] *= -1; //value1 = message.data[7] *= -1; value0 = -message.data[5]; value1 = -message.data[7]; if (message.data[4] == 1) value0 *= -1; if (message.data[6] == 1) value1 *= -1; } long lvalue0 = value0; long lvalue1 = value1; lvalue0 += 255; lvalue0 *= 1000; lvalue0 /= (2*255); lvalue1 += 255; lvalue1 *= 1000; lvalue1 /= (2*255); /* pulsing values */ if (abs(value0) < 45) { if (abs(value0) < 5) { pwm_set(500, 0); } else if (abs(value0) < 13) { pwm_set_ontime(pwm_lookup[0].ontime, 0); pwm_set_offtime(pwm_lookup[0].offtime, 0); pwm_set(value0 < 0 ? 422 : 588, 0); // speed 45 //pwm_set(value0 < 0 ? 250 : 750, 0); // speed 45 } else { double dindex = 0.44*abs(value0)-4.9; unsigned char cindex = (unsigned char)round(dindex)%13; pwm_set_ontime(pwm_lookup[cindex].ontime, 0); pwm_set_offtime(pwm_lookup[cindex].offtime, 0); pwm_set(value0 < 0 ? 422 : 588, 0); // speed 45 //pwm_set(value0 < 0 ? 250 : 750, 0); // speed 45 } } else { pwm_set_ontime(1, 0); pwm_set_offtime(0, 0); pwm_set((unsigned long)lvalue0, 0); } if (abs(value1) < 45) { if (abs(value1) < 5) { pwm_set(500, 1); } else if (abs(value1) < 13) { pwm_set_ontime(pwm_lookup[0].ontime, 1); pwm_set_offtime(pwm_lookup[0].offtime, 1); pwm_set(value1 < 0 ? 422 : 588, 1); // speed 45 //pwm_set(value1 < 0 ? 250 : 750, 1); // speed 45 } else { double dindex = 0.44*abs(value1)-4.9; unsigned char cindex = (unsigned char)round(dindex)%13; pwm_set_ontime(pwm_lookup[cindex].ontime, 1); pwm_set_offtime(pwm_lookup[cindex].offtime, 1); pwm_set(value1 < 0 ? 422 : 588, 1); // speed 45 //pwm_set(value1 < 0 ? 250 : 750, 1); // speed 45 } } else { pwm_set_ontime(1, 1); pwm_set_offtime(0, 1); pwm_set((unsigned long)lvalue1, 1); } //pwm_set((unsigned long)lvalue0, 0); //pwm_set((unsigned long)lvalue1, 1); } } }
///////////////////////////////////////////////////////////////////////////////////////// // CAN message dispatcher void ProcessCANMessage(int index) { unsigned char fn_code; unsigned char node_id; //unsigned short obj_index; //unsigned char sub_index; unsigned char len; unsigned char data[8]; unsigned char data_return = 0; //int i; while (0 == can_get_message(CAN_Ch[index], fn_code, node_id, len, data, false)) { switch (fn_code) { case COBTYPE_TxSDO: { } break; case COBTYPE_TxPDO1: { UpdateStatus(index, node_id, MAKEWORD(data[4], data[5])); printf("\tTxPDO1[node=%d]\n", node_id); printf("\t\tstatus word = "); printBinary(data[5]); printf(" "); printBinary(data[4]); printf("b\n"); printf("\t\tDI = "); printBinary(data[2]); printf(" "); printBinary(data[1]); printf(" "); printBinary(data[0]); printf("b\n"); } break; case COBTYPE_TxPDO2: { printf("\tTxPDO2[node=%d]: ", node_id); printf("%c%c[%d] = ", data[0], data[1], (data[2] | ((unsigned short)(data[3]&0x3F)<<8))); if ((data[3]&0x40) != 0) { printf("ERROR(%04X %04Xh)", MAKEWORD(data[6], data[7]), MAKEWORD(data[4], data[5])); } else { if ((data[3]&0x80) != 0) { printf("%f", (float)(MAKEWORD(data[4], data[5]), MAKEWORD(data[6], data[7]))); } else { printf("%d", (int)(MAKEWORD(data[4], data[5]), MAKEWORD(data[6], data[7]))); } } printf("\n"); } break; case COBTYPE_TxPDO3: { long enc_counter; printf("\tTxPDO3[node=%d]\n", node_id); enc_counter = MAKELONG(MAKEWORD(data[0], data[1]), MAKEWORD(data[2], data[3])); printf("\t\tdemand position = %.1f (deg) / %d (count)\n", COUNT2DEG(enc_counter), enc_counter); enc_counter = MAKELONG(MAKEWORD(data[4], data[5]), MAKEWORD(data[6], data[7])); printf("\t\tactual position = %.1f (deg) / %d (count)\n", COUNT2DEG(enc_counter), enc_counter); } break; case COBTYPE_TxPDO4: { printf("\tTxPDO4[node=%d]: ", node_id); printf("\n"); } break; } } }
int main () { uart_init(38400); // initialisation of the buttons and leds // DDRE &= ~(0xF0); // buttons as input PORTE |= 0xF0; // activate internal pull-ups DDRA |= 0xFF; // leds as output /** CAN TESTING HERE **/ can_init(BITRATE_1_MBPS); sei(); // motor 1 can_filter_t filter0; filter0.id = 9; //filter0.mask = 0x7FF; filter0.mask = 0; filter0.flags.rtr = 0; can_set_filter(0, &filter0); PORTA ^= 0x02; /*while(true) { if (can_check_message()) { can_t msg; can_get_message(&msg); PORTA ^= 0x01; } }*/ PORTA = 0x01; _delay_ms(1000); PORTA = 0x02; int j = 0; while(true) { can_t frame; frame.id = 0x42; frame.flags.rtr = 0; frame.length = 8; for(int i = 0; i < 8; i++) { frame.data[i] = 42;//j + i; } j++; for (int k = 0; k < 8; k++) { if (can_send_message(&frame)) { PORTA &= ~0x0F; PORTA ^= 0xF0; } else { PORTA |= 0x0F; } } //_delay_ms(1); _delay_ms(1); } while(true) { if (can_check_message()) { PORTA ^= 0x03; /*can_t msg; can_get_message(&msg);*/ can_t message; can_get_message(&message); for (int i = 0; i < 8; i++) { uart_debug("%d: %d\n\r", i, message.data[i]); _delay_ms(5); } uart_debug("##########################\n\n\r"); } if (PINE < 0xF0) { can_t frame; frame.id = 0x09; frame.flags.rtr = 0; frame.length = 2; frame.data[0] = 0x2A; frame.data[1] = 0x06; if (can_send_message(&frame)) { PORTA &= ~0xE0; PORTA ^= 0x10; } else PORTA = 0xE0; uart_debug(".\n\r"); _delay_ms(500); } } /** ** ++++++++++ ** **/ return 0; }
void shackbus_main(void) { if ( fifo_get_count(&can_outfifo) > 0 ) { uint8_t cur_nr = fifo_read (&can_outfifo); if ( can_send_message(&framestorage_data[cur_nr]) ) { fifo_get (&can_outfifo); framestorage_get(cur_nr); } } if (shackbus_msg_send_flag) { can_t msg; shackbus_id_t shackbus_id; shackbus_msg_send_flag = 0; shackbus_id.prio = 3; shackbus_id.vlan = 4; shackbus_id.dst = 255; shackbus_id.src = 6; shackbus_id.prot = 13; memset(&msg,0,sizeof(can_t)); msg.id = shackbus_sb2id(&shackbus_id); msg.length = 1; msg.flags.extended = 1; msg.flags.rtr = 0; if (MAINSWITCH_STATE) msg.data[0] = 1; else msg.data[0] = 0; //Send the new message can_send_message_fifo(&msg); } // Check if a new messag was received if (can_check_message()) { can_t msg; // Try to read the message if (can_get_message(&msg)) { if (msg.id == 0x1FF && msg.flags.extended == 1) { led_set(99,0); } shackbus_id_t shackbus_id; shackbus_id2sb(&shackbus_id,&msg); if (shackbus_id.prot == 9 && shackbus_id.dst == 6 && msg.data[0]<12) { if (msg.data[1]==1) enocean_state_set(msg.data[0],ENOCEAN_CHANNEL_SE_SA_SS); if (msg.data[1]==0) enocean_state_set(msg.data[0],ENOCEAN_CHANNEL_SE_SA_CS); //Send the new message //shackbus_send_msg(msg.data[0], msg.data[1]); } //prot=10 = Basis IO data[0]=10 = Ping if (shackbus_id.prot == 10 && shackbus_id.dst == 6 && msg.data[0]==10) { shackbus_id.prio = 3; shackbus_id.vlan = 4; shackbus_id.dst = shackbus_id.src; shackbus_id.src = 6; shackbus_id.prot = 10; msg.id = shackbus_sb2id(&shackbus_id); msg.length = 2; msg.data[0] = 11; msg.data[1] = msg.data[1]; //Send the new message can_send_message_fifo(&msg); } //prot=10 = Basis IO data[0]=04 = Jump2Bootloader if (shackbus_id.prot == 10 && shackbus_id.dst == 6 && msg.data[0]==04) { cli(); wdt_enable(WDTO_15MS); while (1); } /* prot=11 = PowerManagement data[0]=1 =on/off data[1]=channel data[2]=state */ /* channel 120 = Hauptschalter */ /* channel 140 0x8c = DLE Dusche */ /* channel 141 0x8d = DLE E-Lab */ /* channel 142 0x8e = Optionsraeume */ /* channel 143 0x8f = Kueche */ if (shackbus_id.prot == 11 && shackbus_id.dst == 6 && msg.data[0]==1) { shackbus_id.prio = 3; shackbus_id.vlan = 4; shackbus_id.dst = shackbus_id.src; shackbus_id.src = 6; shackbus_id.prot = 11; msg.id = shackbus_sb2id(&shackbus_id); msg.length = 3; msg.data[0] = 1; msg.data[1] = msg.data[1]; msg.data[2] = msg.data[2]; /* Send the message */ can_send_message_fifo(&msg); enocean_packet_send(msg.data[1], msg.data[2]); } } } if (shackbus_system_time_send_flag >= 60) { shackbus_system_time_send_flag = 0; shackbus_id_t ka_id; ka_id.prio = 1; ka_id.vlan = 3; ka_id.dst = 255; ka_id.src = 6; ka_id.prot = 2; can_t ka; memset(&ka,0,sizeof(can_t)); ka.id = shackbus_sb2id(&ka_id); ka.length = 8; ka.flags.extended = 1; ka.flags.rtr = 0; uint8_t sreg = SREG; cli(); for (uint8_t i = 0;i<8;i++) ka.data[i] = system_time.type8[i]; SREG = sreg; can_send_message_fifo(&ka); } }