?? ycc_driver.h
字號:
#ifndef YCC4_DRIVER_H#define YCC4_DRIVER_H//#define _ECOS#define __YCC_DEBUGtypedef signed int LJC_INT;typedef unsigned int LJC_UINT;typedef signed short LJC_SHORT;typedef unsigned short LJC_USHORT;typedef signed char LJC_CHAR;typedef unsigned char LJC_UCHAR;typedef void ljc_thread_entry_t(LJC_UINT);#ifndef bool#define bool int#endif#define MAX_SCRIPT_LENGTH 512#define MAX_STRING_LENGTH 128#define CONFIG_EMPTY 0#define CONFIG_BOOL 1#define CONFIG_INT 2#define CONFIG_STRING 3#define CONFIG_SCRIPT 4#define CONFIG_IP 5#define CONFIG_ESA 6#define CONFIG_INVALID 255struct config_option { char *key; char *title; char *enable; bool enable_sense; int type; unsigned long dflt;} CYG_HAL_TABLE_TYPE;#define ALWAYS_ENABLED (char *) 0#define ENABLE_SENSE_NO_DEFAULT ((bool) 0xFC)#define ENABLE_SENSE_SUPER ((bool) 0xFD)#define ENABLE_SENSE_SECRIT ((bool) 0xFE)#define ENABLE_SENSE_USER_SECRIT ((bool) 0xFF)#ifdef _UCOS_II#include "includes.h"#endif/*#ifdef _ECOS#include <network.h>#include <cyg/kernel/kapi.h>#include <cyg/hal/hal_tables.h>#include <cyg/infra/cyg_type.h>#include <arpa/inet.h>#define LJC_Declare_Mutex(mutex_name) cyg_mutex_t mutex_name#define LJC_Mutex_lock(mutex_name) cyg_mutex_lock(&mutex_name)#define LJC_Mutex_unlock(mutex_name) cyg_mutex_unlock(&mutex_name)#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x4000)extern void stime(time_t *t);typedef struct _ljc_thread_type { char ljc_thread_stack[STACK_SIZE]; cyg_thread ljc_thread_data; cyg_handle_t ljc_handle_thread;// ljc_thread_entry_t *thread_fun;}t_ljc_thread_type;#define ljc_config_option(_t_,_n_,_e_,_ie_,_type_,_dflt_) \struct config_option _config_option_##_n_ \CYG_HAL_TABLE_QUALIFIED_ENTRY(ljc_config_options,_n_) = \ {#_n_,_t_,_e_,_ie_,_type_,(unsigned long)_dflt_};#else#include <sys/ioctl.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <termios.h>#include <unistd.h>//for tcp#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#include <pthread.h>#define LJC_Declare_Mutex(mutex_name) pthread_mutex_t mutex_name //mutex_name=PTHREAD_MUTEX_INITIALIZER#define LJC_Mutex_lock(mutex_name) pthread_mutex_lock(&mutex_name)#define LJC_Mutex_unlock(mutex_name) pthread_mutex_unlock(&mutex_name)typedef struct _ljc_thread_type { pthread_t thread_id; pthread_attr_t thread_Attr;// ljc_thread_entry_t *thread_fun;}t_ljc_thread_type;#define ljc_config_option(_t_,_n_,_e_,_ie_,_type_,_dflt_)#endif //_ECOS*/#define SYSPARASECTION 3010#define SYSBACKSECTION 3016#define FRMINFOOFFSET 100#define METERINFOOFFSET 1000#define ALMINFOOFFSET 2000#define LOGNUMOFFSET 3000#define FRMINFOID 0x01#define METERINFOID 0x02#define ALMINFOID 0x04#define LOGRECINFOID 0x08#define CHANGEIP 0x10#define CURDATABLKID 0X20#define SYSPARAFLAG "SYSPARAFLAG"#define SYSBACKFLAG "SYSBACKFLAG"#define FRMINFOFLAG "FRMINFOFLAG"#define METERINFOFLAG "METERINFOFLAG"#define ENDMETERSEC "ENDMETERINFOFLAG"#define ALMINFOFLAG "ALMINFOFLAG"#define ENDALMSEC "ENDALMINFOFLAG"#define LOGINFOFLAG "LOGINFOFLAG"#include "ycc_type.h"//#define __YCC_DEBUG#define DOCDISKSIZE 4096*4096#define MEMBLKSIZE 4096#define DATABLKSIZE 1024#define DXBLKID 3200//allocate 1 blk for shy,1 blk for shl#define DXRECSIZE 32 //only save 128 recorders#define SYSRUNLOGBLKID 3400#define SYSERRLOGBLKID 3408#define SYSALMLOGBLKID 3416#define LOGRECSIZE 128#define SYSERRLOG 1#define SYSRUNLOG 2#define SYSALMLOG 4#define FORCESAVELOG 8#define RESET_SYSTEM 1000000#define CHANGE_MC8000_IP 1000001#define CHANGE_SERVER_PORT 1000005#define COM_NUM 1 //該系統串口的個數/* c_cflag bit meaning */#ifndef __ECOS#define LINUXCOM1 "/dev/ttyS0"#define LINUXCOM2 "/dev/ttyS1"#endif#define S1200 1200#define S2400 2400#define S4800 4800#define S9600 9600#define D5 0x0000010 //1 is 5 data bits#define D6 0x0000020 //2 is 6 data bits#define D7 0x0000040 //4 is 7 data bits#define D8 0x0000080 ///6 is 8 data bits#define DATA_LEN_MASK 0x00000f0#define STOPB1 0x0000100 //1 is one stop bit#define STOPB15 0x0000200 //2 is 1.5#define STOPB2 0x0000400 //4 is 2 stio bit#define STOP_MASK 0x0000700#define PNONE 0x0001000 //1 is none#define PODD 0x0002000 //2 is odd parity#define PEVEN 0x0004000 //4 is even parity#define PMARK 0x0008000 //6 is mark parity#define PARITY_MASK 0x000f000#ifndef false#define false 0#endif#ifndef true#define true (!false)#endif//2005-10-20,MXL/*// globle declarationextern struct sockaddr_in sa_tcp_server_ip; // remote tcp server addrextern unsigned short tcp_server_port; // remote portextern bool relay_server_have_static_ip;extern unsigned long rcp_link_flag; // system varextern bool gprs_ppp_network;extern unsigned short fool_platform_id; // id of the terminalextern unsigned char ljc_admin_number1[];extern unsigned char ljc_admin_number2[];extern unsigned char ljc_admin_number3[];extern LJC_Declare_Mutex(ComLock);extern LJC_Declare_Mutex(MeterListLock);extern LJC_Declare_Mutex(AlmListLock);extern LJC_Declare_Mutex(SendBufLock);extern LJC_Declare_Mutex(MemLock);extern LJC_Declare_Mutex(LogRecLock);// system function// system functionextern void firmware_up_data(void * buf, int len); // buf is the location of firmware and len is the length of bufferextern void ds1302_set_time(unsigned char sec,unsigned char min,unsigned char hr, unsigned char date,unsigned char mon, unsigned char week, unsigned char yr);extern void ds1302_get_time(unsigned char *sec,unsigned char *min,unsigned char *hr, unsigned char *date,unsigned char *mon, unsigned char *week, unsigned char *yr); extern void dump_buf(unsigned char *p, int s);extern LJC_UINT ljc_thread_cread(ljc_thread_entry_t *thread_entry);// thread id 0 is failextern void ljc_os_start(void);extern unsigned short init_board(void); // return the board id >0extern unsigned long get_current_tick(void); // system current ticks 10ms scaleextern void ljc_sleep_ms(unsigned long ms); //sleep/delay micorsecond now 10ms extern void ljc_delay_us(unsigned int us); // none block delay usextern void ljc_memory_lack_handler(void); // when memory alloc return NULL can use this funcextern void system_reset(void); // reset the system by watchdog;extern void modem_data_req(void); // syn to the modemextern void modem_ppp_status(unsigned char s);// sec: 0-2, each is 4K, can read from sec plus offset as bytes lenextern void ljc_nor_flash_read_bytes(unsigned char *buf,int len,unsigned long sec,unsigned long offset);// sec: 0-2, each is 4K, same as nand memoryextern void ljc_nor_flash_write_sec(unsigned char *buf, unsigned long len,unsigned long sec);// Fetch a configuration data item from flash, returns 'false' if not found. extern bool ljc_flash_get_config(char *key, void *val, int type);// Add a new configuration data item to configuration data base.// Returns 'false' if no space is available. extern bool ljc_flash_add_config(struct config_option *opt, bool update);*/// rs 485 functionextern int ycc_com_init(char *port,unsigned long ctrl,unsigned int baud);extern int ycc_com_sendchar(char port,unsigned char c); // 0 is send ok other errorextern int ycc_com_getchar(char port,unsigned char *c); // same as aboveextern int ycc_com_sendbuf(char port,unsigned char * bf,int len); //same as aboveextern int ycc_printf( char *format,...);//Mask by MXL,2005-10-20/*//ycc io input and outputextern void power_relay_control(unsigned int mode); // mode=0 is close and other is openextern int get_12v_status(void); // 0 is no 12v and other is 12vextern void IO7_output(unsigned char val); // 0 output 0 other output 1extern void IO6_output(unsigned char val); // same as io7extern unsigned char IO3_input(void); // 0 read is 0 other is 1extern unsigned char IO4_input(void); //same as aboveextern unsigned char IO5_input(void); //same as above//TCP functionsextern void get_relay_server_ipaddr(void); // get the sa_tcp_server_ipextern int ycc_connect_tcp(void);extern int ycc_tcp_send(unsigned char *frame, int length);extern void ycc_tcp_receiver(LJC_UINT param);extern void ycc_tcp_process(unsigned char *buffer,int len);extern void reset_tcp_ppp(void);//extern void SendReg(void);//cann't call this function,problely death lock// app functionextern unsigned long (* sms_rev_callback)(unsigned long len, unsigned char *buf,unsigned char *sender_phnum);// sms send call back, the real fun is duty of the appextern int (* gt08_app_callback)(int,int);// app call back for app purposeextern int send_one_sms(unsigned char * sms_content, int length, unsigned char * receiver_phnum); // ok return length other errorextern unsigned long sms_callback (unsigned long sms_len, unsigned char *sms_buf,unsigned char *sender_phnum);// nand flash memoryextern int nand_memory_valid(void); // return the block avilable num// write a block and the block size is 4096extern int nand_memory_write(unsigned char *buf, unsigned long len, unsigned int block); // 1 is ok and 0 is errorextern int nand_memory_read(unsigned char *buf, unsigned long len, unsigned int block);// read a block; same as aboveextern int ycc_mem_write(unsigned char *buf,int len,unsigned long pos);extern int ycc_mem_read(unsigned char *buf,int len,unsigned long pos);extern void ljc_clear_nand_memory(void);//extern int GetItemValue(char* key,int type,int *value);//extern int AddItemOption(char* key,int type,unsigned char *value,int len);extern int ycc_get_para(int itemID,unsigned char *iErr);extern int ycc_save_para(int item,unsigned char *iErr);extern void clear_alarm_list(void);extern void clear_meter_list(void);extern void ycc_init(void);extern void ycc_app(void);*/#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -