Smart LED application based on GoKit and FRDM-KL02

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Smart LED application based on GoKit and FRDM-KL02

Smart LED application based on GoKit and FRDM-KL02

As general introduction on thread https://community.freescale.com/docs/DOC-328302 , I did a smart LED application with GoKit and FRDM-KL02.

In this design, FRDM-KL02 will communicate with GoKit by WIFI, and control LED flash.

pastedImage_0.png

pastedImage_2.png

Code Structure

pastedImage_3.png

Code Basic Introduction

In this project structure, you need to do following items on code.

  • ü Add your functions, such as UART, LED, motor driver code.
  • ü Add function running functions in protocol.c
  • ü Add functions order in main loop.

You can find my main.c and protocol.c as attachment.

In this document, I would like to detail introduce function MessageHandle()

void MessageHandle(void)

{

                pro_headPart    tmp_headPart; //Common command package

                memset(&tmp_headPart, 0, sizeof(pro_headPart));

                if(get_one_package)

                {                                             

                                get_one_package = 0;

                                memcpy(&tmp_headPart, uart_buf, sizeof(pro_headPart));

                               

                                //CRC error, send back error command

                                if(CheckSum(uart_buf, uart_Count) != uart_buf[uart_Count-1])

                                {

                                                SendErrorCmd(ERROR_CHECKSUM, tmp_headPart.sn);

                                                return ;

                                }

                                So, you can see that only get_one_package=1, we can receive frame completely.

                                switch(tmp_headPart.cmd)

                                {             

                                                case       CMD_GET_MCU_INFO:

                                                                CmdGetMcuInfo(tmp_headPart.sn);                                                                                                                                     break;                  

                                                case CMD_SEND_HEARTBEAT:

                                                                SendCommonCmd(CMD_SEND_HEARTBEAT_ACK, tmp_headPart.sn);

                                                                                break;

                                                case CMD_REBOOT_MCU:

                                                                SendCommonCmd(CMD_REBOOT_MCU_ACK, tmp_headPart.sn);

                                                case       CMD_SEND_MCU_P0:

                                                                CmdSendMcuP0(uart_buf);

                                                                break;

                                                case       CMD_REPORT_MODULE_STATUS:

                                                                CmdReportModuleStatus(uart_buf);

                                                                break;

                                                default:

                                                                SendErrorCmd(ERROR_CMD, tmp_headPart.sn);

                                                                break;

                                }             

                }

}

After that, you can do operations mentioned in thread https://community.freescale.com/docs/DOC-328302. You can see smart LED device and been found.

pastedImage_4.pngpastedImage_5.png

pastedImage_6.png

pastedImage_7.png

Labels (1)
Attachments
No ratings
Version history
Last update:
‎09-28-2015 10:08 PM
Updated by: