Skip to content

Commit 4e2232e

Browse files
committed
Expose dccm area
-expose dccm area giving the user an extra 8k of memory -simple implementation of a malloc like function for dccm memory area
1 parent 1c8de0d commit 4e2232e

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

cores/arduino/Arduino.h

+1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@ extern uint32_t pwmPeriod[4];
117117
#include "wiring_analog.h"
118118
#include "wiring_shift.h"
119119
#include "WInterrupts.h"
120+
#include "dccm/dccm_alloc.h"
120121

121122
#endif // Arduino_h

cores/arduino/dccm/dccm_alloc.c

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Copyright (c) 2016 Intel Corporation. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
18+
*/
19+
20+
#include "dccm_alloc.h"
21+
22+
uint16_t dccm_index = 0;
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
void* dccm_malloc(uint16_t size)
29+
{
30+
if((size + dccm_index) > DCCM_SIZE)
31+
{
32+
return 0;
33+
}
34+
35+
void* addr = (void*)(DCCM_START + dccm_index);
36+
dccm_index += size;
37+
return addr;
38+
}
39+
40+
#ifdef __cplusplus
41+
}
42+
#endif

cores/arduino/dccm/dccm_alloc.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright (c) 2016 Intel Corporation. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
18+
*/
19+
20+
#include <stdint.h>
21+
22+
#define DCCM_START 0x80000000
23+
#define DCCM_SIZE 8192
24+
25+
#ifndef _DCCM_ALLOC_
26+
#define _DCCM_ALLOC_
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
void* dccm_malloc(uint16_t size);
33+
34+
#ifdef __cplusplus
35+
}
36+
#endif
37+
38+
39+
#endif

0 commit comments

Comments
 (0)