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
78e5b900
Verified
Commit
78e5b900
authored
5 years ago
by
schneider
Committed by
rahix
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(epicardium): Compile BLE stuff
parent
bb4ad001
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!47
BLE FreeRTOS integration + Demo
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
epicardium/main.c
+15
-0
15 additions, 0 deletions
epicardium/main.c
epicardium/meson.build
+1
-1
1 addition, 1 deletion
epicardium/meson.build
epicardium/modules/ble.c
+134
-0
134 additions, 0 deletions
epicardium/modules/ble.c
epicardium/modules/meson.build
+2
-1
2 additions, 1 deletion
epicardium/modules/meson.build
with
152 additions
and
2 deletions
epicardium/main.c
+
15
−
0
View file @
78e5b900
...
...
@@ -24,6 +24,9 @@
#include
"task.h"
TaskHandle_t
dispatcher_task_id
;
TaskHandle_t
ble_task_id
;
void
vBleTask
(
void
*
pvParameters
);
/*
* API dispatcher task. This task will sleep until an API call is issued and
...
...
@@ -103,6 +106,18 @@ int main(void)
abort
();
}
if
(
xTaskCreate
(
vBleTask
,
(
const
char
*
)
"BLE"
,
configMINIMAL_STACK_SIZE
,
NULL
,
tskIDLE_PRIORITY
+
3
,
&
ble_task_id
)
!=
pdPASS
)
{
printf
(
"Failed to create BLE task!
\n
"
);
abort
();
}
LOG_INFO
(
"startup"
,
"Initializing dispatcher ..."
);
api_dispatcher_init
();
...
...
This diff is collapsed.
Click to expand it.
epicardium/meson.build
+
1
−
1
View file @
78e5b900
...
...
@@ -75,7 +75,7 @@ elf = executable(
'support.c'
,
module_sources
,
l0der_sources
,
dependencies
:
[
libcard10
,
max32665_startup_core0
,
maxusb
,
libff13
],
dependencies
:
[
libcard10
,
max32665_startup_core0
,
maxusb
,
libff13
,
ble
],
link_with
:
[
api_dispatcher_lib
,
freertos
],
link_whole
:
[
max32665_startup_core0_lib
,
board_card10_lib
,
newlib_heap_lib
],
include_directories
:
[
freertos_includes
],
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/ble.c
0 → 100644
+
134
−
0
View file @
78e5b900
#include
"wsf_types.h"
#include
"wsf_os.h"
#include
"wsf_buf.h"
#include
"wsf_timer.h"
#include
"wsf_trace.h"
#include
"app_ui.h"
#include
"ll_api.h"
#include
"sch_api.h"
#include
"fit/fit_api.h"
#include
"mxc_config.h"
#include
"gcr_regs.h"
#include
"mcr_regs.h"
#include
"hci_core.h"
#include
<stdio.h>
#include
<string.h>
/* Number of WSF buffer pools */
#define WSF_BUF_POOLS 6
/*! Free memory for pool buffers (use word elements for word alignment). */
static
uint32_t
mainBufMem
[
3584
/
sizeof
(
uint32_t
)
+
96
];
/*! Default pool descriptor. */
static
wsfBufPoolDesc_t
mainPoolDesc
[
WSF_BUF_POOLS
]
=
{
{
16
,
8
},
{
32
,
4
},
{
64
,
4
},
{
128
,
4
},
{
256
,
4
},
{
384
,
4
}
};
static
void
PlatformInit
(
void
)
{
/* Change the pullup on the RST pin to 25K */
/* TODO: Is this really needed? */
MXC_MCR
->
ctrl
=
0x202
;
/* Set VREGO_D to 1.3V */
*
((
volatile
uint32_t
*
)
0x40004410
)
=
0x50
;
/* Set TX LDO to 1.1V and enable LDO. Set RX LDO to 0.9V and enable LDO */
MXC_GCR
->
btleldocn
=
0xD9
;
// TX 1.1V RX 0.9V
/* Power up the 32MHz XO */
MXC_GCR
->
clkcn
|=
MXC_F_GCR_CLKCN_X32M_EN
;
/* Enable peripheral clocks */
/* TODO: Is this really needed? */
MXC_GCR
->
perckcn0
&=
~
(
MXC_F_GCR_PERCKCN0_GPIO0D
|
MXC_F_GCR_PERCKCN0_GPIO1D
);
// Clear GPIO0 and GPIO1 Disable
MXC_GCR
->
perckcn1
&=
~
(
MXC_F_GCR_PERCKCN1_BTLED
|
MXC_F_GCR_PERCKCN1_TRNGD
);
// Clear BTLE and ICACHE0 disable
}
static
void
myTrace
(
const
char
*
pStr
,
va_list
args
)
{
extern
uint8_t
wsfCsNesting
;
if
(
wsfCsNesting
==
0
)
{
vprintf
(
pStr
,
args
);
printf
(
"
\r\n
"
);
}
}
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.
* This handler can also catch other Application events, but none are currently implemented.
* See ble-profiles/sources/apps/app/common/app_ui.c for further details.
*
*/
void
SetAddress
(
uint8_t
event
)
{
uint8_t
bdAddr
[
6
]
=
{
0x02
,
0x02
,
0x44
,
0x8B
,
0x05
,
0x00
};
switch
(
event
)
{
case
APP_UI_RESET_CMPL
:
printf
(
"Setting address -- MAC %02X:%02X:%02X:%02X:%02X:%02X
\n
"
,
bdAddr
[
5
],
bdAddr
[
4
],
bdAddr
[
3
],
bdAddr
[
2
],
bdAddr
[
1
],
bdAddr
[
0
]);
LlSetBdAddr
((
uint8_t
*
)
&
bdAddr
);
LlGetBdAddr
(
hciCoreCb
.
bdAddr
);
break
;
default:
break
;
}
}
static
void
ble_init
(
void
)
{
PlatformInit
();
WsfInit
();
MacInit
();
//StackInitFit();
//FitStart();
/* Register a handler for Application events */
AppUiActionRegister
(
SetAddress
);
}
void
vBleTask
(
void
*
pvParameters
)
{
ble_init
();
while
(
1
){
// TODO: this need some timing and sleeping
wsfOsDispatcher
();
}
}
This diff is collapsed.
Click to expand it.
epicardium/modules/meson.build
+
2
−
1
View file @
78e5b900
...
...
@@ -9,5 +9,6 @@ module_sources = files(
'stream.c'
,
'vibra.c'
,
'light_sensor.c'
,
'rtc.c'
'rtc.c'
,
'ble.c'
)
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