/**
******************************************************************************
* @file uartSpecial.h
* @author
* @version V1.0.0
* @date 23-12-2015
* @brief uartSpecial function.
******************************************************************************
* @attention
*
*
© COPYRIGHT(c) 2015 STMicroelectronics
*
* 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 STMicroelectronics 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __UART_LIDIAN2_H
#define __UART_LIDIAN2_H
/* Includes ------------------------------------------------------------------*/
#include "usart.h"
/* Define to variables declare---------------------------------------------------*/
//先发高字节再发低字节
typedef union OBC_CtrlInfo1
{
struct
{
UBYTE Curise: 1;
UBYTE Walk: 1;
UBYTE SpeedLimited: 1;//1:超过限速值;0:未超过限速值
UBYTE CuriseTrigMode: 1;
UBYTE CommErr: 1;//0: 通讯正常 1: 通讯故障
UBYTE Light: 1;//灯光控制。0: 关闭 1: 开
UBYTE NonZeroStart: 1;//0: 零启动 1: 非零启动
UBYTE Switch_OnOff: 1;//0: 控制器不工作,1: 控制器工作
} Ctrl_Bit;
UBYTE Ctrl;
} OBC_CtrlInfo1_Struct_t;
typedef union OBC_CtrlInfo2
{
struct
{
UBYTE ucAssistedMagnetSteel: 4;//助力磁钢盘磁钢个数
UBYTE RS1: 1;//备用
UBYTE RS2: 1;//备用
UBYTE CuriseEnabele: 4;//自动巡航标志 0: 无自动巡航, 1: 有自动巡航
UBYTE Reverse: 1;//0: 无效,1: 倒车
} Ctrl_Bit;
UBYTE Ctrl;
} OBC_CtrlInfo2_Struct_t;
typedef struct
{
UBYTE ucPowerStyle;//驱动方式,0-助力驱动,1-电驱动,2-助力驱动和电驱动同时共存
UBYTE ucGearSt;//助力档位
OBC_CtrlInfo1_Struct_t stCtrlInfo1;
UBYTE ucSpeedMagnetSteel; //测速磁钢数
UWORD uwWheelDiameter;//0.1 inch
UBYTE ucAssistSensitivity;//助力灵敏度
UBYTE ucAssistPowerMode;//助力启动强度,0 ~ 5, 0 最弱, 5 最强
UBYTE ucInnerSpeedMagnetSteel;//内测速磁钢数
UBYTE ucSpeedLimiation;//KM/h
UBYTE ucCurrentLimiation;//1A
UWORD uwUnderVoltageLimiation;//0.1V
UWORD uwThrottlePWM;//0.1%
OBC_CtrlInfo2_Struct_t stCtrlInfo2;
} Lidian2_OBC2MCInfo_Struct_t;
typedef union MC_StatusInfo1
{
struct
{
UBYTE RotorLock: 1;//1: 电机缺相
UBYTE BrakeErr: 1;//1: 刹把故障
UBYTE Curise: 1;//1: 巡航状态
UBYTE UnderVoltageErr: 1;//1: 欠压保护
UBYTE ControllerErr: 1;//1: 控制器故障
UBYTE ThrottleErr: 1;//1: 转把故障
UBYTE HallErr: 1;//霍尔故障
UBYTE Walk: 1;//6Km 巡航
} Status_Bit;
UBYTE Status;
} MC_StatusInfo1_Struct_t;
typedef union MC_StatusInfo2
{
struct
{
UBYTE GearSt: 2;//
UBYTE SpeedLimited: 1;//1:限速中
UBYTE Charging: 1;//1:充电中
UBYTE CommErr: 1;//1:通讯故障
UBYTE Brake: 1;//
UBYTE AssistSensorErr: 1;//默认为1
UBYTE Horizontal: 1;//1: 水平状态 0: 非水平状态,默认为1
} Status_Bit;
UBYTE Status;
} MC_StatusInfo2_Struct_t;
typedef struct
{
MC_StatusInfo1_Struct_t stMC_StatusInfo1;
MC_StatusInfo2_Struct_t stMC_StatusInfo2;
UWORD uwCurrent;//0.1A
UBYTE ucCurrentRatio;//电流比例值
UWORD uwSpeed;
UBYTE SOC;//由BMS实现,发0
UWORD uwRemainDistance;//由BMS实现,发0
} Lidian2_MC2OBCInfo_Struct_t;
/* Public variables declare---------------------------------------------------*/
//extern OBC2MCInfo_Struct_t stOBC2MCInfo;
//extern MC2OBCInfo_Struct_t stMC2OBCInfo;
/*Private function declare---------------------------------------------------*/
void Lidian2_OBCSetPara(void);
void Lidian2_USART_DataProcess(USART_Buf_TypeDef* ptUartTx, UBYTE* Data);
void Lidian2_SendData_OBC(USART_Buf_TypeDef* ptUartTx);
void Lidian2_USART_RxData_Process(USART_Buf_TypeDef* ptUartTx, UBYTE* buf, UWORD dataCount);
#endif
/*---------------------------- file end -------------------------------------*/