This is a monitor program for BLE NRF51822 chip. You can check memory, register and system information.
Dependencies: BLE_API mbed nRF51822 nRF51_Vdd
Please refer follows.
/users/kenjiArai/code/debug_tools/
/users/kenjiArai/notebook/ble--tytaiyo-yuden-module-for-mbed/
Diff: debug_tools/debug_nRF51.cpp
- Revision:
- 4:36ad7c7d0400
- Parent:
- 3:367a0d10f176
- Child:
- 5:8c37a47ac34c
--- a/debug_tools/debug_nRF51.cpp Thu Feb 11 05:57:06 2016 +0000 +++ b/debug_tools/debug_nRF51.cpp Sun Feb 14 21:55:30 2016 +0000 @@ -19,13 +19,14 @@ // Include --------------------------------------------------------------------------------------- #include "mbed.h" #include "debug_common.h" -#include "softdevice_handler.h" #include "nrf_soc.h" // for internal Thermo sensoer #include "nRF51_Vdd.h" // Read nRF51 Vdd voltage // Object ---------------------------------------------------------------------------------------- nRF51_Vdd vdd_mon(3.6f, 2.6f); +DigitalOut p_out(P0_1); + // Definition ------------------------------------------------------------------------------------ // RAM ------------------------------------------------------------------------------------------- @@ -34,6 +35,7 @@ // Function prototypes --------------------------------------------------------------------------- extern void cpu_sys(void); +extern int trx_control(void); void debug_core(void); void ble_stack_stop(void); @@ -47,8 +49,10 @@ put_rn(); PRINTF("c - CPU VDD & Temp info"); put_rn(); -// PRINTF("d - Disable radio module"); -// put_rn(); + PRINTF("l - Low current (Sleep Mode)"); + put_rn(); + PRINTF("t - Test Radio module"); + put_rn(); PRINTF("s - CPU system info"); put_rn(); PRINTF("r - Reset(by Software)"); @@ -57,6 +61,10 @@ put_rn(); PRINTF("q - Return to main"); put_rn(); + PRINTF("New function (Number 1,2...)"); + put_rn(); + PRINTF("1 - Try new function"); + put_rn(); } // ---------- Program starts here! --------------------------------------------------------------- @@ -73,12 +81,23 @@ } } +void step_by_step(char c) +{ + PRINTF("Waiting key input"); + while (!READABLE()){;} + PRINTF("--- step %c", c); + put_rn(); + c = GETC(); // dummy read +} + void debug_core(void) { char *ptr; int32_t p_temp; float temperature; + uint32_t n; + put_rn(); put_rn(); PRINTF("%s [Help:'?' key]", mon_msg); @@ -88,12 +107,12 @@ PUTC('>'); ptr = linebuf; get_line(ptr, sizeof(linebuf)); + put_r(); switch (*ptr++) { //--------------------------------------------------------------------------------- // CPU VDD Voltage and Chip temperature //--------------------------------------------------------------------------------- case 'c' : - put_r(); NRF_TEMP->TASKS_START = 1; while (NRF_TEMP->EVENTS_DATARDY == 0){;} NRF_TEMP->EVENTS_DATARDY = 0; @@ -111,17 +130,41 @@ put_rn(); break; //--------------------------------------------------------------------------------- + // Test Radio module + //--------------------------------------------------------------------------------- + case 't' : + trx_control(); + break; + //--------------------------------------------------------------------------------- + // Something new and try new functions + //--------------------------------------------------------------------------------- + + // Please see following file + #include "debugging_nRF51.h" + + //--------------------------------------------------------------------------------- + // Go to Low current (Sleep mode) + //--------------------------------------------------------------------------------- + case 'l' : + PRINTF("Enter Sleep mode (Please push RESET button)"); + put_rn(); + while(true){ + sleep(); + //__WFI(); + //__WFE(); + } + // SCB->AIRCR = 0x05fa0004; // System RESET!! + //break; + //--------------------------------------------------------------------------------- // CPU system info //--------------------------------------------------------------------------------- case 's' : - put_r(); cpu_sys(); break; //--------------------------------------------------------------------------------- // System reset //--------------------------------------------------------------------------------- case 'r' : - put_r(); SCB->AIRCR = 0x05fa0004; // System RESET!! // Not come here (Just in case) deepsleep(); @@ -130,7 +173,6 @@ // help //--------------------------------------------------------------------------------- case '?' : - put_r(); msg_hlp(); break; //--------------------------------------------------------------------------------- @@ -151,7 +193,6 @@ // no support //--------------------------------------------------------------------------------- default: - put_r(); PUTC('?'); put_rn(); break;