nt9856x/code/lib/source/sifar/code/include/sf_commu_mcu.h
2023-05-17 15:33:39 +08:00

80 lines
2.9 KiB
C

/**************************************************************************
*
* Copyright (c) 2015-2020 by WuYuan Technology, Inc.
*
* This software is copyrighted by and is the property of SiFar
* Technology, Inc.. All rights are reserved by SiFar Technology, Inc..
* This software may only be used in accordance with the corresponding
* license agreement. Any unauthorized use, duplication, distribution,
* or disclosure of this software is expressly forbidden.
*
* This Copyright notice MUST not be removed or modified without prior
* written consent of SiFar Technology, Inc..
*
* WuYuan Technology, Inc. reserves the right to modify this software without notice.
*
* Author: ljy
* Ver: 1.0.0 2022.06.15
* Description: creat
**************************************************************************/
#ifndef __SF_COMMU_MCU_H
#define __SF_COMMU_MCU_H
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
#include <sf_mcu.h>
#define SERIAL_DEVICE_PATH "/dev/ttyS2"
#define BUF_REG_SIZE (REG_SIZE*2+8)
typedef struct {
unsigned char buf[BUF_REG_SIZE];
unsigned int index;
}SMAPBUF_t;
/*
typedef struct sf_MESSAGE_Buf_S
{
long mtype;
SINT32 cmdId;
SINT32 s32Wait;
SINT32 arg1;
SINT32 arg2;
SINT32 arg3;
}SF_MESSAGE_BUF_S;
*/
void mcubuf_reset(void);
int sf_commu_mcu_interface_init(int speed, char flow_ctrl, int databits, int stopbits, char parity);
int sf_commu_mcu_open(void);
int sf_commu_mcu_close(void);
int sf_commu_write(unsigned char * buf, int len);
int sf_commu_read(unsigned char * buf, int len);
int sf_set_mcu_reg(unsigned char reg, unsigned char val);
int sf_get_mcu_reg(unsigned char reg);
unsigned int sf_set_mcu_reg_ack_depack(unsigned int * address, unsigned int * value);
unsigned int sf_get_mcu_reg_ack_depack(unsigned int * address, unsigned int * value);
int sf_commu_wait(unsigned char cmd);
void sf_commu_reset(void);
int sf_commu_set_mcu(unsigned char reg, unsigned char val);
int sf_commu_get_mcu(unsigned char reg);
int sf_getRegFromMcu_depack(unsigned char * dataToParse, unsigned int datalen, unsigned char * regAddr, unsigned char * regVal);
int sf_getRegFromMcu_ack(unsigned char regAddr, unsigned char regVal);
unsigned char sf_commu_parse_mcu_data(unsigned char * src, unsigned int len);
void sf_commu_mcu_task_start(void);
void sf_commu_mcu_task_stop(void);
unsigned char sf_commu_mcu_task_running(void);
unsigned int sf_get_mcu_reg_ack_depack_many(unsigned char reg[], unsigned char val[], unsigned int * num);
int sf_set_mcu_reg_many(unsigned char reg[], unsigned char val[], unsigned int num);
int sf_get_mcu_reg_many(unsigned char reg[], unsigned int num);
int sf_commu_set_mcu_many(unsigned char reg[], unsigned char val[], unsigned int *num);
int sf_commu_get_mcu_many(unsigned char reg[], unsigned char val[], unsigned int *num);
#ifdef __cplusplus
}
#endif //__cplusplus
#endif