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.
main.cpp
00001 #include "mbed.h" 00002 #include "nexpaq_mdk.h" 00003 00004 #ifdef __cplusplus 00005 extern "C" { 00006 #endif 00007 extern volatile uint8_t flag_jump_bsl; 00008 #ifdef __cplusplus 00009 } 00010 #endif 00011 DigitalOut ledR(P2_4, LED_OFF); 00012 DigitalOut ledG(P2_5, LED_OFF); 00013 DigitalOut ledB(P2_6, LED_OFF); 00014 00015 AnalogIn ain0(AIN_4); 00016 00017 //Serial pc(P2_1, P2_0); // tx, rx 00018 00019 //DigitalIn button(P0_1, PullUp); 00020 00021 /***** Definitions *****/ 00022 #define FUNCTION_TABLE_NUM 1 00023 #define UUID_NUM 16 //UUID number is 16, don't change it 00024 #define LOOP_DELAY 1000 00025 #define PROX_THRESHOLD 50 00026 00027 /***** Globals *****/ 00028 void my_function_CMD_2700(unsigned char *pData, unsigned char len); 00029 const MDK_REGISTER_CMD my_cmd_func_table[FUNCTION_TABLE_NUM] = { 00030 {0x2700, my_function_CMD_2700}, // Command -> function 00031 }; 00032 00033 //int lastBtn = 1; 00034 //unsigned char btnPress = 0x01; 00035 //int lastPrx = 0; 00036 //unsigned char prxPress = 0x02; 00037 00038 /***** Functions *****/ 00039 void my_function_CMD_2700(unsigned char *pData, unsigned char len){ 00040 unsigned char response = 0x00; 00041 ledR = (pData[0]>0) ? LED_ON : LED_OFF ; 00042 ledG = (pData[1]>0) ? LED_ON : LED_OFF ; 00043 ledB = (pData[2]>0) ? LED_ON : LED_OFF ; 00044 np_api_upload(0x2701, &response, 1); 00045 } 00046 00047 /******************************************************************************/ 00048 void app_setup(){ 00049 time_t initSeconds = 0; 00050 set_time(initSeconds); 00051 printf("App Setup \r\n\n"); 00052 if ( np_api_register((MDK_REGISTER_CMD*)my_cmd_func_table, FUNCTION_TABLE_NUM) == MDK_REGISTER_FAILD ) { 00053 //Register failed handle code 00054 error("MDK Register Failed"); 00055 00056 } 00057 } 00058 00059 void app_loop() { 00060 unsigned char result = 0.0; 00061 00062 result = ain0.read_u16(); 00063 time_t endSeconds = time(NULL); 00064 printf("AIN_0 = %f Time = %d\r\n", result, endSeconds); 00065 ledR = !ledR; 00066 np_api_upload(0x2800, &result, 1); 00067 00068 } 00069 00070 int main(void){ 00071 00072 np_api_init(); 00073 app_setup(); 00074 np_api_start(); 00075 printf("Hello World\r\n\n"); 00076 while(1){ 00077 Thread::wait(LOOP_DELAY); 00078 //wait(LOOP_DELAY); 00079 00080 app_loop(); 00081 np_api_bsl_chk(); 00082 } 00083 00084 return 0; 00085 } 00086 00087 00088 00089 00090 00091
Generated on Tue Jul 12 2022 12:58:29 by
1.7.2