跳到主要內容

typedef 和 enum 使用技巧

第2種方式可以明確的知道lin_cmd_t是uint8_t 佔用一個byte,第一種方式在不同的編譯器可能會變成2個byte.

第1種方式

typedef enum {
    SIGNAL = 0x01
}lin_cmd_t;

和

第2種方式
typedef uint8_t lin_cmd_t;

enum {
    SIGNAL = 0x01
};


const lin_rx_cmd_t scheduleTable[] = {
    //Command, Type, TX/RX Length, Data Address
    {SIGNAL, RECEIVE, 8U, SIGNAL_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時會出問題,找不函數. 但編輯和燒錄時功能都正常.