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:
nexpaq
Date:
Mon Sep 19 14:21:15 2016 +0000
Revision:
4:494741f7f5b2
Parent:
3:9d15891f9352
Child:
6:7b51d2ebef23
Demo for event

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
nexpaq 4:494741f7f5b2 19 #define LOOP_DELAY 100
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 if ( np_api_register((MDK_REGISTER_CMD*)my_cmd_func_table, FUNCTION_TABLE_NUM) == MDK_REGISTER_FAILD ) {
nexpaq 0:b86eda0e990d 42 // Register failed handle code
nexpaq 0:b86eda0e990d 43 error("MDK Register Failed");
nexpaq 0:b86eda0e990d 44 }
nexpaq 0:b86eda0e990d 45 }
nexpaq 0:b86eda0e990d 46
nexpaq 0:b86eda0e990d 47 void app_loop() {
gsteiert 3:9d15891f9352 48 if (!button && lastBtn) {
gsteiert 3:9d15891f9352 49 np_api_upload(0x2800, &btnPress, 1);
gsteiert 3:9d15891f9352 50 }
gsteiert 3:9d15891f9352 51 lastBtn = button;
nexpaq 0:b86eda0e990d 52 }
nexpaq 0:b86eda0e990d 53
nexpaq 0:b86eda0e990d 54 int main(void){
jowen 2:3842948024ca 55
nexpaq 0:b86eda0e990d 56 np_api_init();
nexpaq 0:b86eda0e990d 57 app_setup();
nexpaq 0:b86eda0e990d 58 np_api_start();
nexpaq 0:b86eda0e990d 59 while(1){
gsteiert 3:9d15891f9352 60 Thread::wait(LOOP_DELAY);
nexpaq 0:b86eda0e990d 61 app_loop();
nexpaq 0:b86eda0e990d 62 np_api_bsl_chk();
nexpaq 0:b86eda0e990d 63 }
jowen 2:3842948024ca 64
nexpaq 0:b86eda0e990d 65 return 0;
nexpaq 0:b86eda0e990d 66 }
nexpaq 0:b86eda0e990d 67