nkjnm
Dependencies: MAX44000 nexpaq_mdk
Fork of LED_Demo by
Revision 2:3842948024ca, committed 2016-09-19
- Comitter:
- jowen
- Date:
- Mon Sep 19 09:06:46 2016 +0000
- Parent:
- 1:55a6170b404f
- Child:
- 3:9d15891f9352
- Commit message:
- Add LED indication for debug
Changed in this revision
--- a/main.cpp Sat Sep 17 16:32:05 2016 +0000 +++ b/main.cpp Mon Sep 19 09:06:46 2016 +0000 @@ -1,6 +1,13 @@ #include "mbed.h" #include "nexpaq_mdk.h" +#ifdef __cplusplus +extern "C" { +#endif +extern volatile uint8_t flag_jump_bsl; +#ifdef __cplusplus +} +#endif DigitalOut ledR(P2_4, LED_OFF); DigitalOut ledG(P2_5, LED_OFF); DigitalOut ledB(P2_6, LED_OFF); @@ -67,14 +74,54 @@ } int main(void){ + + uint32_t cnt, i; + + cnt = 500; + ledR = 1; + ledG = 0; + ledB = 1; + np_api_init(); app_setup(); np_api_start(); + //Thread::wait(5000); while(1){ app_loop(); np_api_bsl_chk(); Thread::wait(50); + + if (cnt) { + cnt--; + if (cnt == 0) { + ledR = 1; + ledG = 1; + ledB = 1; + Thread::wait(50); + cnt = 1000; + //NVIC_SystemReset(); + } + } + + i = cnt%30; + if (i == 10) + { + ledR = 1; + ledG = 1; + ledB = 1; + } + else if (i == 20){ + ledR = 1; + ledG = 0; + ledB = 1; + } + else if (i == 0) { + ledR = 1; + ledG = 1; + ledB = 0; + } } + return 0; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbd_os/hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32625/led.c Mon Sep 19 09:06:46 2016 +0000 @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date: 2016-03-11 11:46:37 -0600 (Fri, 11 Mar 2016) $ + * $Revision: 21839 $ + * + ******************************************************************************/ + +#include "mxc_config.h" +#include "led.h" +const gpio_cfg_t led_pin[] = { + { PORT_2, PIN_4, GPIO_FUNC_GPIO, GPIO_PAD_OPEN_DRAIN }, + { PORT_2, PIN_5, GPIO_FUNC_GPIO, GPIO_PAD_OPEN_DRAIN }, + { PORT_2, PIN_6, GPIO_FUNC_GPIO, GPIO_PAD_OPEN_DRAIN }, +}; +const unsigned int num_leds = (sizeof(led_pin) / sizeof(gpio_cfg_t)); + + + +/******************************************************************************/ +int LED_Init(void) +{ + int retval = E_NO_ERROR; + int i; + + /* setup GPIO for the LED */ + for (i = 0; i < num_leds; i++) { + LED_Off(i); // Set the output value + if (GPIO_Config(&led_pin[i]) != E_NO_ERROR) { + retval = E_UNKNOWN; + } + } + + return retval; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbd_os/hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32625/led.h Mon Sep 19 09:06:46 2016 +0000 @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date: 2016-03-11 11:46:37 -0600 (Fri, 11 Mar 2016) $ + * $Revision: 21839 $ + * + ******************************************************************************/ + + +/** + * @file led.h + * @brief LED driver header file. + */ + +#ifndef _LED_H_ +#define _LED_H_ + +#include "mxc_assert.h" +//#include "board.h" +#include "gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/***** Definitions *****/ +#ifndef LED_OFF +#define LED_OFF 1 +#endif + +#ifndef LED_ON +#define LED_ON 0 +#endif + +/***** Global Variables *****/ +extern const gpio_cfg_t led_pin[]; +extern const unsigned int num_leds; + +/***** Function Prototypes *****/ + +/** + * @brief Initialize all LED pins. + * @returns #E_NO_ERROR if everything is successful, error if unsuccessful. + */ +int LED_Init(void); + +/** + * @brief Turn the specified LED on. + * @param idx LED index + */ +__STATIC_INLINE void LED_On(unsigned int idx) +{ + MXC_ASSERT(idx < num_leds); +#if (LED_ON == 0) + GPIO_OutClr(&led_pin[idx]); +#else + GPIO_OutSet(&led_pin[idx]); +#endif +} + +/** + * @brief Turn the specified LED off. + * @param idx LED index + */ +__STATIC_INLINE void LED_Off(unsigned int idx) +{ + MXC_ASSERT(idx < num_leds); +#if (LED_ON == 0) + GPIO_OutSet(&led_pin[idx]); +#else + GPIO_OutClr(&led_pin[idx]); +#endif +} + +/** + * @brief Toggle the state of the specified LED. + * @param idx LED index + */ +__STATIC_INLINE void LED_Toggle(unsigned int idx) +{ + MXC_ASSERT(idx < num_leds); + GPIO_OutToggle(&led_pin[idx]); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _LED_H_ */
--- a/mbd_os/hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32625/system_max32625.c Sat Sep 17 16:32:05 2016 +0000 +++ b/mbd_os/hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32625/system_max32625.c Mon Sep 19 09:06:46 2016 +0000 @@ -42,6 +42,7 @@ #include "flc_regs.h" #include "rtc_regs.h" #include "trim_regs.h" +#include "led.h" #ifndef RO_FREQ #define RO_FREQ 96000000 @@ -161,9 +162,14 @@ */ __weak int PreInit(void) { + LED_Off(0); + LED_Off(1); + LED_Off(2); + /* Increase system clock to 96 MHz */ MXC_CLKMAN->clk_ctrl = MXC_V_CLKMAN_CLK_CTRL_SYSTEM_SOURCE_SELECT_96MHZ_RO; + /* This part already done once at boot loader codes, commomented temporarily*/ /* Performance-measurement hook, may be defined as nothing */ LP0_POST_HOOK; @@ -179,10 +185,15 @@ { /* Configure the interrupt controller to use the application vector table in */ /* the application space */ + + /* If already initialize all hardware, will skip it for speeding up boot*/ + //if (SCB->VTOR == (unsigned long)__Vectors) + // return; #if defined ( __CC_ARM) || defined ( __GNUC__) /* IAR sets the VTOR pointer incorrectly and causes stack corruption */ SCB->VTOR = (unsigned long)__Vectors; #endif /* __CC_ARM || __GNUC__ */ + /* Copy trim information from shadow registers into power manager registers */ /* NOTE: Checks have been added to prevent bad/missing trim values from being loaded */ @@ -267,6 +278,15 @@ __ISB(); #endif + /* Turn off all LEDS*/ + LED_Off(0); + LED_Off(1); + LED_Off(2); /* Perform an initial trim of the internal ring oscillator */ CLKMAN_TrimRO(); + + /*Turn on LED in white color*/ + LED_On(0); + LED_On(1); + LED_On(2); }
--- a/nexpaq_mdk_src/source/np_system.c Sat Sep 17 16:32:05 2016 +0000 +++ b/nexpaq_mdk_src/source/np_system.c Mon Sep 19 09:06:46 2016 +0000 @@ -173,6 +173,7 @@ if( flag_jump_bsl > 0x00 ) { flag_jump_bsl = 0x00; np_system_disable_interrupt(); + #ifdef DBG_MSG printf("Entering NP Bootloader\n\r"); #endif