Ashok Ra

Rapid IoT Kit - Wireless Uart Demo

Discussion created by Ashok Ra on Dec 5, 2018

Hi Everyone,

Here we going to see the demo of "Wireless Uart" Demo on Rapid IoT kit. we know that Rapid IoT has build with two MCU , KW41z & K64F. For this demo you should have SDK for KW41z,I have used  SDK_2.2.0_FRDM-KW41Z.

Wireless Uart Demo

Tools Required:

MCUXpressoIDE -> Download it from here

SDK for Rapid-IoT-Kit -> Download it from here

SDK for KW41z -> Download it from here

Rapid IoT Kit

Android or IOS App - IoT Toolbox here

Steps to follow:

The first step to Import "wireless uart" project from KW41z SDK examples.

the next step, you have to disable the keyboard functionality (keyboard.h)

/*
 * Name: gKeyBoardSupported_d
 * Description: Enables/disables the switches based keyboard
 */
#ifndef gKeyBoardSupported_d
#define gKeyBoardSupported_d                0
#endif

Rapid IoT kit hardware does not have 4 LED's interface with KW41 so some changes are required as below

also remove usage of Led3 & Led4 usages from everywhere.

/*
* Name: gLEDsOnTargetBoardDefault_c
* Description: Default value for LEDs count located on a
*              generic target board
*/
#ifndef gLEDsOnTargetBoardDefault_c
#define gLEDsOnTargetBoardDefault_c     2
#endif

Next step we need to add below code, so that K41z will start the advertising automatically after power on.

 

        /* BLE Host Stack Init */
        if (Ble_Initialize(App_GenericCallback) != gBleSuccess_c)
        {
            panic(0,0,0,0);
            return;
        }

        LED_StopFlashingAllLeds();
        Led1Flashing();

        BleApp_Start(gGapPeripheral_c);

Now we can compile the code and flash it in Rapid IoT Kit.

 

The next part is Import the "Hello World" example from Rapid IoT Kit SDK

next step change the baud-rate for FSCI Interface (UART 4)

/* FSCI Interface Configuration structure */
static const gFsciSerialConfig_t mFsciSerials[] =

{
    {
        .baudrate = gUARTBaudRate115200_c,
        .interfaceType = gSerialMgrUart_c,
        .interfaceChannel = 4,
        .virtualInterface = 0

    },

below changes for  FsciCommunication.c

 

void FSCI_receivePacket( void* param )
{
    uint16_t            readBytes;
    uint8_t             c;
    static uint8_t bytesReceived=0;
    if( gSerial_Success_c != Serial_GetByteFromRxBuffer( gFsciSerialInterfaces[(uint32_t)param], &c, &readBytes ) )
    {
        return;
    }
    while( readBytes && !wuartreceived)
    {
        if(c == '\r'){
            bytesReceived = 0;
            wuartreceived = 1;
        }
        else
        {
            lcdtext[bytesReceived++] =c;
        }  /* if (!startOfFrameSeen) */

        if ( gSerial_Success_c != Serial_GetByteFromRxBuffer( gFsciSerialInterfaces[(uint32_t)param], &c, &readBytes ) )
        {
            break;
        }
    }
}

below changes in hello_world.c

 

    /* Main Application Loop (idle state) */
    while (1)
    {

 

        if(wuartreceived){

            shell_write("\n");
            shell_write(lcdp);

            if(linecount>8)
            {
                GUI_Clear();
                GUI_DispString("\n");
                linecount=0;
            }
            GUI_DispString(" ");
            GUI_DispString(lcdp);
            wuartreceived = 0;
            linecount++;
            Clear_Buffer();

        }

You can also download this code from here https://gitlab.com/mcucodes/rapid-iot-k64f-wuart-hello-world

Compile the code then flash it into Rapid Kit, and  the demo is ready!

 

Happy Coding!

 

Working demo of video is here Rapid IoT Kit - Wireless Uart Demo

Outcomes