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/
debug_tools/debug_nRF51.cpp
- Committer:
- kenjiArai
- Date:
- 2016-02-11
- Revision:
- 2:6a659d71d71f
- Parent:
- 0:08c935d6c28f
- Child:
- 3:367a0d10f176
File content as of revision 2:6a659d71d71f:
/* * mbed Application program * * Copyright (c) 2016 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: Feburary 1st, 2016 * Revised: Feburary 4th, 2016 * * 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 THE AUTHORS OR COPYRIGHT HOLDERS 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. */ #if defined(TARGET_NRF51822) // 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); // Definition ------------------------------------------------------------------------------------ // RAM ------------------------------------------------------------------------------------------- // ROM / Constant data --------------------------------------------------------------------------- // Function prototypes --------------------------------------------------------------------------- extern void cpu_sys(void); void debug_core(void); void ble_stack_stop(void); //------------------------------------------------------------------------------------------------- // Control Program //------------------------------------------------------------------------------------------------- // Help Massage void msg_hlp (void) { PRINTF(mon_msg); put_rn(); PRINTF("c - CPU VDD & Temp info"); put_rn(); // PRINTF("d - Disable radio module"); // put_rn(); PRINTF("s - CPU system info"); put_rn(); PRINTF("r - Reset(by Software)"); put_rn(); PRINTF("x - Goto HW monitor"); put_rn(); PRINTF("q - Return to main"); put_rn(); } // ---------- Program starts here! --------------------------------------------------------------- void debug_interface(uint8_t mode) { BAUD(BAUD_RATE); if (mode){ debug_core(); } else { if(READABLE()){ unsigned char c = GETC(); // dummy read debug_core(); } } } void debug_core(void) { char *ptr; int32_t p_temp; float temperature; put_rn(); put_rn(); PRINTF("%s [Help:'?' key]", mon_msg); put_rn(); for (;;) { put_r(); PUTC('>'); ptr = linebuf; get_line(ptr, sizeof(linebuf)); 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; if ((NRF_TEMP->TEMP & 0x00000200) != 0){ p_temp = (NRF_TEMP->TEMP | 0xFFFFFC00); } else { p_temp = NRF_TEMP->TEMP; } NRF_TEMP->TASKS_STOP = 1; /** Stop the temperature measurement. */ temperature = float(p_temp) / 4; // Original = float(p_temp)/4.0f - 16.0f; PRINTF("nRF51\r\nChip temperature: %+4.1fdegC", temperature); put_rn(); // Vdd voltage PRINTF("Vdd: %4.3fV", vdd_mon.read_real_value()); put_rn(); 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(); break; //--------------------------------------------------------------------------------- // help //--------------------------------------------------------------------------------- case '?' : put_r(); msg_hlp(); break; //--------------------------------------------------------------------------------- // Go to special command //--------------------------------------------------------------------------------- case 'x' : mon_hw(); PRINTF("->Came back monitor\r\n"); break; //--------------------------------------------------------------------------------- // Go back to main() //--------------------------------------------------------------------------------- case 'q' : // Quit PRINTF("\rReturn to main\r\n"); //PRINTF("cannot control anymore from here\r\n"); return; //--------------------------------------------------------------------------------- // no support //--------------------------------------------------------------------------------- default: put_r(); PUTC('?'); put_rn(); break; } } } #endif // defined(TARGET_NRF51822)