<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cy8CKIT-021 &#8211; IoT Expert</title>
	<atom:link href="https://iotexpert.com/category/devkits/cy8ckit-021/feed/" rel="self" type="application/rss+xml" />
	<link>https://iotexpert.com</link>
	<description>Engineering for the Internet of Things</description>
	<lastBuildDate>Sun, 10 Jul 2016 17:05:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://iotexpert.com/wp-content/uploads/2017/01/cropped-Avatar-32x32.jpg</url>
	<title>Cy8CKIT-021 &#8211; IoT Expert</title>
	<link>https://iotexpert.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>CY8CKIT-021: Example 10 &#8212; The iOS App</title>
		<link>https://iotexpert.com/cy8ckit-021-example-10-the-ios-app/</link>
					<comments>https://iotexpert.com/cy8ckit-021-example-10-the-ios-app/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 13 Jun 2016 09:00:47 +0000</pubDate>
				<category><![CDATA[Cy8CKIT-021]]></category>
		<category><![CDATA[DevKits]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=1618</guid>

					<description><![CDATA[Now that we have completely tested PRoC and PSoC4200M firmware the next step is to build an iOS App called Example 10.  The Xcode project is available in the Xcode directory in the project directory at github.com/iotexpert/cy8ckit-021/ Ill try to build this App to be as simple as possible.   Here is what the (single) [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Now that we have completely tested PRoC and PSoC4200M firmware the next step is to build an iOS App called Example 10.  The Xcode project is available in the Xcode directory in the project directory at <a href="https://github.com/iotexpert/cy8ckit-021/" target="_blank">github.com/iotexpert/cy8ckit-021/</a></p>
<p>Ill try to build this App to be as simple as possible.   Here is what the (single) screen looks like in three different state (nothing pressed, button0 pressed, led0 on):</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0027.jpg"><img fetchpriority="high" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0027-169x300.jpg" alt="IMG_0027" width="169" height="300" class="alignnone wp-image-1619 size-medium" srcset="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0027-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0027-600x1065.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0027-577x1024.jpg 577w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0027.jpg 640w" sizes="(max-width: 169px) 100vw, 169px" /></a>     <a href="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0028.jpg"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0028-169x300.jpg" alt="IMG_0028" width="169" height="300" class="alignnone wp-image-1620 size-medium" srcset="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0028-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0028-600x1065.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0028-577x1024.jpg 577w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0028.jpg 640w" sizes="(max-width: 169px) 100vw, 169px" /></a>    <a href="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0029.jpg"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0029-169x300.jpg" alt="IMG_0029" width="169" height="300" class="alignnone wp-image-1621 size-medium" srcset="https://iotexpert.com/wp-content/uploads/2016/06/IMG_0029-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0029-600x1065.jpg 600w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0029-577x1024.jpg 577w, https://iotexpert.com/wp-content/uploads/2016/06/IMG_0029.jpg 640w" sizes="(max-width: 169px) 100vw, 169px" /></a></p>
<p>This App is built up with four files</p>
<ol>
<li>ViewController.swift: an object which controls the screen (button clicks)</li>
<li>BluetoothNeighborhood.swift: an object which controls the Bluetooth in the phone and represents the CY8CKIT021 board (the Model)</li>
<li>globals.swift: Defines the NSNotifications that can be sent</li>
<li>Main.storyboard: The screen layout</li>
</ol>
<p>The code will do the following:</p>
<ol>
<li>When the ViewController (VC) starts it will instantiate a BluetoothNeighborhood (BN) object</li>
<li>VC: Tell the BN to start the bluetooth central in the phone</li>
<li>BN: Scan for BLE Peripherals that are advertising the CY8CKIT-021 Service UUID</li>
<li>BN: When it hears the peripheral with the correct UUID then connect</li>
<li>BN: Read the state of the button0 and led0 then send an NSNotification</li>
<li>BN: Turn on the notify for button0 (to cause the PRoC to send an NSNotification when there are changes)</li>
<li>VC: update the screen when it gets the NSNotification from (5)</li>
<li>VC: If the LED0 switch on the screen is switched then tell the BN to write to the PRoC</li>
<li>BN: If the button0 is changed then send an NSNotification to the VC</li>
<li>VC: If there is an NSNotification (9) of a button0 change then update the screen</li>
<li>VC: If the bootloader button is pressed tell the BN to write the bootloader characteristic</li>
<li>BN: If there is a disconnect event then send an NSNotification to the VC to disable the GUI elements and start scanning again (step 3)</li>
</ol>
<h2>ViewController.swift</h2>
<p>The viewDidLoad method runs when the Apps starts and loads the first screen.  This method</p>
<ol>
<li>Initializes the BluetoothNeighborhood object</li>
<li>Tell it to start the bluetooth scanning</li>
<li>Disables the UI buttons</li>
<li>Then registers with the NSNotificationCenter that it wants to hear the 4 possible messages that the model can send
<ol>
<li>Connect: enable the buttons</li>
<li>Disconnect: disable the buttons</li>
<li>UpdateLED: reflect the current state of the LED on the screen</li>
<li>UpdateButton: reflect the current state of the button on the screen</li>
</ol>
</li>
</ol>
<p>&nbsp;</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="swift"><pre class="de1"><span class="co1">//</span>
<span class="co1">//  ViewController.swift</span>
<span class="co1">//  Example10</span>
<span class="co1">//</span>
<span class="co1">// Project: Example10</span>
<span class="co1">// Kit: CY8CKIT-021 Sheild</span>
<span class="co1">// Baseboard: CY8CKit-44 PSoC4M</span>
<span class="co1">//</span>
<span class="co1">//  This file contains the viewcontroller for the single view application.</span>
<span class="co1">//  Basically when it loads you startup and connect to the bleboard</span>
<span class="co1">//  then display the state of things... or let the user flip the switch</span>
<span class="co1">//</span>
&nbsp;
<span class="kw1">import</span> UIKit
&nbsp;
<span class="kw1">class</span> ViewController<span class="sy0">:</span> <span class="kw13">UIViewController</span> <span class="br0">&#123;</span>
&nbsp;
    <span class="kw1">var</span> bleLand <span class="sy0">:</span> BlueToothNeighborhood<span class="sy0">!</span>
&nbsp;
    <span class="kw1">override</span> <span class="kw1">func</span> viewDidLoad<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw1">super</span>.<span class="me1">viewDidLoad</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
&nbsp;
        <span class="co1">// bleLand-BlueToothNeighborhood is the model.  It is capable of finding</span>
        <span class="co1">// a CY8CKIT021 and connecting to it. It can also read/write etc</span>
        bleLand = BlueToothNeighborhood<span class="br0">&#40;</span><span class="br0">&#41;</span>
        bleLand.<span class="me1">startUpCentralManager</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
&nbsp;
        <span class="co1">// start with the switch disabled.  it will turn on once there is a connection</span>
        led0switch.<span class="me1">userInteractionEnabled</span> = <span class="kw1">false</span>
        bootLoaderButton.<span class="me1">userInteractionEnabled</span> = <span class="kw1">false</span>
&nbsp;
&nbsp;
        <span class="co1">// The global structure CY8CKITNotifications defines the different notificateions</span>
        <span class="co1">// that can come from the bleLand model.  Basically a connection/disconnection or</span>
        <span class="co1">// and update of the Led0 or Button0 State</span>
&nbsp;
        <span class="co1">// If you get a complete connection then turn on the buttons to start working</span>
        <span class="kw7">NSNotificationCenter</span>.<span class="me1">defaultCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">addObserverForName</span><span class="br0">&#40;</span>CY8CKIT021Notifications.<span class="me1">ConnectionComplete</span><span class="sy0">,</span> object<span class="sy0">:</span> <span class="kw1">nil</span><span class="sy0">,</span> queue<span class="sy0">:</span> <span class="kw7">NSOperationQueue</span>.<span class="me1">mainQueue</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> _ <span class="kw1">in</span>
            <span class="kw1">self</span>.<span class="me1">led0switch</span>.<span class="me1">userInteractionEnabled</span> = <span class="kw1">true</span>
            <span class="kw1">self</span>.<span class="me1">bootLoaderButton</span>.<span class="me1">userInteractionEnabled</span> = <span class="kw1">true</span>
        <span class="br0">&#125;</span>
&nbsp;
        <span class="co1">// if you get disconnected then turn off the buttons</span>
        <span class="kw7">NSNotificationCenter</span>.<span class="me1">defaultCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">addObserverForName</span><span class="br0">&#40;</span>CY8CKIT021Notifications.<span class="me1">DisconnectedDevice</span><span class="sy0">,</span> object<span class="sy0">:</span> <span class="kw1">nil</span><span class="sy0">,</span> queue<span class="sy0">:</span> <span class="kw7">NSOperationQueue</span>.<span class="me1">mainQueue</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> _ <span class="kw1">in</span>
                <span class="kw1">self</span>.<span class="me1">led0switch</span>.<span class="me1">userInteractionEnabled</span> = <span class="kw1">false</span>
                <span class="kw1">self</span>.<span class="me1">bootLoaderButton</span>.<span class="me1">userInteractionEnabled</span> = <span class="kw1">false</span>
            <span class="br0">&#125;</span>
&nbsp;
        <span class="co1">// The we got feedback from the model about the state of the button0</span>
        <span class="kw7">NSNotificationCenter</span>.<span class="me1">defaultCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">addObserverForName</span><span class="br0">&#40;</span>CY8CKIT021Notifications.<span class="me1">UpdatedButton0</span><span class="sy0">,</span> object<span class="sy0">:</span> <span class="kw1">nil</span><span class="sy0">,</span> queue<span class="sy0">:</span> <span class="kw7">NSOperationQueue</span>.<span class="me1">mainQueue</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> _ <span class="kw1">in</span> <span class="kw1">self</span>.<span class="me1">button0</span>.<span class="me1">selected</span> = <span class="kw1">self</span>.<span class="me1">bleLand</span>.<span class="me1">button0State</span> <span class="br0">&#125;</span>
&nbsp;
        <span class="co1">// The we got feedback from the model about the state of the led0</span>
        <span class="kw7">NSNotificationCenter</span>.<span class="me1">defaultCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">addObserverForName</span><span class="br0">&#40;</span>CY8CKIT021Notifications.<span class="me1">UpdateLed0</span><span class="sy0">,</span> object<span class="sy0">:</span> <span class="kw1">nil</span><span class="sy0">,</span> queue<span class="sy0">:</span> <span class="kw7">NSOperationQueue</span>.<span class="me1">mainQueue</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> _ <span class="kw1">in</span> <span class="kw1">self</span>.<span class="me1">updateLed0</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#125;</span>
&nbsp;
    <span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>The GUI part of the code just acts when the button/switch is pressed to send messages to the model.  These methods are linked to the GUI elements on the main.storyboard</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="swift"><pre class="de1">    <span class="co1">// This function grabs the current button0 state from the model and sets the button</span>
    <span class="co1">// to indicate it is either being pressed or not</span>
    <span class="kw1">func</span> updateButton0<span class="br0">&#40;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="kw1">self</span>.<span class="me1">button0</span>.<span class="me1">selected</span> = <span class="kw1">self</span>.<span class="me1">bleLand</span>.<span class="me1">button0State</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// This functiong rabs the current led0 state from the model and then flips the </span>
    <span class="co1">// switch the right way</span>
    <span class="kw1">func</span> updateLed0<span class="br0">&#40;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        led0switch.<span class="me1">on</span> = bleLand.<span class="me1">led0State</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="kw2">@IBOutlet</span> <span class="kw1">weak</span> <span class="kw1">var</span> button0<span class="sy0">:</span> <span class="kw13">UIButton</span><span class="sy0">!</span>
    <span class="kw2">@IBOutlet</span> <span class="kw1">weak</span> <span class="kw1">var</span> led0switch<span class="sy0">:</span> <span class="kw13">UISwitch</span><span class="sy0">!</span>
&nbsp;
    <span class="co1">// When the user flips the switch you need to write the updated value to the model</span>
    <span class="kw2">@IBAction</span> <span class="kw1">func</span> led0SwitchAction<span class="br0">&#40;</span>sender<span class="sy0">:</span> <span class="kw13">UISwitch</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
            bleLand.<span class="me1">writeLed0Characteristic</span><span class="br0">&#40;</span>sender.<span class="me1">on</span><span class="br0">&#41;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// If the user presses the bootload button then send the bootload command</span>
    <span class="co1">// this will cause and immediate BLE disconnect... etc</span>
    <span class="kw2">@IBOutlet</span> <span class="kw1">weak</span> <span class="kw1">var</span> bootLoaderButton<span class="sy0">:</span> <span class="kw13">UIButton</span><span class="sy0">!</span>
    <span class="kw2">@IBAction</span> <span class="kw1">func</span> startBootLoader<span class="br0">&#40;</span>sender<span class="sy0">:</span> <span class="kw6">AnyObject</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        bleLand.<span class="me1">startBootloader</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
    <span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<h1>BluetoothNeighborhood</h1>
<p>This file contains all of the code that interacts with the CY8CKIT021 board.  The first block of code defines a structure with a list of the UUIDs that we need to search for.  These are defined in the Bluetooth Component Customizer from the PRoC firmware.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="swift"><pre class="de1"><span class="co1">// BlueToothNeighborhood.swift</span>
<span class="co1">//</span>
<span class="co1">// Project: Example10</span>
<span class="co1">// Kit: CY8CKIT-021 Sheild</span>
<span class="co1">// Baseboard: CY8CKit-44 PSoC4M</span>
<span class="co1">//</span>
<span class="co1">// This file contains the model for the CY8CKIT021 board with 1 LED0 and 1 Button 0</span>
<span class="co1">//</span>
&nbsp;
<span class="kw1">import</span> CoreBluetooth
&nbsp;
&nbsp;
<span class="co1">// This structure conatains the UUIDS for the services and characteristics on the board</span>
<span class="co1">// it MUST match what you defined in the creator BLE Configuration Wizard</span>
<span class="kw1">private</span> <span class="kw1">struct</span> BLEParameters <span class="br0">&#123;</span>
    <span class="kw1">static</span> <span class="kw1">let</span> CY8CKIT021Service = CBUUID<span class="br0">&#40;</span>string<span class="sy0">:</span> <span class="st0">&quot;00000000-0000-1000-8000-00805F9B3400&quot;</span><span class="br0">&#41;</span>
    <span class="kw1">static</span> <span class="kw1">let</span> bootloadCharactersticUUID = CBUUID<span class="br0">&#40;</span>string<span class="sy0">:</span><span class="st0">&quot;00000000-0000-1000-8000-00805F9B3401&quot;</span><span class="br0">&#41;</span>
    <span class="kw1">static</span> <span class="kw1">let</span> ledCharactersticUUID = CBUUID<span class="br0">&#40;</span>string<span class="sy0">:</span><span class="st0">&quot;00000000-0000-1000-8000-00805F9B3402&quot;</span><span class="br0">&#41;</span>
    <span class="kw1">static</span> <span class="kw1">let</span> buttonCharactersticUUID = CBUUID<span class="br0">&#40;</span>string<span class="sy0">:</span><span class="st0">&quot;00000000-0000-1000-8000-00805F9B3404&quot;</span><span class="br0">&#41;</span>
&nbsp;
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>The next block of code</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="swift"><pre class="de1"><span class="co1">// The model for the board</span>
<span class="co1">// The BlueToothNeighborhood has BOTH the board model and the Bluetooth model.  This</span>
<span class="co1">// makes the code slightly simpler to explain but is a bit weird architectururally</span>
<span class="kw1">class</span> BlueToothNeighborhood<span class="sy0">:</span> <span class="kw7">NSObject</span><span class="sy0">,</span> CBCentralManagerDelegate<span class="sy0">,</span> CBPeripheralDelegate  <span class="br0">&#123;</span>
&nbsp;
    <span class="kw1">private</span> <span class="kw1">var</span> centralManager <span class="sy0">:</span> CBCentralManager<span class="sy0">!</span>
    <span class="kw1">private</span> <span class="kw1">var</span> CY8CKIT021Board <span class="sy0">:</span> CBPeripheral?
    <span class="kw1">private</span> <span class="kw1">var</span> CY8CKIT021Service <span class="sy0">:</span> CBService<span class="sy0">!</span>
    <span class="kw1">private</span> <span class="kw1">var</span> led0Characteristic <span class="sy0">:</span> CBCharacteristic<span class="sy0">!</span>
    <span class="kw1">private</span> <span class="kw1">var</span> button0Characteristic <span class="sy0">:</span> CBCharacteristic<span class="sy0">!</span>
    <span class="kw1">private</span> <span class="kw1">var</span> bootloadCharacteristic <span class="sy0">:</span> CBCharacteristic<span class="sy0">!</span>
&nbsp;
    <span class="co1">// This function is called by the main view controller to get things going</span>
    <span class="kw1">func</span> startUpCentralManager<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        centralManager = CBCentralManager<span class="br0">&#40;</span>delegate<span class="sy0">:</span> <span class="kw1">self</span><span class="sy0">,</span> queue<span class="sy0">:</span> <span class="kw1">nil</span><span class="br0">&#41;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// This is the bluetooth delegate function</span>
    <span class="kw2">@objc</span> <span class="kw1">func</span> centralManagerDidUpdateState<span class="br0">&#40;</span>central<span class="sy0">:</span> CBCentralManager<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw1">switch</span> <span class="br0">&#40;</span>central.<span class="me1">state</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw1">case</span> .<span class="me1">PoweredOff</span><span class="sy0">:</span> <span class="kw1">break</span>
        <span class="kw1">case</span> .<span class="me1">PoweredOn</span><span class="sy0">:</span>
            <span class="kw3">print</span><span class="br0">&#40;</span><span class="st0">&quot;Bluetooth is on - Starting scan&quot;</span><span class="br0">&#41;</span>
            <span class="co1">// start scanning for a device that we can talk to</span>
            centralManager.<span class="me1">scanForPeripheralsWithServices</span><span class="br0">&#40;</span><span class="br0">&#91;</span>BLEParameters.<span class="me1">CY8CKIT021Service</span><span class="br0">&#93;</span><span class="sy0">,</span> options<span class="sy0">:</span> <span class="br0">&#91;</span>CBCentralManagerScanOptionAllowDuplicatesKey<span class="sy0">:</span><span class="kw1">false</span><span class="br0">&#93;</span><span class="br0">&#41;</span>
&nbsp;
        <span class="kw1">case</span> .<span class="me1">Resetting</span><span class="sy0">:</span> <span class="kw1">break</span>
        <span class="kw1">case</span> .<span class="me1">Unauthorized</span><span class="sy0">:</span> <span class="kw1">break</span>
        <span class="kw1">case</span> .<span class="me1">Unknown</span><span class="sy0">:</span><span class="kw1">break</span>
        <span class="kw1">case</span> .<span class="me1">Unsupported</span><span class="sy0">:</span><span class="kw1">break</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// This delegate function is called by the bluetooth when it finds a device</span>
    <span class="co1">// that matches our UUID that we told it when we started the scan</span>
    <span class="kw1">func</span> centralManager<span class="br0">&#40;</span>central<span class="sy0">:</span> CBCentralManager<span class="sy0">,</span> didDiscoverPeripheral peripheral<span class="sy0">:</span> CBPeripheral<span class="sy0">,</span> advertisementData<span class="sy0">:</span> <span class="br0">&#91;</span><span class="kw4">String</span> <span class="sy0">:</span> <span class="kw6">AnyObject</span><span class="br0">&#93;</span><span class="sy0">,</span> RSSI<span class="sy0">:</span> <span class="kw7">NSNumber</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="co1">// if you already are connected to a device ignore this one</span>
        <span class="kw1">if</span> CY8CKIT021Board <span class="sy0">==</span> <span class="kw1">nil</span> <span class="br0">&#123;</span>
            <span class="kw3">print</span><span class="br0">&#40;</span><span class="st0">&quot;Found a new Periphal advertising CY8CKIT021 Service&quot;</span><span class="br0">&#41;</span>
            CY8CKIT021Board = peripheral
            centralManager.<span class="me1">stopScan</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
            centralManager.<span class="me1">connectPeripheral</span><span class="br0">&#40;</span>CY8CKIT021Board<span class="sy0">!,</span> options<span class="sy0">:</span> <span class="kw1">nil</span><span class="br0">&#41;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// This delegate is called when a device connection is complete</span>
    <span class="kw1">func</span> centralManager<span class="br0">&#40;</span>central<span class="sy0">:</span> CBCentralManager<span class="sy0">,</span> didConnectPeripheral peripheral<span class="sy0">:</span> CBPeripheral<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw3">print</span><span class="br0">&#40;</span><span class="st0">&quot;Connection complete <span class="es0">\(</span>CY8CKIT021Board) <span class="es0">\(</span>peripheral)&quot;</span><span class="br0">&#41;</span>
        CY8CKIT021Board<span class="sy0">!</span>.<span class="me1">delegate</span> = <span class="kw1">self</span>
        CY8CKIT021Board<span class="sy0">!</span>.<span class="me1">discoverServices</span><span class="br0">&#40;</span><span class="kw1">nil</span><span class="br0">&#41;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// This delegate is called after the service discovery is complete</span>
    <span class="kw1">func</span> peripheral<span class="br0">&#40;</span>peripheral<span class="sy0">:</span> CBPeripheral<span class="sy0">,</span> didDiscoverServices error<span class="sy0">:</span> <span class="kw7">NSError</span>?<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw3">print</span><span class="br0">&#40;</span><span class="st0">&quot;discovered services&quot;</span><span class="br0">&#41;</span>
        <span class="kw1">for</span> service <span class="kw1">in</span> peripheral.<span class="me1">services</span><span class="sy0">!</span> <span class="br0">&#123;</span>
            <span class="kw3">print</span><span class="br0">&#40;</span><span class="st0">&quot;Found service <span class="es0">\(</span>service)&quot;</span><span class="br0">&#41;</span>
            <span class="kw1">if</span> service.<span class="me1">UUID</span> <span class="sy0">==</span> BLEParameters.<span class="me1">CY8CKIT021Service</span> <span class="br0">&#123;</span>
                CY8CKIT021Service = service <span class="co1">// as! CBService</span>
            <span class="br0">&#125;</span>
        <span class="br0">&#125;</span>
        CY8CKIT021Board<span class="sy0">!</span>.<span class="me1">discoverCharacteristics</span><span class="br0">&#40;</span><span class="kw1">nil</span><span class="sy0">,</span> forService<span class="sy0">:</span> CY8CKIT021Service<span class="br0">&#41;</span>
    <span class="br0">&#125;</span>
&nbsp;
&nbsp;
    <span class="co1">// This delegate is called when the characteristic discovery is complete</span>
    <span class="kw1">func</span> peripheral<span class="br0">&#40;</span>peripheral<span class="sy0">:</span> CBPeripheral<span class="sy0">,</span> didDiscoverCharacteristicsForService service<span class="sy0">:</span> CBService<span class="sy0">,</span> error<span class="sy0">:</span> <span class="kw7">NSError</span>?<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw1">for</span> characteristic <span class="kw1">in</span> service.<span class="me1">characteristics</span><span class="sy0">!</span>
        <span class="br0">&#123;</span>
&nbsp;
            <span class="kw3">print</span><span class="br0">&#40;</span><span class="st0">&quot;Found characteristic <span class="es0">\(</span>characteristic)&quot;</span><span class="br0">&#41;</span>
            <span class="kw1">switch</span> characteristic.<span class="me1">UUID</span> <span class="br0">&#123;</span>
            <span class="kw1">case</span> BLEParameters.<span class="me1">buttonCharactersticUUID</span><span class="sy0">:</span> button0Characteristic = characteristic
            <span class="kw1">case</span> BLEParameters.<span class="me1">ledCharactersticUUID</span><span class="sy0">:</span> led0Characteristic = characteristic
            <span class="kw1">case</span> BLEParameters.<span class="me1">bootloadCharactersticUUID</span><span class="sy0">:</span> bootloadCharacteristic = characteristic
            <span class="kw1">default</span><span class="sy0">:</span> <span class="kw1">break</span>
            <span class="br0">&#125;</span>
        <span class="br0">&#125;</span>
&nbsp;
        <span class="co1">// You have a complete connection... so find out the current state of the LED0</span>
        <span class="co1">// and Button.. then notify the viewcontroller that things are rolling</span>
&nbsp;
        <span class="co1">// read the led0 characteristic to find out its current state</span>
        CY8CKIT021Board?.<span class="me1">readValueForCharacteristic</span><span class="br0">&#40;</span>led0Characteristic<span class="br0">&#41;</span>
&nbsp;
        <span class="co1">// read the button0 characteristic to find out its current state</span>
        CY8CKIT021Board?.<span class="me1">readValueForCharacteristic</span><span class="br0">&#40;</span>button0Characteristic<span class="br0">&#41;</span>
&nbsp;
        CY8CKIT021Board<span class="sy0">!</span>.<span class="me1">setNotifyValue</span><span class="br0">&#40;</span><span class="kw1">true</span><span class="sy0">,</span> forCharacteristic<span class="sy0">:</span> button0Characteristic<span class="br0">&#41;</span>
        <span class="kw7">NSNotificationCenter</span>.<span class="me1">defaultCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">postNotificationName</span><span class="br0">&#40;</span>CY8CKIT021Notifications.<span class="me1">ConnectionComplete</span><span class="sy0">,</span> object<span class="sy0">:</span> <span class="kw1">nil</span><span class="br0">&#41;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// disconnected device - start scanning again</span>
    <span class="kw1">func</span> centralManager<span class="br0">&#40;</span>central<span class="sy0">:</span> CBCentralManager<span class="sy0">,</span> didDisconnectPeripheral peripheral<span class="sy0">:</span> CBPeripheral<span class="sy0">,</span> error<span class="sy0">:</span> <span class="kw7">NSError</span>?<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw3">print</span><span class="br0">&#40;</span><span class="st0">&quot;Disconnected <span class="es0">\(</span>peripheral)&quot;</span><span class="br0">&#41;</span>
        CY8CKIT021Board = <span class="kw1">nil</span>
        <span class="kw7">NSNotificationCenter</span>.<span class="me1">defaultCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">postNotificationName</span><span class="br0">&#40;</span>CY8CKIT021Notifications.<span class="me1">DisconnectedDevice</span><span class="sy0">,</span> object<span class="sy0">:</span> <span class="kw1">nil</span><span class="br0">&#41;</span>
        centralManager.<span class="me1">scanForPeripheralsWithServices</span><span class="br0">&#40;</span><span class="br0">&#91;</span>BLEParameters.<span class="me1">CY8CKIT021Service</span><span class="br0">&#93;</span><span class="sy0">,</span> options<span class="sy0">:</span> <span class="br0">&#91;</span>CBCentralManagerScanOptionAllowDuplicatesKey<span class="sy0">:</span><span class="kw1">false</span><span class="br0">&#93;</span><span class="br0">&#41;</span>
&nbsp;
    <span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>The last block of code is responsible for interacting with the board</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="swift"><pre class="de1"><span class="co1">// start the bootloader...this will cause an immediate disconnect by the board</span>
    <span class="kw1">func</span> startBootloader<span class="br0">&#40;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="kw1">var</span> val<span class="sy0">:</span> <span class="kw4">UInt8</span> = <span class="nu0">1</span> <span class="co1">// it doesnt matter the value... any write will cause the bootloader to start</span>
        <span class="kw1">let</span> ns = <span class="kw7">NSData</span><span class="br0">&#40;</span>bytes<span class="sy0">:</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span>val<span class="sy0">,</span> length<span class="sy0">:</span> <span class="kw3">sizeof</span><span class="br0">&#40;</span><span class="kw4">UInt8</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
        CY8CKIT021Board<span class="sy0">!</span>.<span class="me1">writeValue</span><span class="br0">&#40;</span>ns<span class="sy0">,</span> forCharacteristic<span class="sy0">:</span> bootloadCharacteristic<span class="sy0">,</span> type<span class="sy0">:</span> CBCharacteristicWriteType.<span class="me1">WithResponse</span><span class="br0">&#41;</span>
    <span class="br0">&#125;</span>
&nbsp;
&nbsp;
    <span class="co1">// a helper function to write the the device</span>
    <span class="kw1">func</span> writeLed0Characteristic<span class="br0">&#40;</span>state<span class="sy0">:</span> <span class="kw4">Bool</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="kw1">var</span> val <span class="sy0">:</span> <span class="kw4">Int8</span>
        <span class="kw1">if</span><span class="br0">&#40;</span>state<span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            val = <span class="nu0">1</span>
        <span class="br0">&#125;</span>
        <span class="kw1">else</span>
        <span class="br0">&#123;</span>
            val = <span class="nu0">0</span>
        <span class="br0">&#125;</span>
        <span class="kw1">let</span> ns = <span class="kw7">NSData</span><span class="br0">&#40;</span>bytes<span class="sy0">:</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span>val<span class="sy0">,</span> length<span class="sy0">:</span> <span class="kw3">sizeof</span><span class="br0">&#40;</span><span class="kw4">Int8</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
        CY8CKIT021Board<span class="sy0">!</span>.<span class="me1">writeValue</span><span class="br0">&#40;</span>ns<span class="sy0">,</span> forCharacteristic<span class="sy0">:</span> led0Characteristic<span class="sy0">,</span> type<span class="sy0">:</span> CBCharacteristicWriteType.<span class="me1">WithResponse</span><span class="br0">&#41;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// this is the model of the board</span>
    <span class="kw1">var</span> button0State <span class="sy0">:</span> <span class="kw4">Bool</span> = <span class="kw1">false</span> 
    <span class="kw1">var</span> led0State <span class="sy0">:</span> <span class="kw4">Bool</span> = <span class="kw1">false</span> <span class="co1">// assume that it is off</span>
&nbsp;
    <span class="co1">// This delegate function is called when an updated value is received from the Bluetooth Stack</span>
    <span class="kw1">func</span> peripheral<span class="br0">&#40;</span>peripheral<span class="sy0">:</span> CBPeripheral<span class="sy0">,</span> didUpdateValueForCharacteristic characteristic<span class="sy0">:</span> CBCharacteristic<span class="sy0">,</span> error<span class="sy0">:</span> <span class="kw7">NSError</span>?<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw1">if</span> characteristic <span class="sy0">==</span> button0Characteristic <span class="br0">&#123;</span>
            <span class="kw1">var</span> out<span class="sy0">:</span> <span class="kw4">UInt8</span> = <span class="nu0">0</span>
            characteristic.<span class="me1">value</span><span class="sy0">!</span>.<span class="me1">getBytes</span><span class="br0">&#40;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>out<span class="sy0">,</span> length<span class="sy0">:</span><span class="kw3">sizeof</span><span class="br0">&#40;</span><span class="kw4">UInt8</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
            <span class="kw1">if</span><span class="br0">&#40;</span>out <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                button0State = <span class="kw1">false</span>
            <span class="br0">&#125;</span>
            <span class="kw1">else</span>
            <span class="br0">&#123;</span>
                button0State = <span class="kw1">true</span>
            <span class="br0">&#125;</span>
            <span class="kw7">NSNotificationCenter</span>.<span class="me1">defaultCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">postNotificationName</span><span class="br0">&#40;</span>CY8CKIT021Notifications.<span class="me1">UpdatedButton0</span><span class="sy0">,</span> object<span class="sy0">:</span> <span class="kw1">nil</span><span class="br0">&#41;</span>
        <span class="br0">&#125;</span>
&nbsp;
        <span class="kw1">if</span> characteristic <span class="sy0">==</span> led0Characteristic <span class="br0">&#123;</span>
            <span class="kw1">var</span> out<span class="sy0">:</span> NSInteger = <span class="nu0">0</span>
            characteristic.<span class="me1">value</span><span class="sy0">!</span>.<span class="me1">getBytes</span><span class="br0">&#40;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>out<span class="sy0">,</span> length<span class="sy0">:</span><span class="kw3">sizeof</span><span class="br0">&#40;</span><span class="kw4">UInt8</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
            <span class="kw1">if</span><span class="br0">&#40;</span>out <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                led0State = <span class="kw1">false</span>
            <span class="br0">&#125;</span>
            <span class="kw1">else</span>
            <span class="br0">&#123;</span>
                led0State = <span class="kw1">true</span>
            <span class="br0">&#125;</span>
            <span class="kw7">NSNotificationCenter</span>.<span class="me1">defaultCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">postNotificationName</span><span class="br0">&#40;</span>CY8CKIT021Notifications.<span class="me1">UpdateLed0</span><span class="sy0">,</span> object<span class="sy0">:</span> <span class="kw1">nil</span><span class="br0">&#41;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>In the next post Ill show you how to build the Android App.</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >index</th>
<th >description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2016/05/23/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/">CY8CKIT-021: A Simple FM/PSoC + BLE Demonstration Board</a></td>
<td >Introduction to CY8CKIT021</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/24/cy8ckit-021-the-first-4-example-projects/">CY8CKIT-021: The first four example projects</a></td>
<td >Use the LEDs</td>
<td > Buzzer</td>
<td > 7-Segment display and the Potentiometer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/25/cy8ckit-021-the-next-3-example-projects/">CY8CKIT-021: The next three example projects</a></td>
<td >Use theThermistor and two Capsense Examples</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: Bootloading the PRoC</a></td>
<td >How to put firmware into the PRoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/31/cy8ckit-021-the-bleiot-component/">CY8CKIT-021: The BLEIOT Component</a></td>
<td >A custom component to communicate with the PRoC/PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/02/cy8ckit-021-using-the-bleiot-component/">CY8CKIT-021: Using the BLEIOT Component</a></td>
<td >A full example of the tho MCUs talking</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: The PRoC BLE Firmware</a></td>
<td >How to make PRoC Firmware and use it with the BLEIOT Component</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/13/cy8ckit-021-example-10-the-ios-app/">CY8CKIT-021: Example 10 - the new IOS App</a></td>
<td >How to build and IOS App to talk to the development kit</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy8ckit-021-example-10-the-ios-app/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CY8CKIT-021: The PRoC BLE Firmware</title>
		<link>https://iotexpert.com/cy8ckit-021-the-proc-ble-firmware/</link>
					<comments>https://iotexpert.com/cy8ckit-021-the-proc-ble-firmware/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 06 Jun 2016 09:32:49 +0000</pubDate>
				<category><![CDATA[Cy8CKIT-021]]></category>
		<category><![CDATA[DevKits]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=1587</guid>

					<description><![CDATA[In the next few posts I am going to show how to build a very simple BLE project for the shield, debug it using CySmart, make an iOS app, and finally make an Android app.  I am going to try to only put in the bare minimum of feature that will enable you to see [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In the next few posts I am going to show how to build a very simple BLE project for the shield, debug it using CySmart, make an iOS app, and finally make an Android app.  I am going to try to only put in the bare minimum of feature that will enable you to see the whole project work from end to end.  This next series of posts will use</p>
<ul>
<li>LED0: which can be turned on/off from the from the Android and iOS App</li>
<li>Button0: which will be displayed as on/off on the Android and iOS App</li>
<li>Bootload: you will be able to trigger the bootloader from the baseboard or by writing into the BLE Bootload characteristic</li>
<li>The blue LED attached to the PRoC will blink when advertising and be solid when connected</li>
</ul>
<p>All of this firmware is available as Example10a (for the PRoC) and Example10b for the PSoC4200m in the firmware directory on <a href="http://github.com/iotexpert/CY8CKIT-021" target="_blank">github.com/iotexpert/CY8CKIT-021</a></p>
<h2>Example 10a: The PRoC Firmware</h2>
<p>The schematic for this project has two pages.  The first page has everything except for the bootloadble.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.35-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.35-AM.png" alt="Screen Shot 2016-05-30 at 10.11.35 AM" width="630" height="518" class="alignnone size-large wp-image-1592" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.35-AM.png 630w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.35-AM-600x493.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.35-AM-300x247.png 300w" sizes="auto, (max-width: 630px) 100vw, 630px" /></a></p>
<p>The second page of the schematic has the bootloadable.  This allows me to &#8220;disable&#8221; that page if I am not using the Bootloader</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.14.59-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.14.59-AM.png" alt="Screen Shot 2016-05-30 at 10.14.59 AM" width="407" height="450" class="alignnone size-full wp-image-1593" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.14.59-AM.png 407w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.14.59-AM-271x300.png 271w" sizes="auto, (max-width: 407px) 100vw, 407px" /></a></p>
<p>The BLE component has the &#8220;CY8CKIT021&#8221; service with three characteristics one for LED0, Button and Bootload,  The Button has a notify CCCD setup.  All three are uint8s.</p>
<p><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.56-AM.png" alt="Screen Shot 2016-05-30 at 10.11.56 AM" width="918" height="846" class="alignnone size-full wp-image-1591" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.56-AM.png 918w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.56-AM-600x553.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.56-AM-300x276.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-10.11.56-AM-768x708.png 768w" sizes="auto, (max-width: 918px) 100vw, 918px" /></p>
<p>This program is broken up into three functions</p>
<ul>
<li><strong>updateGattDB</strong>: A helper function that can take data as a void* and write it into the correct place in the GattDB.  For example when the app changes the LED0 Characteristic you need to write that update into the GattDB.  This function is generic which will support the same logic on a bunch of different characteristic (for instance when I put in all of the other characteristics LED0/1, Button0/1, Pot, &#8230;)</li>
<li><strong>BleCallBack: </strong>This function  processes the BLE Events
<ul>
<li>Stack on or disconnect: start advertising and start blinking</li>
<li>Write of characterstic from Central: store the written value into the GattDB and do something</li>
<li>Connect: update the GattDB and turn on the LED</li>
</ul>
</li>
<li><strong>main:</strong> This function is very simple and forms the main loop of the program.
<ul>
<li>Start the components</li>
<li>If there is a remote from the 4200M side then update the GattDB</li>
</ul>
</li>
</ul>
<p>First, the updateGattDB helper function.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="c"><pre class="de1"><span class="co1">// updateGattDB() -  </span>
<span class="co1">//</span>
<span class="co1">// Arguments: </span>
<span class="co1">//  uint8* val  - a pointer to the bytes that need to be writted into the GATTDB</span>
<span class="co1">//  int size - the number of bytes that need to be written into the GATTDB</span>
<span class="co1">//  uint8 notify - if the NOTIFY is on then send a notification</span>
<span class="co1">//  CYBLE_GATT_DB_ATTR_HANDLE_T handle - a handle to the entry in the gatt table</span>
<span class="co1">//  uint8 flags - a request </span>
<span class="co1">//   </span>
<span class="co1">// This is a helper function that will update the GATT database with a value.  It update the field of</span>
<span class="co1">// the &quot;CYBLE_GATT_DB_ATTR_HANDLE_T&quot;</span>
&nbsp;
<span class="kw4">void</span> updateGattDB<span class="br0">&#40;</span><span class="kw4">uint8</span> <span class="sy0">*</span>val<span class="sy0">,</span><span class="kw4">int</span> size<span class="sy0">,</span><span class="kw4">uint8</span> notify<span class="sy0">,</span> CYBLE_GATT_DB_ATTR_HANDLE_T handle<span class="sy0">,</span><span class="kw4">uint8</span> flags<span class="br0">&#41;</span>
<span class="br0">&#123;</span>
&nbsp;
    <span class="co1">// this little block of code doesnt make me happy... </span>
    <span class="kw1">switch</span><span class="br0">&#40;</span>CyBle_GetState<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="kw1">case</span> CYBLE_STATE_ADVERTISING<span class="sy0">:</span>
            <span class="kw1">return</span><span class="sy0">;</span>
        <span class="kw1">case</span> CYBLE_STATE_DISCONNECTED<span class="sy0">:</span>
            <span class="kw1">return</span><span class="sy0">;</span>
        <span class="kw1">case</span> CYBLE_STATE_STOPPED<span class="sy0">:</span>
            <span class="kw1">return</span><span class="sy0">;</span>
        <span class="kw1">case</span> CYBLE_STATE_CONNECTED<span class="sy0">:</span>
            <span class="kw2">break</span><span class="sy0">;</span>
        <span class="kw1">case</span> CYBLE_STATE_INITIALIZING<span class="sy0">:</span>
            <span class="kw1">return</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
    <span class="co1">//update the GATT Database</span>
    CYBLE_GATTS_HANDLE_VALUE_NTF_T 	tempHandle<span class="sy0">;</span>
    tempHandle.<span class="me1">attrHandle</span> <span class="sy0">=</span> handle<span class="sy0">;</span>
  	tempHandle.<span class="me1">value</span>.<span class="me1">val</span> <span class="sy0">=</span> val<span class="sy0">;</span>
    tempHandle.<span class="me1">value</span>.<span class="me1">len</span> <span class="sy0">=</span> size<span class="sy0">;</span>
    CYBLE_GATT_ERR_CODE_T ret <span class="sy0">=</span> CyBle_GattsWriteAttributeValue<span class="br0">&#40;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>tempHandle<span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,&amp;</span>amp<span class="sy0">;</span>cyBle_connHandle<span class="sy0">,</span>flags<span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw1">if</span><span class="br0">&#40;</span>ret <span class="sy0">!=</span> CYBLE_GATT_ERR_NONE<span class="br0">&#41;</span> <span class="co1">// this is really not a good place to be.</span>
    <span class="br0">&#123;</span>
        <span class="kw1">return</span><span class="sy0">;</span>
&nbsp;
        CYASSERT<span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="kw1">while</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
    <span class="co1">// if peer initiated then write response.</span>
    <span class="kw1">if</span><span class="br0">&#40;</span>flags <span class="sy0">==</span> CYBLE_GATT_DB_PEER_INITIATED<span class="br0">&#41;</span>
        CyBle_GattsWriteRsp<span class="br0">&#40;</span>cyBle_connHandle<span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span>notify<span class="br0">&#41;</span> <span class="co1">// If notify &amp;amp; local initiated </span>
    <span class="br0">&#123;</span>
        CyBle_GattsNotification<span class="br0">&#40;</span>cyBle_connHandle<span class="sy0">,&amp;</span>amp<span class="sy0">;</span>tempHandle<span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>    
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>The next block of code is the BleCallback.  One cool thing that PSoC Creator does is give you the ability to #ifndef to remove code when a schematic page is disabled.  In the code below when I have &#8220;disabled&#8221; the Bootloadable schematic page it will remove that block of code from my firmware.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="c"><pre class="de1"><span class="coMULTI">/***************************************************************
 * Function to handle the BLE stack
 **************************************************************/</span>
<span class="kw4">void</span> BleCallBack<span class="br0">&#40;</span><span class="kw4">uint32</span> event<span class="sy0">,</span> <span class="kw4">void</span><span class="sy0">*</span> eventParam<span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    CYBLE_GATTS_WRITE_REQ_PARAM_T <span class="sy0">*</span>wrReqParam<span class="sy0">;</span>
    <span class="kw1">switch</span><span class="br0">&#40;</span>event<span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="coMULTI">/* if there is a disconnect or the stack just turned on from a reset then start the advertising and turn on the LED blinking */</span>
        <span class="kw1">case</span> CYBLE_EVT_STACK_ON<span class="sy0">:</span>
        <span class="kw1">case</span> CYBLE_EVT_GAP_DEVICE_DISCONNECTED<span class="sy0">:</span>
            CyBle_GappStartAdvertisement<span class="br0">&#40;</span>CYBLE_ADVERTISING_FAST<span class="br0">&#41;</span><span class="sy0">;</span>
            PWM_Start<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="kw3">memset</span><span class="br0">&#40;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>notifyFlags<span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="kw4">sizeof</span><span class="br0">&#40;</span>notifyFlags<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="kw2">break</span><span class="sy0">;</span>       
&nbsp;
        <span class="kw1">case</span> CYBLE_EVT_GAP_DEVICE_CONNECTED<span class="sy0">:</span>           
            PWM_Stop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
            updateGattDB<span class="br0">&#40;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>BLEIOT_local.<span class="me1">led0</span><span class="sy0">,</span><span class="kw4">sizeof</span><span class="br0">&#40;</span>BLEIOT_local.<span class="me1">led0</span><span class="br0">&#41;</span><span class="sy0">,</span>notifyFlags.<span class="me1">led0</span><span class="sy0">,</span>CYBLE_CY8CKIT021_LED0_CHAR_HANDLE<span class="sy0">,</span>CYBLE_GATT_DB_LOCALLY_INITIATED<span class="br0">&#41;</span><span class="sy0">;</span>
            updateGattDB<span class="br0">&#40;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>BLEIOT_local.<span class="me1">button0</span><span class="sy0">,</span><span class="kw4">sizeof</span><span class="br0">&#40;</span>BLEIOT_local.<span class="me1">button0</span><span class="br0">&#41;</span><span class="sy0">,</span>notifyFlags.<span class="me1">button0</span><span class="sy0">,</span>CYBLE_CY8CKIT021_BUTTON0_CHAR_HANDLE<span class="sy0">,</span>CYBLE_GATT_DB_LOCALLY_INITIATED<span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="kw2">break</span><span class="sy0">;</span>
&nbsp;
        <span class="kw1">case</span> CYBLE_EVT_GATTS_WRITE_REQ<span class="sy0">:</span>
            wrReqParam <span class="sy0">=</span> <span class="br0">&#40;</span>CYBLE_GATTS_WRITE_REQ_PARAM_T <span class="sy0">*</span><span class="br0">&#41;</span> eventParam<span class="sy0">;</span>
           <span class="co1">// Bootload</span>
            <span class="co2">#ifndef BootLoadable__DISABLED</span>
            <span class="kw1">if</span><span class="br0">&#40;</span>wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">attrHandle</span> <span class="sy0">==</span> CYBLE_CY8CKIT021_BOOTLOAD_CHAR_HANDLE<span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                <span class="kw1">if</span><span class="br0">&#40;</span>wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">value</span>.<span class="me1">val</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span> Bootloadable_Load<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
            <span class="br0">&#125;</span>
            <span class="co2">#endif</span>
&nbsp;
            <span class="co1">// LED0</span>
            <span class="kw1">if</span><span class="br0">&#40;</span>wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">attrHandle</span> <span class="sy0">==</span> CYBLE_CY8CKIT021_LED0_CHAR_HANDLE<span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                BLEIOT_updateLed0<span class="br0">&#40;</span>wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">value</span>.<span class="me1">val</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
                updateGattDB<span class="br0">&#40;</span>wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">value</span>.<span class="me1">val</span><span class="sy0">,</span><span class="nu0">1</span><span class="sy0">,</span>notifyFlags.<span class="me1">led0</span><span class="sy0">,</span>CYBLE_CY8CKIT021_LED0_CHAR_HANDLE<span class="sy0">,</span>CYBLE_GATT_DB_PEER_INITIATED<span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="br0">&#125;</span>
&nbsp;
            <span class="kw1">if</span><span class="br0">&#40;</span>wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">attrHandle</span> <span class="sy0">==</span> CYBLE_CY8CKIT021_LED0_CCCD_DESC_HANDLE<span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                notifyFlags.<span class="me1">led0</span> <span class="sy0">=</span> wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">value</span>.<span class="me1">val</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">;</span>
                CyBle_GattsWriteRsp<span class="br0">&#40;</span>cyBle_connHandle<span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="br0">&#125;</span>
&nbsp;
            <span class="co1">// BUTTON 0</span>
            <span class="kw1">if</span><span class="br0">&#40;</span>wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">attrHandle</span> <span class="sy0">==</span> CYBLE_CY8CKIT021_BUTTON0_CCCD_DESC_HANDLE<span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                notifyFlags.<span class="me1">button0</span> <span class="sy0">=</span> wrReqParam<span class="sy0">-&amp;</span>gt<span class="sy0">;</span>handleValPair.<span class="me1">value</span>.<span class="me1">val</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">;</span>
                CyBle_GattsWriteRsp<span class="br0">&#40;</span>cyBle_connHandle<span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="br0">&#125;</span>
        <span class="kw2">break</span><span class="sy0">;</span>  
&nbsp;
        <span class="kw1">default</span><span class="sy0">:</span>
        <span class="kw2">break</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Finally the last block of code is the main loop</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="c"><pre class="de1"><span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    CyGlobalIntEnable<span class="sy0">;</span>
    BLEIOT_Start<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    EZI2C_Start<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    EZI2C_EzI2CSetBuffer1<span class="br0">&#40;</span><span class="kw4">sizeof</span><span class="br0">&#40;</span>BLEIOT_local<span class="br0">&#41;</span><span class="sy0">,</span><span class="nu0">1</span><span class="sy0">,</span><span class="br0">&#40;</span><span class="kw4">uint8</span> <span class="sy0">*</span><span class="br0">&#41;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>BLEIOT_local<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    CyBle_Start<span class="br0">&#40;</span>BleCallBack<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
&nbsp;
        <span class="co2">#ifndef BootLoadable__DISABLED</span>
        <span class="co1">// if they write into the BLEIOT_local.bootload (from EzI2C)</span>
        <span class="kw1">if</span><span class="br0">&#40;</span>BLEIOT_getDirtyFlags<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span> BLEIOT_FLAG_BOOTLOAD <span class="sy0">||</span> BLEIOT_local.<span class="me1">bootload</span><span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            <span class="co1">// enter the bootloader</span>
            Bootloadable_Load<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
&nbsp;
        <span class="co2">#endif</span>
&nbsp;
        <span class="kw1">if</span><span class="br0">&#40;</span>BLEIOT_getDirtyFlags<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span> BLEIOT_FLAG_LED0<span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            BLEIOT_updateLed0<span class="br0">&#40;</span>BLEIOT_remote.<span class="me1">led0</span><span class="br0">&#41;</span><span class="sy0">;</span>
            updateGattDB<span class="br0">&#40;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>BLEIOT_local.<span class="me1">led0</span><span class="sy0">,</span><span class="kw4">sizeof</span><span class="br0">&#40;</span>BLEIOT_local.<span class="me1">led0</span><span class="br0">&#41;</span><span class="sy0">,</span>notifyFlags.<span class="me1">led0</span><span class="sy0">,</span>CYBLE_CY8CKIT021_LED0_CHAR_HANDLE<span class="sy0">,</span>CYBLE_GATT_DB_LOCALLY_INITIATED<span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
&nbsp;
        <span class="kw1">if</span><span class="br0">&#40;</span>BLEIOT_getDirtyFlags<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span> BLEIOT_FLAG_BUTTON0<span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            BLEIOT_updateButton0<span class="br0">&#40;</span>BLEIOT_remote.<span class="me1">button0</span><span class="br0">&#41;</span><span class="sy0">;</span>
            updateGattDB<span class="br0">&#40;</span><span class="sy0">&amp;</span>amp<span class="sy0">;</span>BLEIOT_local.<span class="me1">button0</span><span class="sy0">,</span><span class="kw4">sizeof</span><span class="br0">&#40;</span>BLEIOT_local.<span class="me1">button0</span><span class="br0">&#41;</span><span class="sy0">,</span>notifyFlags.<span class="me1">button0</span><span class="sy0">,</span>CYBLE_CY8CKIT021_BUTTON0_CHAR_HANDLE<span class="sy0">,</span>CYBLE_GATT_DB_LOCALLY_INITIATED<span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
&nbsp;
        CyBle_ProcessEvents<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        CyBle_EnterLPM<span class="br0">&#40;</span>CYBLE_BLESS_DEEPSLEEP<span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<h2>PSoC FIRMWARE</h2>
<p>To make this project work I built the simplest firmware that I can think of for the PSoC4200M.  The schematic has only the BLEIOT, CapSense and the LED.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-11.11.51-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-11.11.51-AM.png" alt="Screen Shot 2016-05-30 at 11.11.51 AM" width="443" height="289" class="alignnone size-full wp-image-1596" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-11.11.51-AM.png 443w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-30-at-11.11.51-AM-300x196.png 300w" sizes="auto, (max-width: 443px) 100vw, 443px" /></a></p>
<p>The firmware just</p>
<ul>
<li>Starts the components</li>
<li>If the capsense is not busy then it updates the Button0 state if it has changed then rescans</li>
<li>If the PRoC side writes the LED0 then it updates the state.</li>
</ul>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="c"><pre class="de1"><span class="co1">// Project: Example10b - PSoC</span>
<span class="co1">// Kit: CY8CKIT-021 Sheild</span>
<span class="co1">// Baseboard: CY8CKit-44 PSoC4M</span>
<span class="co1">//</span>
<span class="co1">// This project demonstrates the simplest connection to the PRoC and BLE</span>
<span class="co1">// It updates the LED0 based on writes from the PRoC side</span>
<span class="co1">// It sends out updates to the PRoC based on button processes</span>
<span class="co2">#include &lt;project.h&gt;</span>
&nbsp;
<span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    CyGlobalIntEnable<span class="sy0">;</span>
&nbsp;
    BLEIOT_Start<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    CapSense_Start<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    CapSense_InitializeEnabledBaselines<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    CapSense_ScanEnabledWidgets<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>CapSense_IsBusy<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            <span class="kw4">uint8</span> b0<span class="sy0">=</span>CapSense_CheckIsWidgetActive<span class="br0">&#40;</span>CapSense_BUTTON0__BTN<span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="kw1">if</span><span class="br0">&#40;</span>b0 <span class="sy0">!=</span> BLEIOT_local.<span class="me1">button0</span><span class="br0">&#41;</span> <span class="co1">// if the state has changed then send an update</span>
                BLEIOT_updateButton0<span class="br0">&#40;</span>b0<span class="br0">&#41;</span><span class="sy0">;</span>
            CapSense_UpdateEnabledBaselines<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
            CapSense_ScanEnabledWidgets<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
&nbsp;
        <span class="kw1">if</span><span class="br0">&#40;</span>BLEIOT_getDirtyFlags<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span> BLEIOT_FLAG_LED0<span class="br0">&#41;</span>  <span class="co1">// if the PRoC side send an update, write it</span>
        <span class="br0">&#123;</span>
            BLEIOT_updateLed0<span class="br0">&#40;</span>BLEIOT_remote.<span class="me1">led0</span><span class="br0">&#41;</span><span class="sy0">;</span>
            led0_Write<span class="br0">&#40;</span><span class="sy0">!</span>BLEIOT_local.<span class="me1">led0</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// the led is active low</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="sy0">&lt;/</span>project.<span class="me1">h</span><span class="sy0">&gt;</span></pre></div></div></div></div></div></div></div>


<p>&nbsp;</p>
<h2>Debugging using CySmart</h2>
<p>After I created all of the code and bootloaded it into the PRoC I used CySmart to debug it.  Once the board is reset I can see the blinking blue LED that is connected to the PRoC.   When I start CySmart I can see the &#8220;C021&#8221; board (that is the name I gave the device in the Gap settings:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112449.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112449-576x1024.png" alt="Screenshot_20160530-112449" width="576" height="1024" class="alignnone size-large wp-image-1599" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112449-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112449-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112449-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112449-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112449.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>When I connect to the device and explore the Gatt Database I can see the three characteristics (Boatload, LED0 and Button0).  You can recognize them from the UUIDs that I configured in the component.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112358.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112358-576x1024.png" alt="Screenshot_20160530-112358" width="576" height="1024" class="alignnone size-large wp-image-1600" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112358-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112358-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112358-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112358-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112358.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>When I write a 1 into the LED0 characteristic the Green LED0 lights up.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112421.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112421-576x1024.png" alt="Screenshot_20160530-112421" width="576" height="1024" class="alignnone size-large wp-image-1601" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112421-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112421-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112421-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112421-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112421.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>When I turn on notification for the Button0 characteristic and then touch the button I can see it turn back and forth from 0/1</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112435.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112435-576x1024.png" alt="Screenshot_20160530-112435" width="576" height="1024" class="alignnone size-large wp-image-1602" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112435-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112435-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112435-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112435-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screenshot_20160530-112435.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Now that everything seems to be working Ill move onto the iPhone App in the next post.</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >index</th>
<th >description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2016/05/23/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/">CY8CKIT-021: A Simple FM/PSoC + BLE Demonstration Board</a></td>
<td >Introduction to CY8CKIT021</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/24/cy8ckit-021-the-first-4-example-projects/">CY8CKIT-021: The first four example projects</a></td>
<td >Use the LEDs</td>
<td > Buzzer</td>
<td > 7-Segment display and the Potentiometer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/25/cy8ckit-021-the-next-3-example-projects/">CY8CKIT-021: The next three example projects</a></td>
<td >Use theThermistor and two Capsense Examples</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: Bootloading the PRoC</a></td>
<td >How to put firmware into the PRoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/31/cy8ckit-021-the-bleiot-component/">CY8CKIT-021: The BLEIOT Component</a></td>
<td >A custom component to communicate with the PRoC/PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/02/cy8ckit-021-using-the-bleiot-component/">CY8CKIT-021: Using the BLEIOT Component</a></td>
<td >A full example of the tho MCUs talking</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: The PRoC BLE Firmware</a></td>
<td >How to make PRoC Firmware and use it with the BLEIOT Component</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/13/cy8ckit-021-example-10-the-ios-app/">CY8CKIT-021: Example 10 - the new IOS App</a></td>
<td >How to build and IOS App to talk to the development kit</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy8ckit-021-the-proc-ble-firmware/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CY8CKIT-021: Using the BLEIOT Component</title>
		<link>https://iotexpert.com/cy8ckit-021-using-the-bleiot-component/</link>
					<comments>https://iotexpert.com/cy8ckit-021-using-the-bleiot-component/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 02 Jun 2016 09:36:15 +0000</pubDate>
				<category><![CDATA[Cy8CKIT-021]]></category>
		<category><![CDATA[DevKits]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=1541</guid>

					<description><![CDATA[Now that we have a component built up, I will build up a test to demonstrate its functionality.  The test will do the following On the PSoC side it will: Read the Capsense Button0.  If it is pressed it will send a &#8220;boatload&#8221; command to the PRoC Read the Capsense Button1.  Each time it is [&#8230;]]]></description>
										<content:encoded><![CDATA[<p lang="c" line="1">Now that we have a <a href="https://iotexpert.com/2016/05/31/cy8ckit-021-the-bleiot-component/" target="_blank">component</a> built up, I will build up a test to demonstrate its functionality.  The test will do the following</p>
<p>On the PSoC side it will:</p>
<ul>
<li lang="c" line="1">Read the Capsense Button0.  If it is pressed it will send a &#8220;boatload&#8221; command to the PRoC</li>
<li lang="c" line="1">Read the Capsense Button1.  Each time it is pressed it will toggle the PRoC blue LED by sending alternating On/Off</li>
<li lang="c" line="1">Read the remote LED0 update and turn on/off the LED0 based on the remote command</li>
</ul>
<p>On the PRoC side it will:</p>
<ul>
<li lang="c" line="1">Alternate sending a 1/0 every 500ms to the &#8220;led0&#8221; on the PSoC side</li>
<li lang="c" line="1">If the Capsense Button 0 is changed from the PSoC side it will turn the Blue LED On/Off</li>
<li lang="c" line="1">If it get a Bootload it will enter the bootloader</li>
</ul>
<p>These projects are available as Example9 in the CY8CKIT-021 workspace that is in the firmware directory on github at <a href="http://github.com/iotexpert/CY8CKIT-021" target="_blank">github.com/iotexpert/CY8CKIT-021</a></p>
<h2>PSoC</h2>
<p>After creating a new schematic for PSoC 4200m, the next thing that I do is make a dependency to the components in the BLEInterface project.  This gives me access to the BLEIOT component.</p>
<p><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-11.56.18-AM.png" alt="Screen Shot 2016-05-28 at 11.56.18 AM" width="581" height="671" class="alignnone size-large wp-image-1565" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-11.56.18-AM.png 581w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-11.56.18-AM-260x300.png 260w" sizes="auto, (max-width: 581px) 100vw, 581px" /></p>
<p>When I go to the component catalog I see the &#8220;IOT&#8221; and in that tab I find the  IOT Tab with the BLEIOT component.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.02.55-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.02.55-PM.png" alt="Screen Shot 2016-05-28 at 12.02.55 PM" width="502" height="352" class="alignnone size-full wp-image-1566" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.02.55-PM.png 502w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.02.55-PM-300x210.png 300w" sizes="auto, (max-width: 502px) 100vw, 502px" /></a></p>
<p>Now I add components for CapSense and the LED to get the final schematic.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.09.56-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.09.56-PM.png" alt="Screen Shot 2016-05-28 at 12.09.56 PM" width="384" height="338" class="alignnone size-full wp-image-1567" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.09.56-PM.png 384w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.09.56-PM-300x264.png 300w" sizes="auto, (max-width: 384px) 100vw, 384px" /></a></p>
<p>Now assign the Pins in the cydwr.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.10.57-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.10.57-PM.png" alt="Screen Shot 2016-05-28 at 12.10.57 PM" width="414" height="173" class="alignnone size-full wp-image-1568" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.10.57-PM.png 414w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.10.57-PM-300x125.png 300w" sizes="auto, (max-width: 414px) 100vw, 414px" /></a></p>
<p>And finally the code:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="c"><pre class="de1"><span class="co1">// Project: Example9b-PSoC-BLEIOT-Test</span>
<span class="co1">// Kit: CY8CKIT-021 Sheild</span>
<span class="co1">// Baseboard: CY8CKit-44 PSoC4M</span>
<span class="co1">//</span>
<span class="co1">// This project demonstrates using the BLEIOT component</span>
<span class="co1">// If the other side writes the LED then update it</span>
<span class="co1">// If the user presses button 0 then send an bootload command</span>
<span class="co1">// If the user presses button 1 then send an update to the button</span>
&nbsp;
<span class="co2">#include &lt;project.h&gt;</span>
&nbsp;
<span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    CyGlobalIntEnable<span class="sy0">;</span> 
    CapSense_Start<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    CapSense_InitializeEnabledBaselines<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    CapSense_ScanEnabledWidgets<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    BLEIOT_Start<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>CapSense_IsBusy<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            <span class="kw4">uint8</span> b0 <span class="sy0">=</span> CapSense_CheckIsWidgetActive<span class="br0">&#40;</span>CapSense_BUTTON0__BTN<span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="kw4">uint8</span> b1 <span class="sy0">=</span> CapSense_CheckIsWidgetActive<span class="br0">&#40;</span>CapSense_BUTTON1__BTN<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
            <span class="kw1">if</span><span class="br0">&#40;</span>b0<span class="br0">&#41;</span>
                BLEIOT_updateBootload<span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// send the bootload command</span>
&nbsp;
            <span class="kw1">if</span><span class="br0">&#40;</span>b1 <span class="sy0">!=</span> BLEIOT_local.<span class="me1">button1</span><span class="br0">&#41;</span> <span class="co1">// if the button state has changed send it</span>
                BLEIOT_updateButton1<span class="br0">&#40;</span>b1<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
            CapSense_UpdateEnabledBaselines<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
            CapSense_ScanEnabledWidgets<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
&nbsp;
        <span class="kw1">if</span><span class="br0">&#40;</span>BLEIOT_getDirtyFlags<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span> BLEIOT_FLAG_LED0<span class="br0">&#41;</span> <span class="co1">// other side wrote LED0, update state</span>
        <span class="br0">&#123;</span>
            BLEIOT_updateLed0<span class="br0">&#40;</span>BLEIOT_local.<span class="me1">led0</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// update local state</span>
            led0_Write<span class="br0">&#40;</span><span class="sy0">!</span>BLEIOT_remote.<span class="me1">led0</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// the LED is active low</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="sy0">&lt;/</span>project.<span class="me1">h</span><span class="sy0">&gt;</span></pre></div></div></div></div></div></div></div>


<h2>PRoC</h2>
<p>Unfortunately it is prohibited to create custom components for PRoC BLE devices.  So, the first thing that I do after creating the project is to copy over BLEIOT_BLEIOT.c and BLEIOT_BLEIOT.h from the generated source directory of the PSoC project.  Yes I understand that this is a bit of a lame thing to do, but there it is:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1"><span class="kw3">cd</span> Example9a-ProC-BLEIOT-Test.cydsn<span class="sy0">/</span>
<span class="kw2">cp</span> ..<span class="sy0">/</span>Example9b-PSoC-BLEIOT-Test.cydsn<span class="sy0">/</span>Generated_Source<span class="sy0">/</span>PSoC4<span class="sy0">/</span>BLEIOT_BLEIOT.<span class="sy0">*</span> .</pre></div></div></div></div></div></div></div>


<p>One you have the files in the correct directory you need to add them to the project by right clicking on the &#8220;header files&#8221; in the workspace explorer and &#8220;add existing&#8221; then adding the BLEIOT_BLEIOT.h.  You also should do the same with &#8220;source files&#8221; and BLEIOT_BLEIOT.c</p>
<p>Finally you need to add #include &#8220;BLEIOT_BLEIOT.h&#8221; to the top of BLEIOT_BLEIOT.c</p>
<p>After that I finish the schematic.  First, add a UART Component to the schematic and call it BLEIOT_UART (so that it will match the code that was generated in the other project).  Then add the bootloadable and the blue LED pin.  Don&#8217;t forget to configure the Bootloadable to link to the bootloader just like Example 8.  Also you need to configure the UART to have a 32 byte software buffer.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.40.14-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.40.14-PM.png" alt="Screen Shot 2016-05-28 at 12.40.14 PM" width="600" height="354" class="alignnone size-full wp-image-1574" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.40.14-PM.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.40.14-PM-300x177.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>Then assign the pins:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.41.51-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.41.51-PM.png" alt="Screen Shot 2016-05-28 at 12.41.51 PM" width="414" height="107" class="alignnone size-full wp-image-1575" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.41.51-PM.png 414w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-12.41.51-PM-300x78.png 300w" sizes="auto, (max-width: 414px) 100vw, 414px" /></a></p>
<p>Finally the main.c</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="c"><pre class="de1"><span class="co1">// Project: Example9b-PRoC-BLEIOT-Test</span>
<span class="co1">// Kit: CY8CKIT-021 Sheild</span>
<span class="co1">// Baseboard: CY8CKit-44 PSoC4M</span>
<span class="co1">//</span>
<span class="co1">// This project should be bootloaded into the PRoC.  It demonstrates using the BLEIOT</span>
<span class="co1">// component.</span>
<span class="co1">//</span>
<span class="co1">// Using the systick, send an update to led0 every 500ms</span>
<span class="co1">// If the other side writes to Bootload... then start the bootloader</span>
<span class="co1">// If the other side writes to the button1... then display that on the blue led</span>
<span class="co2">#include &lt;project.h&gt;</span>
<span class="co2">#include &quot;BLEIOT_BLEIOT.h&quot;</span>
&nbsp;
<span class="kw4">int</span> countMs <span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span>
&nbsp;
<span class="co1">// This is the ISR for the systick</span>
<span class="kw4">void</span> sendLedUpdate<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    <span class="kw1">if</span><span class="br0">&#40;</span>countMs<span class="sy0">++&amp;</span>lt<span class="sy0">;</span><span class="nu0">500</span><span class="br0">&#41;</span> <span class="co1">// count 500ms</span>
        <span class="kw1">return</span><span class="sy0">;</span>
    countMs <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span>
    BLEIOT_updateLed0<span class="br0">&#40;</span><span class="sy0">!</span>BLEIOT_local.<span class="me1">led0</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
&nbsp;
    CyGlobalIntEnable<span class="sy0">;</span> 
    CyDelay<span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span><span class="sy0">;</span>
    BLEIOT_Start<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    CySysTickStart<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// start the systick and register our call back</span>
    CySysTickSetCallback<span class="br0">&#40;</span><span class="nu0">0</span><span class="sy0">,</span>sendLedUpdate<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">for</span><span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
&nbsp;
        <span class="kw1">if</span><span class="br0">&#40;</span>BLEIOT_getDirtyFlags<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span> BLEIOT_FLAG_BOOTLOAD<span class="br0">&#41;</span>
            Bootloadable_Load<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
        <span class="kw1">if</span><span class="br0">&#40;</span>BLEIOT_getDirtyFlags<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;</span> BLEIOT_FLAG_BUTTON1<span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            BLEIOT_updateButton1<span class="br0">&#40;</span>BLEIOT_remote.<span class="me1">button1</span><span class="br0">&#41;</span><span class="sy0">;</span>
            blue_Write<span class="br0">&#40;</span><span class="sy0">!</span>BLEIOT_local.<span class="me1">button1</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
<span class="sy0">&lt;/</span>project.<span class="me1">h</span><span class="sy0">&gt;</span></pre></div></div></div></div></div></div></div>


<p>&nbsp;</p>
<p>As always these projects are available in the firmware directory at <a href="http://github.com/iotexpert/CY8CKIT-021" target="_blank">http://github.com/iotexpert/CY8CKIT-021</a></p>
<p>In the next post Ill show you the BLE Firmware.</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >index</th>
<th >description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2016/05/23/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/">CY8CKIT-021: A Simple FM/PSoC + BLE Demonstration Board</a></td>
<td >Introduction to CY8CKIT021</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/24/cy8ckit-021-the-first-4-example-projects/">CY8CKIT-021: The first four example projects</a></td>
<td >Use the LEDs</td>
<td > Buzzer</td>
<td > 7-Segment display and the Potentiometer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/25/cy8ckit-021-the-next-3-example-projects/">CY8CKIT-021: The next three example projects</a></td>
<td >Use theThermistor and two Capsense Examples</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: Bootloading the PRoC</a></td>
<td >How to put firmware into the PRoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/31/cy8ckit-021-the-bleiot-component/">CY8CKIT-021: The BLEIOT Component</a></td>
<td >A custom component to communicate with the PRoC/PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/02/cy8ckit-021-using-the-bleiot-component/">CY8CKIT-021: Using the BLEIOT Component</a></td>
<td >A full example of the tho MCUs talking</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: The PRoC BLE Firmware</a></td>
<td >How to make PRoC Firmware and use it with the BLEIOT Component</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/13/cy8ckit-021-example-10-the-ios-app/">CY8CKIT-021: Example 10 - the new IOS App</a></td>
<td >How to build and IOS App to talk to the development kit</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy8ckit-021-using-the-bleiot-component/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CY8CKIT-021: The BLEIOT Component</title>
		<link>https://iotexpert.com/cy8ckit-021-the-bleiot-component/</link>
					<comments>https://iotexpert.com/cy8ckit-021-the-bleiot-component/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 31 May 2016 12:50:47 +0000</pubDate>
				<category><![CDATA[Cy8CKIT-021]]></category>
		<category><![CDATA[DevKits]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=1510</guid>

					<description><![CDATA[The PRoC (on the shield) and the baseboard share two pairs of lines that are connected to the Serial Communication Blocks (SCBs) on the chips.  One of the pairs is also connected to the standard I2C Arduino bridge pins and in fact this is how you bootloaded the PRoC in the previous example.  When I [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The PRoC (on the shield) and the baseboard share two pairs of lines that are connected to the Serial Communication Blocks (SCBs) on the chips.  One of the pairs is also connected to the standard I2C Arduino bridge pins and in fact this is how you bootloaded the PRoC in the previous example.  When I started thinking about the problem of making the PRoC on the shield talk to the baseboard I knew that I wanted either side to be able to initiate communication and I did not want either side to poll.  This fact eliminated the master/slave scheme of I2C or SPI.  OK.  UART it is.</p>
<p>The next thing that I knew that I wanted was one set of firmware that would work exactly the same on both side.  This lead me to build a component called BLEIOT.  This component has the following features</p>
<ol>
<li>It transmits its local status every 20 ms</li>
<li>It is triggered by the Systick</li>
<li>It uses UART to transmit and receive</li>
<li>It has a &#8220;Update&#8221; API which will update the local and remote state</li>
<li>It has dirtyFlags which are a bit mask of what was written from the other side and is different than the current local status</li>
<li>The component works the same on both sides</li>
<li>It has a data structure that represents all of the peripherals on the shield (LEDs, Thermistor, CapSense Buttons etc)</li>
</ol>
<p>The system works by having a &#8220;local&#8221; copy of the state and a last known &#8220;remote&#8221; copy of the state.  There is a C-Structure that represents each of the system variables (LED, CapSense, &#8230;).  The way it works is:</p>
<ol>
<li>When something changes in your system you use the &#8220;Update&#8221; API.</li>
<li>The update API changes the local state and the &#8220;Write Flags&#8221; which is just a bit mask of all of the local variables</li>
<li>Every 20ms the component sends the local table to the remote side (assuming something has been written)</li>
<li>The remote side then looks at each variable that has been &#8220;written&#8221; and compares it against the local copy.  If they are different then it marks the &#8220;dirtyFlags&#8221; with the corresponding bitmask</li>
<li>On either side you can monitor the &#8220;dirtyFlags&#8221;.  If the dirtyFlag for a variable is set then you know that the other  side changed it and you can do something.</li>
<li>When you run the &#8220;Update&#8221; API if you write your local copy to be the same as the remote copy then you will clear the dirtyFlag.</li>
</ol>
<p>This project is available as BLEInterface in the CY8CKIT-021 workspace that is in the firmware directory on github at <a href="http://github.com/iotexpert/CY8CKIT-021" target="_blank">github.com/iotexpert/CY8CKIT-021</a></p>
<p>Here is a picture of the architecture:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/bleiot1.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/bleiot1-1024x646.png" alt="bleiot1" width="1024" height="646" class="alignnone size-large wp-image-1518" srcset="https://iotexpert.com/wp-content/uploads/2016/05/bleiot1-1024x646.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/bleiot1-600x378.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/bleiot1-300x189.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/bleiot1-768x484.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/bleiot1.png 1595w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>An example:</p>
<ol>
<li>Everything starts in sync</li>
<li>The PSoC turns on an LED with Pin_Write()</li>
<li>The PSoC calls the BLEIOT_updateLed API</li>
<li>That BLEIOT_updateLed API updates the local state table</li>
<li>That BLEIOT_updateLed API marks the &#8220;writeFlag&#8221; corresponding to the LED</li>
<li>The PSoC systick triggers the BLEIOT component to send the local table to the PRoC via UART</li>
<li>The PRoC UART receives the table and calls the BLEIOT_receive API</li>
<li>The PRoC BLEIOT component looks at the &#8220;Write Flags&#8221; and notices that the LED was written, so it marks the dirtyFlag corresponding to the LED</li>
<li>The PRoC  main loop notices the dirtyFlag and turns on the LED using Pin_Write</li>
<li>The PRoC then runs the BLEIOT_updateLed function which updates the local state and clears the dirtyFlag</li>
<li>The PRoC systick calls the BLEIOT_send which sends the local state table to the PSoC</li>
<li>The PSoC calls the BLEIOT_receive</li>
<li>The PSoC BLEIOT_receive notices that the LED was written but that its remote state now matches its local state so it doesn&#8217;t do anything</li>
</ol>
<h2>Building the Component</h2>
<p>In order to make a component this component I need</p>
<ol>
<li>A symbol for the component</li>
<li>A schematic (with the UART)</li>
<li>The BLEIOT.h (which is the public interface to the component)</li>
<li>The BLEIOT.c (which hold the functions that makeup the component)</li>
</ol>
<p>To make the component I start by adding a &#8220;library project&#8221; to my workspace called BleInterface.  You do this from the new project dialog.</p>
<p>Then I click on the components tab of the BleInterface project.  This is a bit of a trick as it seems like the library is &#8220;empty&#8221; but it isn&#8217;t.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.49.08-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.49.08-PM.png" alt="Screen Shot 2016-05-27 at 1.49.08 PM" width="706" height="660" class="alignnone size-full wp-image-1522" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.49.08-PM.png 706w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.49.08-PM-600x561.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.49.08-PM-300x280.png 300w" sizes="auto, (max-width: 706px) 100vw, 706px" /></a></p>
<p>The next step is to create a symbol by right clicking the library and saying &#8220;add component item&#8221; and choosing Symbol Wizard.  If you are doing this make sure that you give the component a good name (or at least something better than &#8220;component01&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.54.36-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.54.36-PM.png" alt="Screen Shot 2016-05-27 at 1.54.36 PM" width="1012" height="774" class="alignnone size-full wp-image-1523" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.54.36-PM.png 1012w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.54.36-PM-600x459.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.54.36-PM-300x229.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-1.54.36-PM-768x587.png 768w" sizes="auto, (max-width: 1012px) 100vw, 1012px" /></a></p>
<p>This component does not have any visible terminals so just accept the defaults.</p>
<p>In the next step I create a schematic to hold the UART component.  When you add the component item for the schematic you need to configure the architecture to target the PSoC4 family in order to have access to place the SCB UART.  After you have placed the UART component you will automatically get &#8220;buried&#8221; pins which you can assign for that component.</p>
<p>Now that I have a schematic and a symbol, the last steps are to add the .h and .c</p>
<p>The .h contains the public interface to the component.</p>
<p><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.10-PM-1024x820.png" alt="Screen Shot 2016-05-27 at 2.46.10 PM" width="1024" height="820" class="alignnone size-large wp-image-1530" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.10-PM-1024x820.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.10-PM-600x481.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.10-PM-300x240.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.10-PM-768x615.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.10-PM.png 1418w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>This section defines the public interface.  On update function per system state.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-3.36.00-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-3.36.00-PM.png" alt="Screen Shot 2016-05-27 at 3.36.00 PM" width="607" height="435" class="alignnone size-full wp-image-1532" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-3.36.00-PM.png 607w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-3.36.00-PM-600x430.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-3.36.00-PM-300x215.png 300w" sizes="auto, (max-width: 607px) 100vw, 607px" /></a></p>
<p>The bit masks for the dirtyFlags and updatedFlags</p>
<p><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.48-PM-1024x587.png" alt="Screen Shot 2016-05-27 at 2.46.48 PM" width="1024" height="587" class="alignnone size-large wp-image-1528" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.48-PM-1024x587.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.48-PM-600x344.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.48-PM-300x172.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.48-PM-768x440.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.46.48-PM.png 1256w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>The definition of the table of variables.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.47.15-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.47.15-PM-1024x813.png" alt="Screen Shot 2016-05-27 at 2.47.15 PM" width="1024" height="813" class="alignnone size-large wp-image-1526" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.47.15-PM-1024x813.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.47.15-PM-600x476.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.47.15-PM-300x238.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.47.15-PM-768x610.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-2.47.15-PM.png 1338w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The last thing that you need is &#8220;BLEIOT.c&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.31.24-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.31.24-AM.png" alt="Screen Shot 2016-05-28 at 8.31.24 AM" width="908" height="716" class="alignnone size-full wp-image-1535" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.31.24-AM.png 908w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.31.24-AM-600x473.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.31.24-AM-300x237.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.31.24-AM-768x606.png 768w" sizes="auto, (max-width: 908px) 100vw, 908px" /></a></p>
<p>The update function is a generic function that will &#8220;update&#8221; the local table with the current value of one of the local status (LED0, CapSense &#8230;).  This function is called by the various helper function (updateLed0, updateBootload, updateCapsense,&#8230;)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.32.08-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.32.08-AM.png" alt="Screen Shot 2016-05-28 at 8.32.08 AM" width="943" height="815" class="alignnone size-full wp-image-1536" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.32.08-AM.png 943w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.32.08-AM-600x519.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.32.08-AM-300x259.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.32.08-AM-768x664.png 768w" sizes="auto, (max-width: 943px) 100vw, 943px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.10-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.10-AM.png" alt="Screen Shot 2016-05-28 at 8.37.10 AM" width="909" height="688" class="alignnone size-full wp-image-1539" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.10-AM.png 909w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.10-AM-600x454.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.10-AM-300x227.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.10-AM-768x581.png 768w" sizes="auto, (max-width: 909px) 100vw, 909px" /></a></p>
<p><strong><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.35-AM-1024x957.png" alt="Screen Shot 2016-05-28 at 8.37.35 AM" width="1024" height="957" class="alignnone size-large wp-image-1538" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.35-AM-1024x957.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.35-AM-600x561.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.35-AM-300x280.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.35-AM-768x718.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.35-AM.png 1130w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></strong></p>
<p>This function sends the data to the other side when it gets a turn from the systick interrupt</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.50-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.50-AM.png" alt="Screen Shot 2016-05-28 at 8.37.50 AM" width="940" height="664" class="alignnone size-full wp-image-1537" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.50-AM.png 940w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.50-AM-600x424.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.50-AM-300x212.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-28-at-8.37.50-AM-768x543.png 768w" sizes="auto, (max-width: 940px) 100vw, 940px" /></a></p>
<p>In the next post Ill show you an example project of the BLEIOT.</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >index</th>
<th >description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2016/05/23/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/">CY8CKIT-021: A Simple FM/PSoC + BLE Demonstration Board</a></td>
<td >Introduction to CY8CKIT021</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/24/cy8ckit-021-the-first-4-example-projects/">CY8CKIT-021: The first four example projects</a></td>
<td >Use the LEDs</td>
<td > Buzzer</td>
<td > 7-Segment display and the Potentiometer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/25/cy8ckit-021-the-next-3-example-projects/">CY8CKIT-021: The next three example projects</a></td>
<td >Use theThermistor and two Capsense Examples</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: Bootloading the PRoC</a></td>
<td >How to put firmware into the PRoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/31/cy8ckit-021-the-bleiot-component/">CY8CKIT-021: The BLEIOT Component</a></td>
<td >A custom component to communicate with the PRoC/PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/02/cy8ckit-021-using-the-bleiot-component/">CY8CKIT-021: Using the BLEIOT Component</a></td>
<td >A full example of the tho MCUs talking</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: The PRoC BLE Firmware</a></td>
<td >How to make PRoC Firmware and use it with the BLEIOT Component</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/13/cy8ckit-021-example-10-the-ios-app/">CY8CKIT-021: Example 10 - the new IOS App</a></td>
<td >How to build and IOS App to talk to the development kit</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy8ckit-021-the-bleiot-component/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CY8CKIT-021: Bootloading the PRoC</title>
		<link>https://iotexpert.com/cy8ckit-021-bootloading-the-proc/</link>
					<comments>https://iotexpert.com/cy8ckit-021-bootloading-the-proc/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Fri, 27 May 2016 12:29:24 +0000</pubDate>
				<category><![CDATA[Cy8CKIT-021]]></category>
		<category><![CDATA[DevKits]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=1489</guid>

					<description><![CDATA[Now that I have shown you how to make all of the basic functions of the devkit work, I really want to make this shield into an IOT Device.  In order to do this I need to: Get the bootloading to work (so I can put firmware into the PRoC) Have a scheme to communicate between [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Now that I have shown you how to make all of the basic functions of the devkit work, I really want to make this shield into an IOT Device.  In order to do this I need to:</p>
<ol>
<li>Get the bootloading to work (so I can put firmware into the PRoC)</li>
<li>Have a scheme to communicate between between the PRoC and the Baseboard (the subject of the next posts)</li>
<li>Have BLE Firmware (the subject of the next posts)</li>
</ol>
<h2>Bootloading the PRoC</h2>
<p>When the India team sent me the shield, the EZ-USB PRoC came preprogrammed with a bootloader project.  They also sent me the bootloader project that is programmed into the device.  That project, called &#8220;I2C_Bootloader&#8221;, is in the workspace that you can find in the firmware directory at <a href="http://github.com/iotexpert/CY8CKIT-021" target="_blank">github.com/iotexpert/CY8CKIT-021</a>.  In order to make your own firmware application for that PRoC you need to make a reference to the bootloader project in the bootloadable component.</p>
<p>When I first plugged in the board I thought that I was going to have a seizure as the blue LED is blinking like crazy.  That has got to go!  To get firmware into the PRoC you either need to solder a header onto the board so that you can use a miniprog-3 (which I also did) and/or you can bootload the firmware.  The I2C Pins on the PRoC are connected to the KitProg I2C pins on the baseboard.</p>
<p>Bootloading is the process of transferring a hex file image via a serial connection (I2C in this case) into the chip, then flashing it into the memory in the right place.  I wrote in detail about this process in this post <a href="https://iotexpert.com/2016/04/03/the-creek-psoc-4-bootloader-schematic-firmware/" target="_blank">&#8220;The Creek: PSoC4 Bootloader + Firmware&#8221;</a>.    Here is a picture of the architecture:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/02/bootloading.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/02/bootloading-1024x609.png" alt="bootloading" width="1024" height="609" class="alignnone size-large wp-image-675" srcset="https://iotexpert.com/wp-content/uploads/2016/02/bootloading-1024x609.png 1024w, https://iotexpert.com/wp-content/uploads/2016/02/bootloading-600x357.png 600w, https://iotexpert.com/wp-content/uploads/2016/02/bootloading-300x179.png 300w, https://iotexpert.com/wp-content/uploads/2016/02/bootloading.png 1198w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>First ill explain the bootloader project.  This project will:</p>
<ul>
<li>Wait for 100ms, and if the Pin_BL_Select is held low it will start the bootloader otherwise it will start application.  This was done so that you could signal the PRoC from the board that it was plugged into to start the boot loading process via a GPIO.</li>
<li>If there is no application firmware or the application firmware is invalid then it will start the bootloader</li>
<li>The bootloader will listen to the I2C on address 0x0B and load in firmware when it gets a request</li>
<li>The application is yours to write.</li>
</ul>
<p>The schematic is simply a blank SCB I2C component to service the Bootloader, a GPIO pin, a blinking LED using the PWM and the Bootloader component.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.31.10-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.31.10-AM.png" alt="Screen Shot 2016-05-26 at 7.31.10 AM" width="1014" height="608" class="alignnone size-full wp-image-1492" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.31.10-AM.png 1014w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.31.10-AM-600x360.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.31.10-AM-300x180.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.31.10-AM-768x460.png 768w" sizes="auto, (max-width: 1014px) 100vw, 1014px" /></a></p>
<p>Here is the configuration of the I2C component &#8212; just 400KBS and slave address 0x0B:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.45-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.45-AM-1024x974.png" alt="Screen Shot 2016-05-26 at 9.40.45 AM" width="1024" height="974" class="alignnone size-large wp-image-1494" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.45-AM-1024x974.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.45-AM-600x571.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.45-AM-300x285.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.45-AM-768x731.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.45-AM.png 1108w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is the configuration of the Bootloader:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.27-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.27-AM-1024x774.png" alt="Screen Shot 2016-05-26 at 9.40.27 AM" width="1024" height="774" class="alignnone size-large wp-image-1495" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.27-AM-1024x774.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.27-AM-600x454.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.27-AM-300x227.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.27-AM-768x581.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-9.40.27-AM.png 1278w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>And finally the main.c</p>
<p>Line 23-49 are run if the digital input pin is held low when the chip is booted&#8230; indicating that you want the bootloader to start.  You use this to get the PRoC back into the bootloader mode if you have already programmed firmware into it that does something else.</p>
<p>Line 25-32 is a loop that goes for 100ms and makes sure that the line is held down the whole time.  If it is NOT held down then it break out of the loop and start the application (By falling out of the loop)</p>
<p>Line 34-42: if the pin was held down the whole time, then configure the the bootloader component to start</p>
<p>Line 54:  Start the bootloader component.  The component is configured to start the application immediately upon startup.  If line 36 is run, then it will start the boot loading process.  (this was a bit confusing to me when I first looked at this program)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.35.47-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.35.47-AM.png" alt="Screen Shot 2016-05-26 at 7.35.47 AM" width="1004" height="990" class="alignnone size-full wp-image-1496" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.35.47-AM.png 1004w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.35.47-AM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.35.47-AM-600x592.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.35.47-AM-300x296.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-26-at-7.35.47-AM-768x757.png 768w" sizes="auto, (max-width: 1004px) 100vw, 1004px" /></a></p>
<h2>A Bootloadable Application</h2>
<p>Now that you understand the bootloader application, Ill build a simple simple bootloadable (just a program that can be loaded by the bootloader).  My application will do only two things.</p>
<ol>
<li>It will blink the LED at 1HZ</li>
<li>If will have an EzI2C component.  If there is something other than &#8220;0&#8221; written to address 0 it will launch the bootloader (so you can restart the bootloader)</li>
</ol>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.29.44-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.29.44-AM.png" alt="Screen Shot 2016-05-27 at 5.29.44 AM" width="692" height="436" class="alignnone size-full wp-image-1501" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.29.44-AM.png 692w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.29.44-AM-600x378.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.29.44-AM-300x189.png 300w" sizes="auto, (max-width: 692px) 100vw, 692px" /></a></p>
<p>Once the schematic is configured you need to configure the bootloadable component.  Basically you need to tell it where the bootloader hex file exists on your system.  This is required because the bootloader and the bootloadable need to come in pairs.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-4.52.53-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-4.52.53-AM.png" alt="Screen Shot 2016-05-27 at 4.52.53 AM" width="760" height="392" class="alignnone size-full wp-image-1502" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-4.52.53-AM.png 760w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-4.52.53-AM-600x309.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-4.52.53-AM-300x155.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-4.52.53-AM-348x180.png 348w" sizes="auto, (max-width: 760px) 100vw, 760px" /></a></p>
<p>The main.c is very straightforward.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.27.11-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.27.11-AM.png" alt="Screen Shot 2016-05-27 at 5.27.11 AM" width="958" height="667" class="alignnone size-full wp-image-1503" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.27.11-AM.png 958w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.27.11-AM-600x418.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.27.11-AM-300x209.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.27.11-AM-768x535.png 768w" sizes="auto, (max-width: 958px) 100vw, 958px" /></a></p>
<p>Once you have the project put together you will use the &#8220;build&#8221; menu to create the &#8220;.cyacd&#8221; file.  That is just the hex file in a format that can be read by the Bootloader host.  The Bootloader host know how to talk to a Cypress I2C bridge (either KitProg or MiniProg-3) and then send the CYACD file to the PRoC bootloader.</p>
<p>The process is</p>
<ol>
<li>Start the Bootloader host (from the windows start menu or by right clicking the bootloadable component)</li>
<li>Find the .CYADC file for your project</li>
<li>Select the KitProg and the correct I2C address (remember I set 0x0B which is also known as 11)</li>
<li>Then click the &#8220;download&#8221; arrow</li>
</ol>
<p>After each of those steps is done you will see the file being downloaded.  Then you will see you the Blue LED on the kit start blinking a 1hz.  Success!</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.26.58-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.26.58-AM.png" alt="Screen Shot 2016-05-27 at 5.26.58 AM" width="667" height="634" class="alignnone size-full wp-image-1504" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.26.58-AM.png 667w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.26.58-AM-600x570.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.26.58-AM-300x285.png 300w" sizes="auto, (max-width: 667px) 100vw, 667px" /></a></p>
<p>If you are ready to start the bootloader again you now have two options</p>
<ol>
<li>Hold down the PRoC Pin P04 for 100ms as the PRoC boots</li>
<li>Attach the I2C bus and write a 1 to I2C address 0x0B.  The easiest way to do this is with the bridge control panel (see the picture below)</li>
</ol>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.28.02-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.28.02-AM.png" alt="Screen Shot 2016-05-27 at 5.28.02 AM" width="842" height="719" class="alignnone size-full wp-image-1505" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.28.02-AM.png 842w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.28.02-AM-600x512.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.28.02-AM-300x256.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-27-at-5.28.02-AM-768x656.png 768w" sizes="auto, (max-width: 842px) 100vw, 842px" /></a></p>
<p>Finally, On Cypress.com we have a ton of good Application Notes and data sheets to help you understand Bootloading.</p>
<p><a href="http://www.cypress.com/documentation/application-notes/an73854-psoc-3-psoc-4-and-psoc-5lp-introduction-bootloaders?source=search&amp;keywords=bootloading&amp;cat=technical_documents" target="_blank">AN73854 &#8211; PSoC® 3, PSoC 4, and PSoC 5LP Introduction to Bootloaders</a></p>
<p><a href="http://www.cypress.com/documentation/component-datasheets/bootloader-and-bootloadable?source=search&amp;keywords=bootloadable" target="_blank">The Booloader and Bootloadable Component Datasheet</a></p>
<p><a href="http://www.cypress.com/documentation/application-notes/an86526-psoc-4-i2c-bootloader?source=search&amp;keywords=bootloading&amp;cat=technical_documents" target="_blank">AN86526 &#8211; PSoC® 4 I2C Bootloader</a></p>
<p><a href="http://www.cypress.com/documentation/application-notes/an73503-psoc-usb-hid-bootloader?source=search&amp;keywords=bootloading&amp;cat=technical_documents" target="_blank">AN73503 &#8211; PSoC® USB HID Bootloader</a></p>
<p><a href="http://www.cypress.com/documentation/application-notes/an60317-psoc-3-and-psoc-5lp-i2c-bootloader?source=search&amp;keywords=bootloading&amp;cat=technical_documents" target="_blank">AN60317 &#8211; PSoC® 3 and PSoC 5LP I2C Bootloader</a></p>
<p><a href="http://www.cypress.com/documentation/application-notes/an68272-psoc-3-psoc-4-and-psoc-5lp-uart-bootloader?source=search&amp;keywords=bootloading&amp;cat=technical_documents" target="_blank">AN68272 &#8211; PSoC® 3, PSoC 4, and PSoC 5LP UART Bootloader</a></p>
<p>Now that you know how the bootloader and bootloadable projects work Ill address the communication between the PSoC and the PRoC in the next post.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy8ckit-021-bootloading-the-proc/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CY8CKIT-021: The Next 3 Example Projects</title>
		<link>https://iotexpert.com/cy8ckit-021-the-next-3-example-projects/</link>
					<comments>https://iotexpert.com/cy8ckit-021-the-next-3-example-projects/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 25 May 2016 15:11:46 +0000</pubDate>
				<category><![CDATA[Cy8CKIT-021]]></category>
		<category><![CDATA[DevKits]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=1459</guid>

					<description><![CDATA[In the previous post I introduced 4 basic example projects.  In this post Ill finish up the examples with the Thermistor and two Capsense projects. Example 5: A Thermistor Example 6: 2 Capsense Buttons (using the V2.x component) Example 7: 2 Capsense Buttons (using the new V3.x component + tuner) Example 5: The Thermistor A [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In the <a href="https://iotexpert.com/2016/05/24/cy8ckit-021-the-first-4-example-projects/" target="_blank">previous</a> post I introduced 4 basic example projects.  In this post Ill finish up the examples with the Thermistor and two Capsense projects.</p>
<ul>
<li>Example 5: A Thermistor</li>
<li>Example 6: 2 Capsense Buttons (using the V2.x component)</li>
<li>Example 7: 2 Capsense Buttons (using the new V3.x component + tuner)</li>
</ul>
<h2>Example 5: The Thermistor</h2>
<p>A thermistor is a resistor that changes resistance with temperature in a known way.  You can use it in combination with a precision reference resistor to calculate temperature.  PSoC Creator provides a component for making this easy as the actual <a href="http://www.cypress.com/file/45091/download" target="_blank">formula</a> is crazy.  Here is the schematic.  R1 is the known reference resistor.  RT1 is the thermistor.  J6 is a selector that lets you select the analog input from the shield to either be the POT or the Thermistor.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.07.26-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.07.26-AM.png" alt="Screen Shot 2016-05-25 at 7.07.26 AM" width="401" height="563" class="alignnone size-full wp-image-1460" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.07.26-AM.png 401w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.07.26-AM-214x300.png 214w" sizes="auto, (max-width: 401px) 100vw, 401px" /></a></p>
<p>The schematic is simple.  Just an Analog to Digital Convertor and the LCD from the previous design plus the Thermistor.  Notice that the Thermistor symbol shows the configuration that you need on the schematic to make this work.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.10.17-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.10.17-AM.png" alt="Screen Shot 2016-05-25 at 7.10.17 AM" width="707" height="490" class="alignnone size-full wp-image-1461" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.10.17-AM.png 707w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.10.17-AM-600x416.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.10.17-AM-300x208.png 300w" sizes="auto, (max-width: 707px) 100vw, 707px" /></a></p>
<p>In the Thermistor configuration window you get to select the size of the reference resistor (in this case it is 10K) and if you want to use a LUT or use an Equation.  If you choose LUT then PSoC Creator will pre-calculate a temperature versus resistance table and embed that into your program.  This will enable very fast calculation of temperature but will take more flash.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.11.48-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.11.48-AM.png" alt="Screen Shot 2016-05-25 at 7.11.48 AM" width="512" height="388" class="alignnone size-full wp-image-1462" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.11.48-AM.png 512w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.11.48-AM-300x227.png 300w" sizes="auto, (max-width: 512px) 100vw, 512px" /></a></p>
<p>The main.c just reads the voltage, calculates the resistance (using the API), calculates the temperature (using the API) and then displays it on the LCD.  The only problem with this whole setup is that it depends on knowing the exact VDDA voltage because you need to know the voltage across the reference resistor.  I use the handy PSoC Creator #define CYDEV_VDDA_MV to find out what the configured voltage.  The problem with this circuit is that the VDDA will vary and this will throw off the temperature calculation.  This could have been solved if we had used two differential measurements, but we were out of pins.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.15.20-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.15.20-AM.png" alt="Screen Shot 2016-05-25 at 7.15.20 AM" width="985" height="866" class="alignnone size-full wp-image-1463" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.15.20-AM.png 985w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.15.20-AM-600x528.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.15.20-AM-300x264.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.15.20-AM-768x675.png 768w" sizes="auto, (max-width: 985px) 100vw, 985px" /></a></p>
<h2>Example 6: The CapSense Buttons using the 2.x Component</h2>
<p>There are two CapSense buttons on this Development Kit.  I started with the old CapSense component because I know the APIs without looking at the examples.  We have now upgraded the component to support features in the new CapSense block (which I will show in the next example).  The V2.x schematic is simple with just the CapSense component plus the two LED pins.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.14-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.14-AM.png" alt="Screen Shot 2016-05-25 at 7.23.14 AM" width="318" height="241" class="alignnone size-full wp-image-1465" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.14-AM.png 318w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.14-AM-300x227.png 300w" sizes="auto, (max-width: 318px) 100vw, 318px" /></a></p>
<p>The CapSense component uses the default settings including SmartSense tuning.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.40-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.40-AM.png" alt="Screen Shot 2016-05-25 at 7.23.40 AM" width="639" height="483" class="alignnone size-full wp-image-1466" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.40-AM.png 639w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.40-AM-600x454.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.40-AM-300x227.png 300w" sizes="auto, (max-width: 639px) 100vw, 639px" /></a></p>
<p>I add two buttons and use the default values.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.51-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.51-AM.png" alt="Screen Shot 2016-05-25 at 7.23.51 AM" width="639" height="483" class="alignnone size-full wp-image-1467" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.51-AM.png 639w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.51-AM-600x454.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.23.51-AM-300x227.png 300w" sizes="auto, (max-width: 639px) 100vw, 639px" /></a></p>
<p>The code is also very simple.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.27.01-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.27.01-AM.png" alt="Screen Shot 2016-05-25 at 7.27.01 AM" width="808" height="620" class="alignnone size-full wp-image-1468" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.27.01-AM.png 808w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.27.01-AM-600x460.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.27.01-AM-300x230.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.27.01-AM-768x589.png 768w" sizes="auto, (max-width: 808px) 100vw, 808px" /></a></p>
<h2>Example 7:  CapSense 3.0</h2>
<p>In PSoC Creator 3.3 we released a new component to support features in the new CapSense block that was put into the new PSoC 4000S/4100S family.  Like the previous example, this project will light up the LEDs when the corresponding button is pressed. The addition in this example is the EZi2C to support the tuner (which is also new).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.07-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.07-AM.png" alt="Screen Shot 2016-05-25 at 7.42.07 AM" width="578" height="349" class="alignnone size-full wp-image-1470" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.07-AM.png 578w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.07-AM-300x181.png 300w" sizes="auto, (max-width: 578px) 100vw, 578px" /></a></p>
<p>In the EZI2C you need to change the defaults from 100kbps to 400 kbs and 8-bit subaddress to 16-bit subaddress.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.20-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.20-AM.png" alt="Screen Shot 2016-05-25 at 7.42.20 AM" width="557" height="528" class="alignnone size-full wp-image-1471" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.20-AM.png 557w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.20-AM-300x284.png 300w" sizes="auto, (max-width: 557px) 100vw, 557px" /></a></p>
<p>&nbsp;</p>
<p>The first time I put this design together I noticed that the CapSense buttons were very sensitive.  Very means that you get a touch when your finger is 1mm or more from the surface of the button.  I thought that as long as I was going to manually tune some of the buttons that I will show the new tuner-which is really cool-in this example.</p>
<p>First configure two buttons and set the tuning to SmartSense (Hardware parameters only).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.39-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.39-AM.png" alt="Screen Shot 2016-05-25 at 7.42.39 AM" width="888" height="640" class="alignnone size-full wp-image-1472" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.39-AM.png 888w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.39-AM-600x432.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.39-AM-300x216.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.42.39-AM-768x554.png 768w" sizes="auto, (max-width: 888px) 100vw, 888px" /></a></p>
<p>The main.c is also very simple.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.45.36-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.45.36-AM-1024x785.png" alt="Screen Shot 2016-05-25 at 7.45.36 AM" width="1024" height="785" class="alignnone size-large wp-image-1476" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.45.36-AM-1024x785.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.45.36-AM-600x460.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.45.36-AM-300x230.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.45.36-AM-768x589.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-7.45.36-AM.png 1036w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The last step is to run the tuner.  The default finger threshold is 100.  To make the button less sensitive I increase the button touch to 500.  You can see in the picture below that Button 0 has about 1300 counts of signal when I am touching the button so 500 gives us plenty of room to not miss a touch.  You can see that just sitting there untouched that the signal is about 6850 counts and when there is a touch it is about 8150.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.49.30-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.49.30-AM.png" alt="Screen Shot 2016-05-25 at 10.49.30 AM" width="883" height="859" class="alignnone size-full wp-image-1478" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.49.30-AM.png 883w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.49.30-AM-600x584.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.49.30-AM-300x292.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.49.30-AM-768x747.png 768w" sizes="auto, (max-width: 883px) 100vw, 883px" /></a></p>
<p>Button 1 is more interesting.  I decided to run a signal-to-noise measurement on the button.  Here is the &#8220;acquire noise&#8221; graph.  You can see that just sitting there untouched, the signal is about 54170 and there is about 54 counts of noise.  That is quite a bit different than Button 0 which has a baseline of about 6850.  I don&#8217;t know why they are so different.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.51.29-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.51.29-AM.png" alt="Screen Shot 2016-05-25 at 10.51.29 AM" width="882" height="859" class="alignnone size-full wp-image-1479" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.51.29-AM.png 882w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.51.29-AM-600x584.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.51.29-AM-300x292.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.51.29-AM-768x748.png 768w" sizes="auto, (max-width: 882px) 100vw, 882px" /></a></p>
<p>When I run the signal acquisition I get this graph.  You can see that a &#8220;touch&#8221; is about 65500 which means that there is about 10000 counts of difference, so a threshold of 500 will also be stable, in fact it could be 5000 and work just fine.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.52.12-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.52.12-AM.png" alt="Screen Shot 2016-05-25 at 10.52.12 AM" width="884" height="861" class="alignnone size-full wp-image-1480" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.52.12-AM.png 884w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.52.12-AM-600x584.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.52.12-AM-300x292.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.52.12-AM-768x748.png 768w" sizes="auto, (max-width: 884px) 100vw, 884px" /></a></p>
<p>Here is the touch graph:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.50.37-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.50.37-AM.png" alt="Screen Shot 2016-05-25 at 10.50.37 AM" width="890" height="862" class="alignnone size-full wp-image-1482" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.50.37-AM.png 890w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.50.37-AM-600x581.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.50.37-AM-300x291.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-25-at-10.50.37-AM-768x744.png 768w" sizes="auto, (max-width: 890px) 100vw, 890px" /></a></p>
<p>In the next post I will talk about the BlueTooth Firmware.</p>
<p>Alan</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >index</th>
<th >description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2016/05/23/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/">CY8CKIT-021: A Simple FM/PSoC + BLE Demonstration Board</a></td>
<td >Introduction to CY8CKIT021</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/24/cy8ckit-021-the-first-4-example-projects/">CY8CKIT-021: The first four example projects</a></td>
<td >Use the LEDs</td>
<td > Buzzer</td>
<td > 7-Segment display and the Potentiometer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/25/cy8ckit-021-the-next-3-example-projects/">CY8CKIT-021: The next three example projects</a></td>
<td >Use theThermistor and two Capsense Examples</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: Bootloading the PRoC</a></td>
<td >How to put firmware into the PRoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/31/cy8ckit-021-the-bleiot-component/">CY8CKIT-021: The BLEIOT Component</a></td>
<td >A custom component to communicate with the PRoC/PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/02/cy8ckit-021-using-the-bleiot-component/">CY8CKIT-021: Using the BLEIOT Component</a></td>
<td >A full example of the tho MCUs talking</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: The PRoC BLE Firmware</a></td>
<td >How to make PRoC Firmware and use it with the BLEIOT Component</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/13/cy8ckit-021-example-10-the-ios-app/">CY8CKIT-021: Example 10 - the new IOS App</a></td>
<td >How to build and IOS App to talk to the development kit</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy8ckit-021-the-next-3-example-projects/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CY8CKIT-021: The First 4 Example Projects</title>
		<link>https://iotexpert.com/cy8ckit-021-the-first-4-example-projects/</link>
					<comments>https://iotexpert.com/cy8ckit-021-the-first-4-example-projects/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 24 May 2016 13:57:07 +0000</pubDate>
				<category><![CDATA[Cy8CKIT-021]]></category>
		<category><![CDATA[DevKits]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=1422</guid>

					<description><![CDATA[Recall from the last post that the CY8CKIT-021 has 6 different peripherals to attach to.  The first thing that I did with the board is build a simple example for each of the peripherals.  I built all of the projects on the PSoC4200M development board which is also known as CY8CKIT-044.  The pinout for the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Recall from the <a href="https://iotexpert.com/2016/05/23/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/" target="_blank">last post</a> that the CY8CKIT-021 has 6 different peripherals to attach to.  The first thing that I did with the board is build a simple example for each of the peripherals.  I built all of the projects on the PSoC4200M development board which is also known as CY8CKIT-044.  The pinout for the other kits will be different, but the PSoC projects will be the same, but with a different pin map.  Later in the week I&#8217;ll show projects for the FM0 and FM4 development kits.  All of these projects  are available at <a href="https://github.com/iotexpert/CY8CKIT-021" target="_blank">github.com/iotexpert/CY8CKIT-021</a> in the firmware directory and in a single workspace.</p>
<ul>
<li>Example 1: 2 LEDs</li>
<li>Example 2: A buzzer</li>
<li>Example 3: A direct drive 7-segment LCD</li>
<li>Example 4: A potentiometer</li>
<li>Example 5: A thermistor</li>
<li>Example 6: 2 Capsense Buttons (using the V2.x component)</li>
<li>Example 7: 2 Capsense Buttons (using the new V3.x component + tuner)</li>
</ul>
<h2>Example 1: Two LEDs</h2>
<p>This weekend I taught people at the Bay Area Maker Faire to program PSoC.  I told them that the first project that you always do is the blinking LED.  This simple project is perfect to show that the tools work etc.  So, that is what we will do here.  For this example I used a TCPWM to blink the two LEDs.  One LED is connected to the line output and the other one is connected to the line_n output.  This will cause the LEDs to alternate.  The only other slightly interesting thing that I do is put the CPU to sleep and just let the hardware do the blinking.</p>
<p>&nbsp;</p>
<h2><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.03-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.03-AM.png" alt="Screen Shot 2016-05-24 at 8.21.03 AM" width="710" height="445" class="alignnone size-full wp-image-1427" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.03-AM.png 710w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.03-AM-600x376.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.03-AM-300x188.png 300w" sizes="auto, (max-width: 710px) 100vw, 710px" /></a></h2>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.23.44-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.23.44-AM.png" alt="Screen Shot 2016-05-24 at 8.23.44 AM" width="630" height="666" class="alignnone size-full wp-image-1431" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.23.44-AM.png 630w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.23.44-AM-600x634.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.23.44-AM-284x300.png 284w" sizes="auto, (max-width: 630px) 100vw, 630px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.26-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.26-AM-1024x674.png" alt="Screen Shot 2016-05-24 at 8.21.26 AM" width="1024" height="674" class="alignnone size-large wp-image-1428" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.26-AM-1024x674.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.26-AM-600x395.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.26-AM-300x197.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.26-AM-768x505.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.26-AM.png 1064w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.43-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.43-AM.png" alt="Screen Shot 2016-05-24 at 8.21.43 AM" width="781" height="397" class="alignnone size-full wp-image-1429" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.43-AM.png 781w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.43-AM-600x305.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.43-AM-300x152.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.21.43-AM-768x390.png 768w" sizes="auto, (max-width: 781px) 100vw, 781px" /></a></p>
<h2>Example 2: A buzzer</h2>
<p>To beep the buzzer I will use a 440hz tone that is generated by the TCPWM which divides an input clock of 440khz by 1000 to achieve the note &#8220;A&#8221; or &#8220;A4&#8221;.  To make the tone turn on and off I do my most hated thing, use the CyDelay to make a busy wait loop.  Basically, I turn on the PWM, wait for 500ms then turn it off, wait for 500ms and then go back to the start.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.20-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.20-AM.png" alt="Screen Shot 2016-05-24 at 8.25.20 AM" width="543" height="346" class="alignnone size-full wp-image-1432" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.20-AM.png 543w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.20-AM-300x191.png 300w" sizes="auto, (max-width: 543px) 100vw, 543px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.33-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.33-AM.png" alt="Screen Shot 2016-05-24 at 8.25.33 AM" width="629" height="665" class="alignnone size-full wp-image-1433" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.33-AM.png 629w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.33-AM-600x634.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.33-AM-284x300.png 284w" sizes="auto, (max-width: 629px) 100vw, 629px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.26.34-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.26.34-AM.png" alt="Screen Shot 2016-05-24 at 8.26.34 AM" width="481" height="72" class="alignnone size-full wp-image-1434" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.26.34-AM.png 481w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.26.34-AM-300x45.png 300w" sizes="auto, (max-width: 481px) 100vw, 481px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.53-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.53-AM.png" alt="Screen Shot 2016-05-24 at 8.25.53 AM" width="935" height="482" class="alignnone size-full wp-image-1435" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.53-AM.png 935w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.53-AM-600x309.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.53-AM-300x155.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.53-AM-768x396.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.25.53-AM-348x180.png 348w" sizes="auto, (max-width: 935px) 100vw, 935px" /></a></p>
<h2>Example 3: Direct Drive 7 Segment LCD</h2>
<p><span style="text-decoration: underline;"></span>A very cool feature of almost all of the PSoCs is their ability to drive &#8220;direct drive LCDs&#8221;.  This is a very low cost, low power way to add a display to your design.  This display we used on this board is a Lumex LCD-S401M16KR  that costs $0.73 from <a href="http://www.mouser.com/ProductDetail/Lumex/LCD-S401M16KR/?qs=0JU57JYmZjvIRhzkrYuX%252bQ%3d%3d&amp;gclid=CIOIp9rb8swCFUdbfgodAZoCMA" target="_blank">Mouser</a>.  Internally, all LCDs are organized into rows and columns a.k.a Segments and Commons.  To enable a particular segment in the LCD you need to select the correct row and column.  Then to make a symbol on the screen you need to select the combination of segments for that number.  For example, from the picture below, to make a &#8220;7&#8221; on the left digit you would need to turn on C3/S1, C2/S1, and C1/S1.  This would be a serious pain in the ass, but conveniently, the PSoC Creator segment LCD component does this for you automatically.</p>
<p>Our Lumex display is organized into 8 Segments and 4 Commons.  This means that it takes 12 pins on the chip and can show 32 segments.  The segments are organized into 4 characters with 7 segments (28 total segments), a decimal point between each character (3 segments) and a colon. Here is a picture:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.53.59-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.53.59-AM.png" alt="Screen Shot 2016-05-24 at 8.53.59 AM" width="745" height="481" class="alignnone size-full wp-image-1437" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.53.59-AM.png 745w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.53.59-AM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.53.59-AM-300x194.png 300w" sizes="auto, (max-width: 745px) 100vw, 745px" /></a></p>
<p>First add the segment LCD component to your design and attach a clock</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.07-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.07-AM.png" alt="Screen Shot 2016-05-24 at 9.17.07 AM" width="483" height="317" class="alignnone size-full wp-image-1442" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.07-AM.png 483w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.07-AM-300x197.png 300w" sizes="auto, (max-width: 483px) 100vw, 483px" /></a></p>
<p>Then make the top level configuration (4 commons and 8 segments)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.15-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.15-AM.png" alt="Screen Shot 2016-05-24 at 9.17.15 AM" width="636" height="664" class="alignnone size-full wp-image-1441" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.15-AM.png 636w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.15-AM-600x626.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.17.15-AM-287x300.png 287w" sizes="auto, (max-width: 636px) 100vw, 636px" /></a></p>
<p>To configure the component display you need to first add a &#8220;7 segment&#8221; helper to your component by selecting it and then clicking the right arrow.  Then you click the &#8220;+&#8221; 4 times to add 4 digits to your design.  Then you need to drag and drop the each segment from the digits onto the correct location on the segment/common matrix in the &#8220;pixel mapping table&#8221;.  For example &#8220;Common 3 / Segment 1&#8221; or &#8220;C3/S1&#8221; is the top segment in the left digit (look at the picture above), it needs to go in the &#8220;Com3&#8221; column and the &#8220;Seg1&#8221; row.  There is a pattern and once you see it this will not take very long.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.40.52-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.40.52-AM.png" alt="Screen Shot 2016-05-24 at 8.40.52 AM" width="637" height="664" class="alignnone size-full wp-image-1438" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.40.52-AM.png 637w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.40.52-AM-600x625.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.40.52-AM-288x300.png 288w" sizes="auto, (max-width: 637px) 100vw, 637px" /></a></p>
<p>The next step is to add the decimal points and colons to your project.  To do this add a &#8220;barograph and dial&#8221; helper.  Then click the &#8220;+&#8221; 4 times so that you have 4 segments.  As you add each one give it an appropriate name e.g. &#8220;colon&#8221; or &#8220;dp1&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.41.05-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.41.05-AM.png" alt="Screen Shot 2016-05-24 at 8.41.05 AM" width="633" height="661" class="alignnone size-full wp-image-1439" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.41.05-AM.png 633w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.41.05-AM-600x627.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-8.41.05-AM-287x300.png 287w" sizes="auto, (max-width: 633px) 100vw, 633px" /></a></p>
<p>The last thing that you need to do is to assign the pins.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.16.50-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.16.50-AM.png" alt="Screen Shot 2016-05-24 at 9.16.50 AM" width="483" height="319" class="alignnone size-full wp-image-1443" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.16.50-AM.png 483w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.16.50-AM-300x198.png 300w" sizes="auto, (max-width: 483px) 100vw, 483px" /></a></p>
<p>The firmware is simple:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.25.13-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.25.13-AM.png" alt="Screen Shot 2016-05-24 at 9.25.13 AM" width="915" height="666" class="alignnone size-full wp-image-1445" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.25.13-AM.png 915w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.25.13-AM-600x437.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.25.13-AM-300x218.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.25.13-AM-768x559.png 768w" sizes="auto, (max-width: 915px) 100vw, 915px" /></a></p>
<h2>Example 4: The Potentiometer</h2>
<p>To test the potentiometer I will use the ADC to measure its output voltage and then display it on the LCD screen.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.50.55-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.50.55-AM.png" alt="Screen Shot 2016-05-24 at 9.50.55 AM" width="448" height="226" class="alignnone size-full wp-image-1446" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.50.55-AM.png 448w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.50.55-AM-300x151.png 300w" sizes="auto, (max-width: 448px) 100vw, 448px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.39-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.39-AM.png" alt="Screen Shot 2016-05-24 at 9.51.39 AM" width="702" height="600" class="alignnone size-full wp-image-1447" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.39-AM.png 702w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.39-AM-600x513.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.39-AM-300x256.png 300w" sizes="auto, (max-width: 702px) 100vw, 702px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.51-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.51-AM.png" alt="Screen Shot 2016-05-24 at 9.51.51 AM" width="704" height="600" class="alignnone size-full wp-image-1448" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.51-AM.png 704w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.51-AM-600x511.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.51.51-AM-300x256.png 300w" sizes="auto, (max-width: 704px) 100vw, 704px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.52.11-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.52.11-AM.png" alt="Screen Shot 2016-05-24 at 9.52.11 AM" width="917" height="664" class="alignnone size-full wp-image-1449" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.52.11-AM.png 917w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.52.11-AM-600x434.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.52.11-AM-300x217.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-24-at-9.52.11-AM-768x556.png 768w" sizes="auto, (max-width: 917px) 100vw, 917px" /></a></p>
<p>I am out of time&#8230; so in the next post Ill show examples 5,6,7</p>
<p>Alan</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >index</th>
<th >description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2016/05/23/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/">CY8CKIT-021: A Simple FM/PSoC + BLE Demonstration Board</a></td>
<td >Introduction to CY8CKIT021</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/24/cy8ckit-021-the-first-4-example-projects/">CY8CKIT-021: The first four example projects</a></td>
<td >Use the LEDs</td>
<td > Buzzer</td>
<td > 7-Segment display and the Potentiometer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/25/cy8ckit-021-the-next-3-example-projects/">CY8CKIT-021: The next three example projects</a></td>
<td >Use theThermistor and two Capsense Examples</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: Bootloading the PRoC</a></td>
<td >How to put firmware into the PRoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/31/cy8ckit-021-the-bleiot-component/">CY8CKIT-021: The BLEIOT Component</a></td>
<td >A custom component to communicate with the PRoC/PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/02/cy8ckit-021-using-the-bleiot-component/">CY8CKIT-021: Using the BLEIOT Component</a></td>
<td >A full example of the tho MCUs talking</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: The PRoC BLE Firmware</a></td>
<td >How to make PRoC Firmware and use it with the BLEIOT Component</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/13/cy8ckit-021-example-10-the-ios-app/">CY8CKIT-021: Example 10 - the new IOS App</a></td>
<td >How to build and IOS App to talk to the development kit</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy8ckit-021-the-first-4-example-projects/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CY8CKIT-021: A Simple FM/PSoC + BLE Demonstration Board</title>
		<link>https://iotexpert.com/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/</link>
					<comments>https://iotexpert.com/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 23 May 2016 18:23:49 +0000</pubDate>
				<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[Cy8CKIT-021]]></category>
		<category><![CDATA[DevKits]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=1406</guid>

					<description><![CDATA[In my job I spend a lot of time teaching people how to use Cypress Products.  One of the best students that I ever had was Paul Bentley the Cypress VP of Sales for Europe.  He came to Kentucky a few years ago to take my class.  He dove in with reckless abandon and did a [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In my job I spend a lot of time teaching people how to use Cypress Products.  One of the best students that I ever had was Paul Bentley the Cypress VP of Sales for Europe.  He came to Kentucky a few years ago to take my class.  He dove in with reckless abandon and did a amazing job learning how to actually program the PSoC (not just talk about it on powerpoint).  Recently, he was anointed with the responsibility to teach more of our Sales team to use PSoC at the Sales Technical Conference (STCON) which is going on this week.</p>
<p>For some time I have wanted a very simple, inexpensive board to help teach people how get going using our chips&#8230;. all of our chips both the FM products as well as the PSoC products.  The STCON afforded the perfect opportunity to build an education board.  I am very lucky to work with some really good people (in India and New Hampshire) who did the work of realizing the vision of a simple board and getting it made in short time.</p>
<p>Without further ado, here it is, the provisionally name CY8CKIT-021 PSoC and FM Starter Shield (shown connected to the CY8CKIT-044).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/image.jpeg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/image-1024x768.jpeg" alt="image" width="1024" height="768" class="alignnone size-large wp-image-1419" srcset="https://iotexpert.com/wp-content/uploads/2016/05/image-1024x768.jpeg 1024w, https://iotexpert.com/wp-content/uploads/2016/05/image-600x450.jpeg 600w, https://iotexpert.com/wp-content/uploads/2016/05/image-300x225.jpeg 300w, https://iotexpert.com/wp-content/uploads/2016/05/image-768x576.jpeg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a>The shield has an Arduino compatible footprint and has:</p>
<ul>
<li>2 CapSense Buttons</li>
<li>A Potentiometer</li>
<li>A Thermistor</li>
<li>2 LEDs</li>
<li>A PRoC BLE Module</li>
<li>A Piezo-electric buzzer</li>
<li>A 7 Segment direct drive LCD</li>
</ul>
<p>The PRoC is connected to the USB-I2C bridge on the programmer as well as the serial (I2C/UART) pins on the base board.  Here is the schematic:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-23-at-6.53.13-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-23-at-6.53.13-AM-1024x757.png" alt="Screen Shot 2016-05-23 at 6.53.13 AM" width="1024" height="757" class="alignnone size-large wp-image-1413" srcset="https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-23-at-6.53.13-AM-1024x757.png 1024w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-23-at-6.53.13-AM-600x444.png 600w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-23-at-6.53.13-AM-300x222.png 300w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-23-at-6.53.13-AM-768x568.png 768w, https://iotexpert.com/wp-content/uploads/2016/05/Screen-Shot-2016-05-23-at-6.53.13-AM.png 1750w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>One of the cool things about this board is that it is generally compatible with a bunch of the Cypress products including:</p>
<ul>
<li>CY8CKIT-042</li>
<li>CY8CKIT-042-BLE</li>
<li>CY8CKIT-044 (which is shown in the picture above)</li>
<li>CY8CKIT-046</li>
<li>S6E1B8</li>
<li>S6E1C3</li>
</ul>
<p>Over the next several days I am going to show you example projects using the board.  I will culminate at the end of the week by IOTifying the board by writing BLE firmware for the PRoC, building an IOS app and an Android app to talk to the board.<br />
<span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >index</th>
<th >description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2016/05/23/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/">CY8CKIT-021: A Simple FM/PSoC + BLE Demonstration Board</a></td>
<td >Introduction to CY8CKIT021</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/24/cy8ckit-021-the-first-4-example-projects/">CY8CKIT-021: The first four example projects</a></td>
<td >Use the LEDs</td>
<td > Buzzer</td>
<td > 7-Segment display and the Potentiometer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/25/cy8ckit-021-the-next-3-example-projects/">CY8CKIT-021: The next three example projects</a></td>
<td >Use theThermistor and two Capsense Examples</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: Bootloading the PRoC</a></td>
<td >How to put firmware into the PRoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/05/31/cy8ckit-021-the-bleiot-component/">CY8CKIT-021: The BLEIOT Component</a></td>
<td >A custom component to communicate with the PRoC/PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/02/cy8ckit-021-using-the-bleiot-component/">CY8CKIT-021: Using the BLEIOT Component</a></td>
<td >A full example of the tho MCUs talking</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/06/cy8ckit-021-the-proc-ble-firmware/">CY8CKIT-021: The PRoC BLE Firmware</a></td>
<td >How to make PRoC Firmware and use it with the BLEIOT Component</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2016/06/13/cy8ckit-021-example-10-the-ios-app/">CY8CKIT-021: Example 10 - the new IOS App</a></td>
<td >How to build and IOS App to talk to the development kit</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/cy8ckit-021-a-simple-fmpsoc-ble-demonstration-board/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
