{"id":6298,"date":"2024-08-12T18:01:01","date_gmt":"2024-08-12T10:01:01","guid":{"rendered":""},"modified":"2024-08-12T18:01:01","modified_gmt":"2024-08-12T10:01:01","slug":"s32k sdk\u4f7f\u7528\u8be6\u89e3_c++\u7f16\u7a0b\u601d\u60f3","status":"publish","type":"post","link":"https:\/\/mushiming.com\/6298.html","title":{"rendered":"s32k sdk\u4f7f\u7528\u8be6\u89e3_c++\u7f16\u7a0b\u601d\u60f3"},"content":{"rendered":"
\u5185\u5bb9\u63d0\u8981<\/p>\n
<\/p>\n
\u5f15\u8a00<\/p>\n
1. S32 SDK\u7684\u8f6f\u4ef6\u5206\u5c42\u67b6\u6784\u4ecb\u7ecd<\/p>\n
1.1 \u5916\u8bbe\u9a71\u52a8\u5c42(PD--Periperal Driver)<\/p>\n
1.2 \u5916\u8bbe\u62bd\u8c61\u5c42(PAL--Peripheral Abstract Layer)<\/p>\n
1.3 \u4e2d\u95f4\u4ef6\u5c42(Middleware)<\/p>\n
1.4 \u5b9e\u65f6\u64cd\u4f5c\u7cfb\u7edf\u5c42(RTOS)<\/p>\n
1.5 S32 SDK\u5e95\u5c42\u9a71\u52a8\u8f6f\u4ef6\u5206\u5c42\u7684\u4f18\u70b9<\/p>\n
2. S32 SDK\u7684\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u89e3\u6790<\/p>\n
3. S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u4e2d\u65ad\u5904\u7406\u673a\u5236\u8be6\u89e3<\/p>\n
4. S32 SDK\u7684\u901a\u4fe1\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6API\u51fd\u6570\u7684\u963b\u585e\u4e0e\u975e\u963b\u585e\u53d1\u9001\u4e0e\u63a5\u6536API\u51fd\u6570\u5dee\u522b\u4e0e\u4f7f\u7528\u8be6\u89e3\uff1b<\/p>\n
5. S32 SDK\u7684\u5916\u8bbe\u9a71\u52a8\u4e0eRTOS\u4e4b\u95f4\u7684\u4ea4\u4e92\u65b9\u5f0f<\/p>\n
\u603b\u7ed3<\/p>\n
<\/p>\n
\u5f15\u8a00<\/p>\n
<\/p>\n
S32 SDK(Software Development Kit\uff0c\u8f6f\u4ef6\u5f00\u53d1\u5957\u4ef6)\u501f\u9274\u4e86AutoSAR\u8f6f\u4ef6\u548cARM Cortext M\u7cfb\u5217MCU\u8f6f\u4ef6\u63a5\u53e3\u6807\u51c6(CMSIS--Cortex Microcontroller Software Interface Standard)\u7684\u7f16\u7a0b\u601d\u60f3\uff0c\u901a\u8fc7\u5bf9\u5185\u6838\u548c\u5e95\u5c42\u5916\u8bbe\u786c\u4ef6\u9a71\u52a8\u7684\u62bd\u8c61\u5316\uff0c\u5bf9\u5e94\u7528\u5c42\u63d0\u4f9b\u7edf\u4e00\u7684API\uff0c\u4e0d\u4f46\u5927\u5e45\u5ea6\u5730\u964d\u4f4e\u4e86MCU\u7528\u6237\u7684\u8f6f\u4ef6\u5f00\u53d1\u96be\u5ea6\u548c\u7f16\u7a0b\u95e8\u69db\uff0c\u540c\u65f6\u4e5f\u5927\u5927\u63d0\u9ad8\u4ee3\u7801\u7684\u91cd\u7528\u7387\u548c\u53ef\u79fb\u690d\u6027\u53ca\u53ef\u8bfb\u6027\u3002\u4f7f\u5f97\u57fa\u4e8eMCU\u7684\u5d4c\u5165\u5f0f\u8f6f\u4ef6\u7f16\u7a0b\u53d8\u5f97\u66f4\u52a0\u5bb9\u6613\u3002<\/p>\n
<\/p>\n
\u7136\u800c\uff0c\u76f8\u8f83\u4e8e\u4f7f\u7528\u4f20\u7edfMCU--\u6bd4\u598251\u5355\u7247\u673a\u3001S08\u548cS12(X) MCU\u7684\u5e95\u5c42\u8f6f\u4ef6\u5f00\u53d1\uff0c S32 SDK\u7684\u8f6f\u4ef6\u7f16\u7a0b\u6a21\u5f0f\u548c\u7f16\u7a0b\u601d\u60f3\u53d1\u751f\u4e86\u5f88\u5927\u7684\u53d8\u5316\uff0c \u4ee5\u9002\u5e94\u65e5\u76ca\u590d\u6742\u7684MCU\u5185\u6838\u548c\u5916\u8bbe\u8d44\u6e90\u3002\u5982\u679c\u4e4b\u524d\u6ca1\u6709\u63a5\u89e6\u8fc7\u7cfb\u7edf\u7684\u8f6f\u4ef6\u67b6\u6784\u548c\u8f6f\u4ef6\u7f16\u7a0b\u601d\u60f3\u77e5\u8bc6\u4f53\u7cfb\u7684\u5b66\u4e60\uff0c\u4e5f\u672a\u4f7f\u7528\u8fc7AutoSAR \u8f6f\u4ef6\u548cCMSIS\u5e93\uff0c\u5219\u5728\u4f7f\u7528S32 SDK\u65f6\uff0c\u5c06\u4f1a\u53d1\u73b0\u5f88\u591a\u56f0\u60d1\uff0c\u4e0d\u77e5\u9053\u5982\u4f55\u5728\u5e94\u7528\u5c42\u9ad8\u6548\u5730\u8c03\u7528SDK\u7684API\u3001\u5982\u4f55\u901a\u8fc7\u4e8b\u4ef6\u901a\u77e5(Event Notification)\u4e0e\u5e95\u5c42\u9a71\u52a8\u8fdb\u884c\u4ea4\u4e92\uff0c\u4ee5\u53ca\u5982\u4f55\u5728\u4f7f\u7528RTOS\u7684\u7cfb\u7edf\u4e2d\u8c03\u7528SDK\u63d0\u4f9b\u7684\u5e95\u5c42\u9a71\u52a8API\u7b49\uff1f<\/p>\n
<\/p>\n
\u9274\u4e8e\u6b64\uff0c\u672c\u6587\u5c06\u4ee5S32K SDK\u4e3a\u4f8b\uff0c\u8be6\u7ec6\u4ecb\u7ecdS32 SDK\u7684\u8f6f\u4ef6\u7f16\u7a0b\u601d\u60f3\uff0c\u4ee5\u4e3a\u5927\u5bb6\u89e3\u5f00\u4ee5\u4e0a\u7591\u60d1\uff0c\u5e2e\u52a9\u5927\u5bb6\u66f4\u597d\u7684\u4f7f\u7528S32 SDK\u5e76\u771f\u6b63\u7406\u89e3\u5176\u7f16\u7a0b\u4f18\u52bf\u3002<\/p>\n
<\/p>\n
1. S32 SDK\u7684\u8f6f\u4ef6\u5206\u5c42\u67b6\u6784\u4ecb\u7ecd<\/p>\n
<\/p>\n
<\/p>\n
S32 SDK\u7684\u8f6f\u4ef6\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u4ece\u4e0a\u4e00\u7bc7\u6587\u7ae0--\u300aS32K SDK\u4f7f\u7528\u8be6\u89e3\u4e4bS32 SDK\u8f6f\u4ef6\u67b6\u6784\u8be6\u89e3\u300b\u89e3\u8bfb\u4e2d(\u70b9\u51fb\u6587\u7ae0\u6807\u9898\u5373\u53ef\u5feb\u901f\u8df3\u8f6c\u9605\u8bfb)\uff0c<\/p>\n
\u53ef\u4ee5\u770b\u5230S32 SDK\u9664\u4e86\u63d0\u4f9b\u5e95\u5c42\u9a71\u52a8(LLD--Low Level Drivers)\u548c\u4e2d\u95f4\u4ef6(Middleware)\u4e4b\u5916\uff0c\u8fd8\u63d0\u4f9b\u4e86\u4e0d\u540c\u5de5\u5177\u94fe\u7f16\u8bd1\u5668\u7684\u542f\u52a8(Start-up)\u548c\u94fe\u63a5\u6587\u4ef6(Linker filers) \uff0c\u79fb\u690d\u597d\u7684FreeRTOS\u548cRTOS\u63a5\u53e3\u5c42(OSIF)\u4ee5\u53ca\u5904\u7406\u5668\u4e13\u5bb6(Processor Expert)\u914d\u7f6eGUI\u548c\u4e30\u5bcc\u7684demo\u7a0b\u5e8f\u548c\u8be6\u7ec6\u7684\u5e2e\u52a9\u6587\u6863\uff1a<\/p>\n
<\/p>\n
<\/p>\n
\u5177\u4f53\u6765\u770b\uff0cS32 SDK\u7684\u8f6f\u4ef6\u5206\u5c42\u60c5\u51b5\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
1.1 \u5916\u8bbe\u9a71\u52a8\u5c42(PD--Periperal Driver)<\/p>\n
<\/p>\n
PD\u5c42\u7ec4\u4ef6\u901a\u8fc7\u8c03\u7528\u5bf9\u5916\u8bbe\u5bc4\u5b58\u5668\u64cd\u4f5c\u7684\u786c\u4ef6\u8bbf\u95ee\u5c42(Hardware Access)API(\u4e00\u822c\u4e3a\u5b8f\u5b9a\u4e49\u6216\u8005inline\u51fd\u6570\uff0c\u4e14\u4e3a\u9759\u6001static\u4ee3\u7801\uff0c\u4ec5PD\u5c42\u6587\u4ef6\u5185\u90e8\u4f7f\u7528)\uff0c\u8bfb\u5199\u4e0d\u540cS32\u7cfb\u5217MCU\u5e95\u5c42\u786c\u4ef6\u5916\u8bbeIP\u6a21\u5757\u5bc4\u5b58\u5668\uff0c\u4ece\u800c\u5b8c\u6210\u5bf9\u5916\u8bbe\u7684\u521d\u59cb\u5316\u914d\u7f6e\u3001\u72b6\u6001\u8bfb\u53d6--\u5373\u786c\u4ef6\u4ea4\u4e92\uff1b<\/p>\n
<\/p>\n
\u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u6839\u636e\u4e0d\u540c\u7684\u5916\u8bbe\u6a21\u5757\u529f\u80fd\u7279\u6027\uff0c\u7f16\u5199\u76f8\u5e94\u7684\u521d\u59cb\u5316\u51fd\u6570\u3001\u529f\u80fd\u914d\u7f6e\/\u4f7f\u7528\u51fd\u6570\u4ee5\u53ca\u4e2d\u65ad\u5904\u7406\u51fd\u6570(ISR)\uff0c\u4ece\u800c\u6784\u6210\u5b8c\u6210\u7684\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u3002\u8fd9\u91cc\u9762\u5305\u542b\u4e86\u5f88\u591a\u5916\u8bbe\u521d\u59cb\u5316\u914d\u7f6e\u7684\u65f6\u5e8f\/\u987a\u5e8f\u8981\u6c42(\u914d\u7f6e\u5916\u8bbe\u7684initialization\u72b6\u6001\u3001Freeze\u72b6\u6001\u3001STOP\u3001Standby\/Shutdown\u4ee5\u53canomal work\u72b6\u6001)\u548c\u7279\u5b9a\u5bc4\u5b58\u5668\u7684\u64cd\u4f5c\u6743\u9650\u7ba1\u7406(\u6bd4\u5982\u7ba1\u7406\u5458\u6a21\u5f0f\u8fd8\u662f\u7528\u6237\u6a21\u5f0f\u53ef\u4ee5\u8bfb\u5199\u6743\u9650)\u3001\u548c\u5bc4\u5b58\u5668\u64cd\u4f5c\u65b9\u5f0f\u63a7\u5236(\u6bd4\u5982\u6e05\u9664\u5916\u8bbe\u4e2d\u65ad\u6807\u5fd7\u7684\u65b9\u6cd5\u662f\u51991\u6e05\u96f6\u8fd8\u662f\u8bfb\u6e05\u96f6)\u7b49\u3002<\/p>\n
<\/p>\n
Tips\uff1a S32 SDK\u7684PD\u5c42\u5305\u542b\u4e86\u6240\u652f\u6301MCU\u7684\u51e0\u4e4e\u6240\u6709\u7247\u4e0a\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\uff0c\u7531\u4e8e\u5176\u4ee3\u7801\u76f4\u63a5\u64cd\u4f5c\u5916\u8bbeIP\u5bc4\u5b58\u5668\uff0c\u6240\u4ee5\u5176\u6548\u7387\u662f\u6700\u9ad8\u7684\uff0c\u4f46\u4e0d\u80fd\u5b9e\u73b0\u8de8MCU\u5e73\u53f0\/\u7cfb\u5217\u4f7f\u7528\u3002 \u5982\u4e0b\u4e3aS32K SDK\u7684PD\u5c42\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u5217\u8868\uff1a<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
1.2 \u5916\u8bbe\u62bd\u8c61\u5c42(PAL--Peripheral Abstract Layer)<\/p>\n
<\/p>\n
\u5728PD\u5c42\u7684\u57fa\u7840\u4e0a\uff0c S32 SDK\u5c01\u88c5\u4e86\u4e00\u4e2a\u5916\u8bbe\u62bd\u8c61\u5c42\uff0c\u5c06\u80fd\u591f\u5b9e\u73b0\u76f8\u540c\u529f\u80fd\u7684\u5916\u8bbePD\u7ec4\u4ef6\u5c01\u88c5\u4e3a\u4e00\u4e2aPAL\u529f\u80fd\u7ec4\u4ef6\uff0c\u6bd4\u5982\u5b9e\u73b0UART\u4e32\u884c\u901a\u4fe1\u7684\u5916\u8bbe\uff0c\u5728S32K1xx\u7cfb\u5217\u4e0a\u786c\u4ef6\u5916\u8bbe\u4e3aLPUART\uff0c\u5728Qorivva MPC57xx\u548cS32V234\u4e0a\u5219\u662fLINFlex\uff0c\u5728PAL\u5c31\u62bd\u8c61\u4e86\u4e00\u4e2aUART_PAL\uff0c\u5bf9\u5e94\u7528\u5c42\u63d0\u4f9b\u7edf\u4e00\u7684API\u51fd\u6570\uff0c\u4ece\u800c\u5bf9\u5e94\u7528\u5c42\u8f6f\u4ef6\u5f00\u53d1\u4eba\u5458\u5c4f\u853d\u4e86\u5e95\u5c42\u786c\u4ef6\u5916\u8bbe\u7684\u5dee\u522b\uff1a<\/p>\n
<\/p>\n
<\/p>\n
Tips\uff1a \u4f7f\u7528S32 SDK\u7684PAL\u5c42\u80fd\u591f\u5b9e\u73b0\u4ee3\u7801\u7684\u8de8\u5e73\u53f0\u79fb\u690d\u548c\u4f7f\u7528\uff0c\u5178\u578b\u7684PAL\u7ec4\u4ef6\u5305\u62ecCAN\u3001UART\u3001I2C\u3001SPI\u548cI2C\u7b49\u901a\u4fe1\u529f\u80fd\u5916\u8bbe\u6a21\u5757\uff0cPWM\u3001OC\u53caTIMING\u7b49\u5b9a\u65f6\u5668\u529f\u80fd\u6a21\u5757\uff0c\u4ee5\u53caMPU\/MMU\u5b58\u50a8\u5668\u4fdd\u62a4\/\u7ba1\u7406\u529f\u80fd\u6a21\u5757\u4ee5\u53ca\u770b\u95e8\u72d7\u548c\u4fe1\u606f\u5b89\u5168\u7b49\u7cfb\u7edf\u7ea7\u529f\u80fd\u6a21\u5757\u3002 \u5982\u4e0b\u4e3aS32K SDK\u7684PD\u5c42\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u5217\u8868\uff1a<\/p>\n
<\/p>\n
<\/p>\n
1.3 \u4e2d\u95f4\u4ef6\u5c42(Middleware)<\/p>\n
<\/p>\n
S32 SDK\u7684\u4e2d\u95f4\u4ef6\u4e3b\u8981\u5305\u62ec\u4e09\u5927\u7c7b\uff1a\u2460\u529f\u80fd\u9759\u6001\u5e93--\u6bd4\u5982\u7535\u673a\u63a7\u5236\u5e93(AMMCLib)\u3001\u89e6\u63a7\u611f\u5e94\u5e93(Touch Sensing)\u7b49\u548c\u2461\u8f6f\u4ef6\u534f\u8bae\u6808(stack)--\u6bd4\u5982\u4ee5\u592a\u7f51\u534f\u8bae\u6808(TCP\/IP)\u3001LIN\u534f\u8bae\u6808\u548cUSB\u53ca\u6587\u4ef6\u7cfb\u7edf\u7b49\uff0c\u4ee5\u53ca\u2462 \u590d\u6742\u5916\u56f4\u82af\u7247\u9a71\u52a8\u7a0b\u5e8f--\u6bd4\u5982SBC(UJA1169\u548cUJA113x)\u7cfb\u5217\u9a71\u52a8\u7a0b\u5e8f\u3002<\/p>\n
<\/p>\n
Tips\uff1a \u5982\u4e0b\u4e3aS32K SDK\u7684Middleware\u7ec4\u4ef6\u5217\u8868\uff0c\u5176\u4e2dTouch Sense\uff0c ISELED\u548cNFC Middleware\u9700\u8981\u8054\u7cfbNXP Sale\/FAE\u7533\u8bf7license\uff0c\u5728\u5b89\u88c5\u76f8\u5e94\u7684SDK\u7248\u672c\u4e4b\u540e\u5355\u72ec\u4e0b\u8f7d\u5b89\u88c5\uff1a<\/p>\n
<\/p>\n
<\/p>\n
1.4 \u5b9e\u65f6\u64cd\u4f5c\u7cfb\u7edf\u5c42(RTOS)<\/p>\n
<\/p>\n
\u4e3a\u4e86\u7ba1\u7406\u4f17\u591a\u7684MCU\u5916\u8bbe\u8d44\u6e90\u548c\u5b58\u50a8\u5668\u8d44\u6e90\u5e76\u8fdb\u884c\u5b9e\u65f6\u7684\u5e94\u7528\u7a0b\u5e8f\u4efb\u52a1\u8c03\u5ea6\uff0c\u5728S32 SDK\u4e2d\u8fd8\u79fb\u690d\u4e86\u5b9e\u65f6\u64cd\u4f5c\u7cfb\u7edf--FreeRTOS\uff0c\u5e76\u672a\u88f8\u5199\u4ee3\u7801\u63d0\u4f9b\u4e86\u64cd\u4f5c\u7cfb\u7edf\u63a5\u53e3\u670d\u52a1(Osif\u7ec4\u4ef6)\u3002<\/p>\n
<\/p>\n
Tips\uff1a \u5982\u4e0b\u4e3aS32K SDK\u7684\u63d0\u4f9b\u7684FreeRTOS\uff0c\u5728S32K SDK RTM 2.0.0\u4e2d\u662fFreeRTOS\u7684\u7248\u672c\u4e3av8.2.1\uff0c\u5728\u6700\u65b0\u7684Beta 2.9.0(\u53ca\u66f4\u9ad8\u7248\u672c)\u4e2d\u5df2\u7ecfupdate\u5230FreeRTOS v10.0.1\u4e86\u3002<\/p>\n
<\/p>\n
<\/p>\n
1.5 S32 SDK\u5e95\u5c42\u9a71\u52a8\u8f6f\u4ef6\u5206\u5c42\u7684\u4f18\u70b9<\/p>\n
<\/p>\n
\u7efc\u4e0a\u6240\u8ff0\uff0cS32 SDK\u63d0\u4f9b\u7684\u5e95\u5c42\u5916\u8bbe\u9a71\u52a8\u5206\u5c42\uff0c\u5177\u6709\u5982\u4e0b\u4f18\u70b9\uff1a<\/p>\n
<\/p>\n
\u2460 \u5206\u5c42\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff1b<\/p>\n
<\/p>\n
\u2461 \u4f7f\u7528PD\u5c42\uff0c\u5bf9\u4fdd\u8bc1\u5bf9\u5916\u8bbe\u6a21\u5757\u7684\u64cd\u4f5c\u5b9e\u65f6\u6027\u548c\u4ee3\u7801\u8fd0\u884c\u6548\u7387\uff1b<\/p>\n
<\/p>\n
\u2462 \u901a\u8fc7PAL\u5c42\u5bf9\u5e95\u5c42\u786c\u4ef6\u5916\u8bbe\u7684\u62bd\u8c61\uff0c\u5bf9\u5e94\u7528\u5c42\u63d0\u4f9b\u4e86\u7edf\u4e00\u7684API\uff0c\u4fdd\u8bc1\u4e86\u5e95\u5c42\u9a71\u52a8\u4ee3\u7801\u5728\u4e0d\u540cS32 MCU\u786c\u4ef6\u5e73\u53f0\u4e0a\u7684\u901a\u7528\u6027\uff0c\u63d0\u9ad8\u4e86\u5e95\u5c42\u9a71\u52a8\u4ee3\u7801\u7684\u53ef\u79fb\u690d\u6027\u548c\u4f7f\u7528\u6548\u7387\uff1b<\/p>\n
<\/p>\n
\u2463 \u96c6\u6210\u4e30\u5bcc\u7684\u4e2d\u95f4\u4ef6\uff0c\u6781\u5927\u5730\u63d0\u9ad8\u4e86S32 MCU\u5e73\u53f0\u5e94\u7528\u5c42\u8f6f\u4ef6\u7684\u53ef\u6269\u5c55\u6027\u548c\u6613\u7528\u6027\uff1b<\/p>\n
<\/p>\n
\u2464 \u901a\u8fc7OSIF\u9694\u79bb\u786c\u4ef6\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u7a0b\u5e8f\u4e0eRTOS\u5185\u6838\uff0c\u4fdd\u8bc1\u5e95\u5c42\u9a71\u52a8\u5bf9\u4e0d\u540cRTOS\u7684\u652f\u6301\uff1b<\/p>\n
<\/p>\n
\u2465 \u901a\u8fc7\u63d0\u4f9b\u9488\u5bf9\u4e0d\u540c\u8f6f\u4ef6\u5f00\u53d1\u5de5\u5177\u94fe\u7684\u542f\u52a8\u6587\u4ef6(start-up)\u548c\u94fe\u63a5\u6587\u4ef6(linker file)\uff0c\u652f\u6301\u4e3b\u6d41\u5de5\u5177\u94fe--\u6bd4\u5982GNU GCC(S32DS IDE\u81ea\u5e26\u5de5\u5177\u94fe)\u3001DIAB\u3001GHS\u548cIAR\u7b49\uff1b<\/p>\n
<\/p>\n
2. S32 SDK\u7684\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u89e3\u6790<\/p>\n
<\/p>\n
\u5728S32 SDK\u4e2d\u6bcf\u4e00\u4e2a\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u90fd\u6709\u4e00\u4e2a\u7ec4\u4ef6\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53,\u4ee5<\u7ec4\u4ef6\/\u5916\u8bbe\u540d>_state_t\u547d\u540d\uff0c\u7528\u4e8e\u5b58\u653e\u8be5\u5916\u8bbe\/\u7ec4\u4ef6\u7684\u5de5\u4f5c\u72b6\u6001\u548c\u786c\u4ef6\u8d44\u6e90\u4f7f\u7528\u4fe1\u606f\uff0c\u4e3b\u8981\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n
<\/p>\n
\u2460 \u5916\u8bbe\u6a21\u5757\u7684\u914d\u7f6e\u4fe1\u606f\uff1b<\/p>\n
<\/p>\n
\u2461 \u901a\u4fe1\u5916\u8bbe\u6536\u53d1\u5668\u7684\u5de5\u4f5c\u72b6\u6001(isTxBbusy\/isRxBusy);<\/p>\n
<\/p>\n
\u2462 \u901a\u4fe1\u5916\u8bbe\u6536\u53d1\u5668\u662f\u5426\u4e3a\u963b\u585e\u65b9\u5f0f\u5de5\u4f5c(isTxBlocking\/isRxBlocking);<\/p>\n
<\/p>\n
\u2463 \u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u6307\u9488(*callback)\u53ca\u53c2\u6570(*callbackParam)\u5b9a\u4e49\uff1b<\/p>\n
<\/p>\n
\u2464 \u5916\u8bbe\u5de5\u4f5c\/\u901a\u4fe1\u4f7f\u7528\u7684\u4fe1\u53f7(semaphore)(TxComplete\/RxComplete)\u548c\u901a\u4fe1\u72b6\u6001(transmitStatus\/receiveStatus);<\/p>\n
<\/p>\n
\u2465 \u901a\u4fe1\u5916\u8bbe\u6536\u53d1\u6570\u636e\u7684\u7f13\u5b58(txBuff\/rxBuff)\u548c\u5927\u5c0f(txSize\/rxSize)\uff1b<\/p>\n
<\/p>\n
\u2466 \u5916\u8bbe\u4f7f\u7528\u7684DMA\u901a\u9053\u53f7\uff1b<\/p>\n
<\/p>\n
\u4ee5\u4e0b\u662fS32K SDK\u4e2dLPUART\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53lpuart_state_t\u7684\u5b9a\u4e49\uff1a<\/p>\n
<\/p>\n
<\/p>\n
\u800c\u975e\u901a\u4fe1\u5916\u8bbe\u7684\u65f6\u949f\u7ba1\u7406\u5668\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53clock_manager_state_t\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
<\/p>\n
Tips\uff1a\u901a\u5e38\u5728SDK\u5916\u8bbe\u9a71\u52a8(PD)\u5c42\u5b9a\u76f8\u5e94\u786c\u4ef6\u5916\u8bbe\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u7ed3\u6784\u4f53\u6307\u9488\u6570\u7ec4\uff0c\u800c\u5728\u5916\u8bbe\u62bd\u8c61\u5c42(PAL)\u4e3a\u5176\u5b9a\u4e49\u5916\u8bbe\u9a71\u52a8\u5de5\u4f5c\u65f6\u4f7f\u7528\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53(\u5982\u679c\u5305\u542b\u591a\u4e2a\u76f8\u540c\u7684\u5916\u8bbe\u5b9e\u4f53(instance),\u6bd4\u5982LPUART0\/1\/2\u6216\u8005FlexCAN0\/1\/2\u5219\u4e3a\u7ed3\u6784\u4f53\u6570\u7ec4\uff0c\u6bcf\u4e2a\u6210\u5458\u5bf9\u5e94\u76f8\u5e94\u7684\u5916\u8bbe\u5b9e\u4f53)\uff1a<\/p>\n
<\/p>\n
\u6bd4\u5982S32K SDK\u4e2d\u5728LPUART\u7684\u5916\u8bbe\u9a71\u52a8\u5c42\u5b9a\u4e49\u5176\u5de5\u4f5c\u65f6\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u6307\u9488\u6570\u7ec4\uff1a<\/p>\n
<\/p>\n
\u800c\u5728\u5916\u8bbe\u62bd\u8c61\u5c42\u4e2d\uff0c\u624d\u5b9a\u4e49\u5176\u4f7f\u7528\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u6570\u7ec4\uff1a<\/p>\n
<\/p>\n
<\/p>\n
FlexCAN\/CAN_PAL\u7684\u9a71\u52a8\u4e5f\u662f\u5982\u6b64\uff1a<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
\u56e0\u6b64\uff0c\u5982\u679c\u4f7f\u7528PD\u5c42\u7ec4\u4ef6\uff0c\u7528\u6237\u8fd8\u9700\u7ec4\u4ef6\u5b9a\u4e49\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\uff0c\u800c\u4f7f\u7528PAL\u5c42\u7ec4\u4ef6\u65f6\uff0c\u5176\u5c06\u4f1a\u5b9a\u4e49\u8be5\u5916\u8bbe\u8981\u4f7f\u7528\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\uff0c\u65e0\u9700\u7528\u6237\u5b9a\u4e49\u3002<\/p>\n
S32 SDK\u7684LLD\u7ec4\u4ef6\u5916\u8bbe\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u5728SDK\u7ec4\u4ef6\u7684\u521d\u59cb\u5316API\u51fd\u6570\u4e2d\u88ab\u521d\u59cb\u5316\uff0c\u5e76\u4e0e\u5176\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u6307\u9488\u6570\u7ec4\u5173\u8054\u8d77\u6765\u3002\u6bd4\u5982\u5728S32K SDK\u7684LPUART\u9a71\u52a8\u4e2d\uff0c\u5176\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u5c31\u662f\u5176\u521d\u59cb\u5316\u51fd\u6570--LPUART_DRV_Init()\u4e2d\u5b8c\u6210\u521d\u59cb\u5316\u7684\uff1a<\/p>\n
<\/p>\n
\u5f53\u6267\u884c\u67d0\u4e00\u4e2aSDK\u7ec4\u4ef6\u7684\u53cd\u521d\u59cb\u5316\u51fd\u6570(Deinit)\u65f6\uff0c\u5176\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e5f\u5c06\u88ab\u6e05\u9664(\u6307\u5411\u7a7a\u6307\u9488NULL)\u3002\u6bd4\u5982\u5728S32K SDK\u7684LPUART\u9a71\u52a8\u4e2d\uff0c\u5176\u53cd\u521d\u59cb\u5316\u51fd\u6570--LPUART_DRV_Deinit()\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
<\/p>\n
\u6bcf\u4e00\u4e2a\u786c\u4ef6\u5916\u8bbe\u6a21\u5757\u5de5\u4f5c\u65f6\uff0c\u53ea\u80fd\u6709\u4e00\u4e2a\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e0e\u5176\u5bf9\u5e94\uff0c\u5176\u4f7f\u7528\u751f\u547d\u5468\u671f\u662f\u521d\u59cb\u5316\u5b8c\u6210(\u8c03\u7528SDK\u7ec4\u4ef6Init()\u51fd\u6570)\u5230\u53cd\u521d\u59cb\u5316\u51fd\u6570\u6267\u884c(\u8c03\u7528SDK\u7ec4\u4ef6Deinit()\u51fd\u6570)\u3002<\/p>\n
<\/p>\n
Tips\uff1a\u4f7f\u7528S32 SDK\u7684\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8(LLD)\u65f6\uff0c\u63a8\u8350\u5927\u5bb6\u4f7f\u7528PAL\u7ec4\u4ef6\uff0c\u800c\u4e0d\u662fPD\u7ec4\u4ef6\uff1b<\/p>\n
<\/p>\n
Tips\uff1a S32 SDK\u7684LLD\u7ec4\u4ef6\u5916\u8bbe\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e3a\u5b9a\u4e49\u5728MCU SARM\u9759\u6001\u533a(static)\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u5176\u5305\u542b\u5bf9\u5e94\u5916\u8bbe\u6a21\u5757\u7684\u5b8c\u6574\u5de5\u4f5c\u72b6\u6001\u4fe1\u606f\uff0c\u5e76\u5b9e\u65f6\u8bb0\u5f55\u5916\u8bbe\u7684\u5de5\u4f5c\u72b6\u6001\uff0c\u662f\u8c03\u8bd5LLD\u65f6\u6700\u4e3a\u91cd\u8981\u7684\u4e00\u4e2a\u4fe1\u606f\u6e90\uff0c\u5efa\u8bae\u5c06\u5176\u6dfb\u52a0\u5230\u53d8\u91cf\uff08variable\/expression\uff09\u7a97\u53e3\u67e5\u770b\u4ee5\u8ddf\u8e2a\u8c03\u8bd5\u95ee\u9898\u3002<\/p>\n
<\/p>\n
3. S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u4e2d\u65ad\u5904\u7406\u673a\u5236\u8be6\u89e3<\/p>\n
<\/p>\n
\u5728\u57fa\u4e8eMCU\u7684\u5d4c\u5165\u5f0f\u7cfb\u7edf\u8f6f\u4ef6\u5f00\u53d1\u4e2d\uff0c\u5916\u8bbe\u4e2d\u65ad\u662f\u4fdd\u8bc1\u7cfb\u7edf\u8f6f\u4ef6\u5de5\u4f5c\u5b9e\u65f6\u6027\u548c\u5185\u6838\u6548\u7387\u6700\u91cd\u8981\u7684\u5de5\u4f5c\u673a\u5236----\u5728\u5916\u8bbe\u4e8b\u4ef6(\u6bd4\u5982\u901a\u4fe1\u5916\u8bbe\u7684\u6570\u636e\u63a5\u6536\u5b8c\u6210\uff0cGPIO\u72b6\u6001\u6539\u53d8\u4ee5\u53ca\u5b9a\u65f6\u5468\u671f\u6ee1\u7b49)\uff0cCPU\u5185\u6838\u5c06\u505c\u6b62\u5f53\u524d\u7a0b\u5e8f\u6307\u4ee4\u7684\u6267\u884c\uff0c\u53ca\u65f6\u54cd\u5e94\u5916\u8bbe\u4e2d\u65ad\u8bf7\u6c42\u5e76\u505a\u76f8\u5e94\u7684\u5904\u7406(\u6bd4\u5982\u642c\u79fb\u6570\u636e\uff0c\u586b\u5145\u7f13\u51b2\uff0c\u6539\u53d8\u7a0b\u5e8f\u8fd0\u884c\u6761\u4ef6\/\u72b6\u6001\u3001\u6fc0\u6d3b\u65b0\u4efb\u52a1\u7b49)\u3002<\/p>\n
<\/p>\n
\u5728\u4f20\u7edf\u7684\u5d4c\u5165\u5f0fMCU\u5e95\u5c42\u5916\u8bbe\u9a71\u52a8\u7a0b\u5e8f\u5f00\u53d1\u4e2d\uff0c\u5bf9\u4e8e\u5916\u8bbe\u4e2d\u65ad\u7684\u5904\u7406\u6d41\u7a0b\/\u673a\u5236\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
\u2460 POR\u590d\u4f4d\u540e\uff0c\u5728main()\u51fd\u6570\u6700\u5f00\u59cb\u5b8c\u6210\u7cfb\u7edf\u65f6\u949f\u521d\u59cb\u5316\u540e\uff0c\u521d\u59cb\u5316\u5916\u8bbe\u6a21\u5757\u65f6\uff0c\u5c31\u914d\u7f6e\u4f7f\u80fd\u76f8\u5e94\u7684\u5916\u8bbe\u4e2d\u65ad\uff1b<\/p>\n
<\/p>\n
\u2461 \u7f16\u5199\u4e2d\u65ad\u670d\u52a1\u51fd\u6570ISR\uff0c\u5728\u5176\u4e2d\u5904\u7406\u4e2d\u65ad\u4e8b\u4ef6\uff0c\u7f6e\u4f4d\u5168\u5c40\u4e8b\u4ef6\u6807\u5fd7\u901a\u77e5\u5e94\u7528\u7a0b\u5e8f\u505a\u540e\u7eed\u5904\u7406\uff0c \u5e76\u6e05\u9664\u4e2d\u65ad\u6807\u5fd7\uff1b<\/p>\n
<\/p>\n
\u2462 \u5c06\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u653e\u5230MCU\u7684\u4e2d\u65ad\u5411\u91cf\u8868\u4e2d\uff0c\u8fd9\u4e00\u6b65\u53ef\u80fd\u662f\u901a\u8fc7\u5173\u952e\u8bcd(interrupt\uff09+\u4e2d\u65ad\u5411\u91cf\u53f7 + ISR\u5b9a\u4e49\u7684\u65b9\u5f0f\u5b9e\u73b0\uff0c\u5de5\u5177\u94fe\u7684\u7f16\u8bd1\u5668\u548c\u94fe\u63a5\u5668\u81ea\u52a8\u8bc6\u522b\u5e76\u52a0\u8f7d\u5230MCU\u4e2d\u65ad\u5411\u91cf\u8868\u4e2d\uff1b<\/p>\n
<\/p>\n
\u2463 \u4f7f\u80fd\u5168\u5c40\u4e2d\u65ad\uff1b<\/p>\n
<\/p>\n
\u5728\u6574\u4e2aMCU\u6b63\u5e38\u5de5\u4f5c\u671f\u95f4\uff0c\u9664\u975e\u7279\u6b8a\u5e94\u7528\u9700\u8981\uff0c\u4e0d\u4f1a\u5173\u5fc3\u5916\u8bbe\u4e2d\u65ad\u7684\u5173\u95ed\u4e0e\u4f7f\u80fd\uff0c<\/p>\n
<\/p>\n
\u800c\u5728S32 SDK\u4e2d\uff0c\u5176\u8fdb\u884c\u4e86\u5982\u4e0b\u4f18\u5316\uff1a<\/p>\n
<\/p>\n
\u2460\u5916\u8bbe\u521d\u59cb\u5316Init()\u51fd\u6570\u4e2d\uff0c\u4ec5\u4f7f\u80fd\u82af\u7247\u7ea7\u4e2d\u65ad\u63a7\u5236\u5668\u4e2d\u5bf9\u5e94\u7684\u4e2d\u65ad\u6e90(\u6bd4\u5982S32K\u7684ARM Cortex M\u7cfb\u5217\u5185\u6838\u7684NVIC\uff0c\u548cQorivva MPC57xx\/S32R\u7684PowerPC e200\u7cfb\u5217\u5185\u6838\u7684INTC\u6a21\u5757)\u5e76\u4e0d\u4f7f\u80fd\u76f8\u5e94\u5916\u8bbe\u7684IP\u7ea7\u4e2d\u65ad(\u6bd4\u5982LPUART\u7684TX\u548cRX\u4ee5\u53caERROR\u4e2d\u65ad)\uff1b<\/p>\n
<\/p>\n
\u5728\u5177\u4f53\u4f7f\u7528\u5916\u8bbe\u7684\u7279\u5b9a\u529f\u80fd(\u6bd4\u5982LPUART\u7684\u6570\u636e\u53d1\u9001\u548c\u63a5\u6536)\u65f6\uff0c\u624d\u4f7f\u80fd\u8be5\u7279\u5b9a\u529f\u80fd\u7684\u4e2d\u65ad(\u6bd4\u5982LPUART\u7684\u53d1\u9001\u4e2d\u65ad\u548c\u63a5\u6536\u4e2d\u65ad)\uff0c\u5728\u4e2d\u65ad\u53d1\u751f\u540e\uff0c\u82e5\u76f8\u5e94\u7684\u4e2d\u65ad\u5df2\u7ecf\u5b8c\u5168\u53d1\u751f(\u6bd4\u5982\u53d1\u900110\u5b57\u8282\u6570\u636e\uff0c\u5168\u90e8\u53d1\u9001\u5b8c\u6210)\uff0c\u5219\u5728ISR\u7684\u6700\u540e\u5173\u95ed\u8be5\u7279\u5b9a\u529f\u80fd\u4e2d\u65ad\uff1b<\/p>\n
<\/p>\n
\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\uff0c\u907f\u514d\u610f\u5916\u7684\u4e2d\u65ad\u6d6a\u8d39\u5b9d\u8d35\u7684CPU\u8d44\u6e90\uff0c\u6bd4\u5982\u7531\u4e8e\u7a0b\u5e8f\u8dd1\u98de\u5bfc\u81f4\u7684LPUART\u610f\u5916\u6570\u636e\u53d1\u9001\u548c\u63a5\u6536\uff1b<\/p>\n
<\/p>\n
\u2461 \u5728S32 SDK\u7684PD\u5c42\u4e3a\u7edd\u5927\u591a\u6570\u786c\u4ef6\u5916\u8bbe\u6a21\u5757\u63d0\u4f9b\u4e86\u4e2d\u65adISR\u51fd\u6570\uff0c(\u5bf9\u5e94S32K SDK\u6765\u8bf4\uff0c\u4ec5PD\u5c42\u7684LPIT\u7ec4\u4ef6\u548cGPIO\u7684IRQ\u4e2d\u65ad\uff0c\u9700\u8981\u7528\u6237\u81ea\u5df1\u4f7f\u80fdNVIC\u4e2d\u65ad\u5e76\u7f16\u5199\u81ea\u5df1\u7684\u4e2d\u65adISR)\u65e0\u9700\u7528\u6237\u81ea\u5df1\u7f16\u5199\uff1b<\/p>\n
<\/p>\n
\u5728S32 SDK\u7684\u7ec4\u4ef6\u4e2d\uff0c\u76f8\u540c\u5916\u8bbe\u7684\u4e0d\u540c\u5b9e\u4f53(\u6bd4\u5982LPUART0\/1\/2)\u5171\u7528\u540c\u4e00\u4e2a\u4e2d\u65adISR\uff0c\u4f9d\u9760\u5916\u8bbe\u5b9e\u4f53\u53f7(instance)\u6765\u533a\u5206\u4e0d\u540c\u7684\u5904\u7406\uff0c\u7531\u4e8e\u76f8\u540c\u5916\u8bbe\u7684\u5de5\u4f5c\u6d41\u7a0b\u548c\u4e2d\u65ad\u5904\u7406\u6d41\u7a0b\u76f8\u540c\uff0c\u8fd9\u6837\u7684\u597d\u5904\u662f\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u590d\u7528\u6548\u7387\uff1a<\/p>\n
\u5982\u4e0b\u662fS32K144\u7684SDK\u4ee3\u7801\uff0c\u5176\u6709LPUART0\/1\/2\u4e09\u4e2a\u4e32\u53e3\u5916\u8bbe\uff0c\u5176\u4e2d\u65adISR\u5b9a\u4e49\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
<\/p>\n
\u800c\u5728\u771f\u6b63\u7684LPUART\u4e2d\u65ad\u5904\u7406\u51fd\u6570\u4e2d\u4f9d\u9760\u4e0d\u540c\u7684instance\u6765\u533a\u522b\uff1a<\/p>\n
<\/p>\n
<\/p>\n
\u2462 S32 SDK\u9ed8\u8ba4\u5728startup\u8fc7\u7a0b\u4e2d\u5c06\u5916\u8bbe\u4e2d\u65ad\u5411\u91cf\u8868\u62f7\u8d1d\u5230SARM\u4e2d\uff0c\u8fd9\u6837\u8fd0\u884c\u7528\u6237\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u52a8\u6001\u7684\u4fee\u6539\u4e2d\u65adISR\uff1b<\/p>\n
<\/p>\n
\u2463 S32 SDK\u4e2d\u4e3a\u5927\u90e8\u5206\u5916\u8bbe\u90fd\u63d0\u4f9b\u4e86\u4e2d\u65ad\u5904\u7406\u51fd\u6570(ISR)\u2014\u4f4d\u4e8e\u5916\u8bbe\u9a71\u52a8PD\u7684\u4e2d\u65ad\u5904\u7406\u6587\u4ef6(<Peripheral_Name>_irq.c\/h)\u4e2d\uff0c\u5e76\u5728\u5916\u8bbe\u521d\u59cb\u5316\u65f6\u914d\u7f6e\u4e86\u76f8\u5e94\u7684\u4e2d\u65ad\uff0c\u5176\u5916\u8bbe\u4e2d\u65adISR\u5c5e\u4e8eSDK PD\u5c42\u9a71\u52a8\u975e\u5e38\u91cd\u8981\u7684\u4e00\u90e8\u5206\u4ee3\u7801\uff0c\u4e0d\u5141\u8bb8\u7528\u6237\u4fee\u6539\uff0c\u56e0\u6b64\u63d0\u4f9b\u4e86\u5728\u5916\u8bbe\u4e2d\u65adISR\u4e2d\u8c03\u7528\u7528\u6237\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u7684\u65b9\u5f0f\u7ed9\u7528\u6237\u63d0\u4f9b\u4e2d\u65ad\u5904\u7406\u63a5\u53e3\u3002<\/p>\n
<\/p>\n
Tips\uff1a\u5728\u7528\u6237\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u4e2d\uff0c\u65e0\u9700\u7528\u6237\u81ea\u5df1\u6e05\u9664\u5916\u8bbe\u4e2d\u65ad\u6807\u5fd7\uff0c\u56e0\u4e3a\u5728SDK\u63d0\u4f9b\u7684\u5916\u8bbe\u4e2d\u65adISR\u4e2d\u5df2\u7ecf\u505a\u4e86\u76f8\u5e94\u7684\u5904\u7406\u3002\u53ea\u6709\u9700\u8981\u7528\u6237\u8c03\u7528SDK\u4e2d\u65ad\u7ba1\u7406\u5668(interrupt_manager)\u7684API--INT_SYS_InstallHandler()\u624b\u52a8\u6ce8\u518c\u5b89\u88c5\u7684\u5916\u8bbe\u4e2d\u65adISR\uff0c\u624d\u9700\u8981\u7528\u6237\u81ea\u5df1\u6e05\u5916\u8bbe\u4e2d\u65ad\u6807\u5fd7\uff0c\u6bd4\u5982\u5178\u578b\u7684GPIO\u7684IRQ\u4e2d\u65ad\u548cPIT\u5b9a\u65f6\u5668\u4e2d\u65ad\u3002<\/p>\n
<\/p>\n
Tips\uff1a\u4f7f\u7528PD\u5c42\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\uff0c\u9700\u8981\u7528\u6237\u81ea\u5df1\u8c03\u7528\u4e2d\u65ad\u56de\u8c03\u51fd\u6570API\u81ea\u5df1\u5b89\u88c5\u4e2d\u65adCallback\uff1a<\/p>\n
<\/p>\n
<\/p>\n
\u800c\u82e5\u4f7f\u7528PAL\u5c42\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\uff0c\u5219\u53ef\u4ee5\u5728\u5176Processor Expert\u56fe\u5f62\u5316\u914d\u7f6e\u754c\u9762\u4e2d\u6dfb\u52a0\u4e2d\u65adCallback\u51fd\u6570\u540d\uff0c\u7136\u540e\u518d\u7528\u6237\u4ee3\u7801\u4e2d\u5b9e\u73b0\u8be5Callback\u5373\u53ef\uff0c\u65e0\u9700\u7528\u6237\u81ea\u5df1\u8c03\u7528\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u5b89\u88c5API\u3002<\/p>\n
<\/p>\n
<\/p>\n
4. S32 SDK\u7684\u901a\u4fe1\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6API\u51fd\u6570\u7684\u963b\u585e\u4e0e\u975e\u963b\u585e\u53d1\u9001\u4e0e\u63a5\u6536API\u51fd\u6570\u5dee\u522b\u4e0e\u4f7f\u7528\u8be6\u89e3\uff1b<\/p>\n
<\/p>\n
\u5728S32 SDK\uff0c\u901a\u4fe1\u5916\u8bbe\u7ec4\u4ef6\u90fd\u63d0\u4f9b\u4e86\u963b\u585e(Blocking)\u4e0e\u975e\u963b\u585e\u4e24\u7c7b\u53d1\u9001\u4e0e\u63a5\u6536API\u51fd\u6570\uff0c\u6bd4\u5982\uff1a<\/p>\n
<\/p>\n
UART_PAL\u7ec4\u4ef6\u7684API\u51fd\u6570\uff1a<\/p>\n
<\/p>\n
<\/p>\n
CAN_PAL\u7ec4\u4ef6\u7684API\u51fd\u6570\uff1a<\/p>\n
<\/p>\n
<\/p>\n
\u5176\u5dee\u522b\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
\u975e\u963b\u585e\u7c7b\u6570\u636e\u6536\u53d1API\uff0c\u53ea\u662f\u5c06\u8981\u53d1\u9001\u7684\u6570\u636ebuffer\u548c\u957f\u5ea6size\u8bbe\u7f6e\u5230\u5bf9\u5e94\u7684\u901a\u4fe1\u5916\u8bbe\u9a71\u52a8\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\uff0c\u4f7f\u80fd\u6570\u636e\u53d1\u9001\u5668(transmiter)\u548c\u63a5\u6536\u5668(receiver)\uff0c\u6253\u5f00\u6536\u53d1\u548c\u9519\u8bef\u4e2d\u65ad\/\u82e5\u4f7f\u7528DMA\u6536\u53d1\uff0c\u5219\u914d\u7f6e\u76f8\u5e94\u7684DMA\u901a\u9053TCD\uff0c\u4f7f\u80fdDMA\u4e2d\u65ad\uff0c\u5b89\u88c5\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\uff0c\u542f\u52a8DMA\u4f20\u8f93\uff0c \u7136\u540e\u5c31\u7acb\u5373\u8fd4\u56de\u4e86\uff0c\u56e0\u6b64\u975e\u963b\u585e\u7c7bAPI\u7684\u8fd4\u56de\u503c\u603b\u662f\u6210\u529f(STATUS_SUCCESS)\u3002<\/p>\n
<\/p>\n
\u6bd4\u5982S32K SDK\u7684LPUART\u975e\u963b\u585e\u53d1\u9001API--LPUART_DRV_SendData() \u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
<\/p>\n
\u800c\u963b\u585e(Blocking)\u7c7b\u6570\u636e\u6536\u53d1API\uff0c\u51fd\u6570\u53c2\u6570\u591a\u4e86\u4e00\u4e2a\u8d85\u65f6timeout(\u5355\u4f4d\u4e3ams)\u5219\u5728\u5b8c\u6210\u4ee5\u4e0a\u975e\u963b\u585eAPI\u7684\u5de5\u4f5c\u540e\uff0c\u8fd8\u4f1a\u8c03\u7528OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaWait()\u68c0\u67e5\u5916\u8bbe\u9a71\u52a8\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u7684\u6570\u636e\u6536\u53d1\u4fe1\u53f7\u91cf(semaphore)\uff0c\u7b49\u5f85\u6570\u636e\u6536\u53d1\u5b8c\u6210\uff0c\u82e5\u5728\u8bbe\u7f6e\u7684timeout\u65f6\u95f4\u5185\u672a\u5b8c\u6210\u6570\u636e\u4f20\u8f93\uff0c\u5219\u8fd4\u56de\u8d85\u65f6(STATUS_TIMEOUT)\uff0c\u82e5\u5728timeout\u65f6\u95f4\u5185\u6570\u636e\u6536\u53d1\u5b8c\u6210\uff0c\u5219\u8fd4\u56de\u6210\u529f(STATUS_SUCCESS)\u3002<\/p>\n
<\/p>\n
\u6bd4\u5982S32K SDK\u7684LPUART\u963b\u585e(blocking)\u53d1\u9001API--LPUART_DRV_SendDataBlocking()\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
<\/p>\n
Tips\uff1a\u7ed3\u5408\u524d\u9762S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u4e2d\u65ad\u5904\u7406\u673a\u5236\u7684\u4ecb\u7ecd\u53ef\u77e5\uff0c\u65e0\u8bba\u8c03\u7528\u963b\u585e\u51fd\u6570\u975e\u963b\u585e\u6570\u636e\u6536\u53d1\u51fd\u6570\uff0c\u5728\u6210\u529f\u63a5\u6536\u5b8c\u6307\u5b9a\u957f\u5ea6\u7684\u6570\u636e\u540e\uff0c\u90fd\u4f1a\u5c06\u901a\u4fe1\u5916\u8bbe\u7684\u63a5\u6536\u5668\u5173\u95ed\uff0c\u82e5\u60f3\u901a\u4fe1\u5916\u8bbe\u4e00\u76f4\u63a5\u6536\u6570\u636e\uff0c\u5219\u9700\u8981\u5728\u8be5\u9a71\u52a8\u7ec4\u4ef6\u7684\u4e2d\u65ad\u56de\u8c03\u51fd\u6570Callback\u4e2d\uff0c\u8bbe\u7f6e\u65b0\u7684\u6570\u636e\u63a5\u6536buffer\uff0c\u4ece\u800c\u907f\u514d\u5728\u4e2d\u65adISR\u6700\u540e\uff0c\u9a71\u52a8\u7a0b\u5e8f\u5173\u95ed\u6570\u636e\u63a5\u6536\u5668\uff1a<\/p>\n
<\/p>\n
\u6bd4\u5982\u4f7f\u7528S32K\u7684LPUART\u63a5\u6536GPS\u6570\u636e\u65f6\uff0c\u76f8\u5e94\u7684\u6570\u636e\u63a5\u6536\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u5b9a\u4e49\u5982\u4e0b\uff0c\u5176\u4e2d\u4f7f\u7528\u53ccbuffer\uff0c\u5728\u4e00\u4e2abuffer\u63a5\u6536\u5b8c\u6210\u540e\uff0c\u8c03\u7528UART_SetRxBuffer()\u5207\u6362\u65b0\u7684buffer\u7ee7\u7eed\u63a5\u6536\u6570\u636e\uff1a<\/p>\n
<\/p>\n
<\/p>\n
Tips\uff1a\u7531\u4e8e\u5728\u963b\u585eAPI\u51fd\u6570\u4e2d\uff0c\u8c03\u7528\u4e86OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaWait()\u68c0\u67e5\u5916\u8bbe\u9a71\u52a8\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u7684\u6570\u636e\u6536\u53d1\u4fe1\u53f7\u91cf(semaphore)\uff0c \u82e5\u5728\u5e94\u7528\u5de5\u7a0b\u4e2d\u4f7f\u7528\u4e86RTOS\uff0c\u6bd4\u5982FreeRTOS\uff0c\u5219\u8c03\u7528\u8be5\u963b\u585eAPI\u51fd\u6570\u7684\u4efb\u52a1\u5c06\u88ab\u963b\u585e\uff0c\u8ba9\u51faCPU\u8d44\u6e90\u8fd0\u884c\u5176\u4ed6\u5c31\u7eea\u7684\u9ad8\u4f18\u5148\u7ea7\u8ba4\u4e3a\uff0c\u76f4\u81f3\u6536\u636e\u6536\u53d1\u5b8c\u6210(\u4fe1\u53f7\u91cf\u91ca\u653e)\u6216\u8005\u8d85\u65f6\uff0c\u8fd9\u6837CPU\u7684\u6267\u884c\u6548\u7387\u5c06\u5927\u5927\u63d0\u9ad8\uff1b\u800c\u82e5\u5e94\u7528\u5de5\u7a0b\u4e2d\u6ca1\u6709\u4f7f\u7528RTOS\uff0c\u5219\u963b\u585eAPI\u51fd\u6570\u5c06\u4e00\u76f4\u5360\u6709CPU\uff0c\u9020\u6210CPU\u8d44\u6e90\u6d6a\u8d39\uff1b<\/p>\n
\u7efc\u4e0a\uff0c \u82e5\u5e94\u7528\u5de5\u7a0b\u4f7f\u7528\u4e86RTOS\uff0c\u5219\u63a8\u8350\u4f7f\u7528\u963b\u585eAPI\u51fd\u6570\uff1b\u82e5\u5e94\u7528\u5de5\u7a0b\u672a\u4f7f\u7528RTOS\uff0c\u5219\u63a8\u8350\u4f7f\u7528\u975e\u963b\u585eAPI\u51fd\u6570\uff0c\u5e76\u914d\u5408\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\uff0c\u5224\u65ad\u6570\u636e\u6536\u53d1\u72b6\u6001\u5e76\u505a\u76f8\u5e94\u5904\u7406\u3002<\/p>\n
<\/p>\n
5. S32 SDK\u7684\u5916\u8bbe\u9a71\u52a8\u4e0eRTOS\u4e4b\u95f4\u7684\u4ea4\u4e92\u65b9\u5f0f<\/p>\n
<\/p>\n
\u5728S32 SDK\u4e2d\uff0c\u6240\u6709\u7684\u5916\u8bbe\u9a71\u52a8(PD\u548cPAL\u7ec4\u4ef6)\u4ee5\u53ca\u4e2d\u95f4\u4ef6(Middleware)\u7684\u8f6f\u4ef6\u4ee3\u7801\u5b9e\u73b0\uff0c\u90fd\u4f7f\u7528\u4e86OSIF<\/strong>\u7ec4\u4ef6\u63d0\u4f9b\u7684\u64cd\u4f5c\u7cfb\u7edf\u63a5\u53e3API\u5bf9\u5916\u8bbe\u9a71\u52a8\u5de5\u4f5c\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u540c\u6b65\u548c\u4e8b\u4ef6\u65f6\u95f4\u5ef6\u8fdf\uff0c\u4ece\u800c\u4fdd\u8bc1\u4e86S32 SDK\u4ee3\u7801\u5728\u4e0d\u540cRTOS\u4e4b\u95f4\u7684\u517c\u5bb9\uff1a<\/p>\n <\/p>\n \u5176\u4e2d\u4f7f\u7528\u7684\u4fe1\u53f7\u91cf\u90fd\u5728\u76f8\u5e94\u7684\u7ec4\u4ef6\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u5b9a\u4e49\uff0c\u5728\u7ec4\u4ef6\u521d\u59cb\u5316(\u7ec4\u4ef6_Init()\u51fd\u6570)\u65f6\uff0c\u8c03\u7528\u4e86OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaCreate()\u521b\u5efa\uff0c\u6bd4\u5982S32K SDK\u7684LPUART\u9a71\u52a8\u7528\u4e8e\u6570\u636e\u6536\u53d1\u7684\u4fe1\u53f7\u91cfrxComplete\/txComplete\uff0c\u5c31\u5728\u5176\u521d\u59cb\u5316\u51fd\u6570LPUART_DRV_Init()\u4e2d\u521b\u5efa\u7684\uff1a<\/p>\n <\/p>\n \u5728\u7ec4\u4ef6\u7684\u963b\u585e(Blocking)API\u51fd\u6570\u4e2d\u8c03\u7528OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaWait()\u68c0\u67e5\u5916\u8bbe\u9a71\u52a8\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u5b9a\u4e49\u7684\u4fe1\u53f7\u91cf(semaphore)\u4ee5\u5b8c\u6210\u4e8b\u4ef6\u540c\u6b65\u3002\u6bd4\u5982S32K SDK\u7684LPUART\u9a71\u52a8\u4e2d\u6570\u636e\u53d1\u9001\u5b8c\u6210\u4fe1\u53f7\u91cftxComplete\uff0c\u5c31\u5728\u5176\u963b\u585e\u6570\u636e\u53d1\u9001API\u51fd\u6570LPUART_SendDataBlocking()\u4e2d\u4f7f\u7528\u7684\uff1a<\/p>\n <\/p>\n \u5728\u7ec4\u4ef6\u53cd\u521d\u59cb\u5316(\u7ec4\u4ef6_Deinit()\u51fd\u6570)\u65f6\uff0c\u8c03\u7528\u8c03\u7528\u4e86OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaDestroy()\u91ca\u653e\u3002\u6bd4\u5982S32K SDK\u7684LPUART\u9a71\u52a8\u7528\u4e8e\u6570\u636e\u6536\u53d1\u7684\u4fe1\u53f7\u91cfrxComplete\/txComplete\uff0c\u5c31\u5728\u5176\u53cd\u521d\u59cb\u5316\u51fd\u6570LPUART_DRV_Deinit()\u4e2d\u88ab\u9500\u6bc1\u7684\uff1a<\/p>\n <\/p>\n \u4ece\u4ee5\u4e0a\u5206\u6790\u53ef\u77e5\uff0c\u901a\u8fc7\u5728SDK\u7ec4\u4ef6\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u5f15\u5165\u4fe1\u53f7\u91cf(Mutex\/Semaphore)\u548c\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u63a5\u53e3OSIF\u7ec4\u4ef6API\uff0c\u65e2\u4fdd\u8bc1\u4e86S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u7a0b\u5e8f\u548c\u4e2d\u95f4\u4ef6\u8f6f\u4ef6\u5de5\u4f5c\u7684\u540c\u6b65\u548c\u6548\u7387\uff0c\u53c8\u63d0\u9ad8\u4e86SDK\u8f6f\u4ef6\u4ee3\u7801\u7684\u5728\u4e0d\u540cRTOS\u4e4b\u95f4\u7684\u53ef\u79fb\u690d\u6027\uff0c\u4f7f\u7528\u4e0d\u540cRTOS\u65f6\uff0c\u53ea\u9700\u8981\u5173\u5fc3\u548c\u79fb\u690dOSIF\u7ec4\u4ef6\u63d0\u4f9b\u7684API\u51fd\u6570\uff0c\u5373\u53ef\u4fdd\u8bc1S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u548c\u4e2d\u95f4\u4ef6\u8f6f\u4ef6\u4ee3\u7801\u5728\u8be5RTOS\u4e2d\u7684\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n <\/p>\n \u603b\u7ed3<\/p>\n <\/p>\n \u867d\u7136\u6211\u5df2\u7ecf\u529b\u6c42\u5c3d\u91cf\u628a\u5b83\u5199\u7684\u6df1\u5165\u6d45\u51fa\uff0c\u901a\u4fd7\u6613\u61c2\uff0c\u9605\u8bfb\u672c\u6587\u4ecb\u7ecd\u7684\u77e5\u8bc6\u8981\u70b9\u4ecd\u7136\u9700\u8981\u4e00\u5b9a\u7684\u7f16\u7a0b\u57fa\u7840\u548c\u5d4c\u5165\u5f0f\u5e95\u5c42\u9a71\u52a8\u7a0b\u5e8f\u5f00\u53d1\u7ecf\u9a8c\u79ef\u7d2f\uff0c\u6216\u8005\u4f7f\u7528\u8fc7\u4e00\u6bb5\u65f6\u95f4\u7684S32 SDK\u8f6f\u4ef6\u3002\u4e0d\u8fc7\u6ca1\u5173\u7cfb\uff0c\u5728\u540e\u7eed\u7684\u300aS32K SDK\u4f7f\u7528\u8be6\u89e3<\/strong>\u300b\u7cfb\u5217\u6280\u672f\u5206\u4eab\u6587\u7ae0\u4e2d\uff0c\u6211\u8fd8\u5c06\u7ed3\u5408S32K1xx\u7cfb\u5217MCU\u7684\u5185\u6838\u548c\u5916\u8bbe\u529f\u80fd\u7279\u6027\uff0c\u4e3a\u5927\u5bb6\u5e26\u6765\u66f4\u591a\u7684S32 SDK\u4f7f\u7528\u7ec6\u8282\u5206\u89e3\uff0c\u5e0c\u671b\u5927\u5bb6\u53ef\u4ee5\u6301\u7eed\u5173\u6ce8\u548c\u5b66\u4e60\u3002<\/p>\n \u5185\u5bb9\u63d0\u8981<\/p>\n <\/p>\n \u5f15\u8a00<\/p>\n 1. S32 SDK\u7684\u8f6f\u4ef6\u5206\u5c42\u67b6\u6784\u4ecb\u7ecd<\/p>\n 1.1 \u5916\u8bbe\u9a71\u52a8\u5c42(PD--Periperal Driver)<\/p>\n 1.2 \u5916\u8bbe\u62bd\u8c61\u5c42(PAL--Peripheral Abstract Layer)<\/p>\n 1.3 \u4e2d\u95f4\u4ef6\u5c42(Middleware)<\/p>\n 1.4 \u5b9e\u65f6\u64cd\u4f5c\u7cfb\u7edf\u5c42(RTOS)<\/p>\n 1.5 S32 SDK\u5e95\u5c42\u9a71\u52a8\u8f6f\u4ef6\u5206\u5c42\u7684\u4f18\u70b9<\/p>\n 2. S32 SDK\u7684\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u89e3\u6790<\/p>\n 3. S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u4e2d\u65ad\u5904\u7406\u673a\u5236\u8be6\u89e3<\/p>\n 4. S32 SDK\u7684\u901a\u4fe1\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6API\u51fd\u6570\u7684\u963b\u585e\u4e0e\u975e\u963b\u585e\u53d1\u9001\u4e0e\u63a5\u6536API\u51fd\u6570\u5dee\u522b\u4e0e\u4f7f\u7528\u8be6\u89e3\uff1b<\/p>\n 5. S32 SDK\u7684\u5916\u8bbe\u9a71\u52a8\u4e0eRTOS\u4e4b\u95f4\u7684\u4ea4\u4e92\u65b9\u5f0f<\/p>\n \u603b\u7ed3<\/p>\n <\/p>\n \u5f15\u8a00<\/p>\n <\/p>\n S32 SDK(Software Development Kit\uff0c\u8f6f\u4ef6\u5f00\u53d1\u5957\u4ef6)\u501f\u9274\u4e86AutoSAR\u8f6f\u4ef6\u548cARM Cortext M\u7cfb\u5217MCU\u8f6f\u4ef6\u63a5\u53e3\u6807\u51c6(CMSIS--Cortex Microcontroller Software Interface Standard)\u7684\u7f16\u7a0b\u601d\u60f3\uff0c\u901a\u8fc7\u5bf9\u5185\u6838\u548c\u5e95\u5c42\u5916\u8bbe\u786c\u4ef6\u9a71\u52a8\u7684\u62bd\u8c61\u5316\uff0c\u5bf9\u5e94\u7528\u5c42\u63d0\u4f9b\u7edf\u4e00\u7684API\uff0c\u4e0d\u4f46\u5927\u5e45\u5ea6\u5730\u964d\u4f4e\u4e86MCU\u7528\u6237\u7684\u8f6f\u4ef6\u5f00\u53d1\u96be\u5ea6\u548c\u7f16\u7a0b\u95e8\u69db\uff0c\u540c\u65f6\u4e5f\u5927\u5927\u63d0\u9ad8\u4ee3\u7801\u7684\u91cd\u7528\u7387\u548c\u53ef\u79fb\u690d\u6027\u53ca\u53ef\u8bfb\u6027\u3002\u4f7f\u5f97\u57fa\u4e8eMCU\u7684\u5d4c\u5165\u5f0f\u8f6f\u4ef6\u7f16\u7a0b\u53d8\u5f97\u66f4\u52a0\u5bb9\u6613\u3002<\/p>\n <\/p>\n \u7136\u800c\uff0c\u76f8\u8f83\u4e8e\u4f7f\u7528\u4f20\u7edfMCU--\u6bd4\u598251\u5355\u7247\u673a\u3001S08\u548cS12(X) MCU\u7684\u5e95\u5c42\u8f6f\u4ef6\u5f00\u53d1\uff0c S32 SDK\u7684\u8f6f\u4ef6\u7f16\u7a0b\u6a21\u5f0f\u548c\u7f16\u7a0b\u601d\u60f3\u53d1\u751f\u4e86\u5f88\u5927\u7684\u53d8\u5316\uff0c \u4ee5\u9002\u5e94\u65e5\u76ca\u590d\u6742\u7684MCU\u5185\u6838\u548c\u5916\u8bbe\u8d44\u6e90\u3002\u5982\u679c\u4e4b\u524d\u6ca1\u6709\u63a5\u89e6\u8fc7\u7cfb\u7edf\u7684\u8f6f\u4ef6\u67b6\u6784\u548c\u8f6f\u4ef6\u7f16\u7a0b\u601d\u60f3\u77e5\u8bc6\u4f53\u7cfb\u7684\u5b66\u4e60\uff0c\u4e5f\u672a\u4f7f\u7528\u8fc7AutoSAR \u8f6f\u4ef6\u548cCMSIS\u5e93\uff0c\u5219\u5728\u4f7f\u7528S32 SDK\u65f6\uff0c\u5c06\u4f1a\u53d1\u73b0\u5f88\u591a\u56f0\u60d1\uff0c\u4e0d\u77e5\u9053\u5982\u4f55\u5728\u5e94\u7528\u5c42\u9ad8\u6548\u5730\u8c03\u7528SDK\u7684API\u3001\u5982\u4f55\u901a\u8fc7\u4e8b\u4ef6\u901a\u77e5(Event Notification)\u4e0e\u5e95\u5c42\u9a71\u52a8\u8fdb\u884c\u4ea4\u4e92\uff0c\u4ee5\u53ca\u5982\u4f55\u5728\u4f7f\u7528RTOS\u7684\u7cfb\u7edf\u4e2d\u8c03\u7528SDK\u63d0\u4f9b\u7684\u5e95\u5c42\u9a71\u52a8API\u7b49\uff1f<\/p>\n <\/p>\n \u9274\u4e8e\u6b64\uff0c\u672c\u6587\u5c06\u4ee5S32K SDK\u4e3a\u4f8b\uff0c\u8be6\u7ec6\u4ecb\u7ecdS32 SDK\u7684\u8f6f\u4ef6\u7f16\u7a0b\u601d\u60f3\uff0c\u4ee5\u4e3a\u5927\u5bb6\u89e3\u5f00\u4ee5\u4e0a\u7591\u60d1\uff0c\u5e2e\u52a9\u5927\u5bb6\u66f4\u597d\u7684\u4f7f\u7528S32 SDK\u5e76\u771f\u6b63\u7406\u89e3\u5176\u7f16\u7a0b\u4f18\u52bf\u3002<\/p>\n <\/p>\n 1. S32 SDK\u7684\u8f6f\u4ef6\u5206\u5c42\u67b6\u6784\u4ecb\u7ecd<\/p>\n <\/p>\n <\/p>\n S32 SDK\u7684\u8f6f\u4ef6\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u4ece\u4e0a\u4e00\u7bc7\u6587\u7ae0--\u300aS32K SDK\u4f7f\u7528\u8be6\u89e3\u4e4bS32 SDK\u8f6f\u4ef6\u67b6\u6784\u8be6\u89e3\u300b\u89e3\u8bfb\u4e2d(\u70b9\u51fb\u6587\u7ae0\u6807\u9898\u5373\u53ef\u5feb\u901f\u8df3\u8f6c\u9605\u8bfb)\uff0c<\/p>\n \u53ef\u4ee5\u770b\u5230S32 SDK\u9664\u4e86\u63d0\u4f9b\u5e95\u5c42\u9a71\u52a8(LLD--Low Level Drivers)\u548c\u4e2d\u95f4\u4ef6(Middleware)\u4e4b\u5916\uff0c\u8fd8\u63d0\u4f9b\u4e86\u4e0d\u540c\u5de5\u5177\u94fe\u7f16\u8bd1\u5668\u7684\u542f\u52a8(Start-up)\u548c\u94fe\u63a5\u6587\u4ef6(Linker filers) \uff0c\u79fb\u690d\u597d\u7684FreeRTOS\u548cRTOS\u63a5\u53e3\u5c42(OSIF)\u4ee5\u53ca\u5904\u7406\u5668\u4e13\u5bb6(Processor Expert)\u914d\u7f6eGUI\u548c\u4e30\u5bcc\u7684demo\u7a0b\u5e8f\u548c\u8be6\u7ec6\u7684\u5e2e\u52a9\u6587\u6863\uff1a<\/p>\n <\/p>\n <\/p>\n \u5177\u4f53\u6765\u770b\uff0cS32 SDK\u7684\u8f6f\u4ef6\u5206\u5c42\u60c5\u51b5\u5982\u4e0b\uff1a<\/p>\n <\/p>\n 1.1 \u5916\u8bbe\u9a71\u52a8\u5c42(PD--Periperal Driver)<\/p>\n <\/p>\n PD\u5c42\u7ec4\u4ef6\u901a\u8fc7\u8c03\u7528\u5bf9\u5916\u8bbe\u5bc4\u5b58\u5668\u64cd\u4f5c\u7684\u786c\u4ef6\u8bbf\u95ee\u5c42(Hardware Access)API(\u4e00\u822c\u4e3a\u5b8f\u5b9a\u4e49\u6216\u8005inline\u51fd\u6570\uff0c\u4e14\u4e3a\u9759\u6001static\u4ee3\u7801\uff0c\u4ec5PD\u5c42\u6587\u4ef6\u5185\u90e8\u4f7f\u7528)\uff0c\u8bfb\u5199\u4e0d\u540cS32\u7cfb\u5217MCU\u5e95\u5c42\u786c\u4ef6\u5916\u8bbeIP\u6a21\u5757\u5bc4\u5b58\u5668\uff0c\u4ece\u800c\u5b8c\u6210\u5bf9\u5916\u8bbe\u7684\u521d\u59cb\u5316\u914d\u7f6e\u3001\u72b6\u6001\u8bfb\u53d6--\u5373\u786c\u4ef6\u4ea4\u4e92\uff1b<\/p>\n <\/p>\n \u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u6839\u636e\u4e0d\u540c\u7684\u5916\u8bbe\u6a21\u5757\u529f\u80fd\u7279\u6027\uff0c\u7f16\u5199\u76f8\u5e94\u7684\u521d\u59cb\u5316\u51fd\u6570\u3001\u529f\u80fd\u914d\u7f6e\/\u4f7f\u7528\u51fd\u6570\u4ee5\u53ca\u4e2d\u65ad\u5904\u7406\u51fd\u6570(ISR)\uff0c\u4ece\u800c\u6784\u6210\u5b8c\u6210\u7684\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u3002\u8fd9\u91cc\u9762\u5305\u542b\u4e86\u5f88\u591a\u5916\u8bbe\u521d\u59cb\u5316\u914d\u7f6e\u7684\u65f6\u5e8f\/\u987a\u5e8f\u8981\u6c42(\u914d\u7f6e\u5916\u8bbe\u7684initialization\u72b6\u6001\u3001Freeze\u72b6\u6001\u3001STOP\u3001Standby\/Shutdown\u4ee5\u53canomal work\u72b6\u6001)\u548c\u7279\u5b9a\u5bc4\u5b58\u5668\u7684\u64cd\u4f5c\u6743\u9650\u7ba1\u7406(\u6bd4\u5982\u7ba1\u7406\u5458\u6a21\u5f0f\u8fd8\u662f\u7528\u6237\u6a21\u5f0f\u53ef\u4ee5\u8bfb\u5199\u6743\u9650)\u3001\u548c\u5bc4\u5b58\u5668\u64cd\u4f5c\u65b9\u5f0f\u63a7\u5236(\u6bd4\u5982\u6e05\u9664\u5916\u8bbe\u4e2d\u65ad\u6807\u5fd7\u7684\u65b9\u6cd5\u662f\u51991\u6e05\u96f6\u8fd8\u662f\u8bfb\u6e05\u96f6)\u7b49\u3002<\/p>\n <\/p>\n Tips\uff1a S32 SDK\u7684PD\u5c42\u5305\u542b\u4e86\u6240\u652f\u6301MCU\u7684\u51e0\u4e4e\u6240\u6709\u7247\u4e0a\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\uff0c\u7531\u4e8e\u5176\u4ee3\u7801\u76f4\u63a5\u64cd\u4f5c\u5916\u8bbeIP\u5bc4\u5b58\u5668\uff0c\u6240\u4ee5\u5176\u6548\u7387\u662f\u6700\u9ad8\u7684\uff0c\u4f46\u4e0d\u80fd\u5b9e\u73b0\u8de8MCU\u5e73\u53f0\/\u7cfb\u5217\u4f7f\u7528\u3002 \u5982\u4e0b\u4e3aS32K SDK\u7684PD\u5c42\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u5217\u8868\uff1a<\/p>\n <\/p>\n <\/p>\n <\/p>\n 1.2 \u5916\u8bbe\u62bd\u8c61\u5c42(PAL--Peripheral Abstract Layer)<\/p>\n <\/p>\n \u5728PD\u5c42\u7684\u57fa\u7840\u4e0a\uff0c S32 SDK\u5c01\u88c5\u4e86\u4e00\u4e2a\u5916\u8bbe\u62bd\u8c61\u5c42\uff0c\u5c06\u80fd\u591f\u5b9e\u73b0\u76f8\u540c\u529f\u80fd\u7684\u5916\u8bbePD\u7ec4\u4ef6\u5c01\u88c5\u4e3a\u4e00\u4e2aPAL\u529f\u80fd\u7ec4\u4ef6\uff0c\u6bd4\u5982\u5b9e\u73b0UART\u4e32\u884c\u901a\u4fe1\u7684\u5916\u8bbe\uff0c\u5728S32K1xx\u7cfb\u5217\u4e0a\u786c\u4ef6\u5916\u8bbe\u4e3aLPUART\uff0c\u5728Qorivva MPC57xx\u548cS32V234\u4e0a\u5219\u662fLINFlex\uff0c\u5728PAL\u5c31\u62bd\u8c61\u4e86\u4e00\u4e2aUART_PAL\uff0c\u5bf9\u5e94\u7528\u5c42\u63d0\u4f9b\u7edf\u4e00\u7684API\u51fd\u6570\uff0c\u4ece\u800c\u5bf9\u5e94\u7528\u5c42\u8f6f\u4ef6\u5f00\u53d1\u4eba\u5458\u5c4f\u853d\u4e86\u5e95\u5c42\u786c\u4ef6\u5916\u8bbe\u7684\u5dee\u522b\uff1a<\/p>\n <\/p>\n <\/p>\n Tips\uff1a \u4f7f\u7528S32 SDK\u7684PAL\u5c42\u80fd\u591f\u5b9e\u73b0\u4ee3\u7801\u7684\u8de8\u5e73\u53f0\u79fb\u690d\u548c\u4f7f\u7528\uff0c\u5178\u578b\u7684PAL\u7ec4\u4ef6\u5305\u62ecCAN\u3001UART\u3001I2C\u3001SPI\u548cI2C\u7b49\u901a\u4fe1\u529f\u80fd\u5916\u8bbe\u6a21\u5757\uff0cPWM\u3001OC\u53caTIMING\u7b49\u5b9a\u65f6\u5668\u529f\u80fd\u6a21\u5757\uff0c\u4ee5\u53caMPU\/MMU\u5b58\u50a8\u5668\u4fdd\u62a4\/\u7ba1\u7406\u529f\u80fd\u6a21\u5757\u4ee5\u53ca\u770b\u95e8\u72d7\u548c\u4fe1\u606f\u5b89\u5168\u7b49\u7cfb\u7edf\u7ea7\u529f\u80fd\u6a21\u5757\u3002 \u5982\u4e0b\u4e3aS32K SDK\u7684PD\u5c42\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u5217\u8868\uff1a<\/p>\n <\/p>\n <\/p>\n 1.3 \u4e2d\u95f4\u4ef6\u5c42(Middleware)<\/p>\n <\/p>\n S32 SDK\u7684\u4e2d\u95f4\u4ef6\u4e3b\u8981\u5305\u62ec\u4e09\u5927\u7c7b\uff1a\u2460\u529f\u80fd\u9759\u6001\u5e93--\u6bd4\u5982\u7535\u673a\u63a7\u5236\u5e93(AMMCLib)\u3001\u89e6\u63a7\u611f\u5e94\u5e93(Touch Sensing)\u7b49\u548c\u2461\u8f6f\u4ef6\u534f\u8bae\u6808(stack)--\u6bd4\u5982\u4ee5\u592a\u7f51\u534f\u8bae\u6808(TCP\/IP)\u3001LIN\u534f\u8bae\u6808\u548cUSB\u53ca\u6587\u4ef6\u7cfb\u7edf\u7b49\uff0c\u4ee5\u53ca\u2462 \u590d\u6742\u5916\u56f4\u82af\u7247\u9a71\u52a8\u7a0b\u5e8f--\u6bd4\u5982SBC(UJA1169\u548cUJA113x)\u7cfb\u5217\u9a71\u52a8\u7a0b\u5e8f\u3002<\/p>\n <\/p>\n Tips\uff1a \u5982\u4e0b\u4e3aS32K SDK\u7684Middleware\u7ec4\u4ef6\u5217\u8868\uff0c\u5176\u4e2dTouch Sense\uff0c ISELED\u548cNFC Middleware\u9700\u8981\u8054\u7cfbNXP Sale\/FAE\u7533\u8bf7license\uff0c\u5728\u5b89\u88c5\u76f8\u5e94\u7684SDK\u7248\u672c\u4e4b\u540e\u5355\u72ec\u4e0b\u8f7d\u5b89\u88c5\uff1a<\/p>\n <\/p>\n <\/p>\n 1.4 \u5b9e\u65f6\u64cd\u4f5c\u7cfb\u7edf\u5c42(RTOS)<\/p>\n <\/p>\n \u4e3a\u4e86\u7ba1\u7406\u4f17\u591a\u7684MCU\u5916\u8bbe\u8d44\u6e90\u548c\u5b58\u50a8\u5668\u8d44\u6e90\u5e76\u8fdb\u884c\u5b9e\u65f6\u7684\u5e94\u7528\u7a0b\u5e8f\u4efb\u52a1\u8c03\u5ea6\uff0c\u5728S32 SDK\u4e2d\u8fd8\u79fb\u690d\u4e86\u5b9e\u65f6\u64cd\u4f5c\u7cfb\u7edf--FreeRTOS\uff0c\u5e76\u672a\u88f8\u5199\u4ee3\u7801\u63d0\u4f9b\u4e86\u64cd\u4f5c\u7cfb\u7edf\u63a5\u53e3\u670d\u52a1(Osif\u7ec4\u4ef6)\u3002<\/p>\n <\/p>\n Tips\uff1a \u5982\u4e0b\u4e3aS32K SDK\u7684\u63d0\u4f9b\u7684FreeRTOS\uff0c\u5728S32K SDK RTM 2.0.0\u4e2d\u662fFreeRTOS\u7684\u7248\u672c\u4e3av8.2.1\uff0c\u5728\u6700\u65b0\u7684Beta 2.9.0(\u53ca\u66f4\u9ad8\u7248\u672c)\u4e2d\u5df2\u7ecfupdate\u5230FreeRTOS v10.0.1\u4e86\u3002<\/p>\n <\/p>\n <\/p>\n 1.5 S32 SDK\u5e95\u5c42\u9a71\u52a8\u8f6f\u4ef6\u5206\u5c42\u7684\u4f18\u70b9<\/p>\n <\/p>\n \u7efc\u4e0a\u6240\u8ff0\uff0cS32 SDK\u63d0\u4f9b\u7684\u5e95\u5c42\u5916\u8bbe\u9a71\u52a8\u5206\u5c42\uff0c\u5177\u6709\u5982\u4e0b\u4f18\u70b9\uff1a<\/p>\n <\/p>\n \u2460 \u5206\u5c42\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff1b<\/p>\n <\/p>\n \u2461 \u4f7f\u7528PD\u5c42\uff0c\u5bf9\u4fdd\u8bc1\u5bf9\u5916\u8bbe\u6a21\u5757\u7684\u64cd\u4f5c\u5b9e\u65f6\u6027\u548c\u4ee3\u7801\u8fd0\u884c\u6548\u7387\uff1b<\/p>\n <\/p>\n \u2462 \u901a\u8fc7PAL\u5c42\u5bf9\u5e95\u5c42\u786c\u4ef6\u5916\u8bbe\u7684\u62bd\u8c61\uff0c\u5bf9\u5e94\u7528\u5c42\u63d0\u4f9b\u4e86\u7edf\u4e00\u7684API\uff0c\u4fdd\u8bc1\u4e86\u5e95\u5c42\u9a71\u52a8\u4ee3\u7801\u5728\u4e0d\u540cS32 MCU\u786c\u4ef6\u5e73\u53f0\u4e0a\u7684\u901a\u7528\u6027\uff0c\u63d0\u9ad8\u4e86\u5e95\u5c42\u9a71\u52a8\u4ee3\u7801\u7684\u53ef\u79fb\u690d\u6027\u548c\u4f7f\u7528\u6548\u7387\uff1b<\/p>\n <\/p>\n \u2463 \u96c6\u6210\u4e30\u5bcc\u7684\u4e2d\u95f4\u4ef6\uff0c\u6781\u5927\u5730\u63d0\u9ad8\u4e86S32 MCU\u5e73\u53f0\u5e94\u7528\u5c42\u8f6f\u4ef6\u7684\u53ef\u6269\u5c55\u6027\u548c\u6613\u7528\u6027\uff1b<\/p>\n <\/p>\n \u2464 \u901a\u8fc7OSIF\u9694\u79bb\u786c\u4ef6\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u7a0b\u5e8f\u4e0eRTOS\u5185\u6838\uff0c\u4fdd\u8bc1\u5e95\u5c42\u9a71\u52a8\u5bf9\u4e0d\u540cRTOS\u7684\u652f\u6301\uff1b<\/p>\n <\/p>\n \u2465 \u901a\u8fc7\u63d0\u4f9b\u9488\u5bf9\u4e0d\u540c\u8f6f\u4ef6\u5f00\u53d1\u5de5\u5177\u94fe\u7684\u542f\u52a8\u6587\u4ef6(start-up)\u548c\u94fe\u63a5\u6587\u4ef6(linker file)\uff0c\u652f\u6301\u4e3b\u6d41\u5de5\u5177\u94fe--\u6bd4\u5982GNU GCC(S32DS IDE\u81ea\u5e26\u5de5\u5177\u94fe)\u3001DIAB\u3001GHS\u548cIAR\u7b49\uff1b<\/p>\n <\/p>\n 2. S32 SDK\u7684\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u89e3\u6790<\/p>\n <\/p>\n \u5728S32 SDK\u4e2d\u6bcf\u4e00\u4e2a\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\u90fd\u6709\u4e00\u4e2a\u7ec4\u4ef6\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53,\u4ee5<\u7ec4\u4ef6\/\u5916\u8bbe\u540d>_state_t\u547d\u540d\uff0c\u7528\u4e8e\u5b58\u653e\u8be5\u5916\u8bbe\/\u7ec4\u4ef6\u7684\u5de5\u4f5c\u72b6\u6001\u548c\u786c\u4ef6\u8d44\u6e90\u4f7f\u7528\u4fe1\u606f\uff0c\u4e3b\u8981\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n <\/p>\n \u2460 \u5916\u8bbe\u6a21\u5757\u7684\u914d\u7f6e\u4fe1\u606f\uff1b<\/p>\n <\/p>\n \u2461 \u901a\u4fe1\u5916\u8bbe\u6536\u53d1\u5668\u7684\u5de5\u4f5c\u72b6\u6001(isTxBbusy\/isRxBusy);<\/p>\n <\/p>\n \u2462 \u901a\u4fe1\u5916\u8bbe\u6536\u53d1\u5668\u662f\u5426\u4e3a\u963b\u585e\u65b9\u5f0f\u5de5\u4f5c(isTxBlocking\/isRxBlocking);<\/p>\n <\/p>\n \u2463 \u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u6307\u9488(*callback)\u53ca\u53c2\u6570(*callbackParam)\u5b9a\u4e49\uff1b<\/p>\n <\/p>\n \u2464 \u5916\u8bbe\u5de5\u4f5c\/\u901a\u4fe1\u4f7f\u7528\u7684\u4fe1\u53f7(semaphore)(TxComplete\/RxComplete)\u548c\u901a\u4fe1\u72b6\u6001(transmitStatus\/receiveStatus);<\/p>\n <\/p>\n \u2465 \u901a\u4fe1\u5916\u8bbe\u6536\u53d1\u6570\u636e\u7684\u7f13\u5b58(txBuff\/rxBuff)\u548c\u5927\u5c0f(txSize\/rxSize)\uff1b<\/p>\n <\/p>\n \u2466 \u5916\u8bbe\u4f7f\u7528\u7684DMA\u901a\u9053\u53f7\uff1b<\/p>\n <\/p>\n \u4ee5\u4e0b\u662fS32K SDK\u4e2dLPUART\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53lpuart_state_t\u7684\u5b9a\u4e49\uff1a<\/p>\n <\/p>\n <\/p>\n \u800c\u975e\u901a\u4fe1\u5916\u8bbe\u7684\u65f6\u949f\u7ba1\u7406\u5668\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53clock_manager_state_t\u5982\u4e0b\uff1a<\/p>\n <\/p>\n <\/p>\n Tips\uff1a\u901a\u5e38\u5728SDK\u5916\u8bbe\u9a71\u52a8(PD)\u5c42\u5b9a\u76f8\u5e94\u786c\u4ef6\u5916\u8bbe\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u7ed3\u6784\u4f53\u6307\u9488\u6570\u7ec4\uff0c\u800c\u5728\u5916\u8bbe\u62bd\u8c61\u5c42(PAL)\u4e3a\u5176\u5b9a\u4e49\u5916\u8bbe\u9a71\u52a8\u5de5\u4f5c\u65f6\u4f7f\u7528\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53(\u5982\u679c\u5305\u542b\u591a\u4e2a\u76f8\u540c\u7684\u5916\u8bbe\u5b9e\u4f53(instance),\u6bd4\u5982LPUART0\/1\/2\u6216\u8005FlexCAN0\/1\/2\u5219\u4e3a\u7ed3\u6784\u4f53\u6570\u7ec4\uff0c\u6bcf\u4e2a\u6210\u5458\u5bf9\u5e94\u76f8\u5e94\u7684\u5916\u8bbe\u5b9e\u4f53)\uff1a<\/p>\n <\/p>\n \u6bd4\u5982S32K SDK\u4e2d\u5728LPUART\u7684\u5916\u8bbe\u9a71\u52a8\u5c42\u5b9a\u4e49\u5176\u5de5\u4f5c\u65f6\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u6307\u9488\u6570\u7ec4\uff1a<\/p>\n <\/p>\n \u800c\u5728\u5916\u8bbe\u62bd\u8c61\u5c42\u4e2d\uff0c\u624d\u5b9a\u4e49\u5176\u4f7f\u7528\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u6570\u7ec4\uff1a<\/p>\n <\/p>\n <\/p>\n FlexCAN\/CAN_PAL\u7684\u9a71\u52a8\u4e5f\u662f\u5982\u6b64\uff1a<\/p>\n <\/p>\n <\/p>\n <\/p>\n \u56e0\u6b64\uff0c\u5982\u679c\u4f7f\u7528PD\u5c42\u7ec4\u4ef6\uff0c\u7528\u6237\u8fd8\u9700\u7ec4\u4ef6\u5b9a\u4e49\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\uff0c\u800c\u4f7f\u7528PAL\u5c42\u7ec4\u4ef6\u65f6\uff0c\u5176\u5c06\u4f1a\u5b9a\u4e49\u8be5\u5916\u8bbe\u8981\u4f7f\u7528\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\uff0c\u65e0\u9700\u7528\u6237\u5b9a\u4e49\u3002<\/p>\n S32 SDK\u7684LLD\u7ec4\u4ef6\u5916\u8bbe\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u5728SDK\u7ec4\u4ef6\u7684\u521d\u59cb\u5316API\u51fd\u6570\u4e2d\u88ab\u521d\u59cb\u5316\uff0c\u5e76\u4e0e\u5176\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u6307\u9488\u6570\u7ec4\u5173\u8054\u8d77\u6765\u3002\u6bd4\u5982\u5728S32K SDK\u7684LPUART\u9a71\u52a8\u4e2d\uff0c\u5176\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u5c31\u662f\u5176\u521d\u59cb\u5316\u51fd\u6570--LPUART_DRV_Init()\u4e2d\u5b8c\u6210\u521d\u59cb\u5316\u7684\uff1a<\/p>\n <\/p>\n \u5f53\u6267\u884c\u67d0\u4e00\u4e2aSDK\u7ec4\u4ef6\u7684\u53cd\u521d\u59cb\u5316\u51fd\u6570(Deinit)\u65f6\uff0c\u5176\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e5f\u5c06\u88ab\u6e05\u9664(\u6307\u5411\u7a7a\u6307\u9488NULL)\u3002\u6bd4\u5982\u5728S32K SDK\u7684LPUART\u9a71\u52a8\u4e2d\uff0c\u5176\u53cd\u521d\u59cb\u5316\u51fd\u6570--LPUART_DRV_Deinit()\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n <\/p>\n <\/p>\n \u6bcf\u4e00\u4e2a\u786c\u4ef6\u5916\u8bbe\u6a21\u5757\u5de5\u4f5c\u65f6\uff0c\u53ea\u80fd\u6709\u4e00\u4e2a\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e0e\u5176\u5bf9\u5e94\uff0c\u5176\u4f7f\u7528\u751f\u547d\u5468\u671f\u662f\u521d\u59cb\u5316\u5b8c\u6210(\u8c03\u7528SDK\u7ec4\u4ef6Init()\u51fd\u6570)\u5230\u53cd\u521d\u59cb\u5316\u51fd\u6570\u6267\u884c(\u8c03\u7528SDK\u7ec4\u4ef6Deinit()\u51fd\u6570)\u3002<\/p>\n <\/p>\n Tips\uff1a\u4f7f\u7528S32 SDK\u7684\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8(LLD)\u65f6\uff0c\u63a8\u8350\u5927\u5bb6\u4f7f\u7528PAL\u7ec4\u4ef6\uff0c\u800c\u4e0d\u662fPD\u7ec4\u4ef6\uff1b<\/p>\n <\/p>\n Tips\uff1a S32 SDK\u7684LLD\u7ec4\u4ef6\u5916\u8bbe\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e3a\u5b9a\u4e49\u5728MCU SARM\u9759\u6001\u533a(static)\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u5176\u5305\u542b\u5bf9\u5e94\u5916\u8bbe\u6a21\u5757\u7684\u5b8c\u6574\u5de5\u4f5c\u72b6\u6001\u4fe1\u606f\uff0c\u5e76\u5b9e\u65f6\u8bb0\u5f55\u5916\u8bbe\u7684\u5de5\u4f5c\u72b6\u6001\uff0c\u662f\u8c03\u8bd5LLD\u65f6\u6700\u4e3a\u91cd\u8981\u7684\u4e00\u4e2a\u4fe1\u606f\u6e90\uff0c\u5efa\u8bae\u5c06\u5176\u6dfb\u52a0\u5230\u53d8\u91cf\uff08variable\/expression\uff09\u7a97\u53e3\u67e5\u770b\u4ee5\u8ddf\u8e2a\u8c03\u8bd5\u95ee\u9898\u3002<\/p>\n <\/p>\n 3. S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u4e2d\u65ad\u5904\u7406\u673a\u5236\u8be6\u89e3<\/p>\n <\/p>\n \u5728\u57fa\u4e8eMCU\u7684\u5d4c\u5165\u5f0f\u7cfb\u7edf\u8f6f\u4ef6\u5f00\u53d1\u4e2d\uff0c\u5916\u8bbe\u4e2d\u65ad\u662f\u4fdd\u8bc1\u7cfb\u7edf\u8f6f\u4ef6\u5de5\u4f5c\u5b9e\u65f6\u6027\u548c\u5185\u6838\u6548\u7387\u6700\u91cd\u8981\u7684\u5de5\u4f5c\u673a\u5236----\u5728\u5916\u8bbe\u4e8b\u4ef6(\u6bd4\u5982\u901a\u4fe1\u5916\u8bbe\u7684\u6570\u636e\u63a5\u6536\u5b8c\u6210\uff0cGPIO\u72b6\u6001\u6539\u53d8\u4ee5\u53ca\u5b9a\u65f6\u5468\u671f\u6ee1\u7b49)\uff0cCPU\u5185\u6838\u5c06\u505c\u6b62\u5f53\u524d\u7a0b\u5e8f\u6307\u4ee4\u7684\u6267\u884c\uff0c\u53ca\u65f6\u54cd\u5e94\u5916\u8bbe\u4e2d\u65ad\u8bf7\u6c42\u5e76\u505a\u76f8\u5e94\u7684\u5904\u7406(\u6bd4\u5982\u642c\u79fb\u6570\u636e\uff0c\u586b\u5145\u7f13\u51b2\uff0c\u6539\u53d8\u7a0b\u5e8f\u8fd0\u884c\u6761\u4ef6\/\u72b6\u6001\u3001\u6fc0\u6d3b\u65b0\u4efb\u52a1\u7b49)\u3002<\/p>\n <\/p>\n \u5728\u4f20\u7edf\u7684\u5d4c\u5165\u5f0fMCU\u5e95\u5c42\u5916\u8bbe\u9a71\u52a8\u7a0b\u5e8f\u5f00\u53d1\u4e2d\uff0c\u5bf9\u4e8e\u5916\u8bbe\u4e2d\u65ad\u7684\u5904\u7406\u6d41\u7a0b\/\u673a\u5236\u5982\u4e0b\uff1a<\/p>\n <\/p>\n \u2460 POR\u590d\u4f4d\u540e\uff0c\u5728main()\u51fd\u6570\u6700\u5f00\u59cb\u5b8c\u6210\u7cfb\u7edf\u65f6\u949f\u521d\u59cb\u5316\u540e\uff0c\u521d\u59cb\u5316\u5916\u8bbe\u6a21\u5757\u65f6\uff0c\u5c31\u914d\u7f6e\u4f7f\u80fd\u76f8\u5e94\u7684\u5916\u8bbe\u4e2d\u65ad\uff1b<\/p>\n <\/p>\n \u2461 \u7f16\u5199\u4e2d\u65ad\u670d\u52a1\u51fd\u6570ISR\uff0c\u5728\u5176\u4e2d\u5904\u7406\u4e2d\u65ad\u4e8b\u4ef6\uff0c\u7f6e\u4f4d\u5168\u5c40\u4e8b\u4ef6\u6807\u5fd7\u901a\u77e5\u5e94\u7528\u7a0b\u5e8f\u505a\u540e\u7eed\u5904\u7406\uff0c \u5e76\u6e05\u9664\u4e2d\u65ad\u6807\u5fd7\uff1b<\/p>\n <\/p>\n \u2462 \u5c06\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u653e\u5230MCU\u7684\u4e2d\u65ad\u5411\u91cf\u8868\u4e2d\uff0c\u8fd9\u4e00\u6b65\u53ef\u80fd\u662f\u901a\u8fc7\u5173\u952e\u8bcd(interrupt\uff09+\u4e2d\u65ad\u5411\u91cf\u53f7 + ISR\u5b9a\u4e49\u7684\u65b9\u5f0f\u5b9e\u73b0\uff0c\u5de5\u5177\u94fe\u7684\u7f16\u8bd1\u5668\u548c\u94fe\u63a5\u5668\u81ea\u52a8\u8bc6\u522b\u5e76\u52a0\u8f7d\u5230MCU\u4e2d\u65ad\u5411\u91cf\u8868\u4e2d\uff1b<\/p>\n <\/p>\n \u2463 \u4f7f\u80fd\u5168\u5c40\u4e2d\u65ad\uff1b<\/p>\n <\/p>\n \u5728\u6574\u4e2aMCU\u6b63\u5e38\u5de5\u4f5c\u671f\u95f4\uff0c\u9664\u975e\u7279\u6b8a\u5e94\u7528\u9700\u8981\uff0c\u4e0d\u4f1a\u5173\u5fc3\u5916\u8bbe\u4e2d\u65ad\u7684\u5173\u95ed\u4e0e\u4f7f\u80fd\uff0c<\/p>\n <\/p>\n \u800c\u5728S32 SDK\u4e2d\uff0c\u5176\u8fdb\u884c\u4e86\u5982\u4e0b\u4f18\u5316\uff1a<\/p>\n <\/p>\n \u2460\u5916\u8bbe\u521d\u59cb\u5316Init()\u51fd\u6570\u4e2d\uff0c\u4ec5\u4f7f\u80fd\u82af\u7247\u7ea7\u4e2d\u65ad\u63a7\u5236\u5668\u4e2d\u5bf9\u5e94\u7684\u4e2d\u65ad\u6e90(\u6bd4\u5982S32K\u7684ARM Cortex M\u7cfb\u5217\u5185\u6838\u7684NVIC\uff0c\u548cQorivva MPC57xx\/S32R\u7684PowerPC e200\u7cfb\u5217\u5185\u6838\u7684INTC\u6a21\u5757)\u5e76\u4e0d\u4f7f\u80fd\u76f8\u5e94\u5916\u8bbe\u7684IP\u7ea7\u4e2d\u65ad(\u6bd4\u5982LPUART\u7684TX\u548cRX\u4ee5\u53caERROR\u4e2d\u65ad)\uff1b<\/p>\n <\/p>\n \u5728\u5177\u4f53\u4f7f\u7528\u5916\u8bbe\u7684\u7279\u5b9a\u529f\u80fd(\u6bd4\u5982LPUART\u7684\u6570\u636e\u53d1\u9001\u548c\u63a5\u6536)\u65f6\uff0c\u624d\u4f7f\u80fd\u8be5\u7279\u5b9a\u529f\u80fd\u7684\u4e2d\u65ad(\u6bd4\u5982LPUART\u7684\u53d1\u9001\u4e2d\u65ad\u548c\u63a5\u6536\u4e2d\u65ad)\uff0c\u5728\u4e2d\u65ad\u53d1\u751f\u540e\uff0c\u82e5\u76f8\u5e94\u7684\u4e2d\u65ad\u5df2\u7ecf\u5b8c\u5168\u53d1\u751f(\u6bd4\u5982\u53d1\u900110\u5b57\u8282\u6570\u636e\uff0c\u5168\u90e8\u53d1\u9001\u5b8c\u6210)\uff0c\u5219\u5728ISR\u7684\u6700\u540e\u5173\u95ed\u8be5\u7279\u5b9a\u529f\u80fd\u4e2d\u65ad\uff1b<\/p>\n <\/p>\n \u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\uff0c\u907f\u514d\u610f\u5916\u7684\u4e2d\u65ad\u6d6a\u8d39\u5b9d\u8d35\u7684CPU\u8d44\u6e90\uff0c\u6bd4\u5982\u7531\u4e8e\u7a0b\u5e8f\u8dd1\u98de\u5bfc\u81f4\u7684LPUART\u610f\u5916\u6570\u636e\u53d1\u9001\u548c\u63a5\u6536\uff1b<\/p>\n <\/p>\n \u2461 \u5728S32 SDK\u7684PD\u5c42\u4e3a\u7edd\u5927\u591a\u6570\u786c\u4ef6\u5916\u8bbe\u6a21\u5757\u63d0\u4f9b\u4e86\u4e2d\u65adISR\u51fd\u6570\uff0c(\u5bf9\u5e94S32K SDK\u6765\u8bf4\uff0c\u4ec5PD\u5c42\u7684LPIT\u7ec4\u4ef6\u548cGPIO\u7684IRQ\u4e2d\u65ad\uff0c\u9700\u8981\u7528\u6237\u81ea\u5df1\u4f7f\u80fdNVIC\u4e2d\u65ad\u5e76\u7f16\u5199\u81ea\u5df1\u7684\u4e2d\u65adISR)\u65e0\u9700\u7528\u6237\u81ea\u5df1\u7f16\u5199\uff1b<\/p>\n <\/p>\n \u5728S32 SDK\u7684\u7ec4\u4ef6\u4e2d\uff0c\u76f8\u540c\u5916\u8bbe\u7684\u4e0d\u540c\u5b9e\u4f53(\u6bd4\u5982LPUART0\/1\/2)\u5171\u7528\u540c\u4e00\u4e2a\u4e2d\u65adISR\uff0c\u4f9d\u9760\u5916\u8bbe\u5b9e\u4f53\u53f7(instance)\u6765\u533a\u5206\u4e0d\u540c\u7684\u5904\u7406\uff0c\u7531\u4e8e\u76f8\u540c\u5916\u8bbe\u7684\u5de5\u4f5c\u6d41\u7a0b\u548c\u4e2d\u65ad\u5904\u7406\u6d41\u7a0b\u76f8\u540c\uff0c\u8fd9\u6837\u7684\u597d\u5904\u662f\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u590d\u7528\u6548\u7387\uff1a<\/p>\n \u5982\u4e0b\u662fS32K144\u7684SDK\u4ee3\u7801\uff0c\u5176\u6709LPUART0\/1\/2\u4e09\u4e2a\u4e32\u53e3\u5916\u8bbe\uff0c\u5176\u4e2d\u65adISR\u5b9a\u4e49\u5982\u4e0b\uff1a<\/p>\n <\/p>\n <\/p>\n \u800c\u5728\u771f\u6b63\u7684LPUART\u4e2d\u65ad\u5904\u7406\u51fd\u6570\u4e2d\u4f9d\u9760\u4e0d\u540c\u7684instance\u6765\u533a\u522b\uff1a<\/p>\n <\/p>\n <\/p>\n \u2462 S32 SDK\u9ed8\u8ba4\u5728startup\u8fc7\u7a0b\u4e2d\u5c06\u5916\u8bbe\u4e2d\u65ad\u5411\u91cf\u8868\u62f7\u8d1d\u5230SARM\u4e2d\uff0c\u8fd9\u6837\u8fd0\u884c\u7528\u6237\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u52a8\u6001\u7684\u4fee\u6539\u4e2d\u65adISR\uff1b<\/p>\n <\/p>\n \u2463 S32 SDK\u4e2d\u4e3a\u5927\u90e8\u5206\u5916\u8bbe\u90fd\u63d0\u4f9b\u4e86\u4e2d\u65ad\u5904\u7406\u51fd\u6570(ISR)\u2014\u4f4d\u4e8e\u5916\u8bbe\u9a71\u52a8PD\u7684\u4e2d\u65ad\u5904\u7406\u6587\u4ef6(<Peripheral_Name>_irq.c\/h)\u4e2d\uff0c\u5e76\u5728\u5916\u8bbe\u521d\u59cb\u5316\u65f6\u914d\u7f6e\u4e86\u76f8\u5e94\u7684\u4e2d\u65ad\uff0c\u5176\u5916\u8bbe\u4e2d\u65adISR\u5c5e\u4e8eSDK PD\u5c42\u9a71\u52a8\u975e\u5e38\u91cd\u8981\u7684\u4e00\u90e8\u5206\u4ee3\u7801\uff0c\u4e0d\u5141\u8bb8\u7528\u6237\u4fee\u6539\uff0c\u56e0\u6b64\u63d0\u4f9b\u4e86\u5728\u5916\u8bbe\u4e2d\u65adISR\u4e2d\u8c03\u7528\u7528\u6237\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u7684\u65b9\u5f0f\u7ed9\u7528\u6237\u63d0\u4f9b\u4e2d\u65ad\u5904\u7406\u63a5\u53e3\u3002<\/p>\n <\/p>\n Tips\uff1a\u5728\u7528\u6237\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u4e2d\uff0c\u65e0\u9700\u7528\u6237\u81ea\u5df1\u6e05\u9664\u5916\u8bbe\u4e2d\u65ad\u6807\u5fd7\uff0c\u56e0\u4e3a\u5728SDK\u63d0\u4f9b\u7684\u5916\u8bbe\u4e2d\u65adISR\u4e2d\u5df2\u7ecf\u505a\u4e86\u76f8\u5e94\u7684\u5904\u7406\u3002\u53ea\u6709\u9700\u8981\u7528\u6237\u8c03\u7528SDK\u4e2d\u65ad\u7ba1\u7406\u5668(interrupt_manager)\u7684API--INT_SYS_InstallHandler()\u624b\u52a8\u6ce8\u518c\u5b89\u88c5\u7684\u5916\u8bbe\u4e2d\u65adISR\uff0c\u624d\u9700\u8981\u7528\u6237\u81ea\u5df1\u6e05\u5916\u8bbe\u4e2d\u65ad\u6807\u5fd7\uff0c\u6bd4\u5982\u5178\u578b\u7684GPIO\u7684IRQ\u4e2d\u65ad\u548cPIT\u5b9a\u65f6\u5668\u4e2d\u65ad\u3002<\/p>\n <\/p>\n Tips\uff1a\u4f7f\u7528PD\u5c42\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\uff0c\u9700\u8981\u7528\u6237\u81ea\u5df1\u8c03\u7528\u4e2d\u65ad\u56de\u8c03\u51fd\u6570API\u81ea\u5df1\u5b89\u88c5\u4e2d\u65adCallback\uff1a<\/p>\n <\/p>\n <\/p>\n \u800c\u82e5\u4f7f\u7528PAL\u5c42\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6\uff0c\u5219\u53ef\u4ee5\u5728\u5176Processor Expert\u56fe\u5f62\u5316\u914d\u7f6e\u754c\u9762\u4e2d\u6dfb\u52a0\u4e2d\u65adCallback\u51fd\u6570\u540d\uff0c\u7136\u540e\u518d\u7528\u6237\u4ee3\u7801\u4e2d\u5b9e\u73b0\u8be5Callback\u5373\u53ef\uff0c\u65e0\u9700\u7528\u6237\u81ea\u5df1\u8c03\u7528\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u5b89\u88c5API\u3002<\/p>\n <\/p>\n <\/p>\n 4. S32 SDK\u7684\u901a\u4fe1\u5916\u8bbe\u9a71\u52a8\u7ec4\u4ef6API\u51fd\u6570\u7684\u963b\u585e\u4e0e\u975e\u963b\u585e\u53d1\u9001\u4e0e\u63a5\u6536API\u51fd\u6570\u5dee\u522b\u4e0e\u4f7f\u7528\u8be6\u89e3\uff1b<\/p>\n <\/p>\n \u5728S32 SDK\uff0c\u901a\u4fe1\u5916\u8bbe\u7ec4\u4ef6\u90fd\u63d0\u4f9b\u4e86\u963b\u585e(Blocking)\u4e0e\u975e\u963b\u585e\u4e24\u7c7b\u53d1\u9001\u4e0e\u63a5\u6536API\u51fd\u6570\uff0c\u6bd4\u5982\uff1a<\/p>\n <\/p>\n UART_PAL\u7ec4\u4ef6\u7684API\u51fd\u6570\uff1a<\/p>\n <\/p>\n <\/p>\n CAN_PAL\u7ec4\u4ef6\u7684API\u51fd\u6570\uff1a<\/p>\n <\/p>\n <\/p>\n \u5176\u5dee\u522b\u5982\u4e0b\uff1a<\/p>\n <\/p>\n \u975e\u963b\u585e\u7c7b\u6570\u636e\u6536\u53d1API\uff0c\u53ea\u662f\u5c06\u8981\u53d1\u9001\u7684\u6570\u636ebuffer\u548c\u957f\u5ea6size\u8bbe\u7f6e\u5230\u5bf9\u5e94\u7684\u901a\u4fe1\u5916\u8bbe\u9a71\u52a8\u7684\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\uff0c\u4f7f\u80fd\u6570\u636e\u53d1\u9001\u5668(transmiter)\u548c\u63a5\u6536\u5668(receiver)\uff0c\u6253\u5f00\u6536\u53d1\u548c\u9519\u8bef\u4e2d\u65ad\/\u82e5\u4f7f\u7528DMA\u6536\u53d1\uff0c\u5219\u914d\u7f6e\u76f8\u5e94\u7684DMA\u901a\u9053TCD\uff0c\u4f7f\u80fdDMA\u4e2d\u65ad\uff0c\u5b89\u88c5\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\uff0c\u542f\u52a8DMA\u4f20\u8f93\uff0c \u7136\u540e\u5c31\u7acb\u5373\u8fd4\u56de\u4e86\uff0c\u56e0\u6b64\u975e\u963b\u585e\u7c7bAPI\u7684\u8fd4\u56de\u503c\u603b\u662f\u6210\u529f(STATUS_SUCCESS)\u3002<\/p>\n <\/p>\n \u6bd4\u5982S32K SDK\u7684LPUART\u975e\u963b\u585e\u53d1\u9001API--LPUART_DRV_SendData() \u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n <\/p>\n <\/p>\n \u800c\u963b\u585e(Blocking)\u7c7b\u6570\u636e\u6536\u53d1API\uff0c\u51fd\u6570\u53c2\u6570\u591a\u4e86\u4e00\u4e2a\u8d85\u65f6timeout(\u5355\u4f4d\u4e3ams)\u5219\u5728\u5b8c\u6210\u4ee5\u4e0a\u975e\u963b\u585eAPI\u7684\u5de5\u4f5c\u540e\uff0c\u8fd8\u4f1a\u8c03\u7528OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaWait()\u68c0\u67e5\u5916\u8bbe\u9a71\u52a8\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u7684\u6570\u636e\u6536\u53d1\u4fe1\u53f7\u91cf(semaphore)\uff0c\u7b49\u5f85\u6570\u636e\u6536\u53d1\u5b8c\u6210\uff0c\u82e5\u5728\u8bbe\u7f6e\u7684timeout\u65f6\u95f4\u5185\u672a\u5b8c\u6210\u6570\u636e\u4f20\u8f93\uff0c\u5219\u8fd4\u56de\u8d85\u65f6(STATUS_TIMEOUT)\uff0c\u82e5\u5728timeout\u65f6\u95f4\u5185\u6570\u636e\u6536\u53d1\u5b8c\u6210\uff0c\u5219\u8fd4\u56de\u6210\u529f(STATUS_SUCCESS)\u3002<\/p>\n <\/p>\n \u6bd4\u5982S32K SDK\u7684LPUART\u963b\u585e(blocking)\u53d1\u9001API--LPUART_DRV_SendDataBlocking()\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n <\/p>\n <\/p>\n Tips\uff1a\u7ed3\u5408\u524d\u9762S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u4e2d\u65ad\u5904\u7406\u673a\u5236\u7684\u4ecb\u7ecd\u53ef\u77e5\uff0c\u65e0\u8bba\u8c03\u7528\u963b\u585e\u51fd\u6570\u975e\u963b\u585e\u6570\u636e\u6536\u53d1\u51fd\u6570\uff0c\u5728\u6210\u529f\u63a5\u6536\u5b8c\u6307\u5b9a\u957f\u5ea6\u7684\u6570\u636e\u540e\uff0c\u90fd\u4f1a\u5c06\u901a\u4fe1\u5916\u8bbe\u7684\u63a5\u6536\u5668\u5173\u95ed\uff0c\u82e5\u60f3\u901a\u4fe1\u5916\u8bbe\u4e00\u76f4\u63a5\u6536\u6570\u636e\uff0c\u5219\u9700\u8981\u5728\u8be5\u9a71\u52a8\u7ec4\u4ef6\u7684\u4e2d\u65ad\u56de\u8c03\u51fd\u6570Callback\u4e2d\uff0c\u8bbe\u7f6e\u65b0\u7684\u6570\u636e\u63a5\u6536buffer\uff0c\u4ece\u800c\u907f\u514d\u5728\u4e2d\u65adISR\u6700\u540e\uff0c\u9a71\u52a8\u7a0b\u5e8f\u5173\u95ed\u6570\u636e\u63a5\u6536\u5668\uff1a<\/p>\n <\/p>\n \u6bd4\u5982\u4f7f\u7528S32K\u7684LPUART\u63a5\u6536GPS\u6570\u636e\u65f6\uff0c\u76f8\u5e94\u7684\u6570\u636e\u63a5\u6536\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u5b9a\u4e49\u5982\u4e0b\uff0c\u5176\u4e2d\u4f7f\u7528\u53ccbuffer\uff0c\u5728\u4e00\u4e2abuffer\u63a5\u6536\u5b8c\u6210\u540e\uff0c\u8c03\u7528UART_SetRxBuffer()\u5207\u6362\u65b0\u7684buffer\u7ee7\u7eed\u63a5\u6536\u6570\u636e\uff1a<\/p>\n <\/p>\n <\/p>\n Tips\uff1a\u7531\u4e8e\u5728\u963b\u585eAPI\u51fd\u6570\u4e2d\uff0c\u8c03\u7528\u4e86OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaWait()\u68c0\u67e5\u5916\u8bbe\u9a71\u52a8\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u7684\u6570\u636e\u6536\u53d1\u4fe1\u53f7\u91cf(semaphore)\uff0c \u82e5\u5728\u5e94\u7528\u5de5\u7a0b\u4e2d\u4f7f\u7528\u4e86RTOS\uff0c\u6bd4\u5982FreeRTOS\uff0c\u5219\u8c03\u7528\u8be5\u963b\u585eAPI\u51fd\u6570\u7684\u4efb\u52a1\u5c06\u88ab\u963b\u585e\uff0c\u8ba9\u51faCPU\u8d44\u6e90\u8fd0\u884c\u5176\u4ed6\u5c31\u7eea\u7684\u9ad8\u4f18\u5148\u7ea7\u8ba4\u4e3a\uff0c\u76f4\u81f3\u6536\u636e\u6536\u53d1\u5b8c\u6210(\u4fe1\u53f7\u91cf\u91ca\u653e)\u6216\u8005\u8d85\u65f6\uff0c\u8fd9\u6837CPU\u7684\u6267\u884c\u6548\u7387\u5c06\u5927\u5927\u63d0\u9ad8\uff1b\u800c\u82e5\u5e94\u7528\u5de5\u7a0b\u4e2d\u6ca1\u6709\u4f7f\u7528RTOS\uff0c\u5219\u963b\u585eAPI\u51fd\u6570\u5c06\u4e00\u76f4\u5360\u6709CPU\uff0c\u9020\u6210CPU\u8d44\u6e90\u6d6a\u8d39\uff1b<\/p>\n \u7efc\u4e0a\uff0c \u82e5\u5e94\u7528\u5de5\u7a0b\u4f7f\u7528\u4e86RTOS\uff0c\u5219\u63a8\u8350\u4f7f\u7528\u963b\u585eAPI\u51fd\u6570\uff1b\u82e5\u5e94\u7528\u5de5\u7a0b\u672a\u4f7f\u7528RTOS\uff0c\u5219\u63a8\u8350\u4f7f\u7528\u975e\u963b\u585eAPI\u51fd\u6570\uff0c\u5e76\u914d\u5408\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\uff0c\u5224\u65ad\u6570\u636e\u6536\u53d1\u72b6\u6001\u5e76\u505a\u76f8\u5e94\u5904\u7406\u3002<\/p>\n <\/p>\n 5. S32 SDK\u7684\u5916\u8bbe\u9a71\u52a8\u4e0eRTOS\u4e4b\u95f4\u7684\u4ea4\u4e92\u65b9\u5f0f<\/p>\n <\/p>\n \u5728S32 SDK\u4e2d\uff0c\u6240\u6709\u7684\u5916\u8bbe\u9a71\u52a8(PD\u548cPAL\u7ec4\u4ef6)\u4ee5\u53ca\u4e2d\u95f4\u4ef6(Middleware)\u7684\u8f6f\u4ef6\u4ee3\u7801\u5b9e\u73b0\uff0c\u90fd\u4f7f\u7528\u4e86OSIF<\/strong>\u7ec4\u4ef6\u63d0\u4f9b\u7684\u64cd\u4f5c\u7cfb\u7edf\u63a5\u53e3API\u5bf9\u5916\u8bbe\u9a71\u52a8\u5de5\u4f5c\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u540c\u6b65\u548c\u4e8b\u4ef6\u65f6\u95f4\u5ef6\u8fdf\uff0c\u4ece\u800c\u4fdd\u8bc1\u4e86S32 SDK\u4ee3\u7801\u5728\u4e0d\u540cRTOS\u4e4b\u95f4\u7684\u517c\u5bb9\uff1a<\/p>\n <\/p>\n \u5176\u4e2d\u4f7f\u7528\u7684\u4fe1\u53f7\u91cf\u90fd\u5728\u76f8\u5e94\u7684\u7ec4\u4ef6\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u5b9a\u4e49\uff0c\u5728\u7ec4\u4ef6\u521d\u59cb\u5316(\u7ec4\u4ef6_Init()\u51fd\u6570)\u65f6\uff0c\u8c03\u7528\u4e86OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaCreate()\u521b\u5efa\uff0c\u6bd4\u5982S32K SDK\u7684LPUART\u9a71\u52a8\u7528\u4e8e\u6570\u636e\u6536\u53d1\u7684\u4fe1\u53f7\u91cfrxComplete\/txComplete\uff0c\u5c31\u5728\u5176\u521d\u59cb\u5316\u51fd\u6570LPUART_DRV_Init()\u4e2d\u521b\u5efa\u7684\uff1a<\/p>\n <\/p>\n \u5728\u7ec4\u4ef6\u7684\u963b\u585e(Blocking)API\u51fd\u6570\u4e2d\u8c03\u7528OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaWait()\u68c0\u67e5\u5916\u8bbe\u9a71\u52a8\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u5b9a\u4e49\u7684\u4fe1\u53f7\u91cf(semaphore)\u4ee5\u5b8c\u6210\u4e8b\u4ef6\u540c\u6b65\u3002\u6bd4\u5982S32K SDK\u7684LPUART\u9a71\u52a8\u4e2d\u6570\u636e\u53d1\u9001\u5b8c\u6210\u4fe1\u53f7\u91cftxComplete\uff0c\u5c31\u5728\u5176\u963b\u585e\u6570\u636e\u53d1\u9001API\u51fd\u6570LPUART_SendDataBlocking()\u4e2d\u4f7f\u7528\u7684\uff1a<\/p>\n <\/p>\n \u5728\u7ec4\u4ef6\u53cd\u521d\u59cb\u5316(\u7ec4\u4ef6_Deinit()\u51fd\u6570)\u65f6\uff0c\u8c03\u7528\u8c03\u7528\u4e86OSIF\u7ec4\u4ef6\u7684API\u51fd\u6570--OSIF_SemaDestroy()\u91ca\u653e\u3002\u6bd4\u5982S32K SDK\u7684LPUART\u9a71\u52a8\u7528\u4e8e\u6570\u636e\u6536\u53d1\u7684\u4fe1\u53f7\u91cfrxComplete\/txComplete\uff0c\u5c31\u5728\u5176\u53cd\u521d\u59cb\u5316\u51fd\u6570LPUART_DRV_Deinit()\u4e2d\u88ab\u9500\u6bc1\u7684\uff1a<\/p>\n <\/p>\n \u4ece\u4ee5\u4e0a\u5206\u6790\u53ef\u77e5\uff0c\u901a\u8fc7\u5728SDK\u7ec4\u4ef6\u5168\u5c40\u72b6\u6001\u7ed3\u6784\u4f53\u4e2d\u5f15\u5165\u4fe1\u53f7\u91cf(Mutex\/Semaphore)\u548c\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u63a5\u53e3OSIF\u7ec4\u4ef6API\uff0c\u65e2\u4fdd\u8bc1\u4e86S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u7a0b\u5e8f\u548c\u4e2d\u95f4\u4ef6\u8f6f\u4ef6\u5de5\u4f5c\u7684\u540c\u6b65\u548c\u6548\u7387\uff0c\u53c8\u63d0\u9ad8\u4e86SDK\u8f6f\u4ef6\u4ee3\u7801\u7684\u5728\u4e0d\u540cRTOS\u4e4b\u95f4\u7684\u53ef\u79fb\u690d\u6027\uff0c\u4f7f\u7528\u4e0d\u540cRTOS\u65f6\uff0c\u53ea\u9700\u8981\u5173\u5fc3\u548c\u79fb\u690dOSIF\u7ec4\u4ef6\u63d0\u4f9b\u7684API\u51fd\u6570\uff0c\u5373\u53ef\u4fdd\u8bc1S32 SDK\u5916\u8bbe\u5e95\u5c42\u9a71\u52a8\u548c\u4e2d\u95f4\u4ef6\u8f6f\u4ef6\u4ee3\u7801\u5728\u8be5RTOS\u4e2d\u7684\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n <\/p>\n \u603b\u7ed3<\/p>\n <\/p>\n \u867d\u7136\u6211\u5df2\u7ecf\u529b\u6c42\u5c3d\u91cf\u628a\u5b83\u5199\u7684\u6df1\u5165\u6d45\u51fa\uff0c\u901a\u4fd7\u6613\u61c2\uff0c\u9605\u8bfb\u672c\u6587\u4ecb\u7ecd\u7684\u77e5\u8bc6\u8981\u70b9\u4ecd\u7136\u9700\u8981\u4e00\u5b9a\u7684\u7f16\u7a0b\u57fa\u7840\u548c\u5d4c\u5165\u5f0f\u5e95\u5c42\u9a71\u52a8\u7a0b\u5e8f\u5f00\u53d1\u7ecf\u9a8c\u79ef\u7d2f\uff0c\u6216\u8005\u4f7f\u7528\u8fc7\u4e00\u6bb5\u65f6\u95f4\u7684S32 SDK\u8f6f\u4ef6\u3002\u4e0d\u8fc7\u6ca1\u5173\u7cfb\uff0c\u5728\u540e\u7eed\u7684\u300aS32K SDK\u4f7f\u7528\u8be6\u89e3<\/strong>\u300b\u7cfb\u5217\u6280\u672f\u5206\u4eab\u6587\u7ae0\u4e2d\uff0c\u6211\u8fd8\u5c06\u7ed3\u5408S32K1xx\u7cfb\u5217MCU\u7684\u5185\u6838\u548c\u5916\u8bbe\u529f\u80fd\u7279\u6027\uff0c\u4e3a\u5927\u5bb6\u5e26\u6765\u66f4\u591a\u7684S32 SDK\u4f7f\u7528\u7ec6\u8282\u5206\u89e3\uff0c\u5e0c\u671b\u5927\u5bb6\u53ef\u4ee5\u6301\u7eed\u5173\u6ce8\u548c\u5b66\u4e60\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"s32k sdk\u4f7f\u7528\u8be6\u89e3_c++\u7f16\u7a0b\u601d\u60f3\u5185\u5bb9\u63d0\u8981\u5f15\u8a001.S32SDK\u7684\u8f6f\u4ef6\u5206\u5c42\u67b6\u6784\u4ecb\u7ecd1.1\u5916\u8bbe\u9a71\u52a8\u5c42(PDPeriperalDriver)1.2\u5916\u8bbe\u62bd\u8c61\u5c42(PALPe...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6298"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=6298"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6298\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=6298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=6298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=6298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}