1.. _hexiwear: 2 3Hexiwear 4######## 5 6Overview 7******** 8 9Hexiwear is powered by a Kinetis K64 microcontroller based on the ARM Cortex-M4 10core. Another Kinetis wireless MCU, the KW40Z, provides Bluetooth Low Energy 11connectivity. Hexiwear also integrates a wide variety of sensors, as well as a 12user interface consisting of a 1.1" 96px x 96px full color OLED display and six 13capacitive buttons with haptic feedback. 14 15- Eye-catching Smart Watch form factor with powerful, low power Kinetis K6x MCU 16 and 6 on-board sensors. 17- Designed for wearable applications with the onboard rechargeable battery, 18 OLED screen and onboard sensors such as optical heart rate, accelerometer, 19 magnetometer and gyroscope. 20- Designed for IoT end node applications with the onboard sensor's such as 21 temperature, pressure, humidity and ambient light. 22- Flexibility to let you add the sensors of your choice nearly 200 additional 23 sensors through click boards. 24 25.. image:: hexiwear_k64.jpg 26 :align: center 27 :alt: Hexiwear 28 29Hardware 30******** 31 32- Main MCU: NXP Kinetis K64x (ARM Cortex-M4, 120 MHz, 1M Flash, 256K SRAM) 33- Wireless MCU: NXP Kinetis KW4x (ARM Cortex-M0+, Bluetooth Low Energy & 34 802.15.4 radio) 35- 6-axis combo Accelerometer and Magnetometer NXP FXOS8700 36- 3-Axis Gyroscope: NXP FXAS21002 37- Absolute Pressure sensor NXP MPL3115 38- Li-Ion/Li-Po Battery Charger NXP MC34671 39- Optical heart rate sensor Maxim MAX30101 40- Ambient Light sensor, Humidity and Temperature sensor 41- 1.1" full color OLED display 42- Haptic feedback engine 43- 190 mAh 2C Li-Po battery 44- Capacitive touch interface 45- RGB LED 46 47For more information about the K64F SoC and Hexiwear board: 48 49- `K64F Website`_ 50- `K64F Datasheet`_ 51- `K64F Reference Manual`_ 52- `Hexiwear Website`_ 53- `Hexiwear Fact Sheet`_ 54- `Hexiwear Schematics`_ 55 56Supported Features 57================== 58 59The hexiwear/mk64f12 board variant supports the following hardware features: 60 61+-----------+------------+-------------------------------------+ 62| Interface | Controller | Driver/Component | 63+===========+============+=====================================+ 64| NVIC | on-chip | nested vector interrupt controller | 65+-----------+------------+-------------------------------------+ 66| SYSTICK | on-chip | systick | 67+-----------+------------+-------------------------------------+ 68| PINMUX | on-chip | pinmux | 69+-----------+------------+-------------------------------------+ 70| GPIO | on-chip | gpio | 71+-----------+------------+-------------------------------------+ 72| I2C | on-chip | i2c | 73+-----------+------------+-------------------------------------+ 74| WATCHDOG | on-chip | watchdog | 75+-----------+------------+-------------------------------------+ 76| ADC | on-chip | adc | 77+-----------+------------+-------------------------------------+ 78| PWM | on-chip | pwm | 79+-----------+------------+-------------------------------------+ 80| UART | on-chip | serial port-polling; | 81| | | serial port-interrupt | 82+-----------+------------+-------------------------------------+ 83| FLASH | on-chip | soc flash | 84+-----------+------------+-------------------------------------+ 85| SENSOR | off-chip | fxos8700 polling; | 86| | | fxos8700 trigger; | 87| | | fxas21002 polling; | 88| | | fxas21002 trigger; | 89| | | max30101 polling | 90+-----------+------------+-------------------------------------+ 91| RNGA | on-chip | entropy; | 92| | | random | 93+-----------+------------+-------------------------------------+ 94 95The default configuration can be found in the defconfig file: 96 97 :zephyr_file:`boards/nxp/hexiwear/hexiwear_mk64f12_defconfig` 98 99Other hardware features are not currently supported by the port. 100 101Connections and IOs 102=================== 103 104The K64F SoC has five pairs of pinmux/gpio controllers. 105 106+-------+-----------------+---------------------------+ 107| Name | Function | Usage | 108+=======+=================+===========================+ 109| PTA29 | GPIO | LDO_EN | 110+-------+-----------------+---------------------------+ 111| PTB0 | I2C0_SCL | I2C / MAX30101 | 112+-------+-----------------+---------------------------+ 113| PTB1 | I2C0_SDA | I2C / MAX30101 | 114+-------+-----------------+---------------------------+ 115| PTB12 | GPIO | 3V3B EN | 116+-------+-----------------+---------------------------+ 117| PTB16 | UART0_RX | UART Console | 118+-------+-----------------+---------------------------+ 119| PTB17 | UART0_TX | UART Console | 120+-------+-----------------+---------------------------+ 121| PTC8 | GPIO / PWM | Red LED | 122+-------+-----------------+---------------------------+ 123| PTC9 | GPIO / PWM | Green LED | 124+-------+-----------------+---------------------------+ 125| PTC10 | I2C1_SCL | I2C / FXOS8700 / FXAS21002| 126+-------+-----------------+---------------------------+ 127| PTC11 | I2C1_SDA | I2C / FXOS8700 / FXAS21002| 128+-------+-----------------+---------------------------+ 129| PTC14 | GPIO | Battery sense enable | 130+-------+-----------------+---------------------------+ 131| PTC18 | GPIO | FXAS21002 INT2 | 132+-------+-----------------+---------------------------+ 133| PTD0 | GPIO / PWM | Blue LED | 134+-------+-----------------+---------------------------+ 135| PTD13 | GPIO | FXOS8700 INT2 | 136+-------+-----------------+---------------------------+ 137| PTE24 | UART4_RX | UART BT HCI | 138+-------+-----------------+---------------------------+ 139| PTE25 | UART4_TX | UART BT HCI | 140+-------+-----------------+---------------------------+ 141 142.. note:: 143 144 To enable battery sensing, you will need to enable the ``en_bat_sens`` 145 regulator in Devicetree. Similarly, to enable devices connected to the 1V8 146 or 3V3 power rails (sensors), you will need to enable the ``en_ldo`` 147 and ``en_3v3b`` regulators in Devicetree. 148 149System Clock 150============ 151 152The K64F SoC is configured to use the 12 MHz external oscillator on the board 153with the on-chip PLL to generate a 120 MHz system clock. 154 155Serial Port 156=========== 157 158The K64F SoC has six UARTs. One is configured for the console, another for BT 159HCI, and the remaining are not used. 160 161Programming and Debugging 162************************* 163 164Build and flash applications as usual (see :ref:`build_an_application` and 165:ref:`application_run` for more details). 166 167Configuring a Debug Probe 168========================= 169 170A debug probe is used for both flashing and debugging the board. This board is 171configured by default to use the :ref:`opensda-daplink-onboard-debug-probe`, 172but because Segger RTT is required for a console on KW40Z, we recommend that 173you reconfigure the board for the :ref:`opensda-jlink-onboard-debug-probe`. 174 175.. note:: 176 OpenSDA is shared between the K64 and the KW40Z via switches, therefore only 177 one SoC can be flashed, debugged, or have an open console at a time. 178 179Option 1: :ref:`opensda-jlink-onboard-debug-probe` (Recommended) 180---------------------------------------------------------------- 181 182Install the :ref:`jlink-debug-host-tools` and make sure they are in your search 183path. 184 185Follow the instructions in :ref:`opensda-jlink-onboard-debug-probe` to program 186the `OpenSDA J-Link Generic Firmware for V2.1 Bootloader`_. Check that switches 187SW1 and SW2 are **on**, and SW3 and SW4 are **off** to ensure K64F SWD signals 188are connected to the OpenSDA microcontroller. 189 190Option 2: :ref:`opensda-daplink-onboard-debug-probe` 191---------------------------------------------------- 192 193Install the :ref:`pyocd-debug-host-tools` and make sure they are in your search 194path. 195 196Follow the instructions in :ref:`opensda-daplink-onboard-debug-probe` to 197program the `OpenSDA DAPLink Hexiwear Firmware`_. Check that switches SW1 and 198SW2 are **on**, and SW3 and SW4 are **off** to ensure K64F SWD signals are 199connected to the OpenSDA microcontroller. 200 201Add the arguments ``-DBOARD_FLASH_RUNNER=pyocd`` and 202``-DBOARD_DEBUG_RUNNER=pyocd`` when you invoke ``west build`` to override the 203default runner from J-Link to pyOCD: 204 205.. zephyr-app-commands:: 206 :zephyr-app: samples/hello_world 207 :board: hexiwear/mk64f12 208 :gen-args: -DBOARD_FLASH_RUNNER=pyocd -DBOARD_DEBUG_RUNNER=pyocd 209 :goals: build 210 211Configuring a Console 212===================== 213 214Regardless of your choice in debug probe, we will use the OpenSDA 215microcontroller as a usb-to-serial adapter for the serial console. 216 217Connect a USB cable from your PC to CN1. 218 219Use the following settings with your serial terminal of choice (minicom, putty, 220etc.): 221 222- Speed: 115200 223- Data: 8 bits 224- Parity: None 225- Stop bits: 1 226 227Flashing 228======== 229 230Here is an example for the :zephyr:code-sample:`hello_world` application. 231 232.. zephyr-app-commands:: 233 :zephyr-app: samples/hello_world 234 :board: hexiwear/mk64f12 235 :goals: flash 236 237Open a serial terminal, reset the board (press the T4 button), and you should 238see the following message in the terminal: 239 240.. code-block:: console 241 242 ***** Booting Zephyr OS v1.14.0-rc1 ***** 243 Hello World! hexiwear 244 245Debugging 246========= 247 248Here is an example for the :zephyr:code-sample:`hello_world` application. 249 250.. zephyr-app-commands:: 251 :zephyr-app: samples/hello_world 252 :board: hexiwear/mk64f12 253 :goals: debug 254 255Open a serial terminal, step through the application in your debugger, and you 256should see the following message in the terminal: 257 258.. code-block:: console 259 260 ***** Booting Zephyr OS v1.14.0-rc1 ***** 261 Hello World! hexiwear 262 263Using Bluetooth 264*************** 265 266Configure the KW40Z as a Bluetooth controller 267============================================= 268 269The K64 can support Zephyr Bluetooth host applications when you configure the 270KW40Z as a Bluetooth controller. 271 272#. Download and install the `KW40Z Connectivity Software`_. This package 273 contains Bluetooth controller application for the KW40Z. 274#. Flash the file ``tools/binaries/BLE_HCI_Modem.bin`` to the KW40Z. 275 276Now you can build and run the sample Zephyr Bluetooth host applications on the 277K64. You do not need to repeat this step each time you flash a new Bluetooth 278host application to the K64. 279 280Peripheral Heart Rate Sensor 281============================ 282 283Navigate to the Zephyr ``samples/bluetooth/peripheral_hr`` sample 284application, then build and flash it to the Hexiwear K64. Make sure 285the OpenSDA switches on the docking station are configured for the 286K64. 287 288.. zephyr-app-commands:: 289 :zephyr-app: samples/bluetooth/peripheral_hr 290 :board: hexiwear/mk64f12 291 :goals: build flash 292 293Reset the KW40Z and the K64 using the push buttons on the docking station. 294 295Install the Kinetis BLE Toolbox on your smartphone: 296 297- `Kinetis BLE Toolbox for iOS`_ 298- `Kinetis BLE Toolbox for Android`_ 299 300Open the app, tap the **Heart Rate** feature, and you should see a **Zephyr 301Heartrate Sensor** device. Tap the **Zephyr Heartrate Sensor** device and you 302will then see a plot of the heart rate data that updates once per second. 303 304 305.. _Hexiwear Website: 306 https://www.mikroe.com/hexiwear 307 308.. _Hexiwear Fact Sheet: 309 https://www.nxp.com/docs/en/fact-sheet/HEXIWEAR-FS.pdf 310 311.. _Hexiwear Schematics: 312 http://cdn-docs.mikroe.com/images/c/c0/Sch_Hexiwear_MainBoard_v106c.pdf 313 314.. _K64F Website: 315 https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/kinetis-cortex-m-mcus/k-seriesperformancem4/k6x-ethernet/kinetis-k64-120-mhz-256kb-sram-microcontrollers-mcus-based-on-arm-cortex-m4-core:K64_120 316 317.. _K64F Datasheet: 318 https://www.nxp.com/docs/en/data-sheet/K64P144M120SF5.pdf 319 320.. _K64F Reference Manual: 321 https://www.nxp.com/docs/en/reference-manual/K64P144M120SF5RM.pdf 322 323.. _OpenSDA J-Link Generic Firmware for V2.1 Bootloader: 324 https://www.segger.com/downloads/jlink/OpenSDA_V2_1 325 326.. _OpenSDA DAPLink Hexiwear Firmware: 327 https://github.com/MikroElektronika/HEXIWEAR/blob/master/HW/HEXIWEAR_DockingStation/HEXIWEAR_DockingStation_DAPLINK_FW.bin 328 329.. _KW40Z Connectivity Software: 330 https://www.nxp.com/webapp/Download?colCode=KW40Z-CONNECTIVITY-SOFTWARE&appType=license&location=null&fpsp=1&WT_TYPE=Protocol%20Stacks&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=exe&WT_ASSET=Downloads&fileExt=.exe&Parent_nodeId=1432854896956716810497&Parent_pageType=product 331 332.. _Kinetis BLE Toolbox for iOS: 333 https://itunes.apple.com/us/app/kinetis-ble-toolbox/id1049036961?mt=8 334 335.. _Kinetis BLE Toolbox for Android: 336 https://play.google.com/store/apps/details?id=com.freescale.kinetisbletoolbox 337 338 339Hexiwear KW40Z 340############## 341 342Overview 343******** 344 345The KW40Z is a secondary SoC on the board that provides wireless connectivity 346with a multimode BLE and 802.15.4 radio. 347 348For more information about the KW40Z SoC: 349 350- `KW40Z Website`_ 351- `KW40Z Datasheet`_ 352- `KW40Z Reference Manual`_ 353 354Supported Features 355================== 356 357The hexiwear/mkw40z4 board variant supports the following hardware features: 358 359+-----------+------------+-------------------------------------+ 360| Interface | Controller | Driver/Component | 361+===========+============+=====================================+ 362| NVIC | on-chip | nested vector interrupt controller | 363+-----------+------------+-------------------------------------+ 364| SYSTICK | on-chip | systick | 365+-----------+------------+-------------------------------------+ 366| PINMUX | on-chip | pinmux | 367+-----------+------------+-------------------------------------+ 368| GPIO | on-chip | gpio | 369+-----------+------------+-------------------------------------+ 370| ADC | on-chip | adc | 371+-----------+------------+-------------------------------------+ 372| UART | on-chip | serial port-polling; | 373| | | serial port-interrupt | 374+-----------+------------+-------------------------------------+ 375| RTT | on-chip | console | 376+-----------+------------+-------------------------------------+ 377| FLASH | on-chip | soc flash | 378+-----------+------------+-------------------------------------+ 379| TRNG | on-chip | entropy | 380+-----------+------------+-------------------------------------+ 381 382The default configuration can be found in the defconfig file: 383 384 :zephyr_file:`boards/nxp/hexiwear/hexiwear_mkw40z4_defconfig` 385 386Other hardware features are not currently supported by the port. 387 388Connections and IOs 389=================== 390 391The KW40Z SoC has three pairs of pinmux/gpio controllers, but only one is 392currently enabled (PORTC/GPIOC) for the hexiwear/mkw40z4 board. 393 394+-------+-----------------+---------------------------+ 395| Name | Function | Usage | 396+=======+=================+===========================+ 397| PTB1 | ADC | ADC0 channel 1 | 398+-------+-----------------+---------------------------+ 399| PTC6 | UART0_RX | UART BT HCI | 400+-------+-----------------+---------------------------+ 401| PTC7 | UART0_TX | UART BT HCI | 402+-------+-----------------+---------------------------+ 403 404System Clock 405============ 406 407The KW40Z SoC is configured to use the 32 MHz external oscillator on the board 408with the on-chip FLL to generate a 40 MHz system clock. 409 410Serial Port 411=========== 412 413The KW40Z SoC has one UART, which is used for BT HCI. There is no UART 414available for a console. 415 416Programming and Debugging 417************************* 418 419Build and flash applications as usual (see :ref:`build_an_application` and 420:ref:`application_run` for more details). 421 422Configuring a Debug Probe 423========================= 424 425A debug probe is used for both flashing and debugging the board. This board is 426configured by default to use the :ref:`opensda-daplink-onboard-debug-probe`, 427but because Segger RTT is required for a console, you must reconfigure the 428board for one of the following debug probes instead. 429 430:ref:`opensda-jlink-onboard-debug-probe` 431---------------------------------------- 432 433Install the :ref:`jlink-debug-host-tools` and make sure they are in your search 434path. 435 436Follow the instructions in :ref:`opensda-jlink-onboard-debug-probe` to program 437the `OpenSDA J-Link Generic Firmware for V2.1 Bootloader`_. Check that switches 438SW1 and SW2 are **off**, and SW3 and SW4 are **on** to ensure KW40Z SWD signals 439are connected to the OpenSDA microcontroller. 440 441Configuring a Console 442===================== 443 444The console is available using `Segger RTT`_. 445 446Connect a USB cable from your PC to CN1. 447 448Once you have started a debug session, run telnet: 449 450.. code-block:: console 451 452 $ telnet localhost 19021 453 Trying 127.0.0.1... 454 Connected to localhost. 455 Escape character is '^]'. 456 SEGGER J-Link V6.44 - Real time terminal output 457 J-Link OpenSDA 2 compiled Feb 28 2017 19:27:57 V1.0, SN=621000000 458 Process: JLinkGDBServerCLExe 459 460Flashing 461======== 462 463Here is an example for the :zephyr:code-sample:`hello_world` application. 464 465.. zephyr-app-commands:: 466 :zephyr-app: samples/hello_world 467 :board: hexiwear/mkw40z4 468 :goals: flash 469 470The Segger RTT console is only available during a debug session. Use ``attach`` 471to start one: 472 473.. zephyr-app-commands:: 474 :zephyr-app: samples/hello_world 475 :board: hexiwear/mkw40z4 476 :goals: attach 477 478Run telnet as shown earlier, and you should see the following message in the 479terminal: 480 481.. code-block:: console 482 483 ***** Booting Zephyr OS v1.14.0-rc1 ***** 484 Hello World! hexiwear 485 486Debugging 487========= 488 489Here is an example for the :zephyr:code-sample:`hello_world` application. 490 491.. zephyr-app-commands:: 492 :zephyr-app: samples/hello_world 493 :board: hexiwear/mkw40z4 494 :goals: debug 495 496Run telnet as shown earlier, step through the application in your debugger, and 497you should see the following message in the terminal: 498 499.. code-block:: console 500 501 ***** Booting Zephyr OS v1.14.0-rc1 ***** 502 Hello World! hexiwear 503 504.. _KW40Z Website: 505 https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/kinetis-cortex-m-mcus/w-serieswireless-conn.m0-plus-m4/kinetis-kw40z-2.4-ghz-dual-mode-ble-and-802.15.4-wireless-radio-microcontroller-mcu-based-on-arm-cortex-m0-plus-core:KW40Z 506 507.. _KW40Z Datasheet: 508 https://www.nxp.com/docs/en/data-sheet/MKW40Z160.pdf 509 510.. _KW40Z Reference Manual: 511 https://www.nxp.com/webapp/Download?colCode=MKW40Z160RM 512 513.. _Segger RTT: 514 https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/ 515 516.. _OpenSDA J-Link Generic Firmware for V2.1 Bootloader: 517 https://www.segger.com/downloads/jlink/OpenSDA_V2_1 518