Skip to content

Commit 5973ba1

Browse files
authored
Merge pull request #399 from adafruit/develop
Cplayground bluefruit service
2 parents 6d2847f + 8d7a2b1 commit 5973ba1

36 files changed

+1534
-107
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ install:
5656
- BSP_VERSION=`eval ls $BSP_PATH`
5757
- rm -r $BSP_PATH/*
5858
- ln -s $TRAVIS_BUILD_DIR $BSP_PATH/$BSP_VERSION
59-
- arduino --install-library "Adafruit NeoPixel","Adafruit NeoMatrix","Adafruit GFX Library","Adafruit SSD1306","MIDI Library","Adafruit ILI9341","Adafruit HX8357 Library"
59+
- arduino --install-library "Adafruit NeoPixel","Adafruit NeoMatrix","Adafruit GFX Library","Adafruit SSD1306","MIDI Library","Adafruit ILI9341","Adafruit HX8357 Library","Adafruit Circuit Playground"
6060

6161
before_script:
6262

boards.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ feather52832.upload.use_1200bps_touch=false
3232
feather52832.upload.wait_for_upload_port=false
3333
feather52832.upload.native_usb=false
3434
feather52832.upload.maximum_size=290816
35-
feather52832.upload.maximum_data_size=51072
35+
feather52832.upload.maximum_data_size=52224
3636

3737
# Build
3838
feather52832.build.mcu=cortex-m4
@@ -81,7 +81,7 @@ feather52840.upload.protocol=nrfutil
8181
feather52840.upload.use_1200bps_touch=true
8282
feather52840.upload.wait_for_upload_port=true
8383
feather52840.upload.maximum_size=815104
84-
feather52840.upload.maximum_data_size=248832
84+
feather52840.upload.maximum_data_size=237568
8585

8686
# Build
8787
feather52840.build.mcu=cortex-m4
@@ -135,7 +135,7 @@ itsybitsy52840.upload.protocol=nrfutil
135135
itsybitsy52840.upload.use_1200bps_touch=true
136136
itsybitsy52840.upload.wait_for_upload_port=true
137137
itsybitsy52840.upload.maximum_size=815104
138-
itsybitsy52840.upload.maximum_data_size=248832
138+
itsybitsy52840.upload.maximum_data_size=237568
139139

140140
# Build
141141
itsybitsy52840.build.mcu=cortex-m4
@@ -188,7 +188,7 @@ cplaynrf52840.upload.protocol=nrfutil
188188
cplaynrf52840.upload.use_1200bps_touch=true
189189
cplaynrf52840.upload.wait_for_upload_port=true
190190
cplaynrf52840.upload.maximum_size=815104
191-
cplaynrf52840.upload.maximum_data_size=248832
191+
cplaynrf52840.upload.maximum_data_size=237568
192192

193193
# Build
194194
cplaynrf52840.build.mcu=cortex-m4
@@ -295,7 +295,7 @@ metro52840.upload.protocol=nrfutil
295295
metro52840.upload.use_1200bps_touch=true
296296
metro52840.upload.wait_for_upload_port=true
297297
metro52840.upload.maximum_size=815104
298-
metro52840.upload.maximum_data_size=248832
298+
metro52840.upload.maximum_data_size=237568
299299

300300
# Build
301301
metro52840.build.mcu=cortex-m4
@@ -338,7 +338,7 @@ pca10056.upload.protocol=nrfutil
338338
pca10056.upload.use_1200bps_touch=true
339339
pca10056.upload.wait_for_upload_port=true
340340
pca10056.upload.maximum_size=815104
341-
pca10056.upload.maximum_data_size=248832
341+
pca10056.upload.maximum_data_size=237568
342342

343343
# Build
344344
pca10056.build.mcu=cortex-m4

cores/nRF5/freertos/config/FreeRTOSConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
#define configUSE_TIMERS 1
9292
#define configTIMER_TASK_PRIORITY ( 2 ) // Normal
9393
#define configTIMER_QUEUE_LENGTH 32
94-
#define configTIMER_TASK_STACK_DEPTH ( 100 )
94+
#define configTIMER_TASK_STACK_DEPTH ( 256 )
9595

9696
/* Tickless Idle configuration. */
9797
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2

cores/nRF5/linker/nrf52840_s140_v6.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ MEMORY
88
FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
99

