Last active
March 18, 2019 13:28
-
-
Save VictorLamoine/8bbb9caeaae32f0d3348ecdba060eae7 to your computer and use it in GitHub Desktop.
FreeRTOS libopencm3 blink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┌──rtos/queue.c─────────────────────────────────────────────────────────────────────────────────────┐ | |
│1719 } │ | |
│1720 } │ | |
│1721 #endif /* configUSE_MUTEXES */ │ | |
│1722 } │ | |
│1723 else if( xPosition == queueSEND_TO_BACK ) │ | |
│1724 { │ | |
│1725 ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) p│ | |
B+ │1726 pxQueue->pcWriteTo += pxQueue->uxItemSize; │ | |
>│1727 if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception ju│ | |
│1728 { │ | |
│1729 pxQueue->pcWriteTo = pxQueue->pcHead; │ | |
│1730 } │ | |
│1731 else │ | |
│1732 { │ | |
│1733 mtCOVERAGE_TEST_MARKER(); │ | |
│1734 } │ | |
┌───────────────────────────────────────────────────────────────────────────────────────────────────┐ | |
│0x80005ea <prvCopyDataToQueue+22> str r5, [r4, #4] │ | |
│0x80005ec <prvCopyDataToQueue+24> adds r6, #1 │ | |
│0x80005ee <prvCopyDataToQueue+26> str r6, [r4, #56] ; 0x38 │ | |
│0x80005f0 <prvCopyDataToQueue+28> pop {r4, r5, r6, pc} │ | |
│0x80005f2 <prvCopyDataToQueue+30> cbnz r5, 0x8000610 <prvCopyDataToQueue+60> │ | |
│0x80005f4 <prvCopyDataToQueue+32> ldr r0, [r0, #8] │ | |
│0x80005f6 <prvCopyDataToQueue+34> bl 0x8001184 <memcpy> │ | |
B+ │0x80005fa <prvCopyDataToQueue+38> ldr r3, [r4, #8] │ | |
│0x80005fc <prvCopyDataToQueue+40> ldr r2, [r4, #64] ; 0x40 │ | |
│0x80005fe <prvCopyDataToQueue+42> add r3, r2 │ | |
│0x8000600 <prvCopyDataToQueue+44> ldr r2, [r4, #4] │ | |
│0x8000602 <prvCopyDataToQueue+46> str r3, [r4, #8] │ | |
>│0x8000604 <prvCopyDataToQueue+48> cmp r3, r2 │ | |
│0x8000606 <prvCopyDataToQueue+50> bcc.n 0x800060c <prvCopyDataToQueue+56> │ | |
│0x8000608 <prvCopyDataToQueue+52> ldr r3, [r4, #0] │ | |
│0x800060a <prvCopyDataToQueue+54> str r3, [r4, #8] │ | |
└───────────────────────────────────────────────────────────────────────────────────────────────────┘ | |
(gdb) bt | |
#0 blocking_handler () at ../../cm3/vector.c:103 | |
#1 <signal handler called> | |
#2 0x0800048c in prvPortStartFirstTask () at rtos/port.c:270 | |
#3 0x080005c6 in xPortStartScheduler () at rtos/port.c:350 | |
Backtrace stopped: Cannot access memory at address 0x20005004 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <FreeRTOS.h> | |
#include <libopencm3/stm32/gpio.h> | |
#include <libopencm3/stm32/rcc.h> | |
#include <task.h> | |
static void | |
task_on(void *args __attribute__((unused))) | |
{ | |
while (1) | |
{ | |
vTaskDelay(pdMS_TO_TICKS(600)); | |
gpio_clear(GPIOC, GPIO13); | |
} | |
} | |
static void | |
task_off(void *args __attribute__((unused))) | |
{ | |
while (1) | |
{ | |
vTaskDelay(pdMS_TO_TICKS(1000)); | |
gpio_set(GPIOC, GPIO13); | |
} | |
} | |
int | |
main(void) | |
{ | |
rcc_clock_setup_in_hse_8mhz_out_72mhz(); | |
// Blue-Pill led | |
rcc_periph_clock_enable(RCC_GPIOC); | |
gpio_set_mode( | |
GPIOC, | |
GPIO_MODE_OUTPUT_2_MHZ, | |
GPIO_CNF_OUTPUT_PUSHPULL, | |
GPIO13); | |
gpio_set(GPIOC, GPIO13); // Turn off (polarity of the led is inversed!) | |
xTaskCreate(task_on, "ON", 200, NULL, configMAX_PRIORITIES-1, NULL); | |
xTaskCreate(task_off, "OFF", 200, NULL, configMAX_PRIORITIES-1, NULL); | |
vTaskStartScheduler(); | |
while(1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment