Skip to content

Commit dbfa666

Browse files
authored
Merge pull request #338 from adafruit/develop
finished image upload feature
2 parents 63e948a + 75f8a05 commit dbfa666

File tree

21 files changed

+404
-353
lines changed

21 files changed

+404
-353
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ install:
2727
- BSP_VERSION=`eval ls $BSP_PATH`
2828
- rm -r $BSP_PATH/*
2929
- ln -s $TRAVIS_BUILD_DIR $BSP_PATH/$BSP_VERSION
30-
- arduino --install-library "Adafruit NeoPixel","Adafruit NeoMatrix","Adafruit GFX Library","Adafruit SSD1306","MIDI Library","Adafruit ILI9341"
30+
- arduino --install-library "Adafruit NeoPixel","Adafruit NeoMatrix","Adafruit GFX Library","Adafruit SSD1306","MIDI Library","Adafruit ILI9341","Adafruit HX8357 Library"
3131

3232
before_script:
3333

cores/nRF5/Adafruit_TinyUSB_Core/Adafruit_TinyUSB_Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
3535
//--------------------------------------------------------------------+
3636

37-
#define USBD_STACK_SZ (150)
37+
#define USBD_STACK_SZ (200)
3838

3939
// tinyusb function that handles power event (detected, ready, removed)
4040
// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled.

cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
166166

167167
// CDC Descriptor Template
168168
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
169-
// NOTE: This returns an list of byte (uint_8) values
170-
// NOTE: Unwritten & unverified assumption: _itfnum is in range [0..254] (else overflows below adding 1)
171169
#define TUD_CDC_DESCRIPTOR(_itfnum, _stridx, _ep_notif, _ep_notif_size, _epout, _epin, _epsize) \
172170
/* Interface Associate */\
173171
8, TUSB_DESC_INTERFACE_ASSOCIATION, _itfnum, 2, TUSB_CLASS_CDC, CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL, CDC_COMM_PROTOCOL_ATCOMMAND, 0,\
@@ -242,8 +240,6 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
242240
// MIDI simple descriptor
243241
// - 1 Embedded Jack In connected to 1 External Jack Out
244242
// - 1 Embedded Jack out connected to 1 External Jack In
245-
// NOTE: This returns an list of byte (uint_8) values
246-
// NOTE: Unwritten & unverified assumption: _itfnum is in range [0..254] (else overflows below adding 1)
247243
#define TUD_MIDI_DESCRIPTOR(_itfnum, _stridx, _epout, _epin, _epsize) \
248244
/* Audio Control (AC) Interface */\
249245
9, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_PROTOCOL_V1, _stridx,\

cores/nRF5/common_func.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@
114114
//--------------------------------------------------------------------+
115115
// DEBUG HELPER
116116
//--------------------------------------------------------------------+
117-
#if CFG_DEBUG == 2
118-
#define malloc_named( name, size ) ({ PRINTF("[malloc] %s : %d\r\n", name, size); malloc(size); })
119-
#else
120-
#define malloc_named( name, size ) malloc ( size )
121-
#endif
122-
123117
const char* dbg_err_str(int32_t err_id); // TODO move to other place
124118

125119
#if CFG_DEBUG

cores/nRF5/linker/nrf52832_s132_v6.ld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GROUP(-lgcc -lc -lnosys)
55

66
MEMORY
77
{
8-
FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x6D000-0x26000
8+
FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x6D000 - 0x26000
99

1010
/* SRAM required by S132 depend on
1111
* - Attribute Table Size
@@ -14,7 +14,6 @@ MEMORY
1414
* - Concurrent connection peripheral + central + secure links
1515
* - Event Len, HVN queue, Write CMD queue
1616
*/
17-
/* RAM (rwx) : ORIGIN = 0x20003200, LENGTH = 0x20010000 - 0x20003200 */
1817
RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20010000 - 0x20003400
1918
}
2019

cores/nRF5/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ static TaskHandle_t _loopHandle;
3737
void initVariant() __attribute__((weak));
3838
void initVariant() { }
3939

40-
#define LOOP_STACK_SZ (512*3)
40+
#define LOOP_STACK_SZ (256*4)
41+
#define CALLBACK_STACK_SZ (256*3)
4142

4243
static void loop_task(void* arg)
4344
{
@@ -56,7 +57,7 @@ static void loop_task(void* arg)
5657
while (1)
5758
{
5859
loop();
59-
yield(); // yield run usb background task
60+
yield(); // yield to run other task
6061

6162
// Serial events
6263
if (serialEvent && serialEventRun) serialEventRun();
@@ -81,7 +82,7 @@ int main( void )
8182
xTaskCreate( loop_task, "loop", LOOP_STACK_SZ, NULL, TASK_PRIO_LOW, &_loopHandle);
8283

8384
// Initialize callback task
84-
ada_callback_init();
85+
ada_callback_init(CALLBACK_STACK_SZ);
8586

8687
// Start FreeRTOS scheduler.
8788
vTaskStartScheduler();

cores/nRF5/new.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include <stdlib.h>
2020
#include "rtos.h"
2121

22+
#include <errno.h>
23+
#include <sys/stat.h>
24+
#include <malloc.h>
25+
2226
void *operator new(size_t size) {
2327
return rtos_malloc(size);
2428
}
@@ -42,3 +46,46 @@ void operator delete(void * ptr, unsigned int) {
4246
void operator delete[](void * ptr, unsigned int) {
4347
rtos_free(ptr);
4448
}
49+
50+
51+
extern "C"
52+
{
53+
54+
// defined in linker script
55+
extern unsigned char __HeapBase[];
56+
extern unsigned char __HeapLimit[];
57+
58+
static unsigned char *sbrk_heap_top = __HeapBase;
59+
60+
__attribute__((used))
61+
caddr_t _sbrk( int incr )
62+
{
63+
unsigned char *prev_heap;
64+
65+
if ( sbrk_heap_top + incr > __HeapLimit )
66+
{
67+
/* Out of dynamic memory heap space */
68+
errno = ENOMEM;
69+
return (caddr_t) -1;
70+
}
71+
72+
prev_heap = sbrk_heap_top;
73+
74+
sbrk_heap_top += incr;
75+
76+
return (caddr_t) prev_heap;
77+
}
78+
79+
void __malloc_lock(struct _reent *ptr)
80+
{
81+
(void) ptr;
82+
vTaskSuspendAll();
83+
}
84+
85+
void __malloc_unlock(struct _reent *ptr)
86+
{
87+
(void) ptr;
88+
xTaskResumeAll();
89+
}
90+
91+
}

cores/nRF5/rtos.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ void yield(void)
9393

9494
void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName )
9595
{
96-
LOG_LV1("RTOS", "%s Stack Overflow !!!", pcTaskName);
96+
LOG_LV1("RTOS", "Task %s: stack Overflow !!!", pcTaskName);
97+
while(CFG_DEBUG) yield();
9798
}
9899

99100
void vApplicationMallocFailedHook(void)
100101
{
101-
LOG_LV1("RTOS", "Failed to Malloc");
102+
LOG_LV1("RTOS", "Task %s: failed to Malloc", pcTaskGetName(xTaskGetCurrentTaskHandle()));
103+
while(CFG_DEBUG) yield();
102104
}
103105

104106
/* configSUPPORT_STATIC_ALLOCATION is set to 1, so the application must provide an

cores/nRF5/rtos.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ enum
6666
#define tick2us(tck) ( ( ((uint64_t)(tck)) * 1000000) / configTICK_RATE_HZ )
6767

6868
#define malloc_type(type) rtos_malloc( sizeof(type) )
69-
70-
#if 0
71-
#define rtos_malloc(_size) ({ printf("[malloc] %s:%d : %d bytes\r\n", __PRETTY_FUNCTION__, __LINE__, _size); pvPortMalloc(_size); })
72-
#define rtos_free(ptr) ({ printf("[free] %s:%d\r\n" ,__PRETTY_FUNCTION__, __LINE__/*malloc_usable_size(ptr)*/); vPortFree(ptr); })
73-
#else
74-
7569
#define rtos_malloc_type(_type) (_type*) rtos_malloc(sizeof(_type))
7670

7771
static inline void* rtos_malloc(size_t _size)
@@ -84,9 +78,8 @@ static inline void rtos_free( void *pv )
8478
return (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) ? free(pv) : vPortFree(pv);
8579
}
8680

87-
#endif
88-
89-
#ifdef __cplusplus // Visible only with cplusplus
81+
// Visible only with C++
82+
#ifdef __cplusplus
9083

9184
#define SCHEDULER_STACK_SIZE_DFLT (512*2)
9285

@@ -106,7 +99,6 @@ class SchedulerRTOS
10699

107100
extern SchedulerRTOS Scheduler;
108101

109-
#endif
110-
102+
#endif // __cplusplus
111103

112104
#endif /* RTOS_H_ */

cores/nRF5/syscall_newlib.c

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)