Interrupt management
Số trang: 18
Loại file: pdf
Dung lượng: 448.34 KB
Lượt xem: 8
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
FreeRTOS cho phép s d ng ng t. T t c các API có tên k t thúc b ng “FromISR” ho c “FROM_ISR” thì ñư c s d ng trong ISR..Binary semaphore use for synchronizationBinary semaphore use for synchronizationBÙI QU C B O 2.Binary semaphore use for synchronizationBinary semaphore use for synchronizationBÙI QU C B O 3.Binary semaphore use for synchronizationBinary semaphore use for synchronizationBÙI QU C B O 4.Binary semaphore use for synchronizationCreate a binary semaphore vSemaphoreCreateBinary()void vSemaphoreCreateBinary( xSemaphoreHandle xSemaphore );xSemaphore The semaphore being created.BÙI QU C B O 5....
Nội dung trích xuất từ tài liệu:
Interrupt management ARM PROGRAMMING Bùi Qu c B o FreeRTOS cho phép s d ng ng t. T t c các API có tên k t thúc b ng “FromISR” ho c “FROM_ISR” thì ñư c s d ng trong ISR.BÙI QU C B O 1 Binary semaphore use for synchronization Binary semaphore use for synchronizationBÙI QU C B O 2 Binary semaphore use for synchronization Binary semaphore use for synchronizationBÙI QU C B O 3 Binary semaphore use for synchronization Binary semaphore use for synchronizationBÙI QU C B O 4 Binary semaphore use for synchronization Create a binary semaphore vSemaphoreCreateBinary() void vSemaphoreCreateBinary( xSemaphoreHandle xSemaphore ); xSemaphore The semaphore being created.BÙI QU C B O 5 Get the semaphore xSemaphoreTake portBASE_TYPE xSemaphoreTake( xSemaphoreHandle xSemaphore, portTickType xTicksToWait ); xSemaphore: The semaphore being ‘taken’. xTicksToWait: 0: the function will return immediately if the semaphore is not available portMAX_DELAY: the task will wait indefinitely if INCLUDE_vTaskSuspend is set to 1 Return value: pdPASS: success pdFALSE: Fail Give semaphore from ISR xSemaphoreGiveFromISR portBASE_TYPE xSemaphoreGiveFromISR( xSemaphoreHandle xSemaphore, portBASE_TYPE *pxHigherPriorityTaskWoken ); pxHigherPriorityTaskWoken pdTRUE: a higher priority task will pre-emp current task pdFALSE: there are no higher priority task waiting for the semaphore N u pxHigherPriorityTaskWoken là pdTRUE, ISR ph i th c hi n “contextSwitch” trư c khi thoátBÙI QU C B O 6 Give semaphore from ISR xSemaphoreGiveFromISR static void __interrupt __far vExampleInterruptHandler( void ) { static portBASE_TYPE xHigherPriorityTaskWoken; xHigherPriorityTaskWoken = pdFALSE; /* Give the semaphore to unblock the task. */ xSemaphoreGiveFromISR( xBinarySemaphore, &xHigherPriorityTaskWoken ); if( xHigherPriorityTaskWoken == pdTRUE ) { portSWITCH_CONTEXT(); } } Give semaphore from ISR xSemaphoreGiveFromISR static void vPeriodicTask( void *pvParameters ) { for( ;; ) { /* This task is just used to simulate an interrupt by generating a software interrupt every 500ms. */ vTaskDelay( 500 / portTICK_RATE_MS ); vPrintString( Periodic task - About to generate an interrupt.\r\n ); __asm{ int 0x82 } /* This line generates the interrupt. */ vPrintString( Periodic task - Interrupt generated.\r\n\r\n\r\n ); } }BÙI QU C B O 7 Give semaphore from ISR xSemaphoreGiveFromISR static void vHandlerTask( void *pvParameters ) { /* As per most tasks, this task is implemented within an infinite loop. */ for( ;; ) { xSemaphoreTake( xBinarySemaphore, portMAX_DELAY ); vPrintString( Handler task - Processing event.\r\n ); } } Give semaphore from ISR xSemaphoreGiveFromISR int main( void ) { vSemaphoreCreateBinary( xBinarySemaphore ); _dos_setvect( 0x82, vExampleInterruptHandler ); /* Check the semaphore was created successfully. */ if( xBinarySemaphore != NULL ) { xTaskCreate( vHandlerTask, Handler, 1000, NULL, 3, NULL ); xTaskCreate( vPeriodicTask, Periodic, 1000, NULL, 1, NULL ); vTaskStartScheduler(); } for( ;; ); }BÙI QU C B O 8 Give semaphore from ISR xSemaphoreGiveFromISR Counting semaphore N u trong quá trình task ñang th c thi, ISR x y ra và g i hàm xSemap ...
Nội dung trích xuất từ tài liệu:
Interrupt management ARM PROGRAMMING Bùi Qu c B o FreeRTOS cho phép s d ng ng t. T t c các API có tên k t thúc b ng “FromISR” ho c “FROM_ISR” thì ñư c s d ng trong ISR.BÙI QU C B O 1 Binary semaphore use for synchronization Binary semaphore use for synchronizationBÙI QU C B O 2 Binary semaphore use for synchronization Binary semaphore use for synchronizationBÙI QU C B O 3 Binary semaphore use for synchronization Binary semaphore use for synchronizationBÙI QU C B O 4 Binary semaphore use for synchronization Create a binary semaphore vSemaphoreCreateBinary() void vSemaphoreCreateBinary( xSemaphoreHandle xSemaphore ); xSemaphore The semaphore being created.BÙI QU C B O 5 Get the semaphore xSemaphoreTake portBASE_TYPE xSemaphoreTake( xSemaphoreHandle xSemaphore, portTickType xTicksToWait ); xSemaphore: The semaphore being ‘taken’. xTicksToWait: 0: the function will return immediately if the semaphore is not available portMAX_DELAY: the task will wait indefinitely if INCLUDE_vTaskSuspend is set to 1 Return value: pdPASS: success pdFALSE: Fail Give semaphore from ISR xSemaphoreGiveFromISR portBASE_TYPE xSemaphoreGiveFromISR( xSemaphoreHandle xSemaphore, portBASE_TYPE *pxHigherPriorityTaskWoken ); pxHigherPriorityTaskWoken pdTRUE: a higher priority task will pre-emp current task pdFALSE: there are no higher priority task waiting for the semaphore N u pxHigherPriorityTaskWoken là pdTRUE, ISR ph i th c hi n “contextSwitch” trư c khi thoátBÙI QU C B O 6 Give semaphore from ISR xSemaphoreGiveFromISR static void __interrupt __far vExampleInterruptHandler( void ) { static portBASE_TYPE xHigherPriorityTaskWoken; xHigherPriorityTaskWoken = pdFALSE; /* Give the semaphore to unblock the task. */ xSemaphoreGiveFromISR( xBinarySemaphore, &xHigherPriorityTaskWoken ); if( xHigherPriorityTaskWoken == pdTRUE ) { portSWITCH_CONTEXT(); } } Give semaphore from ISR xSemaphoreGiveFromISR static void vPeriodicTask( void *pvParameters ) { for( ;; ) { /* This task is just used to simulate an interrupt by generating a software interrupt every 500ms. */ vTaskDelay( 500 / portTICK_RATE_MS ); vPrintString( Periodic task - About to generate an interrupt.\r\n ); __asm{ int 0x82 } /* This line generates the interrupt. */ vPrintString( Periodic task - Interrupt generated.\r\n\r\n\r\n ); } }BÙI QU C B O 7 Give semaphore from ISR xSemaphoreGiveFromISR static void vHandlerTask( void *pvParameters ) { /* As per most tasks, this task is implemented within an infinite loop. */ for( ;; ) { xSemaphoreTake( xBinarySemaphore, portMAX_DELAY ); vPrintString( Handler task - Processing event.\r\n ); } } Give semaphore from ISR xSemaphoreGiveFromISR int main( void ) { vSemaphoreCreateBinary( xBinarySemaphore ); _dos_setvect( 0x82, vExampleInterruptHandler ); /* Check the semaphore was created successfully. */ if( xBinarySemaphore != NULL ) { xTaskCreate( vHandlerTask, Handler, 1000, NULL, 3, NULL ); xTaskCreate( vPeriodicTask, Periodic, 1000, NULL, 1, NULL ); vTaskStartScheduler(); } for( ;; ); }BÙI QU C B O 8 Give semaphore from ISR xSemaphoreGiveFromISR Counting semaphore N u trong quá trình task ñang th c thi, ISR x y ra và g i hàm xSemap ...
Tìm kiếm theo từ khóa liên quan:
ARM PROGRAMMING programming techniques embedded programming computer programming programming methodsTài liệu có liên quan:
-
Lecture Web technologies and programming – Lecture 1: Introduction to web engineering
48 trang 82 0 0 -
Lecture Web technologies and programming – Lecture 12: Introduction to Cascading Style-sheets (CSS)
52 trang 74 0 0 -
Lecture Web technologies and programming – Lecture 9: HTML tables
50 trang 46 0 0 -
Getting Started with Zend Framework By Rob Allen
19 trang 44 0 0 -
Ebook 6502 assembly language subroutines
562 trang 40 0 0 -
Ebook Code craft: the practice of writing excellent code
617 trang 38 0 0 -
Lecture Web technologies and programming – Lecture 5: Web application architecture
36 trang 38 0 0 -
58 trang 37 0 0
-
C++ from the Ground Up, Third Edition
625 trang 35 0 0 -
Ebook Introduction to algorithms (3rd edition)
1313 trang 34 0 0