diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/FPGA_SD/BOOT.bin b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/FPGA_SD/BOOT.bin new file mode 100644 index 00000000..db2fdd9c Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/FPGA_SD/BOOT.bin differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/LICENSE b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/LICENSE new file mode 100644 index 00000000..29f81d81 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/README.md b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/README.md new file mode 100644 index 00000000..f2566a90 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/README.md @@ -0,0 +1,116 @@ +# Intelligent protection system for forgotten children in vehicle +The "Intelligent protection system for forgotten children in vehicle" is based on ARC and FPGA heterogeneous platforms. Through intelligent sensor systems and image processing systems, vehicles are equipped with intelligent environmental awareness, target detection, remote alert, emergency help, and voice interaction. The system can automatically detect when a child is forgotten in the car and remotely reminds parents to return. The system is equipped with one-click assistance and dangerous time self-startup help functions. At the same time,it can be used as a vehicle environment monitor for real-time display of formaldehyde, temperature and other environmental information inside the vehicle and to remind the superscript, the owner can also use the voice interaction to query the car environment and control some equipment in the car. +* [Introduction](#introduction) + * [Project context](#project-context) + * [System Architecture](#system-architecture) + * [Function](#function) +* [Hardware and Software Setup](#hardware-and-software-setup) + * [Required Hardware](#required-hardware) + * [Required Software](#required-software) + * [Hardware Connection](#hardware-connection) +* [User Manual](#user-manual) + * [Before Running This Application](#before-running-this-application) + * [Run This Application](#run-this-application) +## Introduction +### Project context +With the rapid popularity of automobiles in the world, it brings great convenience to people and also brings many security risks. Among them, accidents caused by the parents’ negligence have caused children to be locked in cars. When the car is parked, children will be locked in the car for a long time. Increased car temperature and decreased oxygen content can easily lead to dehydration, heat stroke, and even life threats. Because children do not have the ability to save themselves, they cannot take appropriate measures. In addition, most of the car window films make it difficult for passers-by to see trapped children from outside. +![0](https://github.com/pfli07/Intelligent-protection-system-for-forgotten-children-in-vehicle/blob/master/screenshots/Project%20context.png) +According to statistics, from 1998 to 2017, there were 709 children in the United States who were forgotten by the parents and caused death in the car. On average, 37 children died each year. In recent years, there have been similar situations in China. It has important practical significance to solve the problem of children's safety in the vehicle. +### System Architecture +![00](https://github.com/pfli07/Intelligent-protection-system-for-forgotten-children-in-vehicle/blob/master/screenshots/yingwen.png) +### Function +"Intelligent protection system for forgotten children in vehicle" is divided into parking and driving modes, both of which can be switched freely. +* Parking Mode + * Forgotten children test (by moving target detection and infrared body sensing) + * Remote SMS and phone alerts + * Emergency help (by flashing light and whistle alarm) + * Temperature monitoring +* Driving mode + * Environmental information monitoring (real-time monitoring of formaldehyde concentration and temperature) + * Voice interactive control system (with voice recognition function, can achieve control of vehicle equipment) +## Hardware and Software Setup +### Required Hardware +* 1 DesignWare ARC EM Starter Kit(EMSK) +* 1 ZYNQ Development Platform (ES-288) +* 1 OV7670 camera +* 1 infrared human body induction module +* 1 temperature detection module +* 1 GPRS module +* 1 SIM card +* 1 formaldehyde module +* 1 speech recognition module +* 1 speech synthesis module +* 1 OLED display +* 2 Relays +* 3 LED lights +* 1 cooling fan +* 2 SDCard +* 2 mobile power +* **The physical picture shown below** +![00](https://github.com/pfli07/Intelligent-protection-system-for-forgotten-children-in-vehicle/blob/master/screenshots/waiguan.jpg)![00](https://github.com/pfli07/Intelligent-protection-system-for-forgotten-children-in-vehicle/blob/master/screenshots/neibu.jpg) +### Required Software +* Metaware or ARC GNU Toolset +* Serial port terminal, such as putty, tera-term or minicom +* Vivado +* Vivado HLS +* Vivado SDK +### Hardware Connection +1. Connect GPRS, OLED display, FPGA development board and other devices to the corresponding interface of EMSK to realize the functions: + - Connect **GPRS module** to **J1** (Using UART0 interface) + - Connect **OLED screen** to **J2** (Using IIC0 interface) + - Connect **Speech recognition module** to **J3** (Using GPIO interface) + - Connect **Infrared human body sensing module** to **J3** (Using GPIO interface) + - **Formaldehyde module**, **temperature detection module**, **speech synthesis module** are all connected to **J4** (Using IIC1 interface) + - Connect **FPGA Development Board** to **J6** via DuPont Line + - Connect **OV7670 camera** to **FPGA Development Board** + - Connect **Relays** and **LED lights** to **J5** +2. Configure your EMSKs with proper core configuration. +## User Manual +### Before Running This Application +Download source code of "Intelligent protection system for forgetten children in vehicle" from github.Write FPGA image file to SD card, start ES-288 FPGA. + +The hardware resources are allocated as following table. + +| Hardware Resource | Function | +| -----------------------------------| ------------------------------------------------------------- | +| OV7670 camera | Gathering images for the FPGA | +|infrared human body induction module| Detect whether there are forgotten children in the car | +| temperature detection module | Check the temperature inside the car | +| GPRS module | Give the parents an emergency call | +| formaldehyde module | Detection of formaldehyde concentration in the car | +| speech recognition module | Identify owner's voice commands | +| speech synthesis module | Synthetic interaction speech answer | +| OLED display | Display interior temperature and formaldehyde concentration | + + + +### Run This Application + + +#### Makefile +- Target options about EMSK and toolchain: + + BOARD ?= emsk + BD_VER ?= 22 + CUR_CORE ?= arcem7d + TOOLCHAIN ?= gnu + +- The relative series of the root directory, here the path of the Makefile is
+`./Intelligent-protection-system-for-forgotten-children-in-vehicle/src/makefile`: + + # + # root dir of embARC + # + EMBARC_ROOT = ../../../.. + +#### Driver +Placing the drivers' source code in `driver` folder, you can see there are subfolders for GPRS module, Formaldehyde module, Speech synthesis module,Placing the C source file and header file in the corresponding subfolder. + +| folder/file | Function | +| ------------------- | ------------------------------| +| CH2O | Formaldehyde module driver | +| DETECT | Child detection | +| GPRS | GPRS module driver | +| LED | LED light driver | +| YUYIN | Speech synthesis output driver| + diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/doc/Intelligent-protection-system-for-forgotten-children-in-vehicle.pdf b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/doc/Intelligent-protection-system-for-forgotten-children-in-vehicle.pdf new file mode 100644 index 00000000..f6587570 Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/doc/Intelligent-protection-system-for-forgotten-children-in-vehicle.pdf differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/children_detect(arm simulation).jpg b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/children_detect(arm simulation).jpg new file mode 100644 index 00000000..9b3e1b13 Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/children_detect(arm simulation).jpg differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/internal_structure.jpg b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/internal_structure.jpg new file mode 100644 index 00000000..628e00ae Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/internal_structure.jpg differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/main_view.jpg b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/main_view.jpg new file mode 100644 index 00000000..6c4c2768 Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/main_view.jpg differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/side_view.jpg b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/side_view.jpg new file mode 100644 index 00000000..9daef15e Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/side_view.jpg differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/top_view.jpg b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/top_view.jpg new file mode 100644 index 00000000..98aa8852 Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/project_picture/top_view.jpg differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/Project context.png b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/Project context.png new file mode 100644 index 00000000..e40496b6 Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/Project context.png differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/neibu.jpg b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/neibu.jpg new file mode 100644 index 00000000..bbf7351d Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/neibu.jpg differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/waiguan.jpg b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/waiguan.jpg new file mode 100644 index 00000000..9daef15e Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/waiguan.jpg differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/yingwen.png b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/yingwen.png new file mode 100644 index 00000000..29bbbb8a Binary files /dev/null and b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/screenshots/yingwen.png differ diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/CH2O/CH2O.c b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/CH2O/CH2O.c new file mode 100644 index 00000000..47ad9815 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/CH2O/CH2O.c @@ -0,0 +1,105 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ +#include "arc.h" +#include "arc_builtin.h" +#include "embARC_toolchain.h" +#include "embARC_error.h" +#include +#include +#include +#include +#include "dev_iic.h" +#include "CH2O.h" +#include "board.h" + +#include "embARC.h" +#include "embARC_debug.h" + +static DEV_IIC *CH2O; +static uint32_t CH2O_Slvaddr; + +int32_t CH2O_regs_read(uint8_t *buff, uint32_t length) +{ + int32_t ercd = E_OK; + CH2O = iic_get_dev(DW_IIC_1_ID); + + EMSK_CH2O_SENSOR_CHECK_EXP_NORTN(CH2O!=NULL); + + CH2O->iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(CH2O_Slvaddr)); + ercd = CH2O->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP)); + ercd = CH2O->iic_read(buff, length); + +error_exit: + return ercd; +} + +int32_t CH2O_IIC_init(uint32_t slv_addr) +{ + int32_t ercd = E_OK; + CH2O = iic_get_dev(DW_IIC_1_ID); + EMSK_CH2O_SENSOR_CHECK_EXP_NORTN(CH2O!=NULL); + ercd = CH2O->iic_open(DEV_MASTER_MODE, IIC_SPEED_FAST); + if ((ercd == E_OK) || (ercd == E_OPNED)) + { + ercd = CH2O->iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(slv_addr)); + CH2O_Slvaddr = slv_addr; + } +error_exit: + return ercd; +} + +uint16_t _CH2O_(void) +{ + int32_t ercd; + uint8_t i = 0; + uint16_t d = 0; + uint8_t CH2O_BUFF1[1] = {0}; + uint8_t CH2O_BUFF2[7] = {0}; + ercd = CH2O_regs_read(CH2O_BUFF1,1); + while(1) + { + ercd = CH2O_regs_read(CH2O_BUFF1,1); + if(CH2O_BUFF1[0]==255) break; + } + while(1) + { + ercd = CH2O_regs_read(CH2O_BUFF1,1); + if((CH2O_BUFF1[0]!=0)) + { + CH2O_BUFF2[i++] = CH2O_BUFF1[0]; + } + else if(i==7) + break; + } + if((CH2O_BUFF2[5]==0x02) && (CH2O_BUFF2[6]==0x05)) + { + d = CH2O_BUFF2[3]*256 + CH2O_BUFF2[4]; + } + else + { + d = CH2O_BUFF2[3]; + } + return d; +} \ No newline at end of file diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/CH2O/CH2O.h b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/CH2O/CH2O.h new file mode 100644 index 00000000..bdcb7820 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/CH2O/CH2O.h @@ -0,0 +1,38 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ +#ifndef _CH2O_H_ +#define _CH2O_H_ + +#include "dev_iic.h" + +#define CH2O_ADDRESS 0x02 + +#define EMSK_CH2O_SENSOR_CHECK_EXP_NORTN(EXPR) CHECK_EXP_NOERCD(EXPR, error_exit) + +extern int32_t CH2O_regs_read(uint8_t *buff, uint32_t length); +extern int32_t CH2O_IIC_init(uint32_t slv_addr); +extern uint16_t _CH2O_(void); + +#endif diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/DETECT/DETECT.c b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/DETECT/DETECT.c new file mode 100644 index 00000000..06496fdd --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/DETECT/DETECT.c @@ -0,0 +1,89 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ + +#include "arc.h" +#include "arc_builtin.h" +#include "embARC_toolchain.h" +#include "embARC_error.h" +#include "board.h" +#include "dev_uart.h" +#include "embARC.h" +#include "embARC_debug.h" +#include "DETECT.h" + +static DEV_GPIO_PTR port_help; +static DEV_GPIO_PTR port_child_detect_open; +static DEV_GPIO_PTR port_child_detect_close; + +static void delay_ms(volatile int z) +{ + volatile uint32_t x,y; + for(x=1400;x>0;x--) + for(y=z;y>0;y--); +} + + +void led_initial() +{ + port_help = gpio_get_dev(DW_GPIO_PORT_A);//定义port_a接口 + port_help ->gpio_open(0x300);//打开PortA[8]=蜂鸣器和PortA[9]=LED闪烁 + port_help ->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x300);//设置portA[11]为输出 + port_help ->gpio_write(0x000, 0x300); +} + + + + +void help(void) +{ + port_help = gpio_get_dev(DW_GPIO_PORT_A);//定义port_a接口 + port_help ->gpio_open(0x300);//打开PortA[8]=蜂鸣器和PortA[9]=LED闪烁 + port_help ->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x300);//设置portA[11]为输出 + port_help ->gpio_write(0x300, 0x300); + delay_ms(1000); + port_help ->gpio_write(0x000, 0x300); + delay_ms(1000); +} + + +void open_child_detect(void) +{ + port_child_detect_open = gpio_get_dev(DW_GPIO_PORT_C);//定义port_C接口 + port_child_detect_open->gpio_open(0x80000); + port_child_detect_open ->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x80000);//设置portC[19]为输出 + port_child_detect_open ->gpio_write(0x80000, 0x80000); + +} + + +void close_child_detect(void) +{ + port_child_detect_close = gpio_get_dev(DW_GPIO_PORT_C);//定义port_C接口 + port_child_detect_close ->gpio_open(0x80000); + port_child_detect_close ->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x80000);//设置portC[19]为输出 + port_child_detect_close ->gpio_write(0x00000, 0x80000); +} + + diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/DETECT/DETECT.h b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/DETECT/DETECT.h new file mode 100644 index 00000000..7c5789b7 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/DETECT/DETECT.h @@ -0,0 +1,33 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ +#ifndef _DETECT_H_ +#define _DETECT_H_ + +extern void help(); +extern void led_initial(); +extern void open_child_detect(); +extern void close_child_detect(); + +#endif \ No newline at end of file diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/GPRS/GPRS.c b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/GPRS/GPRS.c new file mode 100644 index 00000000..62fa1b7a --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/GPRS/GPRS.c @@ -0,0 +1,152 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ +#include "arc.h" +#include "arc_builtin.h" +#include "embARC_toolchain.h" +#include "embARC_error.h" +#include "board.h" +#include "GPRS.h" +#include "dev_uart.h" + +#include +#include +#include "embARC.h" +#include "embARC_debug.h" + +#define INTV 20 +uint8_t rcv_buf[20]; + +static void delay_ms(volatile int z) +{ + volatile uint32_t x,y; + for(x=1400;x>0;x--) + for(y=z;y>0;y--); +} + + +void call_gh(void) +{ + DEV_UART *dev_uart0 = NULL; + uint32_t baudrate = 115200; + dev_uart0 = uart_get_dev(DW_UART_0_ID); + dev_uart0-> uart_open(baudrate); + uint8_t i; + int8_t *cmd[2]={"ATD18710895393;\r\n",}; + for(i = 0; i < 4; i++) + { + dev_uart0->uart_write(cmd[i], strlen(cmd[i])); + delay_ms(100); + } + uint8_t end[]={0x1a,0x00}; + dev_uart0->uart_write(end, strlen(end)); +} + +void call_lpf(void) +{ + DEV_UART *dev_uart0 = NULL; + uint32_t baudrate = 115200; + dev_uart0 = uart_get_dev(DW_UART_0_ID); + dev_uart0-> uart_open(baudrate); + uint8_t i; + int8_t *cmd[2]={"ATD18829210907;\r\n",}; + for(i = 0; i < 4; i++) + { + dev_uart0->uart_write(cmd[i], strlen(cmd[i])); + delay_ms(100); + } + uint8_t end[]={0x1a,0x00}; + dev_uart0->uart_write(end, strlen(end)); +} + + + + +void send(uint8_t *phoneNum, uint8_t *msg) +{ + DEV_UART *dev_uart0 = NULL; + uint32_t baudrate = 115200; + dev_uart0 = uart_get_dev(DW_UART_0_ID); + dev_uart0-> uart_open(baudrate); + + uint8_t i; + uint8_t pnum[64]; + int8_t *cmd[5]={"AT+CMGF=1\r\n", "AT+CSCS=\"UCS2\"\r\n", + "AT+CSCA?\r\n", "AT+CSMP=17,167,0,25\r\n",}; + snprintf(pnum, 64, "AT+CMGS=\"%s\"\r\n", phoneNum); + for(i = 0; i < 4; i++) + { + dev_uart0->uart_write(cmd[i], strlen(cmd[i])); + delay_ms(100); + } + dev_uart0->uart_write(pnum, strlen(pnum)); + delay_ms(100); + dev_uart0->uart_write(msg, strlen(msg)); + delay_ms(100); + uint8_t end[]={0x1a,0x00}; + dev_uart0->uart_write(end, strlen(end)); +} + + + + +void send_data1(void) +{ + DEV_UART *dev_uart0 = NULL; + uint32_t baudrate = 115200; + dev_uart0 = uart_get_dev(DW_UART_0_ID); + dev_uart0->uart_open(baudrate); + + uint8_t *aa="AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"\r\n"; + uint8_t *bb="AT+SAPBR=3,1,\"APN\",\"CMNET\"\r\n"; + uint8_t *cc="AT+SAPBR=1,1\r\n"; + uint8_t *dd="AT+HTTPINIT\r\n" ; //初始化Http + uint8_t *ee="AT+HTTPPARA=\"URL\",\"http://123.206.81.226:8080/boxes/take/box001/1\"\r\n" ;//设置URL + uint8_t *ff="AT+HTTPACTION=0\r\n" ; //0表示get,1表示post,2表示head + + + dev_uart0->uart_write(aa, strlen(aa)); + delay_ms(INTV); + + dev_uart0->uart_write(bb, strlen(bb)); + delay_ms(INTV); + + dev_uart0->uart_write(cc, strlen(cc)); + delay_ms(INTV); + + dev_uart0->uart_write(dd, strlen(dd)); + delay_ms(INTV); + + dev_uart0->uart_write(ee, strlen(ee)); + delay_ms(INTV); + + dev_uart0->uart_write(ff, strlen(ff)); + delay_ms(INTV); + +} + + + + + diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/GPRS/GPRS.h b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/GPRS/GPRS.h new file mode 100644 index 00000000..9a9b62a0 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/GPRS/GPRS.h @@ -0,0 +1,32 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ +#ifndef _GSM_H_ +#define _GSM_H_ +extern void call_gh(void); +extern void call_lpf(void); +extern void send_data0(void); +extern void send_data1(void); +extern void send(uint8_t *phoneNum, uint8_t *msg); +#endif /* _GSM_H_ */ \ No newline at end of file diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/LED/LED.c b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/LED/LED.c new file mode 100644 index 00000000..f17a208b --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/LED/LED.c @@ -0,0 +1,103 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ +#include "arc.h" +#include "arc_builtin.h" +#include "embARC_toolchain.h" +#include "embARC_error.h" +#include "board.h" +#include "LED.h" +#include "dev_uart.h" + +#include +#include +#include "embARC.h" +#include "embARC_debug.h" + +static DEV_GPIO_PTR port_led5; //运动目标检测灯 +static DEV_GPIO_PTR port_led6; //发送短信提示灯 +static DEV_GPIO_PTR port_led7; //拨打电话提示灯 +static DEV_GPIO_PTR port_car_run; //行车模式 +static DEV_GPIO_PTR port_car_stop; //熄火模式 + +static void delay_ms(volatile int z) +{ + volatile uint32_t x,y; + for(x=1400;x>0;x--) + for(y=z;y>0;y--); +} + + +void open_led5() +{ + port_led5 = gpio_get_dev(DW_GPIO_PORT_B); + port_led5 -> gpio_open(0x1ff); //打开PortB[8:0] + port_led5 -> gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x1ff); + port_led5 -> gpio_write(0x1df, 0x1ff); + delay_ms(500); + port_led5 -> gpio_write(0x1ff, 0x1ff); +} + + +void open_led6() +{ + + port_led6 = gpio_get_dev(DW_GPIO_PORT_B); + port_led6 -> gpio_open(0x1ff); //打开PortB[8:0] + port_led6 -> gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x1ff); + port_led6 -> gpio_write(0x1bf, 0x1ff); + delay_ms(2000); + port_led6 -> gpio_write(0x1ff, 0x1ff); + +} + + +void open_led7() +{ + port_led7 = gpio_get_dev(DW_GPIO_PORT_B); + port_led7 -> gpio_open(0x1ff); //打开PortB[8:0] + port_led7 -> gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x1ff); + port_led7 -> gpio_write(0x17f, 0x1ff); + delay_ms(2000); + port_led7 -> gpio_write(0x1ff, 0x1ff); +} + +void car_stop_led() +{ + port_car_stop = gpio_get_dev(DW_GPIO_PORT_C); + port_car_stop-> gpio_open(0x3000000); + port_car_stop-> gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x3000000); + port_car_stop-> gpio_write(0x1000000, 0x3000000); +} + + +void car_run_led() +{ + port_car_run = gpio_get_dev(DW_GPIO_PORT_C); + port_car_run-> gpio_open(0x3000000); + port_car_run-> gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x3000000); + port_car_run-> gpio_write(0x2000000, 0x3000000); +} + + diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/LED/LED.h b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/LED/LED.h new file mode 100644 index 00000000..ebd105ae --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/LED/LED.h @@ -0,0 +1,35 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ + +#ifndef _LED_H_ +#define _LED_H_ +extern void call_gh(void); +extern void open_led5(); +extern void open_led6(); +extern void open_led7(); +extern void car_stop_led(); +extern void car_run_led(); + +#endif /* _LED_H_ */ \ No newline at end of file diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/YUYIN/YUYIN.c b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/YUYIN/YUYIN.c new file mode 100644 index 00000000..75688fc7 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/YUYIN/YUYIN.c @@ -0,0 +1,267 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ +#include "embARC.h" +#include "embARC_debug.h" +#include "embARC_toolchain.h" +#include "embARC_error.h" +#include "stdio.h" +#include "string.h" +#include "board.h" + +#include "dev_uart.h" +#include "dev_iic.h" + +#include "YUYIN.h" + +#define HEADLEN 5 +#define I2C_SLAVE_ADDR1 0x01 + +static DEV_IIC *dev_IIC_YY; +static DEV_GPIO_PTR port_open_con; +static DEV_GPIO_PTR port_close_con; + + +static void delay_ms(volatile int z) //1ms +{ + volatile uint32_t x,y; + for(x=1400;x>0;x--) + for(y=z;y>0;y--); +} + + + +void Txt2YY_temp(int32_t TEMP_Value ) +{ + uint8_t length; + char ecc = 0x00; //Уֽ + uint8_t i=0; + char *text; + if(TEMP_Value==10) text="ǰ¶Ϊ10϶"; + if(TEMP_Value==11) text="ǰ¶Ϊ11϶"; + if(TEMP_Value==12) text="ǰ¶Ϊ12϶"; + if(TEMP_Value==13) text="ǰ¶Ϊ13϶"; + if(TEMP_Value==14) text="ǰ¶Ϊ14϶"; + if(TEMP_Value==15) text="ǰ¶Ϊ15϶"; + if(TEMP_Value==16) text="ǰ¶Ϊ16϶"; + if(TEMP_Value==17) text="ǰ¶Ϊ17϶"; + if(TEMP_Value==18) text="ǰ¶Ϊ18϶"; + if(TEMP_Value==19) text="ǰ¶Ϊ19϶"; + if(TEMP_Value==20) text="ǰ¶Ϊ20϶"; + if(TEMP_Value==21) text="ǰ¶Ϊ21϶"; + if(TEMP_Value==22) text="ǰ¶Ϊ22϶"; + if(TEMP_Value==23) text="ǰ¶Ϊ23϶"; + if(TEMP_Value==24) text="ǰ¶Ϊ24϶"; + if(TEMP_Value==25) text="ǰ¶Ϊ25϶"; + if(TEMP_Value==26) text="ǰ¶Ϊ26϶"; + if(TEMP_Value==27) text="ǰ¶Ϊ27϶"; + if(TEMP_Value==28) text="ǰ¶Ϊ28϶"; + if(TEMP_Value==29) text="ǰ¶Ϊ29϶"; + if(TEMP_Value==30) text="ǰ¶Ϊ30϶"; + if(TEMP_Value==31) text="ǰ¶Ϊ31϶"; + if(TEMP_Value==32) text="ǰ¶Ϊ32϶"; + if(TEMP_Value==33) text="ǰ¶Ϊ33϶"; + if(TEMP_Value==34) text="ǰ¶Ϊ34϶"; + if(TEMP_Value==35) text="ǰ¶Ϊ35϶"; + if(TEMP_Value==36) text="ǰ¶Ϊ36϶"; + if(TEMP_Value==37) text="ǰ¶Ϊ37϶"; + if(TEMP_Value==38) text="ǰ¶Ϊ38϶"; + if(TEMP_Value==39) text="ǰ¶Ϊ39϶"; + if(TEMP_Value==40) text="ǰ¶Ϊ40϶"; + + dev_IIC_YY = iic_get_dev(DW_IIC_1_ID); + dev_IIC_YY-> iic_open(DEV_MASTER_MODE, IIC_SPEED_STANDARD); + dev_IIC_YY-> iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(I2C_SLAVE_ADDR1)); + + length =strlen(text); //Ҫıij + printf("length=%d\r\n",length); + char head[HEADLEN] = {0xfd,0x00,0x00,0x01,0x00}; + head[2] = length + 3; + for(i = 0; i<5; i++) //η͹õ5֡ͷֽ + { + ecc=ecc^(head[i]); //Է͵ֽڽУ + } + dev_IIC_YY->iic_write(head, 5); + for(i = 0; iiic_write(text, length+1); + delay_ms(1000); +} + +void Txt2YY_command1() +{ + uint8_t length; + char ecc = 0x00; //Уֽ + uint8_t i=0; + char text[]={"ʲôԸ"}; + dev_IIC_YY = iic_get_dev(DW_IIC_1_ID); + dev_IIC_YY-> iic_open(DEV_MASTER_MODE, IIC_SPEED_STANDARD); + dev_IIC_YY-> iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(I2C_SLAVE_ADDR1)); + + length =strlen(text); //Ҫıij + printf("length=%d\r\n",length); + char head[HEADLEN] = {0xfd,0x00,0x00,0x01,0x00}; + head[2] = length + 3; + for(i = 0; i<5; i++) //η͹õ5֡ͷֽ + { + ecc=ecc^(head[i]); //Է͵ֽڽУ + } + dev_IIC_YY->iic_write(head, 5); + for(i = 0; iiic_write(text, length+1); + delay_ms(1000); +} + +void Txt2YY_command2() +{ + uint8_t length; + char ecc = 0x00; //Уֽ + uint8_t i=0; + char text[]={"յѴ"}; + dev_IIC_YY = iic_get_dev(DW_IIC_1_ID); + dev_IIC_YY-> iic_open(DEV_MASTER_MODE, IIC_SPEED_STANDARD); + dev_IIC_YY-> iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(I2C_SLAVE_ADDR1)); + + length =strlen(text); //Ҫıij + printf("length=%d\r\n",length); + char head[HEADLEN] = {0xfd,0x00,0x00,0x01,0x00}; + head[2] = length + 3; + for(i = 0; i<5; i++) //η͹õ5֡ͷֽ + { + ecc=ecc^(head[i]); //Է͵ֽڽУ + } + dev_IIC_YY->iic_write(head, 5); + for(i = 0; iiic_write(text, length+1); + delay_ms(1000); +} + +void Txt2YY_command3() +{ + uint8_t length; + char ecc = 0x00; //Уֽ + uint8_t i=0; + char text[]={"յѹر"}; + dev_IIC_YY = iic_get_dev(DW_IIC_1_ID); + dev_IIC_YY-> iic_open(DEV_MASTER_MODE, IIC_SPEED_STANDARD); + dev_IIC_YY-> iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(I2C_SLAVE_ADDR1)); + + length =strlen(text); //Ҫıij + printf("length=%d\r\n",length); + char head[HEADLEN] = {0xfd,0x00,0x00,0x01,0x00}; + head[2] = length + 3; + for(i = 0; i<5; i++) //η͹õ5֡ͷֽ + { + ecc=ecc^(head[i]); //Է͵ֽڽУ + } + dev_IIC_YY->iic_write(head, 5); + for(i = 0; iiic_write(text, length+1); + delay_ms(1000); +} + +void Txt2YY_command4() +{ + uint8_t length; + char ecc = 0x00; //Уֽ + uint8_t i=0; + char text[]={"Բһѧϰ"}; + dev_IIC_YY = iic_get_dev(DW_IIC_1_ID); + dev_IIC_YY-> iic_open(DEV_MASTER_MODE, IIC_SPEED_STANDARD); + dev_IIC_YY-> iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(I2C_SLAVE_ADDR1)); + + length =strlen(text); //Ҫıij + printf("length=%d\r\n",length); + char head[HEADLEN] = {0xfd,0x00,0x00,0x01,0x00}; + head[2] = length + 3; + for(i = 0; i<5; i++) //η͹õ5֡ͷֽ + { + ecc=ecc^(head[i]); //Է͵ֽڽУ + } + dev_IIC_YY->iic_write(head, 5); + for(i = 0; iiic_write(text, length+1); + delay_ms(1000); +} + + +void open_conditioner(void) +{ + port_open_con = gpio_get_dev(DW_GPIO_PORT_A);//port_aӿ + port_open_con ->gpio_open(0x800);//PortA[11] + port_open_con ->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x800);//portA[11]Ϊ + port_open_con ->gpio_write(0x800, 0x800); +} + + + +void close_conditioner(void) +{ + port_close_con = gpio_get_dev(DW_GPIO_PORT_A);//port_aӿ + port_close_con ->gpio_open(0x800);//PortA[11] + port_close_con ->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x800);//portA[11]Ϊ + port_close_con ->gpio_write(0x000, 0x800); +} + + + + + + + + diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/YUYIN/YUYIN.h b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/YUYIN/YUYIN.h new file mode 100644 index 00000000..77291438 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/driver/YUYIN/YUYIN.h @@ -0,0 +1,38 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ + +#ifndef _YUYIN_H_ +#define _YUYIN_H_ + +extern void Txt2YY_temp(int32_t TEMP_Value ); +extern void Txt2YY_command1(); +extern void Txt2YY_command2(); +extern void Txt2YY_command3(); +extern void Txt2YY_command4(); +extern void open_conditioner(); +extern void close_conditioner(); + + +#endif /* _GSM_H_ */ \ No newline at end of file diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/main.c b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/main.c new file mode 100644 index 00000000..a5526b0c --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/main.c @@ -0,0 +1,286 @@ +/* ------------------------------------------ + * Copyright (c) 2017, Synopsys, Inc. All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +--------------------------------------------- */ +#include "embARC.h" +#include "embARC_debug.h" +#include "u8g.h" +#include "dev_uart.h" + +#define BOARD_TEMP_I2C_SLAVE_ADDRESS TEMP_I2C_SLAVE_ADDRESS + +static DEV_GPIO_PTR port_yuyin; +static DEV_GPIO_PTR port_move_detect; +static DEV_GPIO_PTR port_infrared; +static DEV_GPIO_PTR port_call; + +static uint16_t CH2O_Value; +static int32_t TEMP_Value; +static uint32_t time_value; + +static uint32_t count; +static uint32_t a; +static uint32_t start_measure_CH2O; + + +uint8_t *phoneNum ="00310038003700310030003800390035003300390033"; //18710895393 +uint8_t *msg_child ="30108D1D62A45B9D30118BF74E0D89815C06513F7AE56EDE75598F665185FF0C4EE5514D53D1751F53719669FF01"; //벻Ҫͯ +uint8_t *msg_temp ="30108D1D62A45B9D30118F6651856E295EA68FC79AD8FF0C8BF75C3D5FEB8FD456DEFF01";//¶ȹ + +u8g_t u8g; + +static void delay_ms(volatile int z) +{ + volatile uint32_t x,y; + for(x=1400;x>0;x--) + for(y=z;y>0;y--); +} + +static void timer0_isr(void *ptr) +{ + timer_int_clear(TIMER_0); + + if(start_measure_CH2O==1) + { + CH2O_Value = _CH2O_(); + } + TEMP_Value=temp_sensor_read(); +} + +static void timer1_isr(void *ptr) +{ + uint32_t move_signal; + uint32_t infrared_signal; + + timer_int_clear(TIMER_1); + port_move_detect = gpio_get_dev(DW_GPIO_PORT_C); + port_move_detect-> gpio_open(0xf0000000); + port_move_detect-> gpio_control(GPIO_CMD_SET_BIT_DIR_INPUT, (void *)0xf0000000); + port_move_detect-> gpio_read(&move_signal, 0xf0000000); + move_signal=move_signal>>28; + + port_infrared = gpio_get_dev(DW_GPIO_PORT_A); + port_infrared-> gpio_open(0x80000000); + port_infrared-> gpio_control(GPIO_CMD_SET_BIT_DIR_INPUT, (void *)0x80000000); + port_infrared-> gpio_read(&infrared_signal, 0x80000000); + infrared_signal=infrared_signal>>28; + + if((move_signal==0x5)&&(infrared_signal==0x8)||(move_signal==0x5)) + { + count=count+1; + open_led5(); + if(TEMP_Value>290) + { + send(phoneNum, msg_temp); + } + } + if(count>=5) + { + time_value=time_value+1; + } + if(time_value==10) + { + send(phoneNum, msg_child); //⵽ͯ10Ͷ + open_led6(); + } + if(time_value==30) + { + call_gh(); //⵽ͯ30󲦴绰 + open_led7(); + } + if(time_value>60) //60ϵͳ + { + if(a<=10) + { + help(); //Ѻ͵ƹ˸бʵʻһֱ򣬴˴10 + a=a+1; + } + } + if(time_value == 3600) + { + count=0; //һСʱ󣬻ָ + a=0; + time_value =0; + } + +} + +void u8g_prepare(void) { + u8g_SetFont(&u8g, u8g_font_unifont); /* set the current font and reset the font reference position to "Baseline" */ + u8g_SetFontRefHeightExtendedText(&u8g); /* define the calculation method for the ascent and descent of the current font */ + u8g_SetDefaultForegroundColor(&u8g); /* assign one of the default colors as current color index */ + u8g_SetFontPosTop(&u8g); /* set the reference position for the character and string draw procedure */ +} +static void draw(void) { + + u8g_prepare(); + char s1[]="TEMP: C"; + s1[5]=(TEMP_Value/100)+48; + s1[6]=((TEMP_Value/10)%10)+48; + u8g_DrawStr(&u8g, 0, 20, s1); + + char s2[]="CH2O: . mg/m3"; + s2[5]=(CH2O_Value/100)+48; + s2[7]=((CH2O_Value/10)%10)+48; + s2[8]=(CH2O_Value%10)+48; + u8g_DrawStr(&u8g, 0, 40, s2); +} + +//******************************************************************************* +//************************************************************************* +//******************************************************************************* + +int main(void) +{ + cpu_lock(); + board_init(); + cpu_unlock(); + + int32_t ercd_CH2O; + int32_t ercd_TEMP; + + uint32_t rd_avail = 0; + uint32_t rcv_cnt = 0; + uint8_t i; + + uint32_t status; + uint32_t call_signal; + uint32_t switch_signal; + + uint16_t mile; + led_initial(); + +//******************************************IICʼ***************************** + ercd_CH2O = CH2O_IIC_init(CH2O_ADDRESS); + if (ercd_CH2O != E_OK) { + EMBARC_PRINTF("CH2O initial failed\r\n");} + + ercd_TEMP = temp_sensor_init(BOARD_TEMP_I2C_SLAVE_ADDRESS); + if (ercd_TEMP != E_OK) { + EMBARC_PRINTF("Temperature sensor open failed\r\n");} +//******************************************ʱ0ȡϢ***************** + if (timer_present(TIMER_0)) + { + timer_stop(TIMER_0); + int_handler_install(INTNO_TIMER0, timer0_isr); + int_enable(INTNO_TIMER0); + } + if (timer_present(TIMER_0)) + { + timer_start(TIMER_0, TIMER_CTRL_IE, 20*BOARD_CPU_CLOCK); + } +//******************************************ʱ1ͯ********************* + + if (timer_present(TIMER_1)) + { + timer_stop(TIMER_1); + int_handler_install(INTNO_TIMER1, timer1_isr); + int_enable(INTNO_TIMER1); + } + if (timer_present(TIMER_1)) + { + timer_start(TIMER_1, TIMER_CTRL_IE, 1*BOARD_CPU_CLOCK); + } +//******************************************OLEDʼ***************************** + u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_2x_i2c, U8G_COM_SSD_I2C); + u8g_prepare(); + u8g_Begin(&u8g); + + while(1) + { + u8g_FirstPage(&u8g); + do { + u8g_prepare(); + draw(); + } while (u8g_NextPage(&u8g)); + + +//*********************************************************************** + port_yuyin = gpio_get_dev(DW_GPIO_PORT_A); + port_yuyin-> gpio_open(0xf0000); + port_yuyin-> gpio_control(GPIO_CMD_SET_BIT_DIR_INPUT, (void *)0xf0000); + port_yuyin-> gpio_read(&status, 0xf0000); + status=status>>16; + if(status==0x1) + { + Txt2YY_command1(); + delay_ms(1000); + } + if(status==0x2) + { + open_conditioner(); + Txt2YY_command2(); + delay_ms(1000); + } + if(status==0x4) + { + close_conditioner(); + Txt2YY_command3(); + delay_ms(1000); + } + if(status==0x8) + { + Txt2YY_command4(); + delay_ms(1000); + } + + if(status==0x7) + { + Txt2YY_temp(TEMP_Value/10); + delay_ms(1000); + } + + if(status==0x3) + { + open_child_detect(); + start_measure_CH2O=0; + car_stop_led(); + + } + + if(status==0x0) + { + close_child_detect(); + start_measure_CH2O=1; + car_run_led(); + count=0; + a=0; + time_value=0; + + } + +//******************************************һ***************************** + port_call = gpio_get_dev(DW_GPIO_PORT_A); + port_call-> gpio_open(0x10000000); + port_call-> gpio_control(GPIO_CMD_SET_BIT_DIR_INPUT, (void *)0x10000000); + port_call-> gpio_read(&call_signal, 0x10000000); + call_signal=call_signal>>28; + if(call_signal==0x1) + { + call_gh(); + } + + } + return E_SYS; + +} diff --git a/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/makefile b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/makefile new file mode 100644 index 00000000..5dfb8ab4 --- /dev/null +++ b/arc_design_contest/2018/XDU_Intelligent-protection-system-for-forgotten-children-in-vehicle/src/makefile @@ -0,0 +1,64 @@ +# Application name +APPL ?= Child_Detect +# Optimization Level +# Please Refer to toolchain_xxx.mk for this option +OLEVEL ?= O2 + +## +# Current Board And Core +## +BOARD ?= emsk +BD_VER ?= 22 +CUR_CORE ?= arcem7d + +## +# select debugging jtag +## +JTAG ?= usb + +## +# select toolchain +## +TOOLCHAIN ?= gnu + +## +# Uncomment following options +# if you want to set your own heap and stack size +# Default settings see options.mk +## +#HEAPSZ ?= 8192 +#STACKSZ ?= 8192 + +## +# Uncomment following options +# if you want to add your own library into link process +# For example: +# If you want link math lib for gnu toolchain, +# you need to set the option to -lm +## +#APPL_LIBS ?= + +# +# root dir of embARC +# +EMBARC_ROOT = ../../.. + +MID_SEL = common u8glib + +# application source dirs +APPL_CSRC_DIR = . +APPL_ASMSRC_DIR = . + +# application include dirs +APPL_INC_DIR = . + +# application defines +APPL_DEFINES = + +# include current project makefile +COMMON_COMPILE_PREREQUISITES += makefile + +### Options above must be added before include options.mk ### +# include key embARC build system makefile +override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) +include $(EMBARC_ROOT)/options/options.mk \ No newline at end of file