Skip to content

Commit b3c4a08

Browse files
authored
Merge pull request #284 from adafruit/test-travis
fix #240 let travis build all examples each commit
2 parents a697092 + 375f5a1 commit b3c4a08

File tree

16 files changed

+146
-75
lines changed

16 files changed

+146
-75
lines changed

.travis.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
language: c
2-
sudo: false
3-
cache:
4-
directories:
5-
- ~/arduino_ide
6-
2+
dist: xenial
73
git:
84
depth: false
95
quiet: true
106

11-
before_install:
12-
# - source <(curl -SLs https://raw.githubusercontent.com/hathach/travis-ci-arduino/test-nrf52/install.sh)
13-
script:
14-
- echo "test travis"
15-
# - build_platform adafruit:nrf52:feather52840
7+
addons:
8+
apt:
9+
packages:
10+
- python3
11+
- python3-pip
12+
- python3-setuptools
13+
snaps:
14+
- name: ubuntu-make
15+
confinement: classic
1616

17-
notifications:
18-
email:
19-
on_success: change
20-
on_failure: change
17+
install:
18+
- pip3 install --user adafruit-nrfutil
19+
- umake electronics arduino $HOME/arduino_ide
20+
- export PATH=$HOME/arduino_ide:$PATH
21+
- arduino --pref "boardsmanager.additional.urls=https://adafruit.github.io/arduino-board-index/package_adafruit_index.json" --save-prefs
22+
- arduino --install-boards adafruit:nrf52
23+
- arduino --install-library "Adafruit NeoPixel","Adafruit NeoMatrix","Adafruit GFX Library","Adafruit SSD1306","MIDI Library",
24+
25+
before_script:
26+
27+
script:
28+
- python3 tools/build_all.py

cores/nRF5/WInterrupts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void GPIOTE_IRQHandler()
151151
if (channelMap[ch] != -1 && callbacksInt[ch]) {
152152
if ( callbackDeferred[ch] ) {
153153
// Adafruit defer callback to non-isr if configured so
154-
ada_callback_fromISR(NULL, 0, callbacksInt[ch]);
154+
ada_callback(NULL, 0, callbacksInt[ch]);
155155
}else{
156156
callbacksInt[ch]();
157157
}

cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
144144
do{
145145
uint8_t dummy = 0;
146146
uint32_t err_code = sd_nvic_critical_region_enter(&dummy);
147-
//APP_ERROR_CHECK(err_code);
147+
(void) err_code; //APP_ERROR_CHECK(err_code);
148148
}while (0);
149149
#else
150150
__disable_irq();
@@ -229,7 +229,7 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
229229
}
230230
#ifdef SOFTDEVICE_PRESENT
231231
uint32_t err_code = sd_nvic_critical_region_exit(0);
232-
//APP_ERROR_CHECK(err_code);
232+
(void) err_code; //APP_ERROR_CHECK(err_code);
233233
#else
234234
__enable_irq();
235235
#endif

cores/nRF5/utility/AdaCallback.c

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void adafruit_callback_task(void* arg)
5050
// PRINT_HEX(cb_data);
5151
// PRINT_HEX(cb_data->malloced_data);
5252

53-
void* func = cb_data->callback_func;
53+
const void* func = cb_data->callback_func;
5454
uint32_t* args = cb_data->arguments;
5555

5656
switch (cb_data->arg_count)
@@ -72,15 +72,51 @@ void adafruit_callback_task(void* arg)
7272
}
7373
}
7474

75-
void ada_callback_queue(ada_callback_t* cb_data, bool from_isr)
75+
//! Test if in interrupt mode
76+
static inline bool is_isr(void)
7677
{
77-
if ( from_isr )
78+
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0 ;
79+
}
80+
81+
void ada_callback_queue(ada_callback_t* cb_item)
82+
{
83+
if ( is_isr() )
7884
{
79-
xQueueSendFromISR(_cb_queue, (void*) &cb_data, NULL);
85+
xQueueSendFromISR(_cb_queue, (void*) &cb_item, NULL);
8086
}else
8187
{
82-
xQueueSend(_cb_queue, (void*) &cb_data, CFG_CALLBACK_TIMEOUT);
88+
xQueueSend(_cb_queue, (void*) &cb_item, CFG_CALLBACK_TIMEOUT);
89+
}
90+
}
91+
92+
void ada_callback_invoke(const void* malloc_data, uint32_t malloc_len, const void* func, uint32_t arguments[], uint8_t argcount)
93+
{
94+
ada_callback_t* cb_data = (ada_callback_t*) rtos_malloc( sizeof(ada_callback_t) + (argcount ? (argcount-1)*4 : 0) );
95+
cb_data->malloced_data = NULL;
96+
cb_data->callback_func = func;
97+
cb_data->arg_count = argcount;
98+
99+
if ( malloc_data && malloc_len )
100+
{
101+
cb_data->malloced_data = rtos_malloc(malloc_len);
102+
memcpy(cb_data->malloced_data, malloc_data, malloc_len);
83103
}
104+
105+
if ( argcount )
106+
{
107+
// argument most likely has _mdata if used, change it to malloced one
108+
if ( malloc_data && malloc_len )
109+
{
110+
for(uint8_t i=0; i<argcount; i++)
111+
{
112+
if (arguments[i] == ((uint32_t) malloc_data)) arguments[i] = ((uint32_t) cb_data->malloced_data);
113+
}
114+
}
115+
116+
memcpy(cb_data->arguments, arguments, 4*argcount);
117+
}
118+
119+
ada_callback_queue(cb_data);
84120
}
85121

