跳到主要內容

MCC LIN TX 小問題2

新增 found flag,找不到就返回,原本找不到會提供最後一個值。

 void LIN_queuePacket(uint8_t cmd) {

  bool found = false;

  const lin_rx_cmd_t *tempSchedule =

      LIN_rxCommand; // copy table pointer so we can modify it


  cmd &= 0x3F; // clear possible parity bits

  for (uint8_t i = 0U; i < LIN_rxCommandLength; i++) {

    if (cmd == tempSchedule->cmd) {

      found = true;

      break;

    }

    tempSchedule++; // go to next entry

  }

  // 找不到就返回

  if (found == false) {

    return;

  }


  LIN_packet.type = tempSchedule->type;

  LIN_packet.length = tempSchedule->length;


  // Build Packet - User defined data

  // add data

  memcpy(LIN_packet.data, tempSchedule->data, LIN_packet.length);


  // Add Checksum

  LIN_packet.checksum =

      LIN_getChecksum(LIN_packet.length, LIN_packet.PID, LIN_packet.data);

  LIN_sendPacket(LIN_packet.length, LIN_packet.PID, LIN_packet.data);

}

留言

這個網誌中的熱門文章

AD9 SCH尋找相同net

 ALT+滑鼠左鍵點net 不容易找到相同的net 加上這個設定 會有紅線 很容易找到相同的net 取消選取  在空白處點一下滑鼠左鍵   再 Shift+C AD快捷鍵列表

VScode-json-debug&compiler

  {     // Use IntelliSense to learn about possible attributes.     // Hover to view descriptions of existing attributes.     // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387     "version" : "0.2.0" ,     "configurations" : [         {             // Note: Properties here can override MPLAB project settings             "name" : "Debug" ,             "type" : "mplab-core-da" ,             "request" : "launch" ,             "project" : "My_Project" ,             "configuration" : "default" ,             "stopOnEntry" : true ,         },         {             "name" : "Program" ,         ...

MPLAB X IDE 不能在.h檔裡宣告變數,否則debug mode時會出問題,找不函數.

  MPLAB X IDE 不能在.h檔裡宣告變數,否則debug mode時會出問題,找不函數. 但編輯和燒錄時功能都正常.