Skip to content

Commit a724c71

Browse files
committed
Merge branch 'master' into develop
2 parents 836b0d8 + 6c9e42a commit a724c71

File tree

10 files changed

+90
-13
lines changed

10 files changed

+90
-13
lines changed

cores/nRF5/utility/utilities.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const char* getMcuUniqueID(void)
9393
// Skip if already created
9494
if ( serial_str[0] == 0 )
9595
{
96-
sprintf(serial_str, "%08lu%08lu", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
96+
sprintf(serial_str, "%08lX%08lX", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
9797
}
9898

9999
return serial_str;

cores/nRF5/wiring_constants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ extern "C"{
3030
#define OUTPUT (0x1)
3131
#define INPUT_PULLUP (0x2)
3232
#define INPUT_PULLDOWN (0x3)
33+
#define INPUT_PULLUP_SENSE (0x4)
34+
#define INPUT_PULLDOWN_SENSE (0x5)
3335

3436
#define PI 3.1415926535897932384626433832795
3537
#define HALF_PI 1.5707963267948966192313216916398

cores/nRF5/wiring_digital.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ void pinMode( uint32_t ulPin, uint32_t ulMode )
5555
| ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
5656
| ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
5757
break;
58+
59+
case INPUT_PULLUP_SENSE:
60+
// Set pin to input mode with pull-up resistor enabled and sense when Low
61+
port->PIN_CNF[ulPin] = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
62+
| ((uint32_t)GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
63+
| ((uint32_t)GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
64+
| ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
65+
| ((uint32_t)GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos);
66+
break;
5867

5968
case INPUT_PULLDOWN:
6069
// Set pin to input mode with pull-down resistor enabled
@@ -65,6 +74,15 @@ void pinMode( uint32_t ulPin, uint32_t ulMode )
6574
| ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
6675
break;
6776

77+
case INPUT_PULLDOWN_SENSE:
78+
// Set pin to input mode with pull-down resistor enabled
79+
port->PIN_CNF[ulPin] = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
80+
| ((uint32_t)GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
81+
| ((uint32_t)GPIO_PIN_CNF_PULL_Pulldown << GPIO_PIN_CNF_PULL_Pos)
82+
| ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
83+
| ((uint32_t)GPIO_PIN_CNF_SENSE_High << GPIO_PIN_CNF_SENSE_Pos);
84+
break;
85+
6886
case OUTPUT:
6987
// Set pin to output mode
7088
port->PIN_CNF[ulPin] = ((uint32_t)GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos)

libraries/Bluefruit52Lib/examples/Central/central_hid/central_hid.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void setup()
4141

4242
Bluefruit.setName("Bluefruit52 Central");
4343

44-
// Init BLE Central Uart Serivce
44+
// Init BLE Central Hid Serivce
4545
hid.begin();
4646

4747
#if POLLING == 0
@@ -126,7 +126,7 @@ void connect_callback(uint16_t conn_handle)
126126
{
127127
Serial.println("Found NONE");
128128

129-
// disconnect since we couldn't find bleuart service
129+
// disconnect since we couldn't find blehid service
130130
Bluefruit.disconnect(conn_handle);
131131
}
132132
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Blink_sleep
3+
Turns on an LED on for one second, then off for one second, until the time to go to sleep runs out.
4+
You can wake up the feather by pressing a key/switch connecting the WAKE_LOW_PIN to GND and the WAKE_HIGH_PIN to 3.3V (VCC)
5+
6+
Based on the blinky arduino example
7+
8+
This example code is in the public domain.
9+
10+
created 19 Jan 2010
11+
by Pierre Constantineau
12+
13+
*/
14+
#include <bluefruit.h>
15+
16+
#define WAKE_LOW_PIN PIN_A0
17+
#define WAKE_HIGH_PIN PIN_A1
18+
19+
#define SLEEPING_DELAY 30000 // sleep after 30 seconds of blinking
20+
21+
void gotoSleep(unsigned long time)
22+
{
23+
// shutdown when time reaches SLEEPING_DELAY ms
24+
if ((time>SLEEPING_DELAY))
25+
{
26+
// to reduce power consumption when sleeping, turn off all your LEDs (and other power hungry devices)
27+
digitalWrite(LED_BUILTIN, LOW);
28+
29+
// setup your wake-up pins.
30+
pinMode(WAKE_LOW_PIN, INPUT_PULLUP_SENSE); // this pin (WAKE_LOW_PIN) is pulled up and wakes up the feather when externally connected to ground.
31+
pinMode(WAKE_HIGH_PIN, INPUT_PULLDOWN_SENSE); // this pin (WAKE_HIGH_PIN) is pulled down and wakes up the feather when externally connected to 3.3v.
32+
33+
// power down nrf52.
34+
sd_power_system_off(); // this function puts the whole nRF52 to deep sleep (no Bluetooth). If no sense pins are setup (or other hardware interrupts), the nrf52 will not wake up.
35+
}
36+
}
37+
38+
// the setup function runs once when you press reset or power the board
39+
void setup() {
40+
Bluefruit.begin(); // Sleep functions need the softdevice to be active.
41+
42+
// initialize digital pin LED_BUILTIN as an output.
43+
pinMode(LED_BUILTIN, OUTPUT);
44+
}
45+
46+
// the loop function runs over and over again forever
47+
void loop() {
48+
digitalToggle(LED_BUILTIN); // turn the LED on (HIGH is the voltage level)
49+
gotoSleep(millis()); // call millis() and pass it to the sleep function. On wake-up, millis will start at 0 again.
50+
delay(1000); // wait for a second
51+
}

libraries/Bluefruit52Lib/src/BLEClientCharacteristic.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ bool BLEClientCharacteristic::_discoverDescriptor(uint16_t conn_handle, ble_gatt
155155
{
156156
LOG_LV2("DISC", "Found CCDD: handle = %d", disc_rsp.descs[i].handle);
157157
_cccd_handle = disc_rsp.descs[i].handle;
158+
159+
break;
158160
}
159161
}
160162

libraries/Bluefruit52Lib/src/BLEDiscovery.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLEClientChar
134134
{
135135
for (uint8_t i=0; i<count; i++)
136136
{
137+
if ( chr[i]->discovered() )
138+
continue;
139+
137140
if ( chr[i]->uuid == disc_chr->chars[d].uuid )
138141
{
139142
LOG_LV2("DISC", "[CHR] Found 0x%04X, handle = %d\n-----------------", disc_chr->chars[d].uuid.uuid, disc_chr->chars[d].handle_value);

libraries/Bluefruit52Lib/src/BLEGatt.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,20 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
184184
if ( evt_id == BLE_GAP_EVT_DISCONNECTED )
185185
{
186186
// Client
187-
for(uint8_t i=0; i<_client.svc_count; i++)
187+
for(uint8_t i=0; i<_client.chr_count; i++)
188188
{
189-
if ( evt_conn_hdl == _client.svc_list[i]->_conn_hdl)
189+
if ( evt_conn_hdl == _client.chr_list[i]->connHandle() )
190190
{
191-
_client.svc_list[i]->disconnect();
191+
_client.chr_list[i]->disconnect();
192192
}
193193
}
194194

195195
// TODO merge to above loop
196-
for(uint8_t i=0; i<_client.chr_count; i++)
196+
for(uint8_t i=0; i<_client.svc_count; i++)
197197
{
198-
if ( evt_conn_hdl == _client.chr_list[i]->connHandle() )
198+
if ( evt_conn_hdl == _client.svc_list[i]->_conn_hdl)
199199
{
200-
_client.chr_list[i]->disconnect();
200+
_client.svc_list[i]->disconnect();
201201
}
202202
}
203203
}

variants/clue_nrf52840/variant.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ const uint32_t g_ADigitalPinMap[] =
6767
37, // P1.05 (TFT LITE)
6868

6969
// 35 & 36 - PDM mic
70-
40, // D35 is P1.08 (PDM DAT)
71-
11, // D36 is P0.11 (PDM CLK)
70+
0, // D35 is P0.00 (PDM DAT)
71+
1, // D36 is P0.01 (PDM CLK)
7272

7373
// QSPI pins (not exposed via any header / test point)
7474
19, // D37 is P0.19 (QSPI CLK)
@@ -81,6 +81,7 @@ const uint32_t g_ADigitalPinMap[] =
8181
10, // D43 is P0.10 white LED control
8282
9, // D44 is P0.09 APDS IRQ
8383
38, // D45 is P1.06 LSM6DS33 IRQ
84+
32, // D46 is P1.00 Speaker/buzzer
8485
};
8586

8687
void initVariant()

variants/clue_nrf52840/variant.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ extern "C"
3535
#endif // __cplusplus
3636

3737
// Number of pins defined in PinDescription array
38-
#define PINS_COUNT (46)
39-
#define NUM_DIGITAL_PINS (46)
38+
#define PINS_COUNT (47)
39+
#define NUM_DIGITAL_PINS (47)
4040
#define NUM_ANALOG_INPUTS (8)
4141
#define NUM_ANALOG_OUTPUTS (0)
4242

0 commit comments

Comments
 (0)