86122
void ada_callback_init(void)

cores/nRF5/utility/AdaCallback.h

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ extern "C"{
5757

5858
typedef struct
5959
{
60-
void* malloced_data;
61-
void* callback_func;
60+
void* malloced_data;
61+
void const* callback_func;
6262

6363
uint8_t arg_count;
64-
bool from_isr;
65-
// uint8_t _reserved[2];
64+
// uint8_t _reserved[3];
6665

6766
uint32_t arguments[1]; // flexible array holder
6867
}ada_callback_t;
@@ -94,28 +93,11 @@ typedef void (*adacb_5arg_t) (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
9493
/**
9594
* Macro function is called by other module with all intended parameters.
9695
*/
97-
#define _cb_setup(_from_isr, _mdata, _mlen, _func, ... ) \
98-
do { \
99-
uint8_t const _count = VA_ARGS_NUM(__VA_ARGS__); \
100-
ada_callback_t* cb_data = (ada_callback_t*) rtos_malloc( sizeof(ada_callback_t) + (_count ? (_count-1)*4 : 0) );\
101-
cb_data->malloced_data = NULL; \
102-
if ( (_mdata) && (_mlen) ) { \
103-
cb_data->malloced_data = rtos_malloc(_mlen); \
104-
memcpy(cb_data->malloced_data, _mdata, _mlen); \
105-
} \
106-
cb_data->callback_func = (void*)_func; \
107-
cb_data->arg_count = _count; \
108-
if ( _count ) { \
109-
uint32_t arguments[] = { _ADA_CB_ARGS(__VA_ARGS__) }; \
110-
/* argument most likely is _mdata if used, change it to malloced one */\
111-
if ( (_mdata) && (_mlen) ) { \
112-
for(uint8_t i=0; i<_count; i++) {\
113-
if (arguments[i] == ((uint32_t) (_mdata))) { arguments[i] = ((uint32_t) cb_data->malloced_data); } \
114-
}\
115-
}\
116-
memcpy(cb_data->arguments, arguments, 4*_count); \
117-
} \
118-
ada_callback_queue(cb_data, _from_isr); \
96+
#define _cb_setup(_malloc_data, _malloc_len, _func, ... ) \
97+
do { \
98+
uint8_t const _count = VA_ARGS_NUM(__VA_ARGS__); \
99+
uint32_t arguments[] = { _ADA_CB_ARGS(__VA_ARGS__) }; \
100+
ada_callback_invoke(_malloc_data, _malloc_len, (void const*) _func, arguments, _count); \
119101
} while(0)
120102

121103
/**
@@ -127,15 +109,12 @@ typedef void (*adacb_5arg_t) (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
127109
* - 3rd arg : function to be invoked
128110
* - 3rd-7th arg : function argument, will be cast to uint32_t
129111
*/
130-
#define ada_callback(... ) _cb_setup(false, __VA_ARGS__)
112+
#define ada_callback(...) _cb_setup(__VA_ARGS__)
131113

132-
/**
133-
* Similar to ada_callback() but invoke in ISR-context
134-
*/
135-
#define ada_callback_fromISR(... ) _cb_setup(true, __VA_ARGS__)
136114

137115
void ada_callback_init(void);
138-
void ada_callback_queue(ada_callback_t* cb_data, bool from_isr);
116+
void ada_callback_invoke(const void* mdata, uint32_t mlen, const void* func, uint32_t arguments[], uint8_t argcount);
117+
void ada_callback_queue(ada_callback_t* cb_item);
139118

140119
#ifdef __cplusplus
141120
}

cores/nRF5/utility/debug.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffs
182182

183183
const uint8_t item_per_line = 16 / size;
184184

185-
for(int i=0; i<count; i++)
185+
for(uint32_t i=0; i<count; i++)
186186
{
187187
uint32_t value=0;
188188

@@ -246,10 +246,8 @@ void dbgDumpMemoryCFormat(const char* str, void const *buf, uint16_t count)
246246

247247
uint8_t const *buf8 = (uint8_t const *) buf;
248248

249-
for(int i=0; i<count; i++)
249+
for(uint32_t i=0; i<count; i++)
250250
{
251-
uint32_t value=0;
252-
253251
if ( i%16 == 0 )
254252
{
255253
if ( i != 0 ) printf(",\n ");
@@ -258,7 +256,7 @@ void dbgDumpMemoryCFormat(const char* str, void const *buf, uint16_t count)
258256
if ( i != 0 ) printf(", ");
259257
}
260258

261-
printf("0x%02lX", *buf8);
259+
printf("0x%02X", *buf8);
262260
buf8++;
263261
}
264262

cores/nRF5/utility/utilities.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const char* getBootloaderVersion(void)
8080
uint32_t const ver2 = (sd_version % 1000000)/1000;
8181
uint32_t const ver3 = sd_version % 1000;
8282

83-
sprintf(fw_str, "s%d %d.%d.%d", sd_id, ver1, ver2, ver3);
83+
sprintf(fw_str, "s%lu %lu.%lu.%lu", sd_id, ver1, ver2, ver3);
8484
}
8585

8686
return fw_str;
@@ -93,7 +93,7 @@ const char* getMcuUniqueID(void)
9393
// Skip if already created
9494
if ( serial_str[0] == 0 )
9595
{
96-
sprintf(serial_str, "%08lX%08lX", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
96+
sprintf(serial_str, "%08lu%08lu", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
9797
}
9898

9999
return serial_str;

cores/nRF5/wiring_analog_nRF52.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ uint32_t analogRead( uint32_t ulPin )
169169
uint32_t pin = SAADC_CH_PSELP_PSELP_NC;
170170
uint32_t saadcResolution;
171171
uint32_t resolution;
172-
int16_t value;
172+
volatile int16_t value = 0;
173173

174174
if (ulPin >= PINS_COUNT) {
175175
return 0;

libraries/Bluefruit52Lib/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit Bluefruit nRF52 Libraries
2-
version=0.11.0
2+
version=0.11.1
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Arduino library for nRF52-based Adafruit Bluefruit LE modules

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static void bluefruit_blinky_cb( TimerHandle_t xTimer )
106106

107107
static void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info)
108108
{
109+
#if CFG_DEBUG
109110
PRINT_INT(id);
110111
PRINT_HEX(pc);
111112
PRINT_HEX(info);
@@ -123,7 +124,6 @@ static void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info)
123124
LOG_LV1("SD Err", "assert at %s : %d", assert_info->p_file_name, assert_info->line_num);
124125
}
125126

126-
#if CFG_DEBUG
127127
while(1) { }
128128
#endif
129129
}
@@ -865,6 +865,8 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
865865
case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
866866
{
867867
ble_gap_data_length_params_t* param = &evt->evt.gap_evt.params.data_length_update_request.peer_params;
868+
(void) param;
869+
868870
LOG_LV2("GAP", "Data Length Req is (tx, rx) octets = (%d, %d), (tx, rx) time = (%d, %d) us",
869871
param->max_tx_octets, param->max_rx_octets, param->max_tx_time_us, param->max_rx_time_us);
870872

@@ -876,6 +878,8 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
876878
case BLE_GAP_EVT_DATA_LENGTH_UPDATE:
877879
{
878880
ble_gap_data_length_params_t* datalen = &evt->evt.gap_evt.params.data_length_update.effective_params;
881+
(void) datalen;
882+
879883
LOG_LV2("GAP", "Data Length is (tx, rx) octets = (%d, %d), (tx, rx) time = (%d, %d) us",
880884
datalen->max_tx_octets, datalen->max_rx_octets, datalen->max_tx_time_us, datalen->max_rx_time_us);
881885
}
@@ -884,11 +888,11 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
884888
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
885889
{
886890
ble_gap_phys_t* req_phy = &evt->evt.gap_evt.params.phy_update_request.peer_preferred_phys;
887-
888-
#if CFG_DEBUG >= 1
889891
char const *phy_str[] = { "Auto", "1 Mbps", "2 Mbps", "Coded" };
892+
893+
(void) req_phy;
894+
(void) phy_str;
890895
LOG_LV1("GAP", "PHY request tx: %s, rx: %s", phy_str[req_phy->tx_phys], phy_str[req_phy->rx_phys]);
891-
#endif
892896

893897
// Tell SoftDevice to choose PHY automatically
894898
ble_gap_phys_t phy = { BLE_GAP_PHY_AUTO, BLE_GAP_PHY_AUTO };
@@ -900,16 +904,15 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
900904
{
901905
ble_gap_evt_phy_update_t* active_phy = &evt->evt.gap_evt.params.phy_update;
902906

903-
#if CFG_DEBUG >= 1
904907
if ( active_phy->status != BLE_HCI_STATUS_CODE_SUCCESS )
905908
{
906909
LOG_LV1("GAP", "Failed HCI status = 0x%02X", active_phy->status);
907910
}else
908911
{
909912
char const *phy_str[] = { "Auto", "1 Mbps", "2 Mbps", "Coded" };
913+
(void) phy_str;
910914
LOG_LV1("GAP", "PHY active tx: %s, rx: %s", phy_str[active_phy->tx_phy], phy_str[active_phy->rx_phy]);
911915
}
912-
#endif
913916
}
914917
break;
915918

0 commit comments

Comments
 (0)