STM32F1 HAL

Started by tha, June 14, 2022, 09:22:55 AM

Previous topic - Next topic

tha

5   Cohabiting of HAL and LL

The low-ayer APIs ถูกออกแบบเพื่อให้ถูกใช้ใน standalone mode หรือรวมกันกับ the HAL. พวกมันไม่สามารถถูกใช้โดยอัตโนมัติพร้อมกับ the HAL สำหรับ the same peripheral instance. ถ้าคุณใช้ the LL APIs สำหรับ a instance ที่ระบุ, คุณยังคงสามารถใช้ the HAL APIs สำหรับ instances อื่น. โปรดระมัดระวังว่า the low-layer APIs อาจเขียนทับบาง registers ซึ่ง content ถูกส่องใน the HAL handles.

5.1 Low-layer driver used in Standalone mode

The low-layer APIs สามารถถูกใช้โดยไม่มีการเรียก the HAL driver services. นี้ถูกทำโดยเพียงแค่รวม stm32f1xx_ll_ppp.h ใน the application files. The LL APIs for a given peripheral ถูกเรียกโดยการปฏิบัติลำดับที่เหมือนกันกับ the one ที่แนะนำโดย the programming model ใน the corresponding product line reference manual. ในกรณีนี้ the HAL drivers ที่เกี่ยวข้องกับ the used peripheral สามารถถูกเอาออกจาก the workspace. อย่างไรก็ตาม the STM32CubeF1 framework ควรถูกใช้ในวิธีเดียวกันกับใน the HAL drivers case ซึ่งหมายความว่า System file, startup file and CMSIS ควรถูกใช้เสมอ.

Note:   เมื่อ the BSP drivers ถูกรวม, the used HAL drivers ที่เกี่ยวข้องกันกับ the BSP functions drivers ควรถูกรวมใน the
            workspace, แม้ว่าพวกมันไม่ถูกใช้โดย the application layer.

tha

5.2 Mixed use of low-layer APIs and HAL drivers

ในกรณีนี้ the low-layer APIs ถูกใช้ร่วมกันกับ the HAL drivers เพื่อสำเร็จ direct and register level based operations.

การใช้ผสมถูกอนุญาต, อย่างไรก็ตามบาง consideration ควรถูกคำนึงถึง:
•   ขอแนะนำให้หลีกเลี่ยงการใช้ the HAL APIs และ the combination of low-layer APIs พร้อมกันสำหรับ a given peripheral
     instance. หากเป็นกรณีนี้, private fields อย่างน้อยหนึ่งใน the HAL PPP handle structure ควรถูกอัฟเดตสอดคล้องกัน.
•   สำหรับ operations and processes ที่ไม่เปลี่ยนแปลง the handle fields รวมถึง the initialization structure, the HAL
     driver APIs and the low-layer services สามารถถูกใช้ด้วยกันได้สำหรับ the same peripheral instance.
•   The low-layer drivers สามารถถูกใช้โดยไม่มีข้อจำกัดใดๆพร้อมกันกับทุก the HAL drivers ที่ไม่ขึ้นอยู่ handle objects (RCC,
     common HAL, flash and GPIO).

หลายตัวอย่างแสดงวิธีใช้ HAL and LL ใน the same application ถูกจัดให้มีภายใน stm32f1 firmware package (ดูที่ Examples_MIX projects).

Note:   1.  เมื่อ the HAL Init/DeInit APIs ไม่ถูกใช้และถูกแทนที่ด้วย the low-layer macros, the InitMsp() functions ไม่ถูก
                 เรียกและ the MSP initialization ควรถูกทำใน the user application.
           2.   เมื่อ process APIs ไม่ถูกใช้และ the corresponding function ถูกดำเนินการผ่านทาง the low-layer APIs, the
                 callbacks ไม่ถูกเรียกและ post processing หรือ error management ควรถูกทำโดย the user application.
           3.   เมื่อ the LL APIs ถูกใช้สำหรับ process operations, the IRQ handler HAL APIs ไม่สามารถถูกเรียกและ the IRQ
                 ควรถูกจัดให้มีใช้โดย the user application. แต่ละ LL driver จัดให้มีใช้ the macros ที่จำเป็นต้องอ่านและเคลียร์ the
                 associated interrupt flags.