Skip to content

Commit 97e6352

Browse files
committed
new file: arc_design_contest/2019/HUST_electrical_load_identification/appl_mem_config.h
new file: arc_design_contest/2019/HUST_electrical_load_identification/input_buffer.c new file: arc_design_contest/2019/HUST_electrical_load_identification/input_buffer.h new file: arc_design_contest/2019/HUST_electrical_load_identification/main.c new file: arc_design_contest/2019/HUST_electrical_load_identification/makefile new file: arc_design_contest/2019/HUST_electrical_load_identification/model/load_identification_coefficients.c new file: arc_design_contest/2019/HUST_electrical_load_identification/model/load_identification_constants.h new file: arc_design_contest/2019/HUST_electrical_load_identification/model/load_identification_model.c new file: arc_design_contest/2019/HUST_electrical_load_identification/model/load_identification_model.c.bak new file: arc_design_contest/2019/HUST_electrical_load_identification/model/load_identification_model.h new file: arc_design_contest/2019/HUST_electrical_load_identification/oled_display.c new file: arc_design_contest/2019/HUST_electrical_load_identification/oled_display.h new file: arc_design_contest/2019/HUST_electrical_load_identification/process.c new file: arc_design_contest/2019/HUST_electrical_load_identification/process.h new file: arc_design_contest/2019/HUST_electrical_load_identification/ssd1306_app_config.h
1 parent 797d98c commit 97e6352

15 files changed

