Skip to content

Commit 3122781

Browse files
bigdinotechsys_maker
authored and
sys_maker
committed
-add error functions
-add error functions that sets an error_code variable in shared memory and halt the ARC core -this will be used by CODK-M based firmware to toggle the fault led on the Arduino 101
1 parent 752d872 commit 3122781

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

cores/arduino/Arduino.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ extern uint8_t pinmuxMode[NUM_DIGITAL_PINS];
110110
#include "WMath.h"
111111
#include "HardwareSerial.h"
112112
#include "wiring_pulse.h"
113+
#include "error.h"
113114

114115
#endif // __cplusplus
115116

cores/arduino/error.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright (c) 2017 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 "error.h"
21+
22+
void error_continue()
23+
{
24+
error_continue(1);
25+
}
26+
27+
void error_continue(uint8_t error_code)
28+
{
29+
uint32_t exc_addr = aux_reg_read(ARC_V2_EFA);
30+
uint32_t ecr = aux_reg_read(ARC_V2_ECR);
31+
32+
pr_error(0, "Exception vector: 0x%x, cause code: 0x%x, parameter 0x%x\n",
33+
ARC_V2_ECR_VECTOR(ecr),
34+
ARC_V2_ECR_CODE(ecr),
35+
ARC_V2_ECR_PARAMETER(ecr));
36+
pr_error(0, "Address 0x%x\n", exc_addr);
37+
shared_data->error_code = error_code;
38+
}
39+
40+
void error_halt()
41+
{
42+
error_halt(1);
43+
}
44+
45+
void error_halt(uint8_t error_code)
46+
{
47+
error_continue(error_code);
48+
__asm__("flag 0x01") ; /* Halt the CPU */
49+
}

cores/arduino/error.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright (c) 2017 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+
#ifndef _Error_h
21+
#define _Error_h
22+
23+
#include <stdint.h>
24+
#include "os/os.h"
25+
#include "infra/log.h"
26+
#include "aux_regs.h"
27+
#include "platform.h"
28+
29+
extern void error_halt();
30+
31+
extern void error_halt(uint8_t error_code);
32+
33+
extern void error_continue();
34+
35+
extern void error_continue(uint8_t error_code);
36+
37+
#endif

system/libarc32_arduino101/framework/include/platform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ struct platform_shared_block_ {
156156
void* quark_restore_addr;
157157

158158
uint32_t pm_int_status;
159+
160+
uint8_t error_code;
159161
};
160162

161163
#define RAM_START 0xA8000000

0 commit comments

Comments
 (0)