Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of NNN40_CLI by
main.cpp
- Committer:
- silviaChen
- Date:
- 2016-09-23
- Revision:
- 18:4f5b317c04b9
- Parent:
- 17:03c8af30087a
- Child:
- 19:e2de6c1776eb
File content as of revision 18:4f5b317c04b9:
#include <mbed-events/events.h>
#include <mbed.h>
#include "Gap.h"
#include "command-interpreter.h"
#include "nrf_gpio.h"
#include "ble_cli.h"
#define uart_buffer_size 512 //Do not increase uart_buffer_size to prevent out of memory
#define uart_baudrate 115200 //supported baudrate range between 1200 to 230400 (57600) for NQ620 (NNN40)
unsigned char uart_buf[uart_buffer_size];
unsigned int i = 0;
#if defined(TARGET_NRF52_DK)//temp use only
Serial console(p12, p11);
#else
Serial console(USBTX, USBRX);
#endif
void CLI_execute() {
// if (i>=2)
// if (uart_buf[i-2] == 0x0D && uart_buf[i-1] == 0x0A){//detecting CR LF
if (console.readable()) return;//retrun if it is not the end of packet
for (int j=0; j<i; j++)
cyntecProcessCommandInput(uart_buf[j]);
//console.putc(uart_buf[j]);//used for debug only
i=0;
// }
}
void uart_interrupt() {
uart_buf[i++] = console.getc();
CLI_execute();
}
int main(void)
{
console.attach(&uart_interrupt);
console.baud(uart_baudrate);
console.printf("\r\nBLE initialized\r\n");
cynBLEInitCommand();
}