1010
/* SRAM required by S132 depend on
11-
* - Attribute Table Size
11+
* - Attribute Table Size (Number of Services and Characteristics)
1212
* - Vendor UUID count
1313
* - Max ATT MTU
1414
* - Concurrent connection peripheral + central + secure links
1515
* - Event Len, HVN queue, Write CMD queue
1616
*/
17-
RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
17+
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x20040000 - 0x20006000
1818
}
1919

2020
SECTIONS

cores/nRF5/utility/AdaCallback.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,9 @@ void adafruit_callback_task(void* arg)
7373
}
7474
}
7575

76-
//! Test if in interrupt mode
77-
static inline bool is_isr(void)
78-
{
79-
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0 ;
80-
}
81-
8276
void ada_callback_queue(ada_callback_t* cb_item)
8377
{
84-
BaseType_t ret = is_isr() ? xQueueSendFromISR(_cb_queue, (void*) &cb_item, NULL) : xQueueSend(_cb_queue, (void*) &cb_item, CFG_CALLBACK_TIMEOUT);
78+
BaseType_t ret = isInISR() ? xQueueSendFromISR(_cb_queue, (void*) &cb_item, NULL) : xQueueSend(_cb_queue, (void*) &cb_item, CFG_CALLBACK_TIMEOUT);
8579

8680
if ( ret != pdTRUE )
8781
{
@@ -91,7 +85,7 @@ void ada_callback_queue(ada_callback_t* cb_item)
9185
_cb_qdepth = 2*_cb_qdepth;
9286

9387
// try again
94-
if ( is_isr() )
88+
if ( isInISR() )
9589
{
9690
xQueueSendFromISR(_cb_queue, (void*) &cb_item, NULL);
9791
}else

cores/nRF5/utility/SoftwareTimer.cpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019 Ha Thach (tinyusb.org) for Adafruit Industries
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#include "SoftwareTimer.h"
26+
27+
SoftwareTimer::SoftwareTimer()
28+
{
29+
_handle = NULL;
30+
}
31+
32+
SoftwareTimer::~SoftwareTimer ()
33+
{
34+
if ( _handle != NULL ) xTimerDelete(_handle, 0);
35+
}
36+
37+
void SoftwareTimer::begin(uint32_t ms, TimerCallbackFunction_t callback, void* timerID, bool repeating)
38+
{
39+
_handle = xTimerCreate(NULL, ms2tick(ms), repeating, timerID, callback);
40+
}
41+
42+
bool SoftwareTimer::start(void)
43+
{
44+
bool ret = true;
45+
if ( isInISR() )
46+
{
47+
BaseType_t ret, xHigherPriorityTaskWoken = pdFALSE;
48+
ret = (pdPASS == xTimerStartFromISR(_handle, &xHigherPriorityTaskWoken));
49+
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
50+
}else
51+
{
52+
xTimerStart(_handle, 0);
53+
}
54+
return ret;
55+
}
56+
57+
bool SoftwareTimer::stop (void)
58+
{
59+
bool ret = true;
60+
if ( isInISR() )
61+
{
62+
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
63+
ret = (pdPASS == xTimerStopFromISR(_handle, &xHigherPriorityTaskWoken));
64+
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
65+
}
66+
else
67+
{
68+
xTimerStop (_handle, 0);
69+
}
70+
71+
return ret;
72+
}
73+
74+
bool SoftwareTimer::reset (void)
75+
{
76+
bool ret = true;
77+
if ( isInISR() )
78+
{
79+
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
80+
ret = (pdPASS == xTimerResetFromISR(_handle, &xHigherPriorityTaskWoken));
81+
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
82+
}
83+
else
84+
{
85+
xTimerReset(_handle, 0);
86+
}
87+
88+
return ret;
89+
}
90+
91+
bool SoftwareTimer::setPeriod(uint32_t ms)
92+
{
93+
BaseType_t active = xTimerIsTimerActive(_handle);
94+
bool ret = true;
95+
96+
if ( isInISR() )
97+
{
98+
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
99+
ret = (pdPASS == xTimerChangePeriodFromISR(_handle, ms2tick(ms), &xHigherPriorityTaskWoken));
100+
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
101+
}
102+
else
103+
{
104+
xTimerChangePeriod(_handle, ms2tick(ms), 0);
105+
}
106+
107+
// Change period of inactive timer will also start it !!
108+
if ( !active ) stop();
109+
110+
return ret;
111+
}

cores/nRF5/utility/SoftwareTimer.h

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -44,52 +44,16 @@ class SoftwareTimer
4444
TimerHandle_t _handle;
4545

4646
public:
47-
SoftwareTimer() { _handle = NULL; }
48-
virtual ~SoftwareTimer() { if(_handle != NULL) xTimerDelete(_handle, 0); }
47+
SoftwareTimer();
48+
virtual ~SoftwareTimer();
4949

50-
void begin(uint32_t ms, TimerCallbackFunction_t callback, bool repeating = true)
51-
{
52-
_handle = xTimerCreate(NULL, ms2tick(ms), repeating, NULL, callback);
53-
}
50+
void begin(uint32_t ms, TimerCallbackFunction_t callback, void* timerID = NULL, bool repeating = true);
51+
TimerHandle_t getHandle(void) { return _handle; }
5452

55-
TimerHandle_t getHandle(void)
56-
{
57-
return _handle;
58-
}
59-
60-
void start(void) { xTimerStart(_handle, 0); }
61-
void stop (void) { xTimerStop (_handle, 0); }
62-
void reset(void) { xTimerReset(_handle, 0); }
63-
64-
bool startFromISR(void) {
65-
BaseType_t ret, xHigherPriorityTaskWoken = pdFALSE;
66-
ret = xTimerStartFromISR(_handle, &xHigherPriorityTaskWoken);
67-
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
68-
return (ret == pdPASS);
69-
}
70-
71-
bool stopFromISR(void) {
72-
BaseType_t ret, xHigherPriorityTaskWoken = pdFALSE;
73-
ret = xTimerStopFromISR(_handle, &xHigherPriorityTaskWoken);
74-
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
75-
return (ret == pdPASS);
76-
}
77-
78-
bool resetFromISR(void) {
79-
BaseType_t ret, xHigherPriorityTaskWoken = pdFALSE;
80-
ret = xTimerResetFromISR(_handle, &xHigherPriorityTaskWoken);
81-
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
82-
return (ret == pdPASS);
83-
}
84-
85-
void setPeriod(uint32_t ms)
86-
{
87-
BaseType_t active = xTimerIsTimerActive(_handle);
88-
xTimerChangePeriod(_handle, ms2tick(ms), 0);
89-
90-
// Change period of inactive timer will also start it !!
91-
if ( !active ) xTimerStop(_handle, 0);
92-
}
53+
bool start(void);
54+
bool stop (void);
55+
bool reset (void);
56+
bool setPeriod(uint32_t ms);
9357
};
9458

9559
#endif /* SOFTWARETIMER_H_ */

cores/nRF5/wiring.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ void enterUf2Dfu(void);
3636
void waitForEvent(void);
3737
void systemOff(uint32_t pin, uint8_t wake_logic);
3838

39+
// Test if in interrupt mode
40+
static inline bool isInISR(void)
41+
{
42+
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0 ;
43+
}
44+
3945
#ifdef __cplusplus
4046
}
4147
#endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=Adafruit BLE Services
2+
version=1.0
3+
author=Adafruit
4+
maintainer=Adafruit <[email protected]>
5+
sentence=Arduino library for nRF52-based Adafruit Bluefruit LE modules
6+
paragraph=Arduino library for nRF52-based Adafruit Bluefruit LE modules
7+
category=Communication
8+
url=https://github.com/adafruit/Adafruit_nRF52_Arduino
9+
architectures=*
10+
includes=BLEAdafruitService.h
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019 Ha Thach (tinyusb.org) for Adafruit Industries
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#ifndef BLEADAFRUITSERVICE_H_
26+
#define BLEADAFRUITSERVICE_H_
27+
28+
#include "bluefruit_common.h"
29+
#include "BLECharacteristic.h"
30+
#include "BLEService.h"
31+
32+
#include "services/BLEAdafruitSensor.h"
33+
#include "services/BLEAdafruitTemperature.h"
34+
#include "services/BLEAdafruitAccel.h"
35+
#include "services/BLEAdafruitLightSensor.h"
36+
#include "services/BLEAdafruitButton.h"
37+
#include "services/BLEAdafruitTone.h"
38+
#include "services/BLEAdafruitAddressablePixel.h"
39+
40+
#endif /* BLEADAFRUITSERVICE_H_ */

0 commit comments

Comments
 (0)