Basic LED Demo for nexpaq development kit

Dependencies:   nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

LED Demo

MAX32625NEXPAQ development module

This project is a demonstration application for the MAX32625NEXPAQ development module. You will need the nexpaq application and a compatible phone to run this demo. This project demonstrates sending button information back to the application running on the phone, and the phone controlling the on board RGB LED.

Go to the nexpaq developers hub for details on how to load the code for the tile into the application.

Resources

Committer:
gsteiert
Date:
Mon Sep 19 13:13:32 2016 +0000
Revision:
3:9d15891f9352
Parent:
2:3842948024ca
Child:
4:494741f7f5b2
demo changes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:b86eda0e990d 1 #include "mbed.h"
nexpaq 0:b86eda0e990d 2 #include "nexpaq_mdk.h"
nexpaq 0:b86eda0e990d 3
jowen 2:3842948024ca 4 #ifdef __cplusplus
jowen 2:3842948024ca 5 extern "C" {
jowen 2:3842948024ca 6 #endif
jowen 2:3842948024ca 7 extern volatile uint8_t flag_jump_bsl;
jowen 2:3842948024ca 8 #ifdef __cplusplus
jowen 2:3842948024ca 9 }
jowen 2:3842948024ca 10 #endif
nexpaq 0:b86eda0e990d 11 DigitalOut ledR(P2_4, LED_OFF);
nexpaq 0:b86eda0e990d 12 DigitalOut ledG(P2_5, LED_OFF);
nexpaq 0:b86eda0e990d 13 DigitalOut ledB(P2_6, LED_OFF);
nexpaq 0:b86eda0e990d 14 DigitalIn button(P0_1, PullUp);
nexpaq 0:b86eda0e990d 15
nexpaq 0:b86eda0e990d 16 /***** Definitions *****/
nexpaq 0:b86eda0e990d 17 #define FUNCTION_TABLE_NUM 1
nexpaq 0:b86eda0e990d 18 #define UUID_NUM 16 //UUID number is 16, don't change it
gsteiert 3:9d15891f9352 19 #define LOOP_DELAY 250
nexpaq 0:b86eda0e990d 20
nexpaq 0:b86eda0e990d 21 /***** Globals *****/
nexpaq 0:b86eda0e990d 22 void my_function_CMD_2700(unsigned char *pData, unsigned char len);
nexpaq 0:b86eda0e990d 23 const MDK_REGISTER_CMD my_cmd_func_table[FUNCTION_TABLE_NUM] = {
nexpaq 0:b86eda0e990d 24 {0x2700, my_function_CMD_2700}, // Command -> function
nexpaq 0:b86eda0e990d 25 };
nexpaq 0:b86eda0e990d 26
gsteiert 3:9d15891f9352 27 int lastBtn = 1;
nexpaq 0:b86eda0e990d 28 unsigned char btnPress = 0x01;
nexpaq 0:b86eda0e990d 29
nexpaq 0:b86eda0e990d 30 /***** Functions *****/
nexpaq 0:b86eda0e990d 31 void my_function_CMD_2700(unsigned char *pData, unsigned char len){
nexpaq 0:b86eda0e990d 32 unsigned char response = 0x00;
nexpaq 0:b86eda0e990d 33 ledR = (pData[0]>0) ? LED_ON : LED_OFF ;
nexpaq 0:b86eda0e990d 34 ledG = (pData[1]>0) ? LED_ON : LED_OFF ;
nexpaq 0:b86eda0e990d 35 ledB = (pData[2]>0) ? LED_ON : LED_OFF ;
nexpaq 0:b86eda0e990d 36 np_api_upload(0x2701, &response, 1);
nexpaq 0:b86eda0e990d 37 }
nexpaq 0:b86eda0e990d 38
nexpaq 0:b86eda0e990d 39 /******************************************************************************/
nexpaq 0:b86eda0e990d 40 void app_setup(){
nexpaq 0:b86eda0e990d 41 // np_api_set_app_version(0, 0, 3);
nexpaq 0:b86eda0e990d 42 if ( np_api_register((MDK_REGISTER_CMD*)my_cmd_func_table, FUNCTION_TABLE_NUM) == MDK_REGISTER_FAILD ) {
nexpaq 0:b86eda0e990d 43 // Register failed handle code
nexpaq 0:b86eda0e990d 44 error("MDK Register Failed");
nexpaq 0:b86eda0e990d 45 }
nexpaq 0:b86eda0e990d 46 }
nexpaq 0:b86eda0e990d 47
nexpaq 0:b86eda0e990d 48 void app_loop() {
gsteiert 3:9d15891f9352 49 if (!button && lastBtn) {
gsteiert 3:9d15891f9352 50 np_api_upload(0x2800, &btnPress, 1);
gsteiert 3:9d15891f9352 51 }
gsteiert 3:9d15891f9352 52 lastBtn = button;
nexpaq 0:b86eda0e990d 53 }
nexpaq 0:b86eda0e990d 54
nexpaq 0:b86eda0e990d 55 int main(void){
jowen 2:3842948024ca 56
nexpaq 0:b86eda0e990d 57 np_api_init();
nexpaq 0:b86eda0e990d 58 app_setup();
nexpaq 0:b86eda0e990d 59 np_api_start();
jowen 2:3842948024ca 60 //Thread::wait(5000);
nexpaq 0:b86eda0e990d 61 while(1){
gsteiert 3:9d15891f9352 62 Thread::wait(LOOP_DELAY);
nexpaq 0:b86eda0e990d 63 app_loop();
nexpaq 0:b86eda0e990d 64 np_api_bsl_chk();
nexpaq 0:b86eda0e990d 65 }
jowen 2:3842948024ca 66
nexpaq 0:b86eda0e990d 67 return 0;
nexpaq 0:b86eda0e990d 68 }
nexpaq 0:b86eda0e990d 69