Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
6f8e69c3
Verified
Commit
6f8e69c3
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
refactor(epicardium): Move FreeRTOS support into separate source
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
258d5963
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#926
passed
5 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
epicardium/main.c
+1
-81
1 addition, 81 deletions
epicardium/main.c
epicardium/meson.build
+2
-1
2 additions, 1 deletion
epicardium/meson.build
epicardium/support.c
+78
-0
78 additions, 0 deletions
epicardium/support.c
with
81 additions
and
82 deletions
epicardium/main.c
+
1
−
81
View file @
6f8e69c3
...
...
@@ -12,7 +12,7 @@
#include
"FreeRTOS.h"
#include
"task.h"
static
TaskHandle_t
dispatcher_task_id
;
TaskHandle_t
dispatcher_task_id
;
/* TODO: Move out of main.c */
void
epic_leds_set
(
int
led
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
...
...
@@ -21,56 +21,6 @@ void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b)
leds_update
();
}
/*
* This hook is called before FreeRTOS enters tickless idle.
*/
void
pre_idle_sleep
(
TickType_t
xExpectedIdleTime
)
{
if
(
xExpectedIdleTime
>
0
)
{
/*
* WFE because the other core should be able to notify
* epicardium if it wants to issue an API call.
*/
/*
* TODO: Ensure this is actually correct and does not have any
* race conditions.
*/
__asm
volatile
(
"cpsie i"
:::
"memory"
);
__asm
volatile
(
"dsb"
:::
"memory"
);
__asm
volatile
(
"isb"
);
__asm
volatile
(
"wfe"
);
__asm
volatile
(
"dsb"
:::
"memory"
);
__asm
volatile
(
"isb"
);
__asm
volatile
(
"cpsid i"
:::
"memory"
);
__asm
volatile
(
"dsb"
);
__asm
volatile
(
"isb"
);
}
}
/*
* This hook is called after FreeRTOS exits tickless idle.
*/
void
post_idle_sleep
(
TickType_t
xExpectedIdleTime
)
{
/* Check whether a new API call was issued. */
if
(
api_dispatcher_poll_once
())
{
xTaskNotifyGive
(
dispatcher_task_id
);
}
}
#if 0
void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
{
if (xExpectedIdleTime > 0) {
__WFE();
if (api_dispatcher_poll()) {
xTaskNotifyGive(dispatcher_task_id);
}
}
}
#endif
/*
* API dispatcher task. This task will sleep until an API call is issued and
* then wake up to dispatch it.
...
...
@@ -85,36 +35,6 @@ void vApiDispatcher(void*pvParameters)
}
}
void
vApplicationGetIdleTaskMemory
(
StaticTask_t
**
ppxIdleTaskTCBBuffer
,
StackType_t
**
ppxIdleTaskStackBuffer
,
uint32_t
*
pulIdleTaskStackSize
)
{
/*
* If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be allocated on
* the stack and so not exists after this function exits.
*/
static
StaticTask_t
xIdleTaskTCB
;
static
StackType_t
uxIdleTaskStack
[
configMINIMAL_STACK_SIZE
];
/*
* Pass out a pointer to the StaticTask_t structure in which the Idle task's
* ktate will be stored.
*/
*
ppxIdleTaskTCBBuffer
=
&
xIdleTaskTCB
;
/* Pass out the array that will be used as the Idle task's stack. */
*
ppxIdleTaskStackBuffer
=
uxIdleTaskStack
;
/*
* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
* Note that, as the array is necessarily of type StackType_t,
* configMINIMAL_STACK_SIZE is specified in words, not bytes.
*/
*
pulIdleTaskStackSize
=
configMINIMAL_STACK_SIZE
;
}
int
main
(
void
)
{
card10_init
();
...
...
This diff is collapsed.
Click to expand it.
epicardium/meson.build
+
2
−
1
View file @
6f8e69c3
...
...
@@ -63,9 +63,10 @@ freertos = static_library(
elf
=
executable
(
name
+
'.elf'
,
'main.c'
,
'cdcacm.c'
,
'main.c'
,
'serial.c'
,
'support.c'
,
dependencies
:
[
libcard10
,
max32665_startup_core0
,
maxusb
],
link_with
:
[
api_dispatcher_lib
,
freertos
],
link_whole
:
[
max32665_startup_core0_lib
,
board_card10_lib
],
...
...
This diff is collapsed.
Click to expand it.
epicardium/support.c
0 → 100644
+
78
−
0
View file @
6f8e69c3
/*
* FreeRTOS support functions
*/
#include
"FreeRTOS.h"
#include
"task.h"
#include
"api/dispatcher.h"
extern
TaskHandle_t
dispatcher_task_id
;
/*
* This hook is called before FreeRTOS enters tickless idle.
*/
void
pre_idle_sleep
(
TickType_t
xExpectedIdleTime
)
{
if
(
xExpectedIdleTime
>
0
)
{
/*
* WFE because the other core should be able to notify
* epicardium if it wants to issue an API call.
*/
/*
* TODO: Ensure this is actually correct and does not have any
* race conditions.
*/
__asm
volatile
(
"cpsie i"
:::
"memory"
);
__asm
volatile
(
"dsb"
:::
"memory"
);
__asm
volatile
(
"isb"
);
__asm
volatile
(
"wfe"
);
__asm
volatile
(
"dsb"
:::
"memory"
);
__asm
volatile
(
"isb"
);
__asm
volatile
(
"cpsid i"
:::
"memory"
);
__asm
volatile
(
"dsb"
);
__asm
volatile
(
"isb"
);
}
}
/*
* This hook is called after FreeRTOS exits tickless idle.
*/
void
post_idle_sleep
(
TickType_t
xExpectedIdleTime
)
{
/* Check whether a new API call was issued. */
if
(
api_dispatcher_poll_once
())
{
xTaskNotifyGive
(
dispatcher_task_id
);
}
}
void
vApplicationGetIdleTaskMemory
(
StaticTask_t
**
ppxIdleTaskTCBBuffer
,
StackType_t
**
ppxIdleTaskStackBuffer
,
uint32_t
*
pulIdleTaskStackSize
)
{
/*
* If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be allocated on
* the stack and so not exists after this function exits.
*/
static
StaticTask_t
xIdleTaskTCB
;
static
StackType_t
uxIdleTaskStack
[
configMINIMAL_STACK_SIZE
];
/*
* Pass out a pointer to the StaticTask_t structure in which the Idle task's
* ktate will be stored.
*/
*
ppxIdleTaskTCBBuffer
=
&
xIdleTaskTCB
;
/* Pass out the array that will be used as the Idle task's stack. */
*
ppxIdleTaskStackBuffer
=
uxIdleTaskStack
;
/*
* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
* Note that, as the array is necessarily of type StackType_t,
* configMINIMAL_STACK_SIZE is specified in words, not bytes.
*/
*
pulIdleTaskStackSize
=
configMINIMAL_STACK_SIZE
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment