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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
ln
firmware
Commits
278df494
Verified
Commit
278df494
authored
5 years ago
by
schneider
Committed by
rahix
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(epicardium): Implement BLE scheduling
parent
78e5b900
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/main.c
+3
-3
3 additions, 3 deletions
epicardium/main.c
epicardium/modules/ble.c
+83
-16
83 additions, 16 deletions
epicardium/modules/ble.c
with
86 additions
and
19 deletions
epicardium/main.c
+
3
−
3
View file @
278df494
...
...
@@ -24,7 +24,6 @@
#include
"task.h"
TaskHandle_t
dispatcher_task_id
;
TaskHandle_t
ble_task_id
;
void
vBleTask
(
void
*
pvParameters
);
...
...
@@ -106,13 +105,14 @@ int main(void)
abort
();
}
/* BLE */
if
(
xTaskCreate
(
vBleTask
,
(
const
char
*
)
"BLE"
,
configMINIMAL_STACK_SIZE
,
NULL
,
tskIDLE_PRIORITY
+
3
,
&
ble_task_id
tskIDLE_PRIORITY
+
1
,
NULL
)
!=
pdPASS
)
{
printf
(
"Failed to create BLE task!
\n
"
);
abort
();
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/ble.c
+
83
−
16
View file @
278df494
...
...
@@ -12,9 +12,15 @@
#include
"mcr_regs.h"
#include
"hci_core.h"
#include
"FreeRTOS.h"
#include
"timers.h"
#include
<stdio.h>
#include
<string.h>
/* Task ID for the ble handler */
static
TaskHandle_t
ble_task_id
=
NULL
;
/* Number of WSF buffer pools */
#define WSF_BUF_POOLS 6
...
...
@@ -65,28 +71,19 @@ static void myTrace(const char *pStr, va_list args)
}
}
/*************************************************************************************************/
/*!
* \brief Initialize WSF.
*
* \return None.
*/
/*************************************************************************************************/
static
void
WsfInit
(
void
)
{
WsfTimerInit
();
WsfBufInit
(
sizeof
(
mainBufMem
),
(
uint8_t
*
)
mainBufMem
,
WSF_BUF_POOLS
,
mainPoolDesc
);
WsfTraceRegister
(
myTrace
);
}
void
MacInit
(
void
)
{
wsfHandlerId_t
handlerId
;
/* Initialize link layer. */
BbInit
();
handlerId
=
WsfOsSetNextHandler
(
SchHandler
);
SchInit
(
handlerId
);
LlAdvSlaveInit
();
LlConnSlaveInit
();
handlerId
=
WsfOsSetNextHandler
(
LlHandler
);
LlHandlerInit
(
handlerId
);
}
/* TODO: WTF? */
/*
* In two-chip solutions, setting the address must wait until the HCI interface is initialized.
...
...
@@ -109,6 +106,67 @@ void SetAddress(uint8_t event)
}
}
/*************************************************************************************************/
/*!
* \brief Initialize MAC layer.
*
* \param None.
*
* \return None.
*/
/*************************************************************************************************/
extern
int8_t
tx_rfpower_on
;
void
MacInit
(
void
)
{
wsfHandlerId_t
handlerId
;
/* Initialize link layer. */
BbInit
();
handlerId
=
WsfOsSetNextHandler
(
SchHandler
);
SchInit
(
handlerId
);
LlAdvSlaveInit
();
LlConnSlaveInit
();
handlerId
=
WsfOsSetNextHandler
(
LlHandler
);
LlHandlerInit
(
handlerId
);
}
static
StaticTimer_t
x
;
TimerHandle_t
timerWakeup
;
int
lasttick
=
0
;
static
void
vTimerCallback
(
xTimerHandle
pxTimer
)
{
bool_t
timerRunning
;
wsfTimerTicks_t
time_to_next_expire
;
do
{
int
tick
=
xTaskGetTickCount
();
WsfTimerUpdate
(
tick
-
lasttick
);
lasttick
=
tick
;
time_to_next_expire
=
WsfTimerNextExpiration
(
&
timerRunning
);
}
while
(
timerRunning
&&
time_to_next_expire
==
0
);
if
(
timerRunning
)
{
printf
(
"time_to_next_expire = %d
\n
"
,
time_to_next_expire
);
timerWakeup
=
xTimerCreateStatic
(
"timerWakeup"
,
/* name */
pdMS_TO_TICKS
(
time_to_next_expire
),
/* period/time */
pdFALSE
,
/* auto reload */
NULL
,
/* timer ID */
vTimerCallback
,
&
x
);
/* callback */
if
(
timerWakeup
!=
NULL
)
{
xTimerStart
(
timerWakeup
,
0
);
}
else
{
printf
(
"could not create timer
\n
"
);
}
}
else
{
printf
(
"No timer running
\n
"
);
}
}
static
void
ble_init
(
void
)
...
...
@@ -121,14 +179,23 @@ static void ble_init(void)
/* Register a handler for Application events */
AppUiActionRegister
(
SetAddress
);
lasttick
=
xTaskGetTickCount
();
vTimerCallback
(
NULL
);
}
void
vBleTask
(
void
*
pvParameters
)
{
ble_task_id
=
xTaskGetCurrentTaskHandle
();
ble_init
();
const
TickType_t
xDelay
=
500
/
portTICK_PERIOD_MS
;
while
(
1
){
// TODO: this need some timing and sleeping
wsfOsDispatcher
();
vTimerCallback
(
NULL
);
vTaskDelay
(
xDelay
);
}
}
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