Getting Started With EZ-
BLE™ PRoC™ Module
www.cypress.com
Document No.: 001-96841 Rev. **
35
Write the Application Code
The
main.c
file in the workspace has a template for the main program function. The following main firmware blocks are
required for designing any BLE standard profile applications using PSoC Creator:
System initialization
Bluetooth Low Energy stack event handler
Bluetooth Low Energy service-specific event handler
Main loop and low power implementation
This section discusses details of these blocks with respect to the design configured in the previous section.
S y s t e m I n i t i a l i z a t i o n
When the EZ-BLE PRoC Module is reset or wakes up from the hibernate mode, the firmware needs to perform initialization,
which includes platform initialization, enabling global interrupts, and initializing/starting the BLE Component.
Figure 46
shows
the flowchart for system initialization.
As a part of the BLE Component initialization, you must pass the event handler function that will be called to receive events
from the BLE stack. The BLE stack event handler shown in
Figure 49
is registered as part of the BLE initialization. If the BLE
Component initializes successfully, the firmware registers the event handler that will be called to receive IAS events and
switches control to the main loop thread.
Figure 47
shows the firmware source code for system initialization.
Figure 46. System Initialization Flowchart
Reset
Platform Initialization
- BLE Init
- Register
Stack Event
Handler
BLE-Init
Success?
Register
IAS Event
Handler
Y
Error Handling
N
S
y
s
te
m
I
n
it
ia
li
z
a
ti
o
n
Main Processing
Thread