Skip to content

Commit e1af465

Browse files
committed
[NANO130] Fix issues in Greentea test
1 parent 4753787 commit e1af465

File tree

11 files changed

+54
-35
lines changed

11 files changed

+54
-35
lines changed

TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#define STACK_SIZE 768
4242
#elif defined(TARGET_XDOT_L151CC)
4343
#define STACK_SIZE 1024
44+
#elif defined(TARGET_NANO130KE3BN) && defined(TOOLCHAIN_IAR)
45+
#define STACK_SIZE DEFAULT_STACK_SIZE/2
4446
#else
4547
#define STACK_SIZE DEFAULT_STACK_SIZE
4648
#endif

rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ extern void pre_main (void);
361361
static uint32_t thread_stack_main[DEFAULT_STACK_SIZE / sizeof(uint32_t)];
362362
#elif defined(TARGET_XDOT_L151CC)
363363
static uint32_t thread_stack_main[DEFAULT_STACK_SIZE * 6 / sizeof(uint32_t)];
364+
#elif defined(TARGET_NANO130KE3BN) && !defined(TOOLCHAIN_ARM_MICRO)
365+
static uint32_t thread_stack_main[DEFAULT_STACK_SIZE / sizeof(uint32_t)];
364366
#else
365367
static uint32_t thread_stack_main[DEFAULT_STACK_SIZE * 2 / sizeof(uint32_t)];
366368
#endif

targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/objects.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct gpio_irq_s {
3131
PinName pin;
3232
uint32_t irq_handler;
3333
uint32_t irq_id;
34+
struct gpio_irq_s *next;
3435
};
3536

3637
struct port_s {

targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_ARM_MICRO/NANO130.sct

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ LR_IROM1 0x00000000 {
1313
ARM_LIB_STACK 0x20000000 EMPTY 0x800 {
1414
}
1515

16-
;ER_IRAMVEC 0x20000800 EMPTY (4*(16 + 32)) { ; Reserve for vectors
17-
;}
18-
1916
RW_IRAM1 AlignExpr(+0, 16) { ; 16 byte-aligned
2017
.ANY (+RW +ZI)
2118
}

targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_ARM_STD/NANO130.sct

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ LR_IROM1 0x00000000 {
1313
ARM_LIB_STACK 0x20000000 EMPTY 0x800 {
1414
}
1515

16-
;ER_IRAMVEC 0x20000800 EMPTY (4*(16 + 32)) { ; Reserve for vectors
17-
;}
18-
1916
RW_IRAM1 AlignExpr(+0, 16) { ; 16 byte-aligned
2017
.ANY (+RW +ZI)
2118
}

targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_GCC_ARM/NANO130.ld

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,6 @@ SECTIONS
140140
__StackLimit = ADDR(.stack);
141141
PROVIDE(__stack = __StackTop);
142142

143-
/* Relocate vector table in SRAM */
144-
/* .isr_vector.reloc (NOLOAD) :
145-
{
146-
. = ALIGN(1 << LOG2CEIL(__vector_size));
147-
PROVIDE(__start_vector_table__ = .);
148-
. += __vector_size;
149-
PROVIDE(__end_vector_table__ = .);
150-
} > RAM_INTERN
151-
*/
152143
.data :
153144
{
154145
PROVIDE( __etext = LOADADDR(.data) );

targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_GCC_ARM/nano100_retarget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
extern uint32_t __mbed_sbrk_start;
1717
extern uint32_t __mbed_krbs_start;
1818

19-
#define NU_HEAP_ALIGN 32
19+
#define NU_HEAP_ALIGN 4
2020

2121
/**
2222
* The default implementation of _sbrk() (in common/retarget.cpp) for GCC_ARM requires one-region model (heap and stack share one region), which doesn't

targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_IAR/NANO130.icf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
66
/*-Memory Regions-*/
77
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
8-
define symbol __ICFEDIT_region_ROM_end__ = 0x00020000;
8+
define symbol __ICFEDIT_region_ROM_end__ = 0x00020000 - 1;
99
define symbol __ICFEDIT_region_IRAM_start__ = 0x20000000;
10-
define symbol __ICFEDIT_region_IRAM_end__ = 0x20004000;
10+
define symbol __ICFEDIT_region_IRAM_end__ = 0x20004000 - 1;
1111
/*-Sizes-*/
1212
define symbol __ICFEDIT_size_cstack__ = 0x800;
1313
define symbol __ICFEDIT_size_heap__ = 0x1800;

targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define NU_MAX_PIN_PER_PORT 16
2828

2929
struct nu_gpio_irq_var {
30-
gpio_irq_t * obj_arr[NU_MAX_PIN_PER_PORT];
30+
gpio_irq_t * obj_arr;
3131
//IRQn_Type irq_n;
3232
uint32_t gpio_n;
3333
void (*vec)(void);
@@ -39,12 +39,12 @@ static void gpio_irq(struct nu_gpio_irq_var *var);
3939

4040
//EINT0_IRQn
4141
static struct nu_gpio_irq_var gpio_irq_var_arr[] = {
42-
{{NULL}, 0, GPABC_IRQHandler},
43-
{{NULL}, 1, GPABC_IRQHandler},
44-
{{NULL}, 2, GPABC_IRQHandler},
45-
{{NULL}, 3, GPDEF_IRQHandler},
46-
{{NULL}, 4, GPDEF_IRQHandler},
47-
{{NULL}, 5, GPDEF_IRQHandler}
42+
{NULL, 0, GPABC_IRQHandler},
43+
{NULL, 1, GPABC_IRQHandler},
44+
{NULL, 2, GPABC_IRQHandler},
45+
{NULL, 3, GPDEF_IRQHandler},
46+
{NULL, 4, GPDEF_IRQHandler},
47+
{NULL, 5, GPDEF_IRQHandler}
4848
};
4949

5050
#define NU_MAX_PORT (sizeof (gpio_irq_var_arr) / sizeof (gpio_irq_var_arr[0]))
@@ -83,6 +83,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
8383
obj->pin = pin;
8484
obj->irq_handler = (uint32_t) handler;
8585
obj->irq_id = id;
86+
obj->next = NULL;
8687

8788
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
8889
//gpio_set(pin);
@@ -120,7 +121,15 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
120121

121122
struct nu_gpio_irq_var *var = gpio_irq_var_arr + port_index;
122123

123-
var->obj_arr[pin_index] = obj;
124+
// Add obj to linked list
125+
gpio_irq_t *cur_obj = var->obj_arr;
126+
if (cur_obj == NULL) {
127+
cur_obj = obj;
128+
} else {
129+
while (cur_obj->next != NULL)
130+
cur_obj = cur_obj->next;
131+
cur_obj->next = obj;
132+
}
124133

125134
// NOTE: InterruptIn requires IRQ enabled by default.
126135
gpio_irq_enable(obj);
@@ -138,7 +147,21 @@ void gpio_irq_free(gpio_irq_t *obj)
138147
NU_PORT_BASE(port_index)->IER = 0;
139148

140149
MBED_ASSERT(pin_index < NU_MAX_PIN_PER_PORT);
141-
var->obj_arr[pin_index] = NULL;
150+
gpio_irq_t *pre_obj = var->obj_arr;
151+
if (pre_obj->pin == obj->pin)
152+
var->obj_arr = pre_obj->next;
153+
else {
154+
while (pre_obj->next) {
155+
gpio_irq_t *cur_obj = pre_obj->next;
156+
if (cur_obj->pin == obj->pin) {
157+
pre_obj->next = cur_obj->next;
158+
break;
159+
}
160+
pre_obj = pre_obj->next;
161+
}
162+
if (pre_obj->next == NULL)
163+
error("cannot find obj in gpio_irq_free()");
164+
}
142165
}
143166

144167
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
@@ -170,7 +193,6 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
170193

171194
void gpio_irq_enable(gpio_irq_t *obj)
172195
{
173-
//uint32_t pin_index = NU_PINNAME_TO_PIN(obj->pin);
174196
uint32_t port_index = NU_PINNAME_TO_PORT(obj->pin);
175197
struct nu_gpio_irq_var *var = gpio_irq_var_arr + port_index;
176198

@@ -180,7 +202,6 @@ void gpio_irq_enable(gpio_irq_t *obj)
180202

181203
void gpio_irq_disable(gpio_irq_t *obj)
182204
{
183-
//uint32_t pin_index = NU_PINNAME_TO_PIN(obj->pin);
184205
uint32_t port_index = NU_PINNAME_TO_PORT(obj->pin);
185206
struct nu_gpio_irq_var *var = gpio_irq_var_arr + port_index;
186207

@@ -215,18 +236,26 @@ static void gpio_irq(struct nu_gpio_irq_var *var)
215236
uint32_t ier = gpio_base->IER;
216237
while (isrc) {
217238
int pin_index = nu_ctz(isrc);
218-
gpio_irq_t *obj = var->obj_arr[pin_index];
239+
PinName pin = port_pin(port_index, pin_index);
240+
gpio_irq_t *obj = var->obj_arr;
241+
while (obj) {
242+
if (obj->pin == pin)
243+
break;
244+
obj = obj->next;
245+
}
246+
if (obj == NULL)
247+
error("cannot find obj in gpio_irq()");
219248
if (ier & (GPIO_INT_RISING << pin_index)) {
220249
if (GPIO_PIN_ADDR(port_index, pin_index)) {
221-
if (obj->irq_handler) {
250+
if (obj && obj->irq_handler) {
222251
((gpio_irq_handler) obj->irq_handler)(obj->irq_id, IRQ_RISE);
223252
}
224253
}
225254
}
226255

227256
if (ier & (GPIO_INT_FALLING << pin_index)) {
228257
if (! GPIO_PIN_ADDR(port_index, pin_index)) {
229-
if (obj->irq_handler) {
258+
if (obj && obj->irq_handler) {
230259
((gpio_irq_handler) obj->irq_handler)(obj->irq_id, IRQ_FALL);
231260
}
232261
}

targets/TARGET_NUVOTON/mbed_rtx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@
9292
#elif defined(TARGET_NUMAKER_PFM_NANO130)
9393

9494
#ifndef OS_TASKCNT
95-
#define OS_TASKCNT 14
95+
#define OS_TASKCNT 6
9696
#endif
9797
#ifndef OS_MAINSTKSIZE
98-
#define OS_MAINSTKSIZE 256
98+
#define OS_MAINSTKSIZE 128
9999
#endif
100100
#ifndef OS_CLOCK
101101
#define OS_CLOCK 42000000

targets/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2628,7 +2628,7 @@
26282628
"NUMAKER_PFM_NANO130": {
26292629
"core": "Cortex-M0",
26302630
"default_toolchain": "ARM",
2631-
"extra_labels": ["NUVOTON", "NANO100", "NUMAKER_PFM_NANO130"],
2631+
"extra_labels": ["NUVOTON", "NANO100", "NANO130KE3BN"],
26322632
"is_disk_virtual": true,
26332633
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"],
26342634
"inherits": ["Target"],

0 commit comments

Comments
 (0)