Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX44000 nexpaq_mdk
Fork of LED_Demo by
main.cpp
00001 #include "mbed.h" 00002 #include "nexpaq_mdk.h" 00003 00004 DigitalOut ledR(P2_4, LED_OFF); 00005 DigitalOut ledG(P2_5, LED_OFF); 00006 DigitalOut ledB(P2_6, LED_OFF); 00007 DigitalIn button(P0_1, PullUp); 00008 00009 /***** Definitions *****/ 00010 #define FUNCTION_TABLE_NUM 1 00011 #define UUID_NUM 16 //UUID number is 16, don't change it 00012 #define LOOP_DELAY 100 00013 00014 /***** Globals *****/ 00015 void my_function_CMD_2700(unsigned char *pData, unsigned char len); 00016 const MDK_REGISTER_CMD my_cmd_func_table[FUNCTION_TABLE_NUM] = { 00017 {0x2700, my_function_CMD_2700}, // Command -> function 00018 }; 00019 00020 int lastBtn = 1; 00021 unsigned char btnPress = 0x01; 00022 00023 /***** Functions *****/ 00024 void my_function_CMD_2700(unsigned char *pData, unsigned char len) 00025 { 00026 unsigned char response = 0x00; 00027 ledR = (pData[0]>0) ? LED_ON : LED_OFF ; 00028 ledG = (pData[1]>0) ? LED_ON : LED_OFF ; 00029 ledB = (pData[2]>100) ? LED_ON : LED_OFF ; 00030 np_api_upload(0x2701, &response, 1); 00031 } 00032 00033 /******************************************************************************/ 00034 void app_setup() 00035 { 00036 if ( np_api_register((MDK_REGISTER_CMD*)my_cmd_func_table, FUNCTION_TABLE_NUM) == MDK_REGISTER_FAILD ) { 00037 // Register failed handle code 00038 error("MDK Register Failed"); 00039 } 00040 } 00041 00042 void app_loop() 00043 { 00044 if (!button && lastBtn) { 00045 np_api_upload(0x2800, &btnPress, 1); 00046 } 00047 lastBtn = button; 00048 } 00049 00050 int main(void) 00051 { 00052 00053 np_api_init(); 00054 app_setup(); 00055 np_api_start(); 00056 while(1) { 00057 Thread::wait(LOOP_DELAY); 00058 app_loop(); 00059 np_api_bsl_chk(); 00060 } 00061 00062 return 0; 00063 } 00064
Generated on Tue Jul 12 2022 17:03:46 by
1.7.2