+5072
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef _APPL_MEM_CONFIG_H_
2+
#define _APPL_MEM_CONFIG_H_
3+
4+
5+
6+
#define REGION_MLI_ROM REGION_ROM
7+
#define REGION_MLI_DATA REGION_DCCM
8+
#define REGION_MLI_BSS REGION_DCCM
9+
#define REGION_MLI_ZDATA REGION_DCCM
10+
#define REGION_MLI_MODEL_P2 REGION_DCCM
11+
#define REGION_MLI_MODEL REGION_XCCM
12+
#define REGION_MLI_XDATA REGION_XCCM
13+
#define REGION_MLI_YDATA REGION_YCCM
14+
15+
#endif /* _APPL_MEM_CONFIG_H_ */
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* ------------------------------------------
2+
* Copyright (c) 2019, Synopsys, Inc. All rights reserved.
3+
4+
* Redistribution and use in source and binary forms, with or without modification,
5+
* are permitted provided that the following conditions are met:
6+
7+
* 1) Redistributions of source code must retain the above copyright notice, this
8+
* list of conditions and the following disclaimer.
9+
10+
* 2) Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation and/or
12+
* other materials provided with the distribution.
13+
14+
* 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
15+
* be used to endorse or promote products derived from this software without
16+
* specific prior written permission.
17+
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
--------------------------------------------- */
30+
31+
#include "embARC.h"
32+
#include "embARC_debug.h"
33+
#include "input_buffer.h"
34+
35+
/*
36+
* Input buffer declaration and settings
37+
*/
38+
static uint16_t my_index = 0;
39+
float input_buffer[DATA_SIZE] = {0};
40+
uint8_t one_frame_finish_flag = 0;
41+
42+
43+
44+
void input_buffer_push_data(float* data)
45+
{
46+
input_buffer[my_index++] = data[0];
47+
if(my_index == DATA_SIZE) {
48+
one_frame_finish_flag = 1;
49+
my_index = 0;
50+
}
51+
}
52+
53+
54+
55+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* ------------------------------------------
2+
* Copyright (c) 2019, Synopsys, Inc. All rights reserved.
3+
4+
* Redistribution and use in source and binary forms, with or without modification,
5+
* are permitted provided that the following conditions are met:
6+
7+
* 1) Redistributions of source code must retain the above copyright notice, this
8+
* list of conditions and the following disclaimer.
9+
10+
* 2) Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation and/or
12+
* other materials provided with the distribution.
13+
14+
* 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
15+
* be used to endorse or promote products derived from this software without
16+
* specific prior written permission.
17+
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
--------------------------------------------- */
30+
#ifndef _INPUT_BUFFER_H_
31+
#define _INPUT_BUFFER_H_
32+
33+
#include "ad7991.h"
34+
35+
/* Values position inside the input buffer */
36+
#define DATA_SIZE 500
37+
38+
extern float input_buffer[DATA_SIZE];
39+
extern uint8_t one_frame_finish_flag;
40+
41+
extern void input_buffer_push_data(float *data);
42+
43+
#endif /* _INPUT_BUFFER_H_ */
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* ------------------------------------------
2+
* Copyright (c) 2019, Synopsys, Inc. All rights reserved.
3+
4+
* Redistribution and use in source and binary forms, with or without modification,
5+
* are permitted provided that the following conditions are met:
6+
7+
* 1) Redistributions of source code must retain the above copyright notice, this
8+
* list of conditions and the following disclaimer.
9+
10+
* 2) Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation and/or
12+
* other materials provided with the distribution.
13+
14+
* 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
15+
* be used to endorse or promote products derived from this software without
16+
* specific prior written permission.
17+
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
--------------------------------------------- */
30+
31+
#include "embARC.h"
32+
#include "embARC_debug.h"
33+
#include "ad7991.h"
34+
#include "u8g.h"
35+
36+
#include "input_buffer.h"
37+
#include "process.h"
38+
#include "ssd1306_app_config.h"
39+
#include "oled_display.h"
40+
41+
#include "load_identification_model.h"
42+
43+
44+
#define AD7991_IIC_ID DFSS_IIC_0_ID
45+
46+
u8g_t u8g;
47+
48+
static AD7991_DEFINE(ad7991_sensor, AD7991_IIC_ID, ADC_I2C_SLAVE_ADDRESS);
49+
int main(void)
50+
{
51+
52+
float ad_data[4] = {0};
53+
uint8_t proc_flag = 0;
54+
RESULT my_result = 0;
55+
/* initializing the Sensor Hub */
56+
ad7991_adc_init(ad7991_sensor);
57+
u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_2x_i2c, U8G_COM_SSD_I2C);
58+
u8g_Begin(&u8g); /* reset display and put it into default state */
59+
60+
display_welcome(&u8g);
61+
board_delay_ms(2000, 1);
62+
63+
EMBARC_PRINTF("Load Identification\r\n");
64+
/* configuring GPIO to handle the "data ready" interrupt */
65+
while (1) {
66+
board_delay_ms(1, 1);
67+
EMBARC_PRINTF("Hello ARC\r\n");
68+
if(proc_flag == 0){
69+
if(one_frame_finish_flag == 0){
70+
ad7991_adc_read(ad7991_sensor, ad_data);
71+
input_buffer_push_data(ad_data);
72+
}
73+
else{
74+
my_result = Cnn_Net_Classify();
75+
display_result(&u8g, my_result);
76+
one_frame_finish_flag = 0;
77+
proc_flag = 1;
78+
}
79+
}
80+
else{
81+
proc_flag = 0;
82+
board_delay_ms(100, 1);
83+
}
84+
}
85+
return E_SYS;
86+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Application name
2+
APPL ?= load_identification_app
3+
4+
TOOLCHAIN = gnu
5+
6+
BOARD ?= iotdk
7+
8+
EXT_DEV_LIST += adc/ad7991
9+
10+
CUR_CORE = arcem9d
11+
12+
APPL_DEFINES = -DUSE_APPL_MEM_CONFIG -DV2DSP_XY -DMODEL_BIT_DEPTH=16 -g
13+
14+
# optimization Level
15+
OLEVEL = O0
16+
17+
#
18+
# root dir of embARC
19+
#
20+
EMBARC_ROOT = ../../../..
21+
22+
# use -Hpurge option to optimize the code size
23+
ifeq ($(TOOLCHAIN), gnu)
24+
ADT_COPT += -ffunction-sections -fdata-sections
25+
ADT_LOPT += -Wl,--gc-sections
26+
else
27+
ADT_COPT += -Hpurge
28+
ADT_LOPT += -Hpurge
29+
endif
30+
31+
LIB_SEL = embarc_mli
32+
MID_SEL = common u8glib
33+
#MID_SEL = common
34+
35+
# application source dirs
36+
APPL_CSRC_DIR = . model
37+
APPL_ASMSRC_DIR = .
38+
39+
# application include dirs
40+
APPL_INC_DIR = . model
41+
42+
# include current project makefile
43+
COMMON_COMPILE_PREREQUISITES += makefile
44+
45+
### Options above must be added before include options.mk ###
46+
# include key embARC build system makefile
47+
include $(EMBARC_ROOT)/options/options.mk

0 commit comments

Comments
 (0)