102 lines
3.1 KiB
C
102 lines
3.1 KiB
C
#ifndef _COMM_RESOURCE_H_
|
|
#define _COMM_RESOURCE_H_
|
|
|
|
#include "common.h"
|
|
#include "uart_recv.h"
|
|
|
|
#define RS485_MAX_PACK_DATA_LEN 50
|
|
#define PACK_BUFF_SIZE 50
|
|
|
|
/// 上行消息队列指针,device->agent
|
|
extern OS_EVENT *p_queue_up;
|
|
|
|
/// 下行消息队列指针,agent->device
|
|
extern OS_EVENT *p_queue_down;
|
|
|
|
/// 设备层之间使用
|
|
extern BSP_OS_SEM sem_hy_collect_o2;
|
|
extern BSP_OS_SEM sem_hy_collect_co;
|
|
extern BSP_OS_SEM sem_hy_collect_water;
|
|
extern BSP_OS_SEM sem_hy_collect_current;
|
|
extern BSP_OS_SEM sem_hy_collect_well;
|
|
extern BSP_OS_SEM sem_hy_collect_ch4;
|
|
extern BSP_OS_SEM sem_hy_collect_h2s;
|
|
extern BSP_OS_SEM sem_hy_collect_temphumi;
|
|
|
|
/// 485操作共享资源锁
|
|
extern BSP_OS_SEM rs485_mutex;
|
|
|
|
/// 485芯片收发控制--PTC9
|
|
#define RD485_SEND (drv_gpio_setbit(PORTC,5))
|
|
#define RD485_RECEIVE (drv_gpio_clrbit(PORTC,5))
|
|
|
|
/*
|
|
/// 485片选控制盒--PTC5
|
|
#define CS_RS485_BAT_ENABLE (drv_gpio_clrbit(PORTC,5))
|
|
#define CS_RS485_BAT_DISABLE (drv_gpio_setbit(PORTC,5))
|
|
|
|
#define CS_485_J26_ENABLE (drv_gpio_clrbit(PORTC,8))
|
|
#define CS_485_J26_DISABLE (drv_gpio_setbit(PORTC,8))
|
|
|
|
#define CS_485_J28_ENABLE (drv_gpio_clrbit(PORTC,7))
|
|
#define CS_485_J28_DISABLE (drv_gpio_setbit(PORTC,7))
|
|
|
|
#define CS_485_J27_ENABLE (drv_gpio_clrbit(PORTC,6))
|
|
#define CS_485_J27_DISABLE (drv_gpio_setbit(PORTC,6))
|
|
|
|
#define J26_POWER_ON (drv_gpio_setbit(PORTD,9))
|
|
#define J26_POWER_OFF (drv_gpio_clrbit(PORTD,9))*/
|
|
|
|
#define SENSOR_POWER_ON (drv_gpio_setbit(PORTD,11))
|
|
#define SENSOR_POWER_OFF (drv_gpio_clrbit(PORTD,11))
|
|
|
|
|
|
|
|
/// 故障
|
|
#define UP_QUEUE_CODE_DATA 0
|
|
|
|
#define UP_QUEUE_CODE_CH4_COMMERROR 0x22
|
|
#define UP_QUEUE_CODE_CH4_DATAERROR 0x23
|
|
|
|
#define UP_QUEUE_CODE_O2_COMMERROR 0x24
|
|
#define UP_QUEUE_CODE_O2_DATAERROR 0x25
|
|
|
|
#define UP_QUEUE_CODE_CO_COMMERROR 0x26
|
|
#define UP_QUEUE_CODE_CO_DATAERROR 0x27
|
|
|
|
#define UP_QUEUE_CODE_A_CURR_COMMERROR 0x28
|
|
#define UP_QUEUE_CODE_A_CURR_DATAERROR 0x29
|
|
|
|
#define UP_QUEUE_CODE_B_CURR_COMMERROR 0x2A
|
|
#define UP_QUEUE_CODE_B_CURR_DATAERROR 0x2B
|
|
|
|
#define UP_QUEUE_CODE_C_CURR_COMMERROR 0x2C
|
|
#define UP_QUEUE_CODE_C_CURR_DATAERROR 0x2D
|
|
|
|
#define UP_QUEUE_CODE_D_CURR_COMMERROR 0x2E
|
|
#define UP_QUEUE_CODE_D_CURR_DATAERROR 0x2F
|
|
|
|
#define UP_QUEUE_CODE_WATER_COMMERROR 0x30
|
|
#define UP_QUEUE_CODE_WATER_DATAERROR 0x31
|
|
|
|
#define UP_QUEUE_CODE_H2S_COMMERROR 0x32
|
|
#define UP_QUEUE_CODE_H2S_DATAERROR 0x33
|
|
|
|
#define UP_QUEUE_CODE_WELL_COMMERROR 0x34
|
|
#define UP_QUEUE_CODE_WELL_DATAERROR 0x35
|
|
|
|
#define UP_QUEUE_CODE_TEMP_COMMERROR 0x36
|
|
#define UP_QUEUE_CODE_TEMP_DATAERROR 0x37
|
|
|
|
#define UP_QUEUE_CODE_HUMI_COMMERROR 0x38
|
|
#define UP_QUEUE_CODE_HUMI_DATAERROR 0x39
|
|
|
|
|
|
|
|
|
|
void init_rs485_uart();
|
|
void init_rs485_gpio();
|
|
void send_rs485_data(device_handle dev,const void *data, int len);
|
|
void send_up_fault_queue_pack(char *type,u_int8_t code,char *fault_message);
|
|
void init_comm_queue_module();
|
|
#endif |