Sample NordicSemicondictor nRF52 beacon discovery for CO657 (University of Kent, UK); builds on mbed-os, derived from LEDBeacon sample code (on github). Writes out beacons recently seen to serial port and/or LCD (#ifdef job) on the MBED application shield.
Revision 2:a19832685c89, committed 2016-10-28
- Comitter:
- co657_frmb
- Date:
- Fri Oct 28 09:58:31 2016 +0000
- Parent:
- 1:7986f9873e20
- Commit message:
- disable flow-control on serial port (manual)
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Oct 28 08:18:04 2016 +0000 +++ b/main.cpp Fri Oct 28 09:58:31 2016 +0000 @@ -13,7 +13,7 @@ #include "C12832.h" /* output choice */ -#undef SERIAL_OUTPUT +#define SERIAL_OUTPUT #define LCD_OUTPUT /* FRMB note: with the MBED application shield connected, the various LEDs/buttons on the nRF52 become pretty helpless */ @@ -163,7 +163,7 @@ host.printf ("%2.2x", params->peerAddr[i]); } host.printf (":%d:%u:%d:", params->rssi, (unsigned int)params->type, params->advertisingDataLen); - for (i=0; (i<params->advertisingDataLen) && (hlen < (HLEN_MAX-4)); i++) { + for (i=0; i<params->advertisingDataLen; i++) { uint8_t ch = (uint8_t)params->advertisingData[i]; host.printf ("%2.2x", ch); @@ -258,6 +258,19 @@ #ifdef SERIAL_OUTPUT host.baud (38400); + + /* HACK: turn off flow control (okay, this seems to work!) */ + { + volatile uint32_t *ubase_psel_cts = (uint32_t *)0x40002510; + volatile uint32_t *ubase_psel_rts = (uint32_t *)0x40002508; + + //host.printf ("MSG: UART: PSEL.RTS reg is 0x%8.8x\r\n", *ubase_psel_rts); + //host.printf ("MSG: UART: PSEL.CTS reg is 0x%8.8x\r\n", *ubase_psel_cts); + + // Crude: disconnect CTS/RTS + *ubase_psel_cts = (*ubase_psel_cts | 0x80000000); + *ubase_psel_rts = (*ubase_psel_rts | 0x80000000); + } #endif for (int i=0; i<MAX_BEACONS; i++) {