![zephyr System Architecture](https://docs.zephyrproject.org/latest/_images/security-zephyr-system-architecture.png) ![NXP Zephyr-OS](https://www.nxp.com/assets/images/en/block-diagrams/Zephyr-OS.jpg) ![Zephyr Software Layers over NXP MCUXpresso SDK drivers ](https://www.nxp.com/assets/images/en/blogs/BL-ZEPHYR-SOFTWARE-CODE-720x405-3.jpg) 一個device driver 可以有不同的 driver API implement。 [zephyr Device Driver Model¶](https://docs.zephyrproject.org/latest/kernel/drivers/index.html) ![micro ROS Architecture](https://micro.ros.org/img/micro-ROS_architecture.png) ## CMSIS arch [cmsis Introduction](https://siliconlabs.github.io/Gecko_SDK_Doc/CMSIS/General/html/index.html) ![](https://siliconlabs.github.io/Gecko_SDK_Doc/CMSIS/General/html/CMSISv4_small.png) 可以看到cmsis的方案,把東西上下包起來。比較像zephyr RTOS的 platform + os service low level API(含通用driver API) ## ethercat layer identify * if you are not familiar OSI 7 layer model, plz refer [Looking Inside Real-Time Ethernet](https://www.analog.com/en/analog-dialogue/articles/looking-inside-real-time-ethernet.html) * By compare EtherCAT to http+TCP+IP, we can get a clear picture of what is each EtherCAT layer belong. * ![Figure 2. ISO seven-layer model.](https://www.analog.com/-/media/images/analog-dialogue/en/volume-53/number-1/articles/looking-inside-real-time-ethernet/234019_fig_02.png?w=900&la=en&imgver=4) 當成參考就好,它的分類不一定對。 因為EhterCAT 有包很多不同的東西(CANopen, ethernet...),根據包的東西,layer 會完全不同。應該要繼承被包者的特性。 [DewSoft-What Is EtherCAT Protocol and How Does It Work?](https://dewesoft.com/blog/what-is-ethercat-protocol) ![The 7-layer OSI model as implemented by CANopen](https://www.datocms-assets.com/53444/1666079971-7-layer-osi-model-ethernet.png?auto=format&w=1024&dpr=2) ![By skipping OSI layers 3-6, EtherCAT achieves cycle times better than 100 µs and communication jitter better than 1 µs](https://www.datocms-assets.com/53444/1666078525-osi-layer-ethercat.png?auto=format&w=1024&dpr=2) [CANopen Explained - A Simple Intro [2022]](https://www.csselectronics.com/pages/canopen-tutorial-simple-intro) ![](https://canlogger1000.csselectronics.com/img/CANopen-OSI-model-7-layer-standards-401-402-CiA-301-302.svg) ![参考模型](https://static.getiot.tech/CANopen-CAN-Bus-OSI-Layers-CiA-Standards-301-302-401-402.png) [CAN 总线协议](https://getiot.tech/zh/canbus/canbus-protocol) 這是比較清楚的 CANopen,可以看到CiA402 在 application,和http同一 layer。 ## 自己認為的layer 自己認為的layer,和OS archietecture combine ![](https://filedn.com/lzOQU5aSSXB47Aru33KDfTb/driver_arch.dio.svg) cia402 是屬於layer7,所以會是application service。這個情況比較接近真正的app,controller,在電腦端。 app(controller) 要負責參數的儲存,這沒問題。但是希望驅動器保存馬達參數也蠻常見的,特別是配套一對的驅動組。這就變成說,可能要修改cia402的代碼(不能直接用cia402appl) ### 其它可能的層 * ZeroMQ * [zeromq on embedded cortexM3 platform](https://stackoverflow.com/questions/20933676/zeromq-on-embedded-cortexm3-platform) * 要有posix, TCP/IP,其實對MCU很重。 MCU 這邊也一定要有 pub/sub (message queue) 相關的software service。可以cross hardware,也可以不cross。EtherCAT系列當然是類似的功能,但我這邊想要的主要是供software 使用,沒有要求特別的速度或功能,但是一定要輕量,最好是不需要任何OS的機制。 cross hardware的好處是,拓展出software的架構。driver 可以直接被視為一個程式組件,直接被controller 控制。不過老實說,工業總線已經將大部份MCU需要做的事情特別定義好了,那就直接用這些stack就好。cross hardware message queue的需求不大。 ### other ref * [EtherCAT - the Ethernet Fieldbus](https://www.ethercat.org/en/technology.html) * ![ Different communication profiles can coexist in the same system](https://www.ethercat.org/images/technology/EtherCAT_Technology_09_CommunicationProfiles.jpg) # event driven style [alicedodo 一个比较靠谱的单片机裸奔通用程序框架](https://gitee.com/alicedodo/middle_two_age_mcu_prog/raw/master/%E4%B8%80%E4%B8%AA%E6%AF%94%E8%BE%83%E9%9D%A0%E8%B0%B1%E7%9A%84%E5%8D%95%E7%89%87%E6%9C%BA%E8%A3%B8%E5%A5%94%E9%80%9A%E7%94%A8%E7%A8%8B%E5%BA%8F%E6%A1%86%E6%9E%B6.pdf)