123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- /* Copyright Statement:
- *
- * This software/firmware and related documentation ("AutoChips Software") are
- * protected under relevant copyright laws. The information contained herein is
- * confidential and proprietary to AutoChips Inc. and/or its licensors. Without
- * the prior written permission of AutoChips inc. and/or its licensors, any
- * reproduction, modification, use or disclosure of AutoChips Software, and
- * information contained herein, in whole or in part, shall be strictly
- * prohibited.
- *
- * AutoChips Inc. (C) 2018. All rights reserved.
- *
- * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("AUTOCHIPS SOFTWARE")
- * RECEIVED FROM AUTOCHIPS AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
- * ON AN "AS-IS" BASIS ONLY. AUTOCHIPS EXPRESSLY DISCLAIMS ANY AND ALL
- * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
- * NONINFRINGEMENT. NEITHER DOES AUTOCHIPS PROVIDE ANY WARRANTY WHATSOEVER WITH
- * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
- * INCORPORATED IN, OR SUPPLIED WITH THE AUTOCHIPS SOFTWARE, AND RECEIVER AGREES
- * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
- * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
- * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN AUTOCHIPS
- * SOFTWARE. AUTOCHIPS SHALL ALSO NOT BE RESPONSIBLE FOR ANY AUTOCHIPS SOFTWARE
- * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
- * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND AUTOCHIPS'S
- * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE AUTOCHIPS SOFTWARE
- * RELEASED HEREUNDER WILL BE, AT AUTOCHIPS'S OPTION, TO REVISE OR REPLACE THE
- * AUTOCHIPS SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
- * CHARGE PAID BY RECEIVER TO AUTOCHIPS FOR SUCH AUTOCHIPS SOFTWARE AT ISSUE.
- */
- /*************<start>******************/
- /*************<include>****************/
- #include "gpio.h"
- /*************<macro>******************/
- /*************<enum>*******************/
- /*************<union>******************/
- /*************<struct>*****************/
- /*************<variable>***************/
- uint8_t g_svstatus = 0;
- /*************<prototype>**************/
- /**
- * @prototype GPIO_LedInit(void)
- *
- * @param[in] void
- * @return void
- *
- * @brief 初始化引脚.
- */
- void GPIO_PortInit(void)
- {
- /*
- GPIO_SetFunc(GPIO_CLOSE_KEY, GPIO_FUN0);
- GPIO_SetFunc(GPIO_OPEN_KEY, GPIO_FUN0);
- GPIO_SetFunc(GPIO_COVER_KEY, GPIO_FUN0);
-
- GPIO_SetDir(GPIO_CLOSE_KEY, GPIO_IN);
- GPIO_SetDir(GPIO_OPEN_KEY, GPIO_IN);
- GPIO_SetDir(GPIO_COVER_KEY, GPIO_IN);
-
- GPIO_SetPullup(GPIO_CLOSE_KEY, ENABLE);
- GPIO_SetPullup(GPIO_OPEN_KEY, ENABLE);
- GPIO_SetPullup(GPIO_COVER_KEY, ENABLE);
- */
-
- //set pin mux uart1
- GPIO_SetFunc(GPIOA, GPIO_PIN4, GPIO_FUN3);
- GPIO_SetFunc(GPIOA, GPIO_PIN5, GPIO_FUN3);
-
-
- /*初始化引脚功能,如果引脚上电后默认为GPIO,可省略掉初始化步骤.
- 有部分引脚上电默认为非GPIO,则必须选择其功能为GPIO才能作为GPIO使用.*/
- GPIO_SetFunc(RS485CTRL_PORT, RS485CTRL_PIN, GPIO_FUN0);
- GPIO_SetDir(RS485CTRL_PORT, RS485CTRL_PIN, GPIO_OUT);
-
- GPIO_SetFunc(RUNLED_PORT, RUNLED_PIN, GPIO_FUN0);
- GPIO_SetDir(RUNLED_PORT, RUNLED_PIN, GPIO_OUT);
-
- GPIO_SetFunc(SV1_PORT, SV1_PIN, GPIO_FUN0);
- GPIO_SetDir(SV1_PORT, SV1_PIN, GPIO_OUT);
-
- GPIO_SetFunc(SV2_PORT, SV2_PIN, GPIO_FUN0);
- GPIO_SetDir(SV2_PORT, SV2_PIN, GPIO_OUT);
-
- GPIO_SetFunc(SV3_PORT, SV3_PIN, GPIO_FUN0);
- GPIO_SetDir(SV3_PORT, SV3_PIN, GPIO_OUT);
-
- GPIO_SetFunc(SV4_PORT, SV4_PIN, GPIO_FUN0);
- GPIO_SetDir(SV4_PORT, SV4_PIN, GPIO_OUT);
-
- GPIO_SetPinLevel(SV1_PORT, SV1_PIN, GPIO_LOW);
- GPIO_SetPinLevel(SV2_PORT, SV2_PIN, GPIO_LOW);
- GPIO_SetPinLevel(SV3_PORT, SV3_PIN, GPIO_LOW);
- GPIO_SetPinLevel(SV4_PORT, SV4_PIN, GPIO_LOW);
-
- g_svstatus = 0x00;
-
-
- }
- void Sv_Control(uint8_t id, uint8_t action)
- {
- uint8_t out_level;
-
- if(id >= SV_ALL){
- return ;
- }
-
- if(SV_OPEN == action){
- g_svstatus |= (1 << id);
- out_level = GPIO_HIGH;
-
- }else if(SV_CLOSE == action){
- g_svstatus &= ~(1 << id);
- out_level = GPIO_LOW;
- }else{
- return;
- }
-
- if(SV_01 == id){
- GPIO_SetPinLevel(SV1_PORT, SV1_PIN, out_level);
- }else if(SV_02 == id){
- GPIO_SetPinLevel(SV2_PORT, SV2_PIN, out_level);
- }else if(SV_03 == id){
- GPIO_SetPinLevel(SV3_PORT, SV3_PIN, out_level);
- }else if(SV_04 == id){
- GPIO_SetPinLevel(SV4_PORT, SV4_PIN, out_level);
- }
- }
- /*************<end>********************/
|