update bootloader binaries and multiple clean up

This commit is contained in:
hathach committed 2018-10-30 19:43:38 +07:00
1 parent 5580249807
commit 608cde9b85
16 files changed
+4380 -7404

No files matched your search

+4 -2
View File
@@ -142,8 +142,10 @@ but enter the `MSDEnable` command.
This core is based on [Arduino-nRF5](https://github.com/sandeepmistry/arduino-nRF5) by Sandeep Mistry,
which in turn is based on the [Arduino SAMD Core](https://github.com/arduino/ArduinoCore-samd).
The following repos are used:
The following libraries are used:
- adafruit-nrfutil is based on Nordic Semiconductor ASA's [pc-nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil)
- [tinyusb](https://github.com/hathach/tinyusb) as usb stack
- [nrfx](https://github.com/NordicSemiconductor/nrfx) for driver
- [nrfx](https://github.com/NordicSemiconductor/nrfx) for peripherals driver
- [littlefs](https://github.com/ARMmbed/littlefs) for internal file system
- [fatfs by elm-chan](http://elm-chan.org/fsw/ff/00index_e.html) for external file system
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-26
View File
@@ -278,32 +278,6 @@ static inline bool is_within(uint32_t lower, uint32_t value, uint32_t upper)
return (lower <= value) && (value <= upper);
}
static inline uint8_t log2_of(uint32_t value)
{
uint8_t result = 0; // log2 of a value is its MSB's position
while (value >>= 1) result++;
return result;
}
// return the number of set bits in value
static inline uint8_t cardinality_of(uint32_t value)
{
// Brian Kernighan's method goes through as many iterations as there are set bits. So if we have a 32-bit word with only
// the high bit set, then it will only go once through the loop
// Published in 1988, the C Programming Language 2nd Ed. (by Brian W. Kernighan and Dennis M. Ritchie)
// mentions this in exercise 2-9. On April 19, 2006 Don Knuth pointed out to me that this method
// "was first published by Peter Wegner in CACM 3 (1960), 322. (Also discovered independently by Derrick Lehmer and
// published in 1964 in a book edited by Beckenbach.)"
uint8_t count;
for (count = 0; value; count++)
{
value &= value - 1; // clear the least significant bit set
}
return count;
}
#ifdef __cplusplus
}
#endif
File diff suppressed because it is too large. Load diff
@@ -29,7 +29,6 @@
#include <Arduino.h>
// Maximum 12 pins can be used for 3 PWM module ( 4 channel each )
#if defined ARDUINO_NRF52_FEATHER
int pins[12] =
{
A0 , A1 , A2 , A3,
@@ -37,17 +36,6 @@ int pins[12] =
27 , LED_BLUE, PIN_WIRE_SDA, PIN_WIRE_SCL
};
#elif defined ARDUINO_NRF52_METRO
int pins[12] =
{
D0, D1 , D2, D3,
D4, D5 , D6, LED_RED,
D7, LED_BLUE, D8, D9
};
#endif
/**************************************************************************/
/*!
@brief The setup function runs once when reset the board
@@ -55,9 +43,6 @@ int pins[12] =
/**************************************************************************/
void setup()
{
Serial.begin(115200);
while ( !Serial ) delay(10); // for nrf52840 with native usb
// Add 4 pins into a group
// It is better to add Pin before call .begin()
for (int i=0; i<12; i++)
@@ -91,4 +91,3 @@ void loop()
{
// loop is already suspended, CPU will not run loop() at all
}
@@ -14,12 +14,9 @@
#include <bluefruit.h>
// BLE Service
BLEDis bledis;
BLEUart bleuart;
BLEBas blebas;
// Software Timer for blinking RED LED
SoftwareTimer blinkTimer;
BLEDis bledis; // device information
BLEUart bleuart; // uart over ble
BLEBas blebas; // battery
void setup()
{
@@ -29,10 +26,6 @@ void setup()
Serial.println("Bluefruit52 BLEUART Example");
Serial.println("---------------------------\n");
// Initialize blinkTimer for 1000 ms and start it
blinkTimer.begin(1000, blink_timer_callback);
blinkTimer.start();
// Setup the BLE LED to be enabled on CONNECT
// Note: This is actually the default behaviour, but provided
// here in case you want to control this LED manually via PIN 19
@@ -123,6 +116,7 @@ void loop()
waitForEvent();
}
// callback invoked when central connects
void connect_callback(uint16_t conn_handle)
{
char central_name[32] = { 0 };
@@ -145,38 +139,3 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason)
Serial.println();
Serial.println("Disconnected");
}
/**
* Software Timer callback is invoked via a built-in FreeRTOS thread with
* minimal stack size. Therefore it should be as simple as possible. If
* a periodically heavy task is needed, please use Scheduler.startLoop() to
* create a dedicated task for it.
*
* More information http://www.freertos.org/RTOS-software-timer.html
*/
void blink_timer_callback(TimerHandle_t xTimerID)
{
(void) xTimerID;
digitalToggle(LED_RED);
}
/**
* RTOS Idle callback is automatically invoked by FreeRTOS
* when there are no active threads. E.g when loop() calls delay() and
* there is no bluetooth or hw event. This is the ideal place to handle
* background data.
*
* NOTE: FreeRTOS is configured as tickless idle mode. After this callback
* is executed, if there is time, freeRTOS kernel will go into low power mode.
* Therefore waitForEvent() should not be called in this callback.
* http://www.freertos.org/low-power-tickless-rtos.html
*
* WARNING: This function MUST NOT call any blocking FreeRTOS API
* such as delay(), xSemaphoreTake() etc ... for more information
* http://www.freertos.org/a00016.html
*/
void rtos_idle_callback(void)
{
// Don't call any other FreeRTOS blocking API()
// Perform background task(s) here
}
+10 -10
View File
@@ -181,7 +181,7 @@ bool BLEGap::requestPairing(uint16_t conn_hdl)
xSemaphoreTake(peer->pair_sem, portMAX_DELAY);
// Failed to pair using centra stored keys, this happens when
// Failed to pair using central stored keys, this happens when
// Prph delete bonds while we did not --> let's remove the obsolete keyfile and move on
if ( !peer->paired && (cntr_ediv != 0xffff) )
{
@@ -333,7 +333,7 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
case BLE_GAP_EVT_AUTH_STATUS:
{
// Bonding process completed
// Pairing process completed
ble_gap_evt_auth_status_t* status = &evt->evt.gap_evt.params.auth_status;
// Pairing succeeded --> save encryption keys ( Bonding )
@@ -355,8 +355,9 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
case BLE_GAP_EVT_SEC_INFO_REQUEST:
{
// Reconnection. If bonded previously, Central will ask for stored keys.
// return security information. Otherwise NULL
// Central ask for the stored keys.
// - load key and return if bonded previously.
// - Else return NULL --> Initiate key exchange
ble_gap_evt_sec_info_request_t* sec_req = (ble_gap_evt_sec_info_request_t*) &evt->evt.gap_evt.params.sec_info_request;
bond_data_t bdata;
@@ -379,10 +380,10 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
const ble_gap_conn_sec_t* conn_sec = &evt->evt.gap_evt.params.conn_sec_update.conn_sec;
// Connection is secured (paired)
// Occurs if bonded + reconnection, or we initiate the pairing process
if ( !( conn_sec->sec_mode.sm == 1 && conn_sec->sec_mode.lv == 1) )
{
// Previously bonded --> secure by re-connection process
// --> Load & Set Sys Attr (Apply Service Context)
// Previously bonded --> secure by re-connection process --> Load & Set Sys Attr (Apply Service Context)
// Else Init Sys Attr
bond_load_cccd(peer->role, conn_hdl, peer->ediv);
@@ -395,10 +396,9 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
case BLE_GAP_EVT_PASSKEY_DISPLAY:
{
// ble_gap_evt_passkey_display_t const* passkey_display = &evt->evt.gap_evt.params.passkey_display;
//
// PRINT_INT(passkey_display->match_request);
// PRINT_BUFFER(passkey_display->passkey, 6);
// ble_gap_evt_passkey_display_t const* passkey_display = &evt->evt.gap_evt.params.passkey_display;
// PRINT_INT(passkey_display->match_request);
// PRINT_BUFFER(passkey_display->passkey, 6);
// sd_ble_gap_auth_key_reply
}
+1 -1
View File
@@ -722,7 +722,7 @@ void AdafruitBluefruit::printInfo(void)
// Address
Serial.printf(title_fmt, "Address");
{
char const * type_str[] = { "Public", "Static", "Private Resolvable", "Private Non Resolvable" };
char const * type_str[] = { "Public", "Static", "Private Resolvable", "Private Non Resolvable" };
uint8_t mac[6];
uint8_t type = Gap.getAddr(mac);
@@ -38,7 +38,6 @@
#include <Arduino.h>
#include "ble.h"
#include "ble_hci.h"
#include "nrf_sdm.h"
#include "utility/AdaMsg.h"
+10 -1
View File
@@ -66,6 +66,9 @@ static const char* dbg_strerr_lfs (int32_t err)
{
switch ( err )
{
case LFS_ERR_OK:
return "LFS_ERR_OK";
case LFS_ERR_IO:
return "LFS_ERR_IO";
@@ -100,7 +103,11 @@ static const char* dbg_strerr_lfs (int32_t err)
return "LFS_ERR_NOMEM";
default:
return "Unlikely Error";
{
static char errcode[10];
sprintf(errcode, "%d", err);
return errcode;
}
}
}
@@ -236,6 +243,8 @@ BluefuritLib::File LittleFS::_open_file (char const *filepath, uint8_t mode)
if ( flags )
{
lfs_file_t* fhdl = (lfs_file_t*) rtos_malloc(sizeof(lfs_file_t));
VERIFY(fhdl, file);
int rc = lfs_file_open(&_lfs, fhdl, filepath, flags);
if ( rc )