CY8CKIT-040 PSoC
®
4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F
62
Code Examples
The firmware does the following:
■
The CapSense/input initialization part tunes the CapSense system parameters using Smart-
Sense.
■
The output initialization part configures the PWM and the software UART TX output.
■
The infinite loop code is divided into two phases: input process and output process.
❐
The input process phase scans the proximity sensor and processes the sensor signal, such
as applying filter, calculating baseline, and signal.
❐
The output process phase is also split into two phases: the data calculation and data output
subphases.
i. The data calculation subphase compares the proximity signal with a minimum and maximum
threshold defined for an approaching hand. The LED brightness is then calculated based on the
sensor's signal value relative to the thresholds. The minimum threshold generates the lowest
LED brightness, and the maximum threshold generates the highest LED brightness.
ii. The data output subphase updates the PWM compare value with the calculated brightness.
The system data such as sensor raw data, baseline, signal, and calculated LED brightness are
sent over the UART TX line.
The device monitors the activity on the proximity sensor, and if there is no activity, that is, if the hand
is out of range of the proximity, then the device enters a sleep-scan mode. The time for which the
device checks for a no activity on the sensor before entering sleep-scan mode is set to 5 seconds
and is configurable in the project (ENTER_SLEEP_COUNTS macro in
main.h
). In the sleep-scan
mode, the device wakes up every 100 ms and checks for any activity on the proximity sensor. This
wakeup rate is configurable by modifying the WATCHDOG_TIMER_COUNT macro in the
main.h
file.
Note:
There are macros defined in
main.h
for configuring the project based on user requirements.
The details of each macro are mentioned in comments above its definition.
Useful CapSense Component Functions/Variables
, and
provide details of some useful variables, macro definitions, and
component APIs respectively. These details are also available in the
Note:
All reference to the API/variable/macro assume the CapSense Component instance name as
‘CapSense’.
Содержание CY8CKIT-040 PSoC 4000 Pioneer Kit
Страница 20: ...CY8CKIT 040 PSoC 4000 Pioneer Kit Guide Doc 001 91316 Rev F 20 Kit Operation...
Страница 37: ...CY8CKIT 040 PSoC 4000 Pioneer Kit Guide Doc 001 91316 Rev F 37 Hardware...
Страница 73: ...CY8CKIT 040 PSoC 4000 Pioneer Kit Guide Doc 001 91316 Rev F 73 Code Examples Raw count and Baseline